From c4dd45689d4f6eeb6b6d8f97848dadc2ac6f3aef Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 29 Jun 2022 16:20:12 +0400 Subject: [PATCH] Use src/dst prefixes instead of from/to. --- .../SourceFiles/calls/calls_video_bubble.cpp | 14 +++++----- Telegram/SourceFiles/ffmpeg/ffmpeg_emoji.cpp | 26 ++++++++--------- .../SourceFiles/ffmpeg/ffmpeg_utility.cpp | 28 +++++++++---------- Telegram/lib_ui | 2 +- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Telegram/SourceFiles/calls/calls_video_bubble.cpp b/Telegram/SourceFiles/calls/calls_video_bubble.cpp index c5d55a8278..c137b52e02 100644 --- a/Telegram/SourceFiles/calls/calls_video_bubble.cpp +++ b/Telegram/SourceFiles/calls/calls_video_bubble.cpp @@ -160,14 +160,14 @@ void VideoBubble::prepareFrame() { } Assert(_frame.width() >= frame.width() && _frame.height() >= frame.height()); - const auto toPerLine = _frame.bytesPerLine(); - const auto fromPerLine = frame.bytesPerLine(); + const auto dstPerLine = _frame.bytesPerLine(); + const auto srcPerLine = frame.bytesPerLine(); const auto lineSize = frame.width() * 4; - auto to = _frame.bits(); - auto from = frame.bits(); - const auto till = from + frame.height() * fromPerLine; - for (; from != till; from += fromPerLine, to += toPerLine) { - memcpy(to, from, lineSize); + auto dst = _frame.bits(); + auto src = frame.bits(); + const auto till = src + frame.height() * srcPerLine; + for (; src != till; src += srcPerLine, dst += dstPerLine) { + memcpy(dst, src, lineSize); } _frame = Images::Round( std::move(_frame), diff --git a/Telegram/SourceFiles/ffmpeg/ffmpeg_emoji.cpp b/Telegram/SourceFiles/ffmpeg/ffmpeg_emoji.cpp index 6ad8c8e41b..60e53792ce 100644 --- a/Telegram/SourceFiles/ffmpeg/ffmpeg_emoji.cpp +++ b/Telegram/SourceFiles/ffmpeg/ffmpeg_emoji.cpp @@ -179,16 +179,16 @@ EmojiGenerator::Frame EmojiGenerator::Impl::renderCurrent( const auto dstSize = scaled; const auto bgra = (srcFormat == AV_PIX_FMT_BGRA); const auto withAlpha = bgra || (srcFormat == AV_PIX_FMT_YUVA420P); - const auto toPerLine = storage.bytesPerLine(); - auto to = storage.bits(); + const auto dstPerLine = storage.bytesPerLine(); + auto dst = storage.bits(); if (srcSize == dstSize && bgra) { - const auto fromPerLine = frame->linesize[0]; - const auto perLine = std::min(fromPerLine, toPerLine); - auto from = frame->data[0]; - for (auto y = 0, height =srcSize.height(); y != height; ++y) { - memcpy(to, from, perLine); - from += fromPerLine; - to += toPerLine; + const auto srcPerLine = frame->linesize[0]; + const auto perLine = std::min(srcPerLine, dstPerLine); + auto src = frame->data[0]; + for (auto y = 0, height = srcSize.height(); y != height; ++y) { + memcpy(dst, src, perLine); + src += srcPerLine; + dst += dstPerLine; } } else { _scale = MakeSwscalePointer( @@ -200,16 +200,16 @@ EmojiGenerator::Frame EmojiGenerator::Impl::renderCurrent( Assert(_scale != nullptr); // AV_NUM_DATA_POINTERS defined in AVFrame struct - uint8_t *toData[AV_NUM_DATA_POINTERS] = { to, nullptr }; - int toLinesize[AV_NUM_DATA_POINTERS] = { toPerLine, 0 }; + uint8_t *dstData[AV_NUM_DATA_POINTERS] = { dst, nullptr }; + int dstLinesize[AV_NUM_DATA_POINTERS] = { dstPerLine, 0 }; sws_scale( _scale.get(), frame->data, frame->linesize, 0, frame->height, - toData, - toLinesize); + dstData, + dstLinesize); } if (withAlpha) { PremultiplyInplace(storage); diff --git a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp index 377876ff01..2335e181ea 100644 --- a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp +++ b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp @@ -515,26 +515,26 @@ QImage CreateFrameStorage(QSize size) { cleanupData); } -void UnPremultiply(QImage &to, const QImage &from) { +void UnPremultiply(QImage &dst, const QImage &src) { // This creates QImage::Format_ARGB32_Premultiplied, but we use it // as an image in QImage::Format_ARGB32 format. - if (!GoodStorageForFrame(to, from.size())) { - to = CreateFrameStorage(from.size()); + if (!GoodStorageForFrame(dst, src.size())) { + dst = CreateFrameStorage(src.size()); } - 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) { + const auto srcPerLine = src.bytesPerLine(); + const auto dstPerLine = dst.bytesPerLine(); + const auto width = src.width(); + const auto height = src.height(); + auto srcBytes = src.bits(); + auto dstBytes = dst.bits(); + if (srcPerLine != width * 4 || dstPerLine != width * 4) { for (auto i = 0; i != height; ++i) { - UnPremultiplyLine(toBytes, fromBytes, width); - fromBytes += fromPerLine; - toBytes += toPerLine; + UnPremultiplyLine(dstBytes, srcBytes, width); + srcBytes += srcPerLine; + dstBytes += dstPerLine; } } else { - UnPremultiplyLine(toBytes, fromBytes, width * height); + UnPremultiplyLine(dstBytes, srcBytes, width * height); } } diff --git a/Telegram/lib_ui b/Telegram/lib_ui index cb5296a6b0..32cf0968a1 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit cb5296a6b0e14a608cb97d3cafe8971ea25e7f56 +Subproject commit 32cf0968a14f7ef7756834f72500fc58fef50c6d