mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Mirror recorded round message.
This commit is contained in:
parent
cf52f2a743
commit
0991e7d8a4
3 changed files with 27 additions and 20 deletions
BIN
Telegram/Resources/art/round_placeholder.jpg
Normal file
BIN
Telegram/Resources/art/round_placeholder.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 787 B |
|
@ -7,6 +7,7 @@
|
||||||
<file alias="art/logo_256.png">../../art/logo_256.png</file>
|
<file alias="art/logo_256.png">../../art/logo_256.png</file>
|
||||||
<file alias="art/logo_256_no_margin.png">../../art/logo_256_no_margin.png</file>
|
<file alias="art/logo_256_no_margin.png">../../art/logo_256_no_margin.png</file>
|
||||||
<file alias="art/themeimage.jpg">../../art/themeimage.jpg</file>
|
<file alias="art/themeimage.jpg">../../art/themeimage.jpg</file>
|
||||||
|
<file alias="art/round_placeholder.jpg">../../art/round_placeholder.jpg</file>
|
||||||
<file alias="day-blue.tdesktop-theme">../../day-blue.tdesktop-theme</file>
|
<file alias="day-blue.tdesktop-theme">../../day-blue.tdesktop-theme</file>
|
||||||
<file alias="night.tdesktop-theme">../../night.tdesktop-theme</file>
|
<file alias="night.tdesktop-theme">../../night.tdesktop-theme</file>
|
||||||
<file alias="night-green.tdesktop-theme">../../night-green.tdesktop-theme</file>
|
<file alias="night-green.tdesktop-theme">../../night-green.tdesktop-theme</file>
|
||||||
|
|
|
@ -143,6 +143,7 @@ private:
|
||||||
void updateMaxLevel(const Media::Capture::Chunk &chunk);
|
void updateMaxLevel(const Media::Capture::Chunk &chunk);
|
||||||
void updateResultDuration(int64 pts, AVRational timeBase);
|
void updateResultDuration(int64 pts, AVRational timeBase);
|
||||||
|
|
||||||
|
void mirrorYUV420P(not_null<AVFrame*> frame);
|
||||||
void cutCircleFromYUV420P(not_null<AVFrame*> frame);
|
void cutCircleFromYUV420P(not_null<AVFrame*> frame);
|
||||||
|
|
||||||
[[nodiscard]] RoundVideoResult appendToPrevious(RoundVideoResult video);
|
[[nodiscard]] RoundVideoResult appendToPrevious(RoundVideoResult video);
|
||||||
|
@ -752,6 +753,7 @@ void RoundVideoRecorder::Private::encodeVideoFrame(
|
||||||
_videoFrame->data,
|
_videoFrame->data,
|
||||||
_videoFrame->linesize);
|
_videoFrame->linesize);
|
||||||
|
|
||||||
|
mirrorYUV420P(_videoFrame.get());
|
||||||
cutCircleFromYUV420P(_videoFrame.get());
|
cutCircleFromYUV420P(_videoFrame.get());
|
||||||
|
|
||||||
_videoFrame->pts = mcstimestamp - _videoFirstTimestamp;
|
_videoFrame->pts = mcstimestamp - _videoFirstTimestamp;
|
||||||
|
@ -836,6 +838,21 @@ void RoundVideoRecorder::Private::initMinithumbsCanvas() {
|
||||||
_minithumbs = QImage(width, height, QImage::Format_ARGB32_Premultiplied);
|
_minithumbs = QImage(width, height, QImage::Format_ARGB32_Premultiplied);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RoundVideoRecorder::Private::mirrorYUV420P(not_null<AVFrame*> frame) {
|
||||||
|
for (auto p = 0; p < 3; ++p) {
|
||||||
|
const auto size = p ? (kSide / 2) : kSide;
|
||||||
|
const auto linesize = _videoFrame->linesize[p];
|
||||||
|
auto data = _videoFrame->data[p];
|
||||||
|
for (auto y = 0; y != size; ++y) {
|
||||||
|
auto left = data + y * linesize;
|
||||||
|
auto right = left + size - 1;
|
||||||
|
while (left < right) {
|
||||||
|
std::swap(*left++, *right--);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RoundVideoRecorder::Private::cutCircleFromYUV420P(
|
void RoundVideoRecorder::Private::cutCircleFromYUV420P(
|
||||||
not_null<AVFrame*> frame) {
|
not_null<AVFrame*> frame) {
|
||||||
const auto width = frame->width;
|
const auto width = frame->width;
|
||||||
|
@ -1104,26 +1121,14 @@ void RoundVideoRecorder::progressTo(float64 progress) {
|
||||||
void RoundVideoRecorder::preparePlaceholder(const QImage &placeholder) {
|
void RoundVideoRecorder::preparePlaceholder(const QImage &placeholder) {
|
||||||
const auto ratio = style::DevicePixelRatio();
|
const auto ratio = style::DevicePixelRatio();
|
||||||
const auto full = QSize(_side, _side) * ratio;
|
const auto full = QSize(_side, _side) * ratio;
|
||||||
if (!placeholder.isNull()) {
|
_framePlaceholder = Images::Circle(
|
||||||
_framePlaceholder = Images::Circle(
|
(placeholder.isNull()
|
||||||
placeholder.scaled(
|
? QImage(u":/gui/art/round_placeholder.jpg"_q)
|
||||||
|
: placeholder).scaled(
|
||||||
full,
|
full,
|
||||||
Qt::KeepAspectRatio,
|
Qt::KeepAspectRatio,
|
||||||
Qt::SmoothTransformation));
|
Qt::SmoothTransformation));
|
||||||
_framePlaceholder.setDevicePixelRatio(ratio);
|
_framePlaceholder.setDevicePixelRatio(ratio);
|
||||||
} else {
|
|
||||||
_framePlaceholder = QImage(
|
|
||||||
full,
|
|
||||||
QImage::Format_ARGB32_Premultiplied);
|
|
||||||
_framePlaceholder.fill(Qt::transparent);
|
|
||||||
_framePlaceholder.setDevicePixelRatio(ratio);
|
|
||||||
|
|
||||||
auto p = QPainter(&_framePlaceholder);
|
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
|
||||||
p.setPen(Qt::NoPen);
|
|
||||||
p.setBrush(Qt::black);
|
|
||||||
p.drawEllipse(0, 0, _side, _side);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RoundVideoRecorder::prepareFrame(bool blurred) {
|
void RoundVideoRecorder::prepareFrame(bool blurred) {
|
||||||
|
@ -1159,14 +1164,15 @@ void RoundVideoRecorder::prepareFrame(bool blurred) {
|
||||||
QSize(kBlurredSize, kBlurredSize),
|
QSize(kBlurredSize, kBlurredSize),
|
||||||
Qt::KeepAspectRatio,
|
Qt::KeepAspectRatio,
|
||||||
Qt::FastTransformation),
|
Qt::FastTransformation),
|
||||||
kRadius);
|
kRadius).mirrored(true, false);
|
||||||
preparePlaceholder(image);
|
preparePlaceholder(image);
|
||||||
_placeholderUpdates.fire(std::move(image));
|
_placeholderUpdates.fire(std::move(image));
|
||||||
} else {
|
} else {
|
||||||
_framePrepared = Images::Circle(copy.scaled(
|
auto scaled = copy.scaled(
|
||||||
QSize(_side, _side) * ratio,
|
QSize(_side, _side) * ratio,
|
||||||
Qt::KeepAspectRatio,
|
Qt::KeepAspectRatio,
|
||||||
Qt::SmoothTransformation));
|
Qt::SmoothTransformation).mirrored(true, false);
|
||||||
|
_framePrepared = Images::Circle(std::move(scaled));
|
||||||
_framePrepared.setDevicePixelRatio(ratio);
|
_framePrepared.setDevicePixelRatio(ratio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue