mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-22 06:40:26 +00:00
lavc: replace deprecated items
Some AVCodec properties like pix_fmts or sample_fmts are marked as deprecated and should be replaced by avcodec_get_supported_config() in current FFmpeg. Created compat functions to get rid of deprecate warnings running with both old and new FFmpeg.
This commit is contained in:
@@ -347,4 +347,61 @@ get_avpixfmts_names(const enum AVPixelFormat *pixfmts)
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ctx may be nullptr if codec is not
|
||||
* @param codec may be nullptr if ctx is not
|
||||
*
|
||||
* If passed ctx, values such as `strict_std_compliance` may afect the result.
|
||||
*/
|
||||
static const void *
|
||||
avc_get_supported_config(const AVCodecContext *ctx, const AVCodec *codec,
|
||||
enum AVCodecConfig config)
|
||||
{
|
||||
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(61, 13, 100)
|
||||
const void *ret = NULL;
|
||||
int unused_count = 0;
|
||||
const int rc = avcodec_get_supported_config(
|
||||
ctx, codec, config, /*flags*/ 0, &ret,
|
||||
&unused_count);
|
||||
if (rc != 0) {
|
||||
MSG(ERROR, "Cannot get list of supported config %d for %s!\n",
|
||||
(int) config, codec->name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
#else
|
||||
abort(); // cannot reach here (shouldn't be called)
|
||||
#endif
|
||||
}
|
||||
///< @copydoc avc_get_supported_config
|
||||
const enum AVPixelFormat *
|
||||
avc_get_supported_pix_fmts(const AVCodecContext *ctx, const AVCodec *codec)
|
||||
{
|
||||
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(61, 13, 100)
|
||||
return avc_get_supported_config(ctx, codec, AV_CODEC_CONFIG_PIX_FORMAT);
|
||||
#else
|
||||
return codec->pix_fmts;
|
||||
#endif
|
||||
}
|
||||
///< @copydoc avc_get_supported_config
|
||||
const enum AVSampleFormat *
|
||||
avc_get_supported_sample_fmts(const AVCodecContext *ctx, const AVCodec *codec)
|
||||
{
|
||||
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(61, 13, 100)
|
||||
return avc_get_supported_config(ctx, codec, AV_CODEC_CONFIG_SAMPLE_FORMAT);
|
||||
#else
|
||||
return codec->pix_fmts;
|
||||
#endif
|
||||
}
|
||||
///< @copydoc avc_get_supported_config
|
||||
const int *avc_get_supported_sample_rates(const AVCodecContext *ctx, const AVCodec *codec)
|
||||
{
|
||||
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(61, 13, 100)
|
||||
return avc_get_supported_config(ctx, codec, AV_CODEC_CONFIG_SAMPLE_RATE);
|
||||
#else
|
||||
return codec->supported_samplerates;
|
||||
#endif
|
||||
}
|
||||
/* vi: set expandtab sw=8: */
|
||||
|
||||
@@ -122,6 +122,13 @@ struct audio_desc audio_desc_from_av_frame(const AVFrame *frm);
|
||||
enum AVSampleFormat audio_bps_to_av_sample_fmt(int bps, bool planar);
|
||||
const char *get_avpixfmts_names(const enum AVPixelFormat *pixfmts);
|
||||
|
||||
const enum AVPixelFormat *avc_get_supported_pix_fmts(const AVCodecContext *ctx,
|
||||
const AVCodec *codec);
|
||||
const enum AVSampleFormat *
|
||||
avc_get_supported_sample_fmts(const AVCodecContext *ctx, const AVCodec *codec);
|
||||
const int *avc_get_supported_sample_rates(const AVCodecContext *ctx,
|
||||
const AVCodec *codec);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user