Skip to content

Commit cb3c2a5

Browse files
Merge pull request #870 from cho-m/ffmpeg-7
Fix build with FFmpeg 7
2 parents f3e327a + 9c9444f commit cb3c2a5

4 files changed

Lines changed: 32 additions & 0 deletions

File tree

Source/Core/AudioStats.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
extern "C"
1414
{
1515
#include <libavutil/frame.h>
16+
#include <libavutil/version.h>
1617
#include <libavformat/avformat.h>
1718
}
1819
#include <qavplayer.h>
@@ -296,8 +297,13 @@ void AudioStats::TimeStampFromFrame (const QAVFrame& frame, size_t FramePos)
296297
x[2][FramePos]=x[1][FramePos]/60;
297298
x[3][FramePos]=x[2][FramePos]/60;
298299
}
300+
#if LIBAVUTIL_VERSION_INT <= AV_VERSION_INT(57, 30, 0)
299301
if (Frame->pkt_duration != AV_NOPTS_VALUE)
300302
durations[FramePos]=((double)Frame->pkt_duration)/Frequency;
303+
#else
304+
if (Frame->duration != AV_NOPTS_VALUE)
305+
durations[FramePos]=((double)Frame->duration)/Frequency;
306+
#endif
301307
}
302308

303309
//---------------------------------------------------------------------------

Source/Core/AudioStreamStats.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ extern "C"
1515
#include <libavutil/frame.h>
1616
#include <libavutil/pixdesc.h>
1717
#include <libavutil/bprint.h>
18+
#include <libavutil/version.h>
1819
#include <libavformat/avformat.h>
1920
#include <libavcodec/avcodec.h>
2021
}
@@ -62,7 +63,11 @@ AudioStreamStats::AudioStreamStats(XMLElement *streamElement) : CommonStreamStat
6263
AudioStreamStats::AudioStreamStats(QAVStream* stream) : CommonStreamStats(stream),
6364
sample_fmt_string(""),
6465
sample_rate(stream != NULL ? stream->stream()->codecpar->sample_rate : 0),
66+
#if LIBAVUTIL_VERSION_INT <= AV_VERSION_INT(57, 23, 0)
6567
channels(stream != NULL ? stream->stream()->codecpar->channels : 0),
68+
#else
69+
channels(stream != NULL ? stream->stream()->codecpar->ch_layout.nb_channels : 0),
70+
#endif
6671
channel_layout(""),
6772
bits_per_sample(stream != NULL ? av_get_bits_per_sample(stream->stream()->codecpar->codec_id) : 0)
6873
{
@@ -81,9 +86,15 @@ AudioStreamStats::AudioStreamStats(QAVStream* stream) : CommonStreamStats(stream
8186
AVBPrint pbuf;
8287
av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
8388

89+
#if LIBAVUTIL_VERSION_INT <= AV_VERSION_INT(57, 23, 0)
8490
if (stream->stream()->codecpar->channel_layout) {
8591
av_bprint_clear(&pbuf);
8692
av_bprint_channel_layout(&pbuf, stream->stream()->codecpar->channels, stream->stream()->codecpar->channel_layout);
93+
#else
94+
if (av_channel_layout_check(&stream->stream()->codecpar->ch_layout)) {
95+
av_bprint_clear(&pbuf);
96+
av_channel_layout_describe_bprint(&stream->stream()->codecpar->ch_layout, &pbuf);
97+
#endif
8798
channel_layout = pbuf.str;
8899
} else {
89100
channel_layout = "unknown";

Source/Core/FileInformation.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ extern "C" {
2929
#include <libavutil/pixfmt.h>
3030
#include <libavutil/imgutils.h>
3131
#include <libavutil/ffversion.h>
32+
#include <libavutil/version.h>
3233

3334
#ifndef WITH_SYSTEM_FFMPEG
3435
#include <config.h>
@@ -1580,7 +1581,11 @@ struct Output {
15801581
return outPacket;
15811582
}
15821583

1584+
#if LIBAVUTIL_VERSION_INT <= AV_VERSION_INT(57, 30, 0)
15831585
outPacket->duration = Frame->pkt_duration;
1586+
#else
1587+
outPacket->duration = Frame->duration;
1588+
#endif
15841589
return outPacket;
15851590
}
15861591
};
@@ -2142,7 +2147,11 @@ std::string FileInformation::channelLayout() const
21422147
if (stream.codec()->codec()->long_name == nullptr)
21432148
return std::string();
21442149

2150+
#if LIBAVUTIL_VERSION_INT <= AV_VERSION_INT(57, 23, 0)
21452151
switch (stream.stream()->codecpar->channel_layout)
2152+
#else
2153+
switch (stream.stream()->codecpar->ch_layout.u.mask)
2154+
#endif
21462155
{
21472156
case AV_CH_LAYOUT_MONO: return "mono";
21482157
case AV_CH_LAYOUT_STEREO: return "stereo";

Source/Core/VideoStats.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extern "C"
1414
{
1515
#include <libavutil/frame.h>
1616
#include <libavutil/pixdesc.h>
17+
#include <libavutil/version.h>
1718
}
1819
#include <qavplayer.h>
1920

@@ -411,8 +412,13 @@ void VideoStats::TimeStampFromFrame (const QAVFrame& frame, size_t FramePos)
411412
x[2][FramePos]=x[1][FramePos]/60;
412413
x[3][FramePos]=x[2][FramePos]/60;
413414
}
415+
#if LIBAVUTIL_VERSION_INT <= AV_VERSION_INT(57, 30, 0)
414416
if (Frame->pkt_duration!=AV_NOPTS_VALUE)
415417
durations[FramePos]=((double)Frame->pkt_duration)/Frequency;
418+
#else
419+
if (Frame->duration!=AV_NOPTS_VALUE)
420+
durations[FramePos]=((double)Frame->duration)/Frequency;
421+
#endif
416422
}
417423

418424
//---------------------------------------------------------------------------

0 commit comments

Comments
 (0)