Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qffmpegvideobuffer_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QFFMPEGVIDEOBUFFER_P_H
5#define QFFMPEGVIDEOBUFFER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtMultimedia/private/qhwvideobuffer_p.h>
19#include <QtCore/qvariant.h>
20
21#include <QtFFmpegMediaPluginImpl/private/qffmpeg_p.h>
22#include <QtFFmpegMediaPluginImpl/private/qffmpeghwaccel_p.h>
23
25
27{
28public:
30
31 QFFmpegVideoBuffer(AVFrameUPtr frame, AVRational pixelAspectRatio = { 1, 1 });
33
34 MapData map(QVideoFrame::MapMode mode) override;
35 void unmap() override;
36
37 QVideoFrameTexturesUPtr mapTextures(QRhi &, QVideoFrameTexturesUPtr& oldTextures) override;
38
40 QSize size() const;
41
42 static QVideoFrameFormat::PixelFormat toQtPixelFormat(AVPixelFormat avPixelFormat, bool *needsConversion = nullptr);
43 static AVPixelFormat toAVPixelFormat(QVideoFrameFormat::PixelFormat pixelFormat);
44
45 void convertSWFrame();
46
47 AVFrame *getHWFrame() const { return m_hwFrame.get(); }
48
49 void initTextureConverter(QRhi &rhi) override;
50
51 QRhi *rhi() const override;
52
56
57 float maxNits();
58
59private:
60 // The result texture converter must be accessed from the rhi's thread
61 QFFmpeg::TextureConverter &ensureTextureConverter(QRhi &rhi);
62
63 QVideoFrameTexturesUPtr createTexturesFromHwFrame(QRhi &, QVideoFrameTexturesUPtr& oldTextures);
64
65private:
66 QVideoFrameFormat::PixelFormat m_pixelFormat;
67 AVFrame *m_frame = nullptr;
68 AVFrameUPtr m_hwFrame;
69 AVFrameUPtr m_swFrame;
70 QSize m_size;
71 QVideoFrame::MapMode m_mode = QVideoFrame::NotMapped;
72};
73
74QT_END_NAMESPACE
75
76#endif
QVideoFrameFormat::PixelFormat pixelFormat() const
QVideoFrameFormat::ColorSpace colorSpace() const
QRhi * rhi() const override
void unmap() override
Releases the memory mapped by the map() function.
MapData map(QVideoFrame::MapMode mode) override
Maps the planes of a video buffer to memory.
QVideoFrameFormat::ColorTransfer colorTransfer() const
void initTextureConverter(QRhi &rhi) override
static AVPixelFormat toAVPixelFormat(QVideoFrameFormat::PixelFormat pixelFormat)
QVideoFrameTexturesUPtr mapTextures(QRhi &, QVideoFrameTexturesUPtr &oldTextures) override
QVideoFrameFormat::ColorRange colorRange() const
AVFrame * getHWFrame() const
static QVideoFrameFormat::PixelFormat toQtPixelFormat(AVPixelFormat avPixelFormat, bool *needsConversion=nullptr)
QFFmpegVideoBuffer(AVFrameUPtr frame, AVRational pixelAspectRatio={ 1, 1 })
~QFFmpegVideoBuffer() override
RenderingResult renderInternal(Frame frame) override
void setOutput(QVideoSink *sink, bool cleanPrevSink=false)
std::conditional_t< QT_FFMPEG_AVIO_WRITE_CONST, const uint8_t *, uint8_t * > AvioWriteBufferType