mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-28 19:40:54 +00:00
Use src/dst prefixes instead of from/to.
This commit is contained in:
parent
3c01bb5a4a
commit
c4dd45689d
@ -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),
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit cb5296a6b0e14a608cb97d3cafe8971ea25e7f56
|
||||
Subproject commit 32cf0968a14f7ef7756834f72500fc58fef50c6d
|
Loading…
Reference in New Issue
Block a user