diff options
Diffstat (limited to 'testing')
-rw-r--r-- | testing/telegram-desktop/0012-ffmpeg.patch | 210 | ||||
-rw-r--r-- | testing/telegram-desktop/APKBUILD | 4 |
2 files changed, 157 insertions, 57 deletions
diff --git a/testing/telegram-desktop/0012-ffmpeg.patch b/testing/telegram-desktop/0012-ffmpeg.patch index 4d9d7fdd84..0319fb6de2 100644 --- a/testing/telegram-desktop/0012-ffmpeg.patch +++ b/testing/telegram-desktop/0012-ffmpeg.patch @@ -1,73 +1,173 @@ +From 0710dde4d5526454318b2748331e887c01ecfdce Mon Sep 17 00:00:00 2001 +From: John Preston <johnprestonmail@gmail.com> +Date: Tue, 9 Jul 2019 13:43:57 +0200 +Subject: [PATCH] Use private Qt color API only in official build. + +Fixes #6219. +--- + .../SourceFiles/ffmpeg/ffmpeg_utility.cpp | 100 ++++++++++++------ + Telegram/gyp/lib_ffmpeg.gyp | 6 +- + 2 files changed, 71 insertions(+), 35 deletions(-) + diff --git a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp -index 5d0e50926..24b47e8c8 100644 +index 5d0e50926..3775f7503 100644 --- a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp +++ b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp -@@ -354,7 +354,41 @@ QImage CreateFrameStorage(QSize size) { - cleanupData); +@@ -11,7 +11,10 @@ For license and copyright information please follow this link: + #include "logs.h" + + #include <QImage> ++ ++#ifdef TDESKTOP_OFFICIAL_TARGET + #include <private/qdrawhelper_p.h> ++#endif // TDESKTOP_OFFICIAL_TARGET + + extern "C" { + #include <libavutil/opt.h> +@@ -44,6 +47,58 @@ void AlignedImageBufferCleanupHandler(void* data) { + && !(image.bytesPerLine() % kAlignImageBy); } -+QImage CreateFromData(const QImage & from, QImage::Format format){ -+ const auto size = from.size(); -+ const auto width = size.width(); -+ const auto height = size.height(); -+ const auto widthAlign = kAlignImageBy / kPixelBytesSize; -+ const auto neededWidth = width + ((width % widthAlign) -+ ? (widthAlign - (width % widthAlign)) -+ : 0); -+ const auto perLine = neededWidth * kPixelBytesSize; -+ const auto buffer = new uchar[perLine * height + kAlignImageBy]; -+ memcpy(buffer, from.bits(), perLine * height + kAlignImageBy); -+ const auto cleanupData = reinterpret_cast<const void *>(buffer); -+ const auto address = reinterpret_cast<uintptr_t>(buffer); -+ const auto alignedBuffer = buffer + ((address % kAlignImageBy) -+ ? (kAlignImageBy - (address % kAlignImageBy)) -+ : 0); -+ return QImage( -+ alignedBuffer, -+ width, -+ height, -+ perLine, -+ format, -+ AlignedImageBufferCleanupHandler, -+ const_cast<void*>(cleanupData)); ++void UnPremultiplyLine(uchar *dst, const uchar *src, int intsCount) { ++#ifdef TDESKTOP_OFFICIAL_TARGET ++ const auto layout = &qPixelLayouts[QImage::Format_ARGB32]; ++ const auto convert = layout->convertFromARGB32PM; ++#else // TDESKTOP_OFFICIAL_TARGET ++ const auto layout = nullptr; ++ const auto convert = []( ++ uint *dst, ++ const uint *src, ++ int count, ++ std::nullptr_t, ++ std::nullptr_t) { ++ for (auto i = 0; i != count; ++i) { ++ dst[i] = qUnpremultiply(src[i]); ++ } ++ }; ++#endif // TDESKTOP_OFFICIAL_TARGET ++ ++ convert( ++ reinterpret_cast<uint*>(dst), ++ reinterpret_cast<const uint*>(src), ++ intsCount, ++ layout, ++ nullptr); +} + - void UnPremultiply(QImage &to, const QImage &from) { -+ auto result = CreateFromData(from, QImage::Format_ARGB32_Premultiplied); -+ result = result.convertToFormat(QImage::Format_ARGB32); -+ to = CreateFromData(result, QImage::Format_ARGB32_Premultiplied); -+ return; ++void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) { ++#ifdef TDESKTOP_OFFICIAL_TARGET ++ const auto layout = &qPixelLayouts[QImage::Format_ARGB32]; ++ const auto convert = layout->convertToARGB32PM; ++#else // TDESKTOP_OFFICIAL_TARGET ++ const auto layout = nullptr; ++ const auto convert = []( ++ uint *dst, ++ const uint *src, ++ int count, ++ std::nullptr_t, ++ std::nullptr_t) { ++ for (auto i = 0; i != count; ++i) { ++ dst[i] = qPremultiply(src[i]); ++ } ++ }; ++#endif // TDESKTOP_OFFICIAL_TARGET + -+ //// below is original tdesktop code, we shortcut them by using Qt public API -+ //// see https://github.com/telegramdesktop/tdesktop/issues/6219 -+ /* - // This creates QImage::Format_ARGB32_Premultiplied, but we use it - // as an image in QImage::Format_ARGB32 format. ++ convert( ++ reinterpret_cast<uint*>(dst), ++ reinterpret_cast<const uint*>(src), ++ intsCount, ++ layout, ++ nullptr); ++} ++ + } // namespace + + IOPointer MakeIOPointer( +@@ -360,58 +415,35 @@ void UnPremultiply(QImage &to, const QImage &from) { if (!GoodStorageForFrame(to, from.size())) { -@@ -387,9 +421,17 @@ void UnPremultiply(QImage &to, const QImage &from) { - layout, - nullptr); + to = CreateFrameStorage(from.size()); + } +- +- const auto layout = &qPixelLayouts[QImage::Format_ARGB32]; +- const auto convert = layout->convertFromARGB32PM; + const auto fromPerLine = from.bytesPerLine(); + const auto toPerLine = to.bytesPerLine(); + const auto width = from.width(); ++ const auto height = from.height(); ++ auto fromBytes = from.bits(); ++ auto toBytes = to.bits(); + if (fromPerLine != width * 4 || toPerLine != width * 4) { +- auto fromBytes = from.bits(); +- auto toBytes = to.bits(); +- for (auto i = 0; i != to.height(); ++i) { +- convert( +- reinterpret_cast<uint*>(toBytes), +- reinterpret_cast<const uint*>(fromBytes), +- width, +- layout, +- nullptr); ++ for (auto i = 0; i != height; ++i) { ++ UnPremultiplyLine(toBytes, fromBytes, width); + fromBytes += fromPerLine; + toBytes += toPerLine; + } + } else { +- convert( +- reinterpret_cast<uint*>(to.bits()), +- reinterpret_cast<const uint*>(from.bits()), +- from.width() * from.height(), +- layout, +- nullptr); ++ UnPremultiplyLine(toBytes, fromBytes, width * height); } -+ */ } void PremultiplyInplace(QImage &image) { -+ image = CreateFromData(image, QImage::Format_ARGB32); -+ image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); -+ return; -+ -+ //// below is original tdesktop code, we shortcut them by using Qt public API -+ //// see https://github.com/telegramdesktop/tdesktop/issues/6219 -+ /* - const auto layout = &qPixelLayouts[QImage::Format_ARGB32]; - const auto convert = layout->convertToARGB32PM; +- const auto layout = &qPixelLayouts[QImage::Format_ARGB32]; +- const auto convert = layout->convertToARGB32PM; const auto perLine = image.bytesPerLine(); -@@ -413,6 +455,7 @@ void PremultiplyInplace(QImage &image) { - layout, - nullptr); + const auto width = image.width(); ++ const auto height = image.height(); ++ auto bytes = image.bits(); + if (perLine != width * 4) { +- auto bytes = image.bits(); +- for (auto i = 0; i != image.height(); ++i) { +- convert( +- reinterpret_cast<uint*>(bytes), +- reinterpret_cast<const uint*>(bytes), +- width, +- layout, +- nullptr); ++ for (auto i = 0; i != height; ++i) { ++ PremultiplyLine(bytes, bytes, width); + bytes += perLine; + } + } else { +- convert( +- reinterpret_cast<uint*>(image.bits()), +- reinterpret_cast<const uint*>(image.bits()), +- image.width() * image.height(), +- layout, +- nullptr); ++ PremultiplyLine(bytes, bytes, width * height); } -+ */ } - } // namespace FFmpeg +diff --git a/Telegram/gyp/lib_ffmpeg.gyp b/Telegram/gyp/lib_ffmpeg.gyp +index 9971d76ae..b9ada5362 100644 +--- a/Telegram/gyp/lib_ffmpeg.gyp ++++ b/Telegram/gyp/lib_ffmpeg.gyp +@@ -46,7 +46,11 @@ + '<(src_loc)/ffmpeg/ffmpeg_utility.cpp', + '<(src_loc)/ffmpeg/ffmpeg_utility.h', + ], +- 'conditions': [[ 'build_macold', { ++ 'conditions': [[ '"<(official_build_target)" != ""', { ++ 'defines': [ ++ 'TDESKTOP_OFFICIAL_TARGET=<(official_build_target)', ++ ], ++ }], [ 'build_macold', { + 'xcode_settings': { + 'OTHER_CPLUSPLUSFLAGS': [ '-nostdinc++' ], + }, diff --git a/testing/telegram-desktop/APKBUILD b/testing/telegram-desktop/APKBUILD index 96492edaae..305e10a261 100644 --- a/testing/telegram-desktop/APKBUILD +++ b/testing/telegram-desktop/APKBUILD @@ -11,7 +11,7 @@ _crl_commit=9ea870038a2a667add7f621be6252db909068386 _rlottie_commit=40ccf084445c60a32d72d4811edf0efd0580dcaa _Catch2_commit=5ca44b68721833ae3731802ed99af67c6f38a53a _xxhash_commit=7cc9639699f64b750c0b82333dced9ea77e8436e -pkgrel=0 +pkgrel=1 pkgdesc="Telegram Desktop messaging app" options="!check" # Requires Catch2 to be packaged. url="https://desktop.telegram.org/" @@ -156,6 +156,6 @@ cb01655dd097b68e89b15e6e4b1f6da10c52e8bec681eeef9807ca376283b10cb3da34acc976c790 d4ef17600e095b753bcbc4df0078cc025dd235056a8f4946183fc5416e0452bceac020badda60221b98b410261c5aaef72d18e8abc82781257e8075a133908f6 0009-lz4.patch 7d5642672f42f435e206acd047a20b7e38346ed95548f16c0059913546e4e4f54a58927fccb8c1da8e43b6a691bbce2a9608d0db032774d7874d4800e7202d53 0010-libtgvoip.patch 216f8fd0deae38d18d92815b84b4a945a2b83231117d5addd0aa9338acf5cb471c29b2fdfb86ca22c237230f61fbeac14f0445379db4daaddd512cf5e546166e 0011-no-static-qt.patch -30df0fbe5849bbcadb2d28483944f1a5397c056feb0bb4785d481e3e02cad10bb89566b4fb83e0692ca8080963b3d6b817c6ad275bbfebfe74d752a5f5c55c61 0012-ffmpeg.patch +6b524ebfa5703f705ae66949aaef746e0b422597aa6aa2ed6f6b25b17529f6c9dc126a4a33e77440aa61e67e80c91121c2b7ac781bcaff18ec20f638af15a780 0012-ffmpeg.patch aaff642634f42ba017ac94a2c2cd7df595d0a304a62f5f46dbec82e2c88c00a8cfd6346b2809013228f47f301aedf94e10e77197eebefa26b6df81267e8b1a64 0013-lz4.patch ab6ef737712cbc934a908aabb57332a4d207c223f50f0108668b8c3c9fd07cd840845ef99c0dc18dca2139f476fcb0309f99058af710ffaf1272023d1d2f1ab4 0014-clock_gettime.patch" |