Skip to content

Commit

Permalink
Merge pull request #538 from IENT/feature/addSupportForFFmpeg6
Browse files Browse the repository at this point in the history
Feature/add support for f fmpeg6
  • Loading branch information
ChristianFeldmann committed Sep 4, 2023
2 parents 76e9146 + bd3e8a0 commit f1e3ae8
Show file tree
Hide file tree
Showing 18 changed files with 142 additions and 86 deletions.
12 changes: 6 additions & 6 deletions YUViewLib/src/decoder/decoderDav1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -217,7 +217,7 @@ template <typename T> 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;
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion YUViewLib/src/decoder/decoderFFmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion YUViewLib/src/decoder/decoderVVDec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
8 changes: 4 additions & 4 deletions YUViewLib/src/ffmpeg/AVCodecContextWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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<AVCodecContext_59 *>(this->codec);
auto p = reinterpret_cast<AVCodecContext_59_60 *>(this->codec);
this->codec_type = p->codec_type;
this->codec_name = QString("Not supported in AVCodec >= 58");
this->codec_id = p->codec_id;
Expand Down
42 changes: 21 additions & 21 deletions YUViewLib/src/ffmpeg/AVCodecParametersWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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

Expand Down Expand Up @@ -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<AVCodecParameters_57_58_59 *>(this->param);
auto p = reinterpret_cast<AVCodecParameters_57_58_59_60 *>(this->param);
p->codec_type = AVMEDIA_TYPE_UNKNOWN;
p->codec_id = AV_CODEC_ID_NONE;
p->codec_tag = 0;
Expand Down Expand Up @@ -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<AVCodecParameters_57_58_59 *>(this->param);
auto p = reinterpret_cast<AVCodecParameters_57_58_59_60 *>(this->param);
p->codec_type = type;
this->codec_type = type;
}
Expand All @@ -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<AVCodecParameters_57_58_59 *>(this->param);
auto p = reinterpret_cast<AVCodecParameters_57_58_59_60 *>(this->param);
p->codec_id = id;
this->codec_id = id;
}
Expand All @@ -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<AVCodecParameters_57_58_59 *>(this->param);
auto p = reinterpret_cast<AVCodecParameters_57_58_59_60 *>(this->param);
p->extradata = reinterpret_cast<uint8_t *>(this->extradata.data());
p->extradata_size = this->extradata.length();
}
Expand All @@ -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<AVCodecParameters_57_58_59 *>(this->param);
auto p = reinterpret_cast<AVCodecParameters_57_58_59_60 *>(this->param);
p->width = size.width;
p->height = size.height;
this->width = size.width;
Expand All @@ -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<AVCodecParameters_57_58_59 *>(this->param);
auto p = reinterpret_cast<AVCodecParameters_57_58_59_60 *>(this->param);
p->format = format;
this->format = format;
}
Expand All @@ -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<AVCodecParameters_57_58_59 *>(this->param);
auto p = reinterpret_cast<AVCodecParameters_57_58_59_60 *>(this->param);
p->profile = profile;
p->level = level;
this->profile = profile;
Expand All @@ -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<AVCodecParameters_57_58_59 *>(param);
auto p = reinterpret_cast<AVCodecParameters_57_58_59_60 *>(param);
AVRational ratio;
ratio.num = num;
ratio.den = den;
Expand All @@ -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<AVCodecParameters_57_58_59 *>(this->param);
auto p = reinterpret_cast<AVCodecParameters_57_58_59_60 *>(this->param);

this->codec_type = p->codec_type;
this->codec_id = p->codec_id;
Expand All @@ -388,4 +388,4 @@ void AVCodecParametersWrapper::update()
throw std::runtime_error("Invalid library version");
}

} // namespace FFmpeg
} // namespace FFmpeg
10 changes: 6 additions & 4 deletions YUViewLib/src/ffmpeg/AVFormatContextWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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<AVFormatContext_59 *>(this->ctx);
auto p = reinterpret_cast<AVFormatContext_59_60 *>(this->ctx);
this->ctx_flags = p->ctx_flags;
this->nb_streams = p->nb_streams;
for (unsigned i = 0; i < nb_streams; i++)
Expand Down
8 changes: 4 additions & 4 deletions YUViewLib/src/ffmpeg/AVFrameSideDataWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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<AVFrameSideData_59 *>(sideData);
auto p = reinterpret_cast<AVFrameSideData_57_58 *>(sideData);
this->type = p->type;
this->data = p->data;
this->size = p->size;
Expand Down
10 changes: 6 additions & 4 deletions YUViewLib/src/ffmpeg/AVFrameWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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<AVFrame_57 *>(this->frame);
auto p = reinterpret_cast<AVFrame_57_58 *>(this->frame);
for (unsigned i = 0; i < AV_NUM_DATA_POINTERS; i++)
{
this->data[i] = p->data[i];
Expand Down
9 changes: 5 additions & 4 deletions YUViewLib/src/ffmpeg/AVInputFormatWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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

Expand All @@ -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<AVInputFormat_56_57_58_59 *>(this->fmt);
auto p = reinterpret_cast<AVInputFormat_56_57_58_59_60 *>(this->fmt);
this->name = QString(p->name);
this->long_name = QString(p->long_name);
this->flags = p->flags;
Expand Down
Loading

0 comments on commit f1e3ae8

Please sign in to comment.