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