Browse Source

MT#55283 fix ffmpeg deprecation warning

ffmpeg 7.1+ has deprecated direct usage of ->sample_fmts in favour of a
call to avcodec_get_supported_config(). Update accordingly.

Change-Id: I0fbecbbcf52c38976f3387e34d816d11e1d09480
pull/1884/head
Richard Fuchs 1 year ago
parent
commit
65477ac5d5
2 changed files with 18 additions and 4 deletions
  1. +16
    -4
      lib/codeclib.c
  2. +2
    -0
      lib/codeclib.h

+ 16
- 4
lib/codeclib.c View File

@ -897,7 +897,13 @@ static const char *avc_decoder_init(decoder_t *dec, const str *extra_opts) {
return "failed to open codec context";
}
for (const enum AVSampleFormat *sfmt = codec->sample_fmts; sfmt && *sfmt != -1; sfmt++)
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 19, 0)
avcodec_get_supported_config(dec->avc.avcctx, codec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, (const void **) &dec->avc.sample_fmts, NULL);
#else
dec->avc.sample_fmts = codec->sample_fmts;
#endif
for (const enum AVSampleFormat *sfmt = dec->avc.sample_fmts; sfmt && *sfmt != -1; sfmt++)
cdbg("supported sample format for input codec %s: %s",
codec->name, av_get_sample_fmt_name(*sfmt));
@ -1845,15 +1851,21 @@ static const char *avc_encoder_init(encoder_t *enc, const str *extra_opts) {
enc->actual_format = enc->requested_format;
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 19, 0)
avcodec_get_supported_config(enc->avc.avcctx, enc->avc.codec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, (const void **) &enc->avc.sample_fmts, NULL);
#else
enc->avc.sample_fmts = enc->avc.codec->sample_fmts;
#endif
enc->actual_format.format = -1;
for (const enum AVSampleFormat *sfmt = enc->avc.codec->sample_fmts; sfmt && *sfmt != -1; sfmt++) {
for (const enum AVSampleFormat *sfmt = enc->avc.sample_fmts; sfmt && *sfmt != -1; sfmt++) {
cdbg("supported sample format for output codec %s: %s",
enc->avc.codec->name, av_get_sample_fmt_name(*sfmt));
if (*sfmt == enc->requested_format.format)
enc->actual_format.format = *sfmt;
}
if (enc->actual_format.format == -1 && enc->avc.codec->sample_fmts)
enc->actual_format.format = enc->avc.codec->sample_fmts[0];
if (enc->actual_format.format == -1 && enc->avc.sample_fmts)
enc->actual_format.format = enc->avc.sample_fmts[0];
cdbg("using output sample format %s for codec %s",
av_get_sample_fmt_name(enc->actual_format.format), enc->avc.codec->name);


+ 2
- 0
lib/codeclib.h View File

@ -280,6 +280,7 @@ struct decoder_s {
struct {
AVCodecContext *avcctx;
AVPacket *avpkt;
const enum AVSampleFormat *sample_fmts;
union {
struct {
@ -324,6 +325,7 @@ struct encoder_s {
struct {
const AVCodec *codec;
AVCodecContext *avcctx;
const enum AVSampleFormat *sample_fmts;
union {
struct {


Loading…
Cancel
Save