mirror of
https://github.com/k4yt3x/video2x.git
synced 2025-01-28 21:38:41 +00:00
fix(encoder): read pix_fmts from AVCodec->pix_fmts for old libavformat
Signed-off-by: k4yt3x <i@k4yt3x.com>
This commit is contained in:
parent
e393910f21
commit
4c919de6ba
@ -5,6 +5,8 @@ extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
}
|
||||
|
||||
#define CALC_FFMPEG_VERSION(a, b, c) (a << 16 | b << 8 | c)
|
||||
|
||||
int64_t get_video_frame_count(AVFormatContext *ifmt_ctx, int in_vstream_idx);
|
||||
|
||||
enum AVPixelFormat
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user