Skip to content

Commit 98df3c3

Browse files
authored
Merge pull request #267 from blackforest-tom/master
Support newer ffmpeg versions
2 parents 067d146 + e07254f commit 98df3c3

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/av/include/scy/av/ffmpeg.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ extern "C" {
2727
#endif
2828
}
2929

30+
31+
#define LIBAVCODEC_VERSION_CHECK( a, b, c, d, e ) \
32+
( (LIBAVCODEC_VERSION_MICRO < 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( a, b, c ) ) || \
33+
(LIBAVCODEC_VERSION_MICRO >= 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( a, d, e ) ) )
34+
3035
#endif
3136

3237

src/av/src/audioencoder.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,13 @@ void AudioEncoder::create()
133133

134134
// Some container formats (like MP4) require global headers to be present
135135
// Mark the encoder so that it behaves accordingly.
136-
if (format && format->oformat->flags & AVFMT_GLOBALHEADER)
137-
ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
136+
if (format && format->oformat->flags & AVFMT_GLOBALHEADER) {
137+
#if LIBAVCODEC_VERSION_CHECK(52, 30, 2, 30, 2)
138+
ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
139+
#else
140+
ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
141+
#endif
142+
}
138143

139144
// Open the encoder for the audio stream to use it later.
140145
if ((err = avcodec_open2(ctx, codec, nullptr)) < 0) {

src/av/src/videoencoder.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,12 @@ void VideoEncoder::create()
118118
// TODO: Use oparams.quality to determine values
119119
// ctx->mb_lmin = ctx->lmin = ctx->qmin * FF_QP2LAMBDA;
120120
// ctx->mb_lmax = ctx->lmax = ctx->qmax * FF_QP2LAMBDA;
121-
ctx->flags = CODEC_FLAG_QSCALE;
121+
#if LIBAVCODEC_VERSION_CHECK(52, 30, 2, 30, 2)
122+
ctx->flags |= AV_CODEC_FLAG_QSCALE;
123+
#else
124+
ctx->flags |= CODEC_FLAG_QSCALE;
125+
#endif
126+
122127
ctx->global_quality = ctx->qmin * FF_QP2LAMBDA;
123128
break;
124129
case AV_CODEC_ID_MPEG2VIDEO:
@@ -129,8 +134,13 @@ void VideoEncoder::create()
129134
}
130135

131136
// Some formats want stream headers to be separate
132-
if (format && format->oformat->flags & AVFMT_GLOBALHEADER)
133-
ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
137+
if (format && format->oformat->flags & AVFMT_GLOBALHEADER) {
138+
#if LIBAVCODEC_VERSION_CHECK(52, 30, 2, 30, 2)
139+
ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
140+
#else
141+
ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
142+
#endif
143+
}
134144

135145
// Allocate the input frame
136146
frame = createVideoFrame(av_get_pix_fmt(iparams.pixelFmt.c_str()),

0 commit comments

Comments
 (0)