From 604238174de9700b9e4dc088ce31bb856bfe4916 Mon Sep 17 00:00:00 2001 From: Christian Feldmann Date: Mon, 4 Sep 2023 10:01:12 +0200 Subject: [PATCH 1/5] Some renamings --- YUViewLib/src/decoder/decoderDav1d.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/YUViewLib/src/decoder/decoderDav1d.cpp b/YUViewLib/src/decoder/decoderDav1d.cpp index 7fd21f7e5..895d75b96 100644 --- a/YUViewLib/src/decoder/decoderDav1d.cpp +++ b/YUViewLib/src/decoder/decoderDav1d.cpp @@ -112,7 +112,7 @@ decoderDav1d::decoderDav1d(int signalID, bool cachingDecoder) : decoderBaseSingl { currentOutputBuffer.clear(); - // Libde265 can only decoder HEVC in YUV format + // libdav1d can only decode the YUV format this->rawFormat = video::RawFormat::YUV; QSettings settings; @@ -217,7 +217,7 @@ template T decoderDav1d::resolve(T &fun, const char *symbol, bool o if (!ptr) { if (!optional) - setError(QStringLiteral("Error loading the libde265 library: Can't find function %1.") + setError(QStringLiteral("Error loading the libdav1d library: Can't find function %1.") .arg(symbol)); return nullptr; } @@ -285,7 +285,7 @@ bool decoderDav1d::decodeNextFrame() { if (decoderState != DecoderState::RetrieveFrames) { - DEBUG_DAV1D("decoderLibde265::decodeNextFrame: Wrong decoder state."); + DEBUG_DAV1D("decoderDav1d::decodeNextFrame: Wrong decoder state."); return false; } if (decodedFrameWaiting) @@ -546,7 +546,7 @@ bool decoderDav1d::checkLibraryFile(QString libFilePath, QString &error) } // Now let's see if we can retrive all the function pointers that we will need. - // If this works, we can be fairly certain that this is a valid libde265 library. + // If this works, we can be fairly certain that this is a valid libdav1d library. testDecoder.resolveLibraryFunctionPointers(); error = testDecoder.decoderErrorString(); @@ -566,8 +566,8 @@ QString decoderDav1d::getDecoderName() const QStringList decoderDav1d::getLibraryNames() const { // If the file name is not set explicitly, QLibrary will try to open - // the libde265.so file first. Since this has been compiled for linux - // it will fail and not even try to open the libde265.dylib. + // the libdav1d.so file first. Since this has been compiled for linux + // it will fail and not even try to open the libdav1d.dylib. // On windows and linux ommitting the extension works if (is_Q_OS_MAC) return QStringList() << "libdav1d-internals.dylib" From cac001e5283d971278387d6c0c3edf3b370870c5 Mon Sep 17 00:00:00 2001 From: Christian Feldmann Date: Mon, 4 Sep 2023 10:02:21 +0200 Subject: [PATCH 2/5] Typo in fuction name --- YUViewLib/src/decoder/decoderFFmpeg.cpp | 2 +- YUViewLib/src/ffmpeg/FFmpegVersionHandler.cpp | 2 +- YUViewLib/src/ffmpeg/FFmpegVersionHandler.h | 2 +- YUViewLib/src/filesource/FileSourceFFmpegFile.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/YUViewLib/src/decoder/decoderFFmpeg.cpp b/YUViewLib/src/decoder/decoderFFmpeg.cpp index 110a3fb88..89c0ec69e 100644 --- a/YUViewLib/src/decoder/decoderFFmpeg.cpp +++ b/YUViewLib/src/decoder/decoderFFmpeg.cpp @@ -298,7 +298,7 @@ void decoderFFmpeg::cacheCurStatistics() bool decoderFFmpeg::pushData(QByteArray &data) { if (!this->raw_pkt) - this->raw_pkt = this->ff.allocatePaket(); + this->raw_pkt = this->ff.allocatePacket(); if (data.length() == 0) { // Push an empty packet to indicate that the file has ended diff --git a/YUViewLib/src/ffmpeg/FFmpegVersionHandler.cpp b/YUViewLib/src/ffmpeg/FFmpegVersionHandler.cpp index 10df6a6e8..78add6585 100644 --- a/YUViewLib/src/ffmpeg/FFmpegVersionHandler.cpp +++ b/YUViewLib/src/ffmpeg/FFmpegVersionHandler.cpp @@ -634,7 +634,7 @@ void FFmpegVersionHandler::freeFrame(AVFrameWrapper &frame) frame.clear(); } -AVPacketWrapper FFmpegVersionHandler::allocatePaket() +AVPacketWrapper FFmpegVersionHandler::allocatePacket() { auto rawPacket = this->lib.avcodec.av_packet_alloc(); this->lib.avcodec.av_init_packet(rawPacket); diff --git a/YUViewLib/src/ffmpeg/FFmpegVersionHandler.h b/YUViewLib/src/ffmpeg/FFmpegVersionHandler.h index 2db886bd6..b916a246f 100644 --- a/YUViewLib/src/ffmpeg/FFmpegVersionHandler.h +++ b/YUViewLib/src/ffmpeg/FFmpegVersionHandler.h @@ -70,7 +70,7 @@ class FFmpegVersionHandler AVFrameWrapper allocateFrame(); void freeFrame(AVFrameWrapper &frame); - AVPacketWrapper allocatePaket(); + AVPacketWrapper allocatePacket(); void unrefPacket(AVPacketWrapper &packet); void freePacket(AVPacketWrapper &packet); diff --git a/YUViewLib/src/filesource/FileSourceFFmpegFile.cpp b/YUViewLib/src/filesource/FileSourceFFmpegFile.cpp index d66c9d431..0346a7893 100644 --- a/YUViewLib/src/filesource/FileSourceFFmpegFile.cpp +++ b/YUViewLib/src/filesource/FileSourceFFmpegFile.cpp @@ -510,7 +510,7 @@ void FileSourceFFmpegFile::openFileAndFindVideoStream(QString fileName) if (!this->video_stream) return; - this->currentPacket = this->ff.allocatePaket(); + this->currentPacket = this->ff.allocatePacket(); // Get the frame rate, picture size and color conversion mode auto avgFrameRate = this->video_stream.getAvgFrameRate(); From bbfc8ca639e413a16f0ba093dce1cf81f9aee7f1 Mon Sep 17 00:00:00 2001 From: Christian Feldmann Date: Mon, 4 Sep 2023 10:03:01 +0200 Subject: [PATCH 3/5] Wrong codec name --- YUViewLib/src/decoder/decoderVVDec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YUViewLib/src/decoder/decoderVVDec.h b/YUViewLib/src/decoder/decoderVVDec.h index 437d8dfb4..f622d2f07 100644 --- a/YUViewLib/src/decoder/decoderVVDec.h +++ b/YUViewLib/src/decoder/decoderVVDec.h @@ -90,7 +90,7 @@ class decoderVVDec : public decoderBaseSingleLib static bool checkLibraryFile(QString libFilePath, QString &error); QString getDecoderName() const override; - QString getCodecName() const override { return "hevc"; } + QString getCodecName() const override { return "vvc"; } int nrSignalsSupported() const override { return nrSignals; } From fa0eef79d9c1c4cce2359bd2d88f67a12a506d37 Mon Sep 17 00:00:00 2001 From: Christian Feldmann Date: Mon, 4 Sep 2023 10:46:20 +0200 Subject: [PATCH 4/5] Enable support for ffmpeg 6.0 interface --- .../src/ffmpeg/AVCodecContextWrapper.cpp | 8 ++-- .../src/ffmpeg/AVCodecParametersWrapper.cpp | 42 +++++++++--------- .../src/ffmpeg/AVFormatContextWrapper.cpp | 10 +++-- .../src/ffmpeg/AVFrameSideDataWrapper.cpp | 8 ++-- YUViewLib/src/ffmpeg/AVFrameWrapper.cpp | 10 +++-- YUViewLib/src/ffmpeg/AVInputFormatWrapper.cpp | 9 ++-- YUViewLib/src/ffmpeg/AVPacketWrapper.cpp | 25 ++++++----- YUViewLib/src/ffmpeg/AVPacketWrapper.h | 4 +- YUViewLib/src/ffmpeg/AVStreamWrapper.cpp | 43 ++++++++++++++++++- YUViewLib/src/ffmpeg/FFmpegVersionHandler.cpp | 11 +++-- .../playlistItemCompressedVideo.cpp | 25 +++++------ YUViewLib/src/video/rgb/videoHandlerRGB.cpp | 2 +- 12 files changed, 126 insertions(+), 71 deletions(-) diff --git a/YUViewLib/src/ffmpeg/AVCodecContextWrapper.cpp b/YUViewLib/src/ffmpeg/AVCodecContextWrapper.cpp index d5922b40c..dea86930a 100644 --- a/YUViewLib/src/ffmpeg/AVCodecContextWrapper.cpp +++ b/YUViewLib/src/ffmpeg/AVCodecContextWrapper.cpp @@ -332,7 +332,7 @@ typedef struct AVCodecContext_58 // Actually, there is more here, but the variables above are the only we need. } AVCodecContext_58; -typedef struct AVCodecContext_59 +typedef struct AVCodecContext_59_60 { const AVClass * av_class; int log_level_offset; @@ -410,7 +410,7 @@ typedef struct AVCodecContext_59 int slices; // Actually, there is more here, but the variables above are the only we need. -} AVCodecContext_59; +} AVCodecContext_59_60; } // namespace @@ -730,9 +730,9 @@ void AVCodecContextWrapper::update() this->color_range = p->color_range; this->chroma_sample_location = p->chroma_sample_location; } - else if (libVer.avcodec.major == 59) + else if (libVer.avcodec.major == 59 || libVer.avcodec.major == 60) { - auto p = reinterpret_cast(this->codec); + auto p = reinterpret_cast(this->codec); this->codec_type = p->codec_type; this->codec_name = QString("Not supported in AVCodec >= 58"); this->codec_id = p->codec_id; diff --git a/YUViewLib/src/ffmpeg/AVCodecParametersWrapper.cpp b/YUViewLib/src/ffmpeg/AVCodecParametersWrapper.cpp index b1f8ef794..56d0c943e 100644 --- a/YUViewLib/src/ffmpeg/AVCodecParametersWrapper.cpp +++ b/YUViewLib/src/ffmpeg/AVCodecParametersWrapper.cpp @@ -40,7 +40,7 @@ namespace { // AVCodecParameters is part of avcodec. -typedef struct AVCodecParameters_57_58_59 +typedef struct AVCodecParameters_57_58_59_60 { AVMediaType codec_type; AVCodecID codec_id; @@ -65,7 +65,7 @@ typedef struct AVCodecParameters_57_58_59 int video_delay; // Actually, there is more here, but the variables above are the only we need. -} AVCodecParameters_57_58_59; +} AVCodecParameters_57_58_59_60; } // namespace @@ -230,9 +230,9 @@ QStringPairList AVCodecParametersWrapper::getInfoText() void AVCodecParametersWrapper::setClearValues() { if (this->libVer.avformat.major == 57 || this->libVer.avformat.major == 58 || - this->libVer.avformat.major == 59) + this->libVer.avformat.major == 59 || this->libVer.avformat.major == 60) { - auto p = reinterpret_cast(this->param); + auto p = reinterpret_cast(this->param); p->codec_type = AVMEDIA_TYPE_UNKNOWN; p->codec_id = AV_CODEC_ID_NONE; p->codec_tag = 0; @@ -266,9 +266,9 @@ void AVCodecParametersWrapper::setClearValues() void AVCodecParametersWrapper::setAVMediaType(AVMediaType type) { if (this->libVer.avformat.major == 57 || this->libVer.avformat.major == 58 || - this->libVer.avformat.major == 59) + this->libVer.avformat.major == 59 || this->libVer.avformat.major == 60) { - auto p = reinterpret_cast(this->param); + auto p = reinterpret_cast(this->param); p->codec_type = type; this->codec_type = type; } @@ -277,9 +277,9 @@ void AVCodecParametersWrapper::setAVMediaType(AVMediaType type) void AVCodecParametersWrapper::setAVCodecID(AVCodecID id) { if (this->libVer.avformat.major == 57 || this->libVer.avformat.major == 58 || - this->libVer.avformat.major == 59) + this->libVer.avformat.major == 59 || this->libVer.avformat.major == 60) { - auto p = reinterpret_cast(this->param); + auto p = reinterpret_cast(this->param); p->codec_id = id; this->codec_id = id; } @@ -288,10 +288,10 @@ void AVCodecParametersWrapper::setAVCodecID(AVCodecID id) void AVCodecParametersWrapper::setExtradata(QByteArray data) { if (this->libVer.avformat.major == 57 || this->libVer.avformat.major == 58 || - this->libVer.avformat.major == 59) + this->libVer.avformat.major == 59 || this->libVer.avformat.major == 60) { this->extradata = data; - auto p = reinterpret_cast(this->param); + auto p = reinterpret_cast(this->param); p->extradata = reinterpret_cast(this->extradata.data()); p->extradata_size = this->extradata.length(); } @@ -300,9 +300,9 @@ void AVCodecParametersWrapper::setExtradata(QByteArray data) void AVCodecParametersWrapper::setSize(Size size) { if (this->libVer.avformat.major == 57 || this->libVer.avformat.major == 58 || - this->libVer.avformat.major == 59) + this->libVer.avformat.major == 59 || this->libVer.avformat.major == 60) { - auto p = reinterpret_cast(this->param); + auto p = reinterpret_cast(this->param); p->width = size.width; p->height = size.height; this->width = size.width; @@ -313,9 +313,9 @@ void AVCodecParametersWrapper::setSize(Size size) void AVCodecParametersWrapper::setAVPixelFormat(AVPixelFormat format) { if (this->libVer.avformat.major == 57 || this->libVer.avformat.major == 58 || - this->libVer.avformat.major == 59) + this->libVer.avformat.major == 59 || this->libVer.avformat.major == 60) { - auto p = reinterpret_cast(this->param); + auto p = reinterpret_cast(this->param); p->format = format; this->format = format; } @@ -324,9 +324,9 @@ void AVCodecParametersWrapper::setAVPixelFormat(AVPixelFormat format) void AVCodecParametersWrapper::setProfileLevel(int profile, int level) { if (this->libVer.avformat.major == 57 || this->libVer.avformat.major == 58 || - this->libVer.avformat.major == 59) + this->libVer.avformat.major == 59 || this->libVer.avformat.major == 60) { - auto p = reinterpret_cast(this->param); + auto p = reinterpret_cast(this->param); p->profile = profile; p->level = level; this->profile = profile; @@ -337,9 +337,9 @@ void AVCodecParametersWrapper::setProfileLevel(int profile, int level) void AVCodecParametersWrapper::setSampleAspectRatio(int num, int den) { if (this->libVer.avformat.major == 57 || this->libVer.avformat.major == 58 || - this->libVer.avformat.major == 59) + this->libVer.avformat.major == 59 || this->libVer.avformat.major == 60) { - auto p = reinterpret_cast(param); + auto p = reinterpret_cast(param); AVRational ratio; ratio.num = num; ratio.den = den; @@ -359,9 +359,9 @@ void AVCodecParametersWrapper::update() this->param = nullptr; } else if (this->libVer.avformat.major == 57 || this->libVer.avformat.major == 58 || - this->libVer.avformat.major == 59) + this->libVer.avformat.major == 59 || this->libVer.avformat.major == 60) { - auto p = reinterpret_cast(this->param); + auto p = reinterpret_cast(this->param); this->codec_type = p->codec_type; this->codec_id = p->codec_id; @@ -388,4 +388,4 @@ void AVCodecParametersWrapper::update() throw std::runtime_error("Invalid library version"); } -} // namespace FFmpeg \ No newline at end of file +} // namespace FFmpeg diff --git a/YUViewLib/src/ffmpeg/AVFormatContextWrapper.cpp b/YUViewLib/src/ffmpeg/AVFormatContextWrapper.cpp index c7c3410b6..4bcc37278 100644 --- a/YUViewLib/src/ffmpeg/AVFormatContextWrapper.cpp +++ b/YUViewLib/src/ffmpeg/AVFormatContextWrapper.cpp @@ -147,7 +147,7 @@ typedef struct AVFormatContext_58 // Actually, there is more here, but the variables above are the only we need. } AVFormatContext_58; -typedef struct AVFormatContext_59 +typedef struct AVFormatContext_59_60 { const AVClass * av_class; struct AVInputFormat * iformat; @@ -178,7 +178,9 @@ typedef struct AVFormatContext_59 unsigned int nb_chapters; AVChapter ** chapters; AVDictionary * metadata; -} AVFormatContext_59; + + // Actually, there is more here, but the variables above are the only we need. +} AVFormatContext_59_60; } // namespace @@ -334,9 +336,9 @@ void AVFormatContextWrapper::update() this->iformat = AVInputFormatWrapper(p->iformat, this->libVer); } - else if (this->libVer.avformat.major == 59) + else if (this->libVer.avformat.major == 59 || this->libVer.avformat.major == 60) { - auto p = reinterpret_cast(this->ctx); + auto p = reinterpret_cast(this->ctx); this->ctx_flags = p->ctx_flags; this->nb_streams = p->nb_streams; for (unsigned i = 0; i < nb_streams; i++) diff --git a/YUViewLib/src/ffmpeg/AVFrameSideDataWrapper.cpp b/YUViewLib/src/ffmpeg/AVFrameSideDataWrapper.cpp index 0f582cf99..2e905b1d4 100644 --- a/YUViewLib/src/ffmpeg/AVFrameSideDataWrapper.cpp +++ b/YUViewLib/src/ffmpeg/AVFrameSideDataWrapper.cpp @@ -48,14 +48,14 @@ typedef struct AVFrameSideData_54_55_56 AVBufferRef * buf; } AVFrameSideData_54_55_56; -typedef struct AVFrameSideData_59 +typedef struct AVFrameSideData_57_58 { enum AVFrameSideDataType type; uint8_t * data; size_t size; AVDictionary * metadata; AVBufferRef * buf; -} AVFrameSideData_59; +} AVFrameSideData_57_58; } // namespace @@ -98,9 +98,9 @@ void AVFrameSideDataWrapper::update() this->metadata = p->metadata; this->buf = p->buf; } - else if (this->libVer.avutil.major == 57) + else if (this->libVer.avutil.major == 57 || this->libVer.avutil.major == 58) { - auto p = reinterpret_cast(sideData); + auto p = reinterpret_cast(sideData); this->type = p->type; this->data = p->data; this->size = p->size; diff --git a/YUViewLib/src/ffmpeg/AVFrameWrapper.cpp b/YUViewLib/src/ffmpeg/AVFrameWrapper.cpp index a2ef9f64d..de10570c9 100644 --- a/YUViewLib/src/ffmpeg/AVFrameWrapper.cpp +++ b/YUViewLib/src/ffmpeg/AVFrameWrapper.cpp @@ -81,7 +81,7 @@ typedef struct AVFrame_55_56 // Actually, there is more here, but the variables above are the only we need. } AVFrame_55_56; -typedef struct AVFrame_57 +typedef struct AVFrame_57_58 { uint8_t * data[AV_NUM_DATA_POINTERS]; int linesize[AV_NUM_DATA_POINTERS]; @@ -121,8 +121,9 @@ typedef struct AVFrame_57 int64_t pkt_pos; int64_t pkt_duration; AVDictionary * metadata; + // Actually, there is more here, but the variables above are the only we need. -} AVFrame_57; +} AVFrame_57_58; } // namespace @@ -248,9 +249,10 @@ void AVFrameWrapper::update() this->display_picture_number = p->display_picture_number; this->quality = p->quality; } - else if (this->libVer.avutil.major == 57) + else if (this->libVer.avutil.major == 57 || // + this->libVer.avutil.major == 58) { - auto p = reinterpret_cast(this->frame); + auto p = reinterpret_cast(this->frame); for (unsigned i = 0; i < AV_NUM_DATA_POINTERS; i++) { this->data[i] = p->data[i]; diff --git a/YUViewLib/src/ffmpeg/AVInputFormatWrapper.cpp b/YUViewLib/src/ffmpeg/AVInputFormatWrapper.cpp index 3bdaa43f2..7362e3372 100644 --- a/YUViewLib/src/ffmpeg/AVInputFormatWrapper.cpp +++ b/YUViewLib/src/ffmpeg/AVInputFormatWrapper.cpp @@ -38,7 +38,7 @@ namespace FFmpeg namespace { -typedef struct AVInputFormat_56_57_58_59 +typedef struct AVInputFormat_56_57_58_59_60 { const char * name; const char * long_name; @@ -49,7 +49,7 @@ typedef struct AVInputFormat_56_57_58_59 const char * mime_type; // There is more but it is not part of the public ABI -} AVInputFormat_56_57_58_59; +} AVInputFormat_56_57_58_59_60; } // namespace @@ -73,9 +73,10 @@ void AVInputFormatWrapper::update() if (this->libVer.avformat.major == 56 || // this->libVer.avformat.major == 57 || // this->libVer.avformat.major == 58 || // - this->libVer.avformat.major == 59) + this->libVer.avformat.major == 59 || // + this->libVer.avformat.major == 60) { - auto p = reinterpret_cast(this->fmt); + auto p = reinterpret_cast(this->fmt); this->name = QString(p->name); this->long_name = QString(p->long_name); this->flags = p->flags; diff --git a/YUViewLib/src/ffmpeg/AVPacketWrapper.cpp b/YUViewLib/src/ffmpeg/AVPacketWrapper.cpp index 60df6717e..1d144ca97 100644 --- a/YUViewLib/src/ffmpeg/AVPacketWrapper.cpp +++ b/YUViewLib/src/ffmpeg/AVPacketWrapper.cpp @@ -148,9 +148,10 @@ AVPacketWrapper::AVPacketWrapper(LibraryVersion libVersion, AVPacket *packet) p->size = 0; this->pkt = reinterpret_cast(p); } - else if (this->libVer.avcodec.major == 59) + else if (this->libVer.avcodec.major == 59 || // + this->libVer.avcodec.major == 60) { - auto p = reinterpret_cast(packet); + auto p = reinterpret_cast(packet); p->data = nullptr; p->size = 0; this->pkt = reinterpret_cast(p); @@ -183,9 +184,10 @@ void AVPacketWrapper::setData(QByteArray &set_data) data = p->data; size = p->size; } - else if (this->libVer.avcodec.major == 59) + else if (this->libVer.avcodec.major == 59 || // + this->libVer.avcodec.major == 60) { - auto p = reinterpret_cast(this->pkt); + auto p = reinterpret_cast(this->pkt); p->data = (uint8_t *)set_data.data(); p->size = set_data.size(); data = p->data; @@ -209,9 +211,10 @@ void AVPacketWrapper::setPTS(int64_t pts) p->pts = pts; this->pts = pts; } - else if (this->libVer.avcodec.major == 59) + else if (this->libVer.avcodec.major == 59 || // + this->libVer.avcodec.major == 60) { - auto p = reinterpret_cast(this->pkt); + auto p = reinterpret_cast(this->pkt); p->pts = pts; this->pts = pts; } @@ -233,9 +236,10 @@ void AVPacketWrapper::setDTS(int64_t dts) p->dts = dts; this->dts = dts; } - else if (this->libVer.avcodec.major == 59) + else if (this->libVer.avcodec.major == 59 || // + this->libVer.avcodec.major == 60) { - auto p = reinterpret_cast(this->pkt); + auto p = reinterpret_cast(this->pkt); p->dts = dts; this->dts = dts; } @@ -387,9 +391,10 @@ void AVPacketWrapper::update() this->duration = p->duration; this->pos = p->pos; } - else if (this->libVer.avcodec.major == 59) + else if (this->libVer.avcodec.major == 59 || // + this->libVer.avcodec.major == 60) { - auto p = reinterpret_cast(this->pkt); + auto p = reinterpret_cast(this->pkt); this->buf = p->buf; this->pts = p->pts; diff --git a/YUViewLib/src/ffmpeg/AVPacketWrapper.h b/YUViewLib/src/ffmpeg/AVPacketWrapper.h index 908f7057c..7d727c0e7 100644 --- a/YUViewLib/src/ffmpeg/AVPacketWrapper.h +++ b/YUViewLib/src/ffmpeg/AVPacketWrapper.h @@ -95,7 +95,7 @@ typedef struct AVPacket_57_58 int64_t convergence_duration; } AVPacket_57_58; -typedef struct AVPacket_59 +typedef struct AVPacket_59_60 { AVBufferRef * buf; int64_t pts; @@ -111,7 +111,7 @@ typedef struct AVPacket_59 void * opaque; AVBufferRef * opaque_ref; AVRational time_base; -} AVPacket_59; +} AVPacket_59_60; // A wrapper around the different versions of the AVPacket versions. // It also adds some functions like automatic deletion when it goes out of scope. diff --git a/YUViewLib/src/ffmpeg/AVStreamWrapper.cpp b/YUViewLib/src/ffmpeg/AVStreamWrapper.cpp index e4f5a8e4e..b465bb76a 100644 --- a/YUViewLib/src/ffmpeg/AVStreamWrapper.cpp +++ b/YUViewLib/src/ffmpeg/AVStreamWrapper.cpp @@ -196,7 +196,7 @@ typedef struct AVStream_59 AVRational sample_aspect_ratio; AVDictionary * metadata; AVRational avg_frame_rate; - AVPacket_59 attached_pic; + AVPacket_59_60 attached_pic; AVPacketSideData * side_data; int nb_side_data; int event_flags; @@ -205,6 +205,30 @@ typedef struct AVStream_59 int pts_wrap_bits; } AVStream_59; +typedef struct AVStream_60 +{ + const AVClass * av_class; + int index; + int id; + AVCodecParameters *codecpar; + void * priv_data; + AVRational time_base; + int64_t start_time; + int64_t duration; + int64_t nb_frames; + int disposition; + enum AVDiscard discard; + AVRational sample_aspect_ratio; + AVDictionary * metadata; + AVRational avg_frame_rate; + AVPacket_59_60 attached_pic; + AVPacketSideData * side_data; + int nb_side_data; + int event_flags; + AVRational r_frame_rate; + int pts_wrap_bits; +} AVStream_60; + } // namespace AVStreamWrapper::AVStreamWrapper(AVStream *src_str, LibraryVersion v) @@ -391,6 +415,23 @@ void AVStreamWrapper::update() this->event_flags = p->event_flags; this->codecpar = AVCodecParametersWrapper(p->codecpar, libVer); } + else if (libVer.avformat.major == 60) + { + auto p = reinterpret_cast(this->stream); + this->index = p->index; + this->id = p->id; + this->time_base = p->time_base; + this->start_time = p->start_time; + this->duration = p->duration; + this->nb_frames = p->nb_frames; + this->disposition = p->nb_frames; + this->discard = p->discard; + this->sample_aspect_ratio = p->sample_aspect_ratio; + this->avg_frame_rate = p->avg_frame_rate; + this->nb_side_data = p->nb_side_data; + this->event_flags = p->event_flags; + this->codecpar = AVCodecParametersWrapper(p->codecpar, libVer); + } else throw std::runtime_error("Invalid library version"); } diff --git a/YUViewLib/src/ffmpeg/FFmpegVersionHandler.cpp b/YUViewLib/src/ffmpeg/FFmpegVersionHandler.cpp index 78add6585..0cb91f739 100644 --- a/YUViewLib/src/ffmpeg/FFmpegVersionHandler.cpp +++ b/YUViewLib/src/ffmpeg/FFmpegVersionHandler.cpp @@ -101,10 +101,13 @@ LibraryVersion addMinorAndMicroVersion(FFmpegLibraryFunctions &lib, LibraryVersi // These FFmpeg versions are supported. The numbers indicate the major version of // the following libraries in this order: Util, codec, format, swresample // The versions are sorted from newest to oldest, so that we try to open the newest ones first. -auto SupportedLibraryVersionCombinations = {LibraryVersion(57, 59, 59, 4), - LibraryVersion(56, 58, 58, 3), - LibraryVersion(55, 57, 57, 2), - LibraryVersion(54, 56, 56, 1)}; +auto SupportedLibraryVersionCombinations = { + LibraryVersion(58, 60, 60, 4), + LibraryVersion(57, 59, 59, 4), + LibraryVersion(56, 58, 58, 3), + LibraryVersion(55, 57, 57, 2), + LibraryVersion(54, 56, 56, 1), +}; } // namespace diff --git a/YUViewLib/src/playlistitem/playlistItemCompressedVideo.cpp b/YUViewLib/src/playlistitem/playlistItemCompressedVideo.cpp index 796f2e36b..a093a68ec 100644 --- a/YUViewLib/src/playlistitem/playlistItemCompressedVideo.cpp +++ b/YUViewLib/src/playlistitem/playlistItemCompressedVideo.cpp @@ -177,7 +177,7 @@ playlistItemCompressedVideo::playlistItemCompressedVideo(const QString &compress << frameSize.width << "x" << frameSize.height); formatYuv = this->inputFileAnnexBParser->getPixelFormat(); DEBUG_COMPRESSED("playlistItemCompressedVideo::playlistItemCompressedVideo YUV format " - << this->formatYuv.getName().c_str()); + << formatYuv.getName().c_str()); this->rawFormat = video::RawFormat::YUV; this->prop.frameRate = this->inputFileAnnexBParser->getFramerate(); DEBUG_COMPRESSED("playlistItemCompressedVideo::playlistItemCompressedVideo framerate " @@ -204,7 +204,7 @@ playlistItemCompressedVideo::playlistItemCompressedVideo(const QString &compress // Is this file RGB or YUV? this->rawFormat = this->inputFileFFmpegLoading->getRawFormat(); DEBUG_COMPRESSED("playlistItemCompressedVideo::playlistItemCompressedVideo Raw format " - << (this->rawFormat == raw_YUV ? "YUV" + << (this->rawFormat == video::RawFormat::YUV ? "YUV" : this->rawFormat == video::RawFormat::RGB ? "RGB" : "Unknown")); if (this->rawFormat == video::RawFormat::YUV) @@ -268,7 +268,7 @@ playlistItemCompressedVideo::playlistItemCompressedVideo(const QString &compress return; } - // Allocate the videoHander (RGB or YUV) + // Allocate the videoHandler (RGB or YUV) if (this->rawFormat == video::RawFormat::YUV) { this->video = std::make_unique(); @@ -685,10 +685,10 @@ void playlistItemCompressedVideo::loadRawData(int frameIdx, bool caching) : this->inputFileFFmpegLoading->getNextPacket(repushData); repushData = false; if (pkt) - DEBUG_COMPRESSED("playlistItemCompressedVideo::loadRawData retrived packet PTS " + DEBUG_COMPRESSED("playlistItemCompressedVideo::loadRawData retrieved packet PTS " << pkt.getPTS()); else - DEBUG_COMPRESSED("playlistItemCompressedVideo::loadRawData retrived empty packet"); + DEBUG_COMPRESSED("playlistItemCompressedVideo::loadRawData retrieved empty packet"); auto ffmpegDec = (caching ? dynamic_cast(this->cachingDecoder.get()) : dynamic_cast(this->loadingDecoder.get())); @@ -723,11 +723,12 @@ void playlistItemCompressedVideo::loadRawData(int frameIdx, bool caching) data = caching ? this->inputFileAnnexBCaching->getFrameData(*frameStartEndFilePos) : this->inputFileAnnexBLoading->getFrameData(*frameStartEndFilePos); - DEBUG_COMPRESSED("playlistItemCompressedVideo::loadRawData retrived frame data from file " - "- AnnexBCnt " - << this->readAnnexBFrameCounterCodingOrder << " startEnd " - << frameStartEndFilePos->first << "-" << frameStartEndFilePos->second - << " - size " << data.size()); + DEBUG_COMPRESSED( + "playlistItemCompressedVideo::loadRawData retrieved frame data from file " + "- AnnexBCnt " + << this->readAnnexBFrameCounterCodingOrder << " startEnd " + << frameStartEndFilePos->first << "-" << frameStartEndFilePos->second << " - size " + << data.size()); } if (!dec->pushData(data)) @@ -752,7 +753,7 @@ void playlistItemCompressedVideo::loadRawData(int frameIdx, bool caching) auto data = caching ? this->inputFileAnnexBCaching->getNextNALUnit(repushData) : this->inputFileAnnexBLoading->getNextNALUnit(repushData); DEBUG_COMPRESSED( - "playlistItemCompressedVideo::loadRawData retrived nal unit from file - size " + "playlistItemCompressedVideo::loadRawData retrieved nal unit from file - size " << data.size()); this->repushData = !dec->pushData(data); } @@ -763,7 +764,7 @@ void playlistItemCompressedVideo::loadRawData(int frameIdx, bool caching) auto data = caching ? this->inputFileFFmpegCaching->getNextUnit(repushData) : this->inputFileFFmpegLoading->getNextUnit(repushData); DEBUG_COMPRESSED( - "playlistItemCompressedVideo::loadRawData retrived nal unit from file - size " + "playlistItemCompressedVideo::loadRawData retrieved nal unit from file - size " << data.size()); this->repushData = !dec->pushData(data); } diff --git a/YUViewLib/src/video/rgb/videoHandlerRGB.cpp b/YUViewLib/src/video/rgb/videoHandlerRGB.cpp index f27fba58e..1fe288dec 100644 --- a/YUViewLib/src/video/rgb/videoHandlerRGB.cpp +++ b/YUViewLib/src/video/rgb/videoHandlerRGB.cpp @@ -459,7 +459,7 @@ void videoHandlerRGB::loadFrame(int frameIndex, bool loadToDoubleBuffer) // Does the data in currentFrameRawData need to be updated? if (!loadRawRGBData(frameIndex) || currentFrameRawData.isEmpty()) { - DEBUG_RGB("videoHandlerRGB::loadFrame Loading faile or is still running in the background"); + DEBUG_RGB("videoHandlerRGB::loadFrame Loading failed or is still running in the background"); return; } From bd3e8a01dc770c41640b4904ca59f4c0e380289b Mon Sep 17 00:00:00 2001 From: Christian Feldmann Date: Mon, 4 Sep 2023 11:20:35 +0200 Subject: [PATCH 5/5] Parse pixel format for new interface correctly --- YUViewLib/src/ffmpeg/AVPixFmtDescriptorWrapper.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/YUViewLib/src/ffmpeg/AVPixFmtDescriptorWrapper.cpp b/YUViewLib/src/ffmpeg/AVPixFmtDescriptorWrapper.cpp index f72819cc5..91c1c6768 100644 --- a/YUViewLib/src/ffmpeg/AVPixFmtDescriptorWrapper.cpp +++ b/YUViewLib/src/ffmpeg/AVPixFmtDescriptorWrapper.cpp @@ -109,7 +109,7 @@ typedef struct AVComponentDescriptor_57 int depth; } AVComponentDescriptor_57; -typedef struct AVPixFmtDescriptor_57 +typedef struct AVPixFmtDescriptor_57_58 { const char * name; uint8_t nb_components; @@ -118,7 +118,7 @@ typedef struct AVPixFmtDescriptor_57 uint64_t flags; AVComponentDescriptor_57 comp[4]; const char * alias; -} AVPixFmtDescriptor_57; +} AVPixFmtDescriptor_57_58; AVPixFmtDescriptorWrapper::Flags parseFlags(uint8_t flagsValue) { @@ -217,9 +217,10 @@ AVPixFmtDescriptorWrapper::AVPixFmtDescriptorWrapper(AVPixFmtDescriptor *descrip aliases = QString(p->alias); } - else if (libVer.avutil.major == 57) + else if (libVer.avutil.major == 57 || // + libVer.avutil.major == 58) { - auto p = reinterpret_cast(descriptor); + auto p = reinterpret_cast(descriptor); this->name = QString(p->name); this->nb_components = p->nb_components; this->log2_chroma_w = p->log2_chroma_w;