From 024bafe4a13a44b172304d2ba71c35596d03997b Mon Sep 17 00:00:00 2001 From: Artem Dyomin Date: Fri, 8 Mar 2024 15:40:05 +0100 Subject: Fix naming of members in QFFmpegVideoBuffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pick-to: 6.7 6.6 6.5 Change-Id: I73a3312d60b0ef6a30b90344d13e3a5ed8d490fc Reviewed-by: Jøger Hansegård Reviewed-by: Artem Dyomin --- .../multimedia/ffmpeg/qffmpegvideobuffer.cpp | 76 +++++++++++----------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'src/plugins/multimedia/ffmpeg/qffmpegvideobuffer.cpp') diff --git a/src/plugins/multimedia/ffmpeg/qffmpegvideobuffer.cpp b/src/plugins/multimedia/ffmpeg/qffmpegvideobuffer.cpp index f6317dd83..b7c97d4b3 100644 --- a/src/plugins/multimedia/ffmpeg/qffmpegvideobuffer.cpp +++ b/src/plugins/multimedia/ffmpeg/qffmpegvideobuffer.cpp @@ -25,18 +25,18 @@ QT_BEGIN_NAMESPACE QFFmpegVideoBuffer::QFFmpegVideoBuffer(AVFrameUPtr frame, AVRational pixelAspectRatio) : QAbstractVideoBuffer(QVideoFrame::NoHandle), - frame(frame.get()), + m_frame(frame.get()), m_size(qCalculateFrameSize({ frame->width, frame->height }, { pixelAspectRatio.num, pixelAspectRatio.den })) { if (frame->hw_frames_ctx) { - hwFrame = std::move(frame); - m_pixelFormat = toQtPixelFormat(QFFmpeg::HWAccel::format(hwFrame.get())); + m_hwFrame = std::move(frame); + m_pixelFormat = toQtPixelFormat(QFFmpeg::HWAccel::format(m_hwFrame.get())); return; } - swFrame = std::move(frame); - m_pixelFormat = toQtPixelFormat(AVPixelFormat(swFrame->format)); + m_swFrame = std::move(frame); + m_pixelFormat = toQtPixelFormat(AVPixelFormat(m_swFrame->format)); convertSWFrame(); } @@ -45,16 +45,16 @@ QFFmpegVideoBuffer::~QFFmpegVideoBuffer() = default; void QFFmpegVideoBuffer::convertSWFrame() { - Q_ASSERT(swFrame); + Q_ASSERT(m_swFrame); - const auto actualAVPixelFormat = AVPixelFormat(swFrame->format); + const auto actualAVPixelFormat = AVPixelFormat(m_swFrame->format); const auto targetAVPixelFormat = toAVPixelFormat(m_pixelFormat); - if (actualAVPixelFormat != targetAVPixelFormat || isFrameFlipped(*swFrame) - || m_size != QSize(swFrame->width, swFrame->height)) { + if (actualAVPixelFormat != targetAVPixelFormat || isFrameFlipped(*m_swFrame) + || m_size != QSize(m_swFrame->width, m_swFrame->height)) { Q_ASSERT(toQtPixelFormat(targetAVPixelFormat) == m_pixelFormat); // convert the format into something we can handle - SwsContext *c = sws_getContext(swFrame->width, swFrame->height, actualAVPixelFormat, + SwsContext *c = sws_getContext(m_swFrame->width, m_swFrame->height, actualAVPixelFormat, m_size.width(), m_size.height(), targetAVPixelFormat, SWS_BICUBIC, nullptr, nullptr, nullptr); @@ -64,24 +64,24 @@ void QFFmpegVideoBuffer::convertSWFrame() newFrame->format = targetAVPixelFormat; av_frame_get_buffer(newFrame.get(), 0); - sws_scale(c, swFrame->data, swFrame->linesize, 0, swFrame->height, newFrame->data, newFrame->linesize); - if (frame == swFrame.get()) - frame = newFrame.get(); - swFrame = std::move(newFrame); + sws_scale(c, m_swFrame->data, m_swFrame->linesize, 0, m_swFrame->height, newFrame->data, newFrame->linesize); + if (m_frame == m_swFrame.get()) + m_frame = newFrame.get(); + m_swFrame = std::move(newFrame); sws_freeContext(c); } } void QFFmpegVideoBuffer::setTextureConverter(const QFFmpeg::TextureConverter &converter) { - textureConverter = converter; - textureConverter.init(hwFrame.get()); + m_textureConverter = converter; + m_textureConverter.init(m_hwFrame.get()); m_type = converter.isNull() ? QVideoFrame::NoHandle : QVideoFrame::RhiTextureHandle; } QVideoFrameFormat::ColorSpace QFFmpegVideoBuffer::colorSpace() const { - switch (frame->colorspace) { + switch (m_frame->colorspace) { default: case AVCOL_SPC_UNSPECIFIED: case AVCOL_SPC_RESERVED: @@ -108,7 +108,7 @@ QVideoFrameFormat::ColorSpace QFFmpegVideoBuffer::colorSpace() const QVideoFrameFormat::ColorTransfer QFFmpegVideoBuffer::colorTransfer() const { - switch (frame->color_trc) { + switch (m_frame->color_trc) { case AVCOL_TRC_BT709: // The following three cases have transfer characteristics identical to BT709 case AVCOL_TRC_BT1361_ECG: @@ -139,7 +139,7 @@ QVideoFrameFormat::ColorTransfer QFFmpegVideoBuffer::colorTransfer() const QVideoFrameFormat::ColorRange QFFmpegVideoBuffer::colorRange() const { - switch (frame->color_range) { + switch (m_frame->color_range) { case AVCOL_RANGE_MPEG: return QVideoFrameFormat::ColorRange_Video; case AVCOL_RANGE_JPEG: @@ -152,8 +152,8 @@ QVideoFrameFormat::ColorRange QFFmpegVideoBuffer::colorRange() const float QFFmpegVideoBuffer::maxNits() { float maxNits = -1; - for (int i = 0; i < frame->nb_side_data; ++i) { - AVFrameSideData *sd = frame->side_data[i]; + for (int i = 0; i < m_frame->nb_side_data; ++i) { + AVFrameSideData *sd = m_frame->side_data[i]; // TODO: Longer term we might want to also support HDR10+ dynamic metadata if (sd->type == AV_FRAME_DATA_MASTERING_DISPLAY_METADATA) { auto *data = reinterpret_cast(sd->data); @@ -172,11 +172,11 @@ QVideoFrame::MapMode QFFmpegVideoBuffer::mapMode() const QAbstractVideoBuffer::MapData QFFmpegVideoBuffer::map(QVideoFrame::MapMode mode) { - if (!swFrame) { - Q_ASSERT(hwFrame && hwFrame->hw_frames_ctx); - swFrame = QFFmpeg::makeAVFrame(); + if (!m_swFrame) { + Q_ASSERT(m_hwFrame && m_hwFrame->hw_frames_ctx); + m_swFrame = QFFmpeg::makeAVFrame(); /* retrieve data from GPU to CPU */ - int ret = av_hwframe_transfer_data(swFrame.get(), hwFrame.get(), 0); + int ret = av_hwframe_transfer_data(m_swFrame.get(), m_hwFrame.get(), 0); if (ret < 0) { qWarning() << "Error transferring the data to system memory:" << ret; return {}; @@ -190,11 +190,11 @@ QAbstractVideoBuffer::MapData QFFmpegVideoBuffer::map(QVideoFrame::MapMode mode) auto *desc = QVideoTextureHelper::textureDescription(pixelFormat()); mapData.nPlanes = desc->nplanes; for (int i = 0; i < mapData.nPlanes; ++i) { - Q_ASSERT(swFrame->linesize[i] >= 0); + Q_ASSERT(m_swFrame->linesize[i] >= 0); - mapData.data[i] = swFrame->data[i]; - mapData.bytesPerLine[i] = swFrame->linesize[i]; - mapData.size[i] = mapData.bytesPerLine[i]*desc->heightForPlane(swFrame->height, i); + mapData.data[i] = m_swFrame->data[i]; + mapData.bytesPerLine[i] = m_swFrame->linesize[i]; + mapData.size[i] = mapData.bytesPerLine[i]*desc->heightForPlane(m_swFrame->height, i); } return mapData; } @@ -206,27 +206,27 @@ void QFFmpegVideoBuffer::unmap() std::unique_ptr QFFmpegVideoBuffer::mapTextures(QRhi *) { - if (textures) + if (m_textures) return {}; - if (!hwFrame) + if (!m_hwFrame) return {}; - if (textureConverter.isNull()) { - textures = nullptr; + if (m_textureConverter.isNull()) { + m_textures = nullptr; return {}; } - textures.reset(textureConverter.getTextures(hwFrame.get())); - if (!textures) { + m_textures.reset(m_textureConverter.getTextures(m_hwFrame.get())); + if (!m_textures) { static thread_local int lastFormat = 0; - if (std::exchange(lastFormat, hwFrame->format) != hwFrame->format) // prevent logging spam - qWarning() << " failed to get textures for frame; format:" << hwFrame->format; + if (std::exchange(lastFormat, m_hwFrame->format) != m_hwFrame->format) // prevent logging spam + qWarning() << " failed to get textures for frame; format:" << m_hwFrame->format; } return {}; } quint64 QFFmpegVideoBuffer::textureHandle(int plane) const { - return textures ? textures->textureHandle(plane) : 0; + return m_textures ? m_textures->textureHandle(plane) : 0; } QVideoFrameFormat::PixelFormat QFFmpegVideoBuffer::pixelFormat() const -- cgit v1.2.3