From 77721ec69facafe3f3269bdd8a7fb6470587256d Mon Sep 17 00:00:00 2001 From: Artem Dyomin Date: Tue, 15 Nov 2022 12:48:29 +0100 Subject: Old decoder, 6.4, Define for Android only force creating hw frames ctx In general case, force creating of the context is not correct since ffmpeg can use additional data fields if hw_frames_ctx exists. Ideally, the context should be created on ffmpeg side. The investigation should be done under QTBUG-108446 (fix ffmpeg side or this code). Read more in the task description. We encounter the problem after fixing of HWAccel::createFramesContext, see codereview.qt-project.org/c/qt/qtmultimedia/+/442644, force creation of the context didn't work before anyway. This commit is required in order to integrate codereview.qt-project.org/c/qt/qtmultimedia/+/442644 Task-number: QTBUG-108446 Pick-to: 6.4 Change-Id: I71c520fabbbdd80d227db4412c8541639b0baf18 Reviewed-by: Lars Knoll --- src/plugins/multimedia/ffmpeg/qffmpegdecoder.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plugins/multimedia/ffmpeg/qffmpegdecoder.cpp b/src/plugins/multimedia/ffmpeg/qffmpegdecoder.cpp index 7bfc8b31d..399501c41 100644 --- a/src/plugins/multimedia/ffmpeg/qffmpegdecoder.cpp +++ b/src/plugins/multimedia/ffmpeg/qffmpegdecoder.cpp @@ -663,6 +663,12 @@ void VideoRenderer::loop() // qCDebug(qLcVideoRenderer) << "RHI:" << accel.isNull() << accel.rhi() << sink->rhi(); // in practice this only happens with mediacodec +#ifdef Q_OS_ANDROID + // QTBUG-108446 + // In general case, just creation of frames context is not correct since + // frames may require additional specific data for hw contexts, so + // just setting of hw_frames_ctx is not enough. + // TODO: investigate the case in order to remove or fix the code. if (frame.codec()->hwAccel() && !frame.avFrame()->hw_frames_ctx) { HWAccel *hwaccel = frame.codec()->hwAccel(); AVFrame *avframe = frame.avFrame(); @@ -672,6 +678,7 @@ void VideoRenderer::loop() avframe->hw_frames_ctx = av_buffer_ref(hwaccel->hwFramesContextAsBuffer()); } +#endif QFFmpegVideoBuffer *buffer = new QFFmpegVideoBuffer(frame.takeAVFrame()); QVideoFrameFormat format(buffer->size(), buffer->pixelFormat()); -- cgit v1.2.3