mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Correctly preserve first frame alpha in video streaming.
This commit is contained in:
parent
2e39befd7c
commit
079772a399
2 changed files with 9 additions and 3 deletions
|
@ -611,6 +611,8 @@ bool VideoTrackObject::processFirstFrame() {
|
||||||
if (_stream.frame->width * _stream.frame->height > kMaxFrameArea) {
|
if (_stream.frame->width * _stream.frame->height > kMaxFrameArea) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
const auto alpha = (_stream.frame->format == AV_PIX_FMT_BGRA)
|
||||||
|
|| (_stream.frame->format == AV_PIX_FMT_YUVA420P);
|
||||||
auto frame = ConvertFrame(
|
auto frame = ConvertFrame(
|
||||||
_stream,
|
_stream,
|
||||||
_stream.frame.get(),
|
_stream.frame.get(),
|
||||||
|
@ -619,7 +621,7 @@ bool VideoTrackObject::processFirstFrame() {
|
||||||
if (frame.isNull()) {
|
if (frame.isNull()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_shared->init(std::move(frame), _syncTimePoint.trackTime);
|
_shared->init(std::move(frame), alpha, _syncTimePoint.trackTime);
|
||||||
callReady();
|
callReady();
|
||||||
queueReadFrames();
|
queueReadFrames();
|
||||||
return true;
|
return true;
|
||||||
|
@ -702,12 +704,16 @@ void VideoTrackObject::fail(Error error) {
|
||||||
_error(error);
|
_error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoTrack::Shared::init(QImage &&cover, crl::time position) {
|
void VideoTrack::Shared::init(
|
||||||
|
QImage &&cover,
|
||||||
|
bool hasAlpha,
|
||||||
|
crl::time position) {
|
||||||
Expects(!initialized());
|
Expects(!initialized());
|
||||||
|
|
||||||
_frames[0].original = std::move(cover);
|
_frames[0].original = std::move(cover);
|
||||||
_frames[0].position = position;
|
_frames[0].position = position;
|
||||||
_frames[0].format = FrameFormat::ARGB32;
|
_frames[0].format = FrameFormat::ARGB32;
|
||||||
|
_frames[0].alpha = hasAlpha;
|
||||||
|
|
||||||
// Usually main thread sets displayed time before _counter increment.
|
// Usually main thread sets displayed time before _counter increment.
|
||||||
// But in this case we update _counter, so we set a fake displayed time.
|
// But in this case we update _counter, so we set a fake displayed time.
|
||||||
|
|
|
@ -110,7 +110,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
// Called from the wrapped object queue.
|
// Called from the wrapped object queue.
|
||||||
void init(QImage &&cover, crl::time position);
|
void init(QImage &&cover, bool hasAlpha, crl::time position);
|
||||||
[[nodiscard]] bool initialized() const;
|
[[nodiscard]] bool initialized() const;
|
||||||
|
|
||||||
[[nodiscard]] PrepareState prepareState(
|
[[nodiscard]] PrepareState prepareState(
|
||||||
|
|
Loading…
Add table
Reference in a new issue