diff --git a/submodules/TelegramUI/TelegramUI/CachedResourceRepresentations.swift b/submodules/TelegramUI/TelegramUI/CachedResourceRepresentations.swift index becdc85c14..211e2fc57a 100644 --- a/submodules/TelegramUI/TelegramUI/CachedResourceRepresentations.swift +++ b/submodules/TelegramUI/TelegramUI/CachedResourceRepresentations.swift @@ -271,7 +271,7 @@ final class CachedAnimatedStickerRepresentation: CachedMediaResourceRepresentati let height: Int32 var uniqueId: String { - return "animated-sticker-\(self.width)x\(self.height)-v3" + return "animated-sticker-\(self.width)x\(self.height)-v4" } init(width: Int32, height: Int32) { diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageInteractiveMediaNode.swift b/submodules/TelegramUI/TelegramUI/ChatMessageInteractiveMediaNode.swift index 90fc0b3f65..b1c84924d2 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageInteractiveMediaNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageInteractiveMediaNode.swift @@ -685,7 +685,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode { strongSelf.imageNode.isHidden = true } strongSelf.animatedStickerNode = animatedStickerNode - animatedStickerNode.setup(account: context.account, resource: updatedAnimatedStickerFile.resource, width: 400, height: 400, mode: .cached) + animatedStickerNode.setup(account: context.account, resource: updatedAnimatedStickerFile.resource, width: 380, height: 380, mode: .cached) strongSelf.insertSubnode(animatedStickerNode, aboveSubnode: strongSelf.imageNode) animatedStickerNode.visibility = strongSelf.visibility } diff --git a/submodules/TelegramUI/TelegramUI/HorizontalStickerGridItem.swift b/submodules/TelegramUI/TelegramUI/HorizontalStickerGridItem.swift index e163136a15..8716bf3ce3 100755 --- a/submodules/TelegramUI/TelegramUI/HorizontalStickerGridItem.swift +++ b/submodules/TelegramUI/TelegramUI/HorizontalStickerGridItem.swift @@ -106,7 +106,7 @@ final class HorizontalStickerGridItemNode: GridItemNode { animationNode.started = { [weak self] in self?.imageNode.alpha = 0.0 } - animationNode.setup(account: account, resource: item.file.resource, width: 140, height: 140, mode: .cached) + animationNode.setup(account: account, resource: item.file.resource, width: 160, height: 160, mode: .cached) } else { self.imageNode.alpha = 1.0 self.imageNode.setSignal(chatMessageSticker(account: account, file: item.file, small: true)) diff --git a/submodules/TelegramUI/TelegramUI/MediaInputPaneTrendingItem.swift b/submodules/TelegramUI/TelegramUI/MediaInputPaneTrendingItem.swift index dd9134e05e..64d2cef179 100644 --- a/submodules/TelegramUI/TelegramUI/MediaInputPaneTrendingItem.swift +++ b/submodules/TelegramUI/TelegramUI/MediaInputPaneTrendingItem.swift @@ -113,7 +113,7 @@ private final class TrendingTopItemNode: ASDisplayNode { animationNode.started = { [weak self] in self?.imageNode.alpha = 0.0 } - animationNode.setup(account: account, resource: item.file.resource, width: 140, height: 140, mode: .cached) + animationNode.setup(account: account, resource: item.file.resource, width: 160, height: 160, mode: .cached) } else { self.imageNode.setSignal(chatMessageSticker(account: account, file: item.file, small: true, synchronousLoad: synchronousLoads), attemptSynchronously: synchronousLoads) diff --git a/submodules/TelegramUI/TelegramUI/YUV.m b/submodules/TelegramUI/TelegramUI/YUV.m index 103dbea0cd..a53dd0c585 100644 --- a/submodules/TelegramUI/TelegramUI/YUV.m +++ b/submodules/TelegramUI/TelegramUI/YUV.m @@ -2,14 +2,14 @@ #import void encodeRGBAToYUVA(uint8_t *yuva, uint8_t const *argb, int width, int height) { - vImage_YpCbCrPixelRange pixelRange = (vImage_YpCbCrPixelRange){ 0, 128, 255, 255, 255, 0, 255, 0 }; - vImage_ARGBToYpCbCr info; + static vImage_ARGBToYpCbCr info; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + vImage_YpCbCrPixelRange pixelRange = (vImage_YpCbCrPixelRange){ 0, 128, 255, 255, 255, 1, 255, 0 }; + vImageConvert_ARGBToYpCbCr_GenerateConversion(kvImage_ARGBToYpCbCrMatrix_ITU_R_709_2, &pixelRange, &info, kvImageARGB8888, kvImage420Yp8_Cb8_Cr8, 0); + }); - vImage_Error error; - error = vImageConvert_ARGBToYpCbCr_GenerateConversion(kvImage_ARGBToYpCbCrMatrix_ITU_R_709_2, &pixelRange, &info, kvImageARGB8888, kvImage420Yp8_Cb8_Cr8, 0); - if (error != kvImageNoError) { - return; - } + vImage_Error error = kvImageNoError; vImage_Buffer src; src.data = (void *)argb; @@ -49,14 +49,14 @@ void encodeRGBAToYUVA(uint8_t *yuva, uint8_t const *argb, int width, int height) } void decodeYUVAToRGBA(uint8_t const *yuva, uint8_t *argb, int width, int height) { - vImage_YpCbCrPixelRange pixelRange = (vImage_YpCbCrPixelRange){ 0, 128, 255, 255, 255, 0, 255, 0 }; - vImage_YpCbCrToARGB info; + static vImage_YpCbCrToARGB info; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + vImage_YpCbCrPixelRange pixelRange = (vImage_YpCbCrPixelRange){ 0, 128, 255, 255, 255, 1, 255, 0 }; + vImageConvert_YpCbCrToARGB_GenerateConversion(kvImage_YpCbCrToARGBMatrix_ITU_R_709_2, &pixelRange, &info, kvImage420Yp8_Cb8_Cr8, kvImageARGB8888, 0); + }); - vImage_Error error; - error = vImageConvert_YpCbCrToARGB_GenerateConversion(kvImage_YpCbCrToARGBMatrix_ITU_R_709_2, &pixelRange, &info, kvImage420Yp8_Cb8_Cr8, kvImageARGB8888, 0); - if (error != kvImageNoError) { - return; - } + vImage_Error error = kvImageNoError; vImage_Buffer srcYp; srcYp.data = (void *)(yuva + 0); @@ -81,8 +81,10 @@ void decodeYUVAToRGBA(uint8_t const *yuva, uint8_t *argb, int width, int height) uint8_t const *alpha = yuva + (width * height * 1 + width * height * 1); for (int i = 0; i < width * height; i += 2) { uint8_t a = alpha[i / 2]; - argb[i * 4 + 0] = (a & (0xf0U)); - argb[(i + 1) * 4 + 0] = (a & (0x0fU)) << 4; + uint8_t a1 = (a & (0xf0U)); + uint8_t a2 = ((a & (0x0fU)) << 4); + argb[i * 4 + 0] = a1 | (a1 >> 4); + argb[(i + 1) * 4 + 0] = a2 | (a2 >> 4); } error = vImagePremultiplyData_ARGB8888(&dest, &dest, kvImageDoNotTile);