mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Use src/dst prefixes instead of from/to.
This commit is contained in:
parent
3c01bb5a4a
commit
c4dd45689d
4 changed files with 35 additions and 35 deletions
|
@ -160,14 +160,14 @@ void VideoBubble::prepareFrame() {
|
||||||
}
|
}
|
||||||
Assert(_frame.width() >= frame.width()
|
Assert(_frame.width() >= frame.width()
|
||||||
&& _frame.height() >= frame.height());
|
&& _frame.height() >= frame.height());
|
||||||
const auto toPerLine = _frame.bytesPerLine();
|
const auto dstPerLine = _frame.bytesPerLine();
|
||||||
const auto fromPerLine = frame.bytesPerLine();
|
const auto srcPerLine = frame.bytesPerLine();
|
||||||
const auto lineSize = frame.width() * 4;
|
const auto lineSize = frame.width() * 4;
|
||||||
auto to = _frame.bits();
|
auto dst = _frame.bits();
|
||||||
auto from = frame.bits();
|
auto src = frame.bits();
|
||||||
const auto till = from + frame.height() * fromPerLine;
|
const auto till = src + frame.height() * srcPerLine;
|
||||||
for (; from != till; from += fromPerLine, to += toPerLine) {
|
for (; src != till; src += srcPerLine, dst += dstPerLine) {
|
||||||
memcpy(to, from, lineSize);
|
memcpy(dst, src, lineSize);
|
||||||
}
|
}
|
||||||
_frame = Images::Round(
|
_frame = Images::Round(
|
||||||
std::move(_frame),
|
std::move(_frame),
|
||||||
|
|
|
@ -179,16 +179,16 @@ EmojiGenerator::Frame EmojiGenerator::Impl::renderCurrent(
|
||||||
const auto dstSize = scaled;
|
const auto dstSize = scaled;
|
||||||
const auto bgra = (srcFormat == AV_PIX_FMT_BGRA);
|
const auto bgra = (srcFormat == AV_PIX_FMT_BGRA);
|
||||||
const auto withAlpha = bgra || (srcFormat == AV_PIX_FMT_YUVA420P);
|
const auto withAlpha = bgra || (srcFormat == AV_PIX_FMT_YUVA420P);
|
||||||
const auto toPerLine = storage.bytesPerLine();
|
const auto dstPerLine = storage.bytesPerLine();
|
||||||
auto to = storage.bits();
|
auto dst = storage.bits();
|
||||||
if (srcSize == dstSize && bgra) {
|
if (srcSize == dstSize && bgra) {
|
||||||
const auto fromPerLine = frame->linesize[0];
|
const auto srcPerLine = frame->linesize[0];
|
||||||
const auto perLine = std::min(fromPerLine, toPerLine);
|
const auto perLine = std::min(srcPerLine, dstPerLine);
|
||||||
auto from = frame->data[0];
|
auto src = frame->data[0];
|
||||||
for (auto y = 0, height =srcSize.height(); y != height; ++y) {
|
for (auto y = 0, height = srcSize.height(); y != height; ++y) {
|
||||||
memcpy(to, from, perLine);
|
memcpy(dst, src, perLine);
|
||||||
from += fromPerLine;
|
src += srcPerLine;
|
||||||
to += toPerLine;
|
dst += dstPerLine;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_scale = MakeSwscalePointer(
|
_scale = MakeSwscalePointer(
|
||||||
|
@ -200,16 +200,16 @@ EmojiGenerator::Frame EmojiGenerator::Impl::renderCurrent(
|
||||||
Assert(_scale != nullptr);
|
Assert(_scale != nullptr);
|
||||||
|
|
||||||
// AV_NUM_DATA_POINTERS defined in AVFrame struct
|
// AV_NUM_DATA_POINTERS defined in AVFrame struct
|
||||||
uint8_t *toData[AV_NUM_DATA_POINTERS] = { to, nullptr };
|
uint8_t *dstData[AV_NUM_DATA_POINTERS] = { dst, nullptr };
|
||||||
int toLinesize[AV_NUM_DATA_POINTERS] = { toPerLine, 0 };
|
int dstLinesize[AV_NUM_DATA_POINTERS] = { dstPerLine, 0 };
|
||||||
sws_scale(
|
sws_scale(
|
||||||
_scale.get(),
|
_scale.get(),
|
||||||
frame->data,
|
frame->data,
|
||||||
frame->linesize,
|
frame->linesize,
|
||||||
0,
|
0,
|
||||||
frame->height,
|
frame->height,
|
||||||
toData,
|
dstData,
|
||||||
toLinesize);
|
dstLinesize);
|
||||||
}
|
}
|
||||||
if (withAlpha) {
|
if (withAlpha) {
|
||||||
PremultiplyInplace(storage);
|
PremultiplyInplace(storage);
|
||||||
|
|
|
@ -515,26 +515,26 @@ QImage CreateFrameStorage(QSize size) {
|
||||||
cleanupData);
|
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
|
// This creates QImage::Format_ARGB32_Premultiplied, but we use it
|
||||||
// as an image in QImage::Format_ARGB32 format.
|
// as an image in QImage::Format_ARGB32 format.
|
||||||
if (!GoodStorageForFrame(to, from.size())) {
|
if (!GoodStorageForFrame(dst, src.size())) {
|
||||||
to = CreateFrameStorage(from.size());
|
dst = CreateFrameStorage(src.size());
|
||||||
}
|
}
|
||||||
const auto fromPerLine = from.bytesPerLine();
|
const auto srcPerLine = src.bytesPerLine();
|
||||||
const auto toPerLine = to.bytesPerLine();
|
const auto dstPerLine = dst.bytesPerLine();
|
||||||
const auto width = from.width();
|
const auto width = src.width();
|
||||||
const auto height = from.height();
|
const auto height = src.height();
|
||||||
auto fromBytes = from.bits();
|
auto srcBytes = src.bits();
|
||||||
auto toBytes = to.bits();
|
auto dstBytes = dst.bits();
|
||||||
if (fromPerLine != width * 4 || toPerLine != width * 4) {
|
if (srcPerLine != width * 4 || dstPerLine != width * 4) {
|
||||||
for (auto i = 0; i != height; ++i) {
|
for (auto i = 0; i != height; ++i) {
|
||||||
UnPremultiplyLine(toBytes, fromBytes, width);
|
UnPremultiplyLine(dstBytes, srcBytes, width);
|
||||||
fromBytes += fromPerLine;
|
srcBytes += srcPerLine;
|
||||||
toBytes += toPerLine;
|
dstBytes += dstPerLine;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
UnPremultiplyLine(toBytes, fromBytes, width * height);
|
UnPremultiplyLine(dstBytes, srcBytes, width * height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit cb5296a6b0e14a608cb97d3cafe8971ea25e7f56
|
Subproject commit 32cf0968a14f7ef7756834f72500fc58fef50c6d
|
Loading…
Add table
Reference in a new issue