fix(encoder): read pix_fmts from AVCodec->pix_fmts for old libavformat

Signed-off-by: k4yt3x <i@k4yt3x.com>
This commit is contained in:
k4yt3x
2024-11-10 00:00:00 +00:00
parent e393910f21
commit 4c919de6ba
2 changed files with 6 additions and 0 deletions

View File

@@ -60,6 +60,7 @@ get_encoder_default_pix_fmt(const AVCodec *encoder, AVPixelFormat target_pix_fmt
char errbuf[AV_ERROR_MAX_STRING_SIZE];
// Retrieve the list of supported pixel formats
#if LIBAVCODEC_BUILD >= CALC_FFMPEG_VERSION(61, 13, 100)
const enum AVPixelFormat *supported_pix_fmts = nullptr;
ret = avcodec_get_supported_config(
nullptr, encoder, AV_CODEC_CONFIG_PIX_FORMAT, 0, (const void **)&supported_pix_fmts, nullptr
@@ -79,6 +80,9 @@ get_encoder_default_pix_fmt(const AVCodec *encoder, AVPixelFormat target_pix_fmt
return target_pix_fmt;
}
}
#else
const enum AVPixelFormat *supported_pix_fmts = encoder->pix_fmts;
#endif
// Determine if the target pixel format has an alpha channel
const AVPixFmtDescriptor *desc = nullptr;