40 if (!frame.isValid()) {
41 m_sink->setVideoFrame({});
47 const auto codecContext = frame.codecContext();
48 Q_ASSERT(codecContext);
56 if (codecContext->hwAccel() && !frame.avFrame()->hw_frames_ctx) {
57 HWAccel *hwaccel = codecContext->hwAccel();
58 AVFrame *avframe = frame.avFrame();
59 if (!hwaccel->hwFramesContext())
60 hwaccel->createFramesContext(AVPixelFormat(avframe->format),
61 { avframe->width, avframe->height });
63 if (hwaccel->hwFramesContext())
64 avframe->hw_frames_ctx = av_buffer_ref(hwaccel->hwFramesContextAsBuffer());
68 const auto pixelAspectRatio = codecContext->pixelAspectRatio(frame.avFrame());
69 auto buffer = std::make_unique<QFFmpegVideoBuffer>(frame.takeAVFrame(), pixelAspectRatio);
70 QVideoFrameFormat format(buffer->size(), buffer->pixelFormat());
71 format.setColorSpace(buffer->colorSpace());
72 format.setColorTransfer(buffer->colorTransfer());
73 format.setColorRange(buffer->colorRange());
74 format.setMaxLuminance(buffer->maxNits());
75 format.setRotation(m_transform.rotation);
76 format.setMirrored(m_transform.mirroredHorizontallyAfterRotation);
77 QVideoFrame videoFrame = QVideoFramePrivate::createFrame(std::move(buffer), format);
78 videoFrame.setStartTime(frame.startTime().get());
79 videoFrame.setEndTime(frame.endTime().get());
80 m_sink->setVideoFrame(videoFrame);