summaryrefslogtreecommitdiffstats
path: root/src/plugins/multimedia/ffmpeg/recordingengine/qffmpegvideoframeencoder_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/multimedia/ffmpeg/recordingengine/qffmpegvideoframeencoder_p.h')
-rw-r--r--src/plugins/multimedia/ffmpeg/recordingengine/qffmpegvideoframeencoder_p.h31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/plugins/multimedia/ffmpeg/recordingengine/qffmpegvideoframeencoder_p.h b/src/plugins/multimedia/ffmpeg/recordingengine/qffmpegvideoframeencoder_p.h
index b8e51e6c1..731789926 100644
--- a/src/plugins/multimedia/ffmpeg/recordingengine/qffmpegvideoframeencoder_p.h
+++ b/src/plugins/multimedia/ffmpeg/recordingengine/qffmpegvideoframeencoder_p.h
@@ -26,12 +26,21 @@ namespace QFFmpeg {
class VideoFrameEncoder
{
public:
+ struct SourceParams
+ {
+ QSize size;
+ AVPixelFormat format = AV_PIX_FMT_NONE;
+ AVPixelFormat swFormat = AV_PIX_FMT_NONE;
+ QtVideo::Rotation rotation = QtVideo::Rotation::None;
+ bool xMirrored = false;
+ bool yMirrored = false;
+ qreal frameRate = 0.;
+ AVColorTransferCharacteristic colorTransfer = AVCOL_TRC_UNSPECIFIED;
+ AVColorSpace colorSpace = AVCOL_SPC_UNSPECIFIED;
+ AVColorRange colorRange = AVCOL_RANGE_UNSPECIFIED;
+ };
static std::unique_ptr<VideoFrameEncoder> create(const QMediaEncoderSettings &encoderSettings,
- const QSize &sourceSize,
- QtVideo::Rotation sourceRotation,
- qreal sourceFrameRate,
- AVPixelFormat sourceFormat,
- AVPixelFormat sourceSWFormat,
+ const SourceParams &sourceParams,
AVFormatContext *formatContext);
~VideoFrameEncoder();
@@ -45,28 +54,34 @@ public:
const AVRational &getTimeBase() const;
- int sendFrame(AVFrameUPtr frame);
+ int sendFrame(AVFrameUPtr inputFrame);
AVPacketUPtr retrievePacket();
+ const QMediaEncoderSettings &settings() { return m_settings; }
+
private:
VideoFrameEncoder() = default;
+ bool updateSourceFormatAndSize(const AVFrame *frame);
+
void updateConversions();
bool initCodec();
bool initTargetFormats();
- bool initCodecContext(AVFormatContext *formatContext);
+ bool initCodecContext(const SourceParams &sourceParams, AVFormatContext *formatContext);
+
+ qint64 estimateDuration(const AVPacket &packet, bool isFirstPacket);
private:
QMediaEncoderSettings m_settings;
QSize m_sourceSize;
- QtVideo::Rotation m_sourceRotation = QtVideo::Rotation::None;
std::unique_ptr<HWAccel> m_accel;
const AVCodec *m_codec = nullptr;
AVStream *m_stream = nullptr;
+ qint64 m_lastPacketTime = AV_NOPTS_VALUE;
AVCodecContextUPtr m_codecContext;
std::unique_ptr<SwsContext, decltype(&sws_freeContext)> m_converter = { nullptr,
&sws_freeContext };