FFmpeg: compilation fix

The compat FF_API_PLUS1_MINUS1 macro (babdb792) was incorrectly used -
if it were defined, the new depth field is already present. On contrary,
if not, depth_minus1 needed to be used. Rather do not depend on it,
anyway and use libavutil version.
This commit is contained in:
Martin Pulec
2021-05-14 15:00:34 +02:00
parent f2c4c146e1
commit e6720ddea4
2 changed files with 8 additions and 8 deletions

View File

@@ -114,7 +114,7 @@ struct libavcodec_codec_state {
uint32_t magic;
pthread_mutex_t *libav_global_lock;
AVCodecContext *codec_ctx;
AVCodec *codec;
const AVCodec *codec;
AVFrame *av_frame;
@@ -224,7 +224,7 @@ static void *libavcodec_init(audio_codec_t audio_codec, audio_codec_direction_t
}
/* check that a given sample format is supported by the encoder */
static int check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt)
static int check_sample_fmt(const AVCodec *codec, enum AVSampleFormat sample_fmt)
{
const enum AVSampleFormat *p = codec->sample_fmts;

View File

@@ -779,7 +779,7 @@ static int get_subsampling(enum AVPixelFormat fmt) {
* The list is ordered according to input description and requested subsampling.
*/
static list<enum AVPixelFormat> get_available_pix_fmts(struct video_desc in_desc,
AVCodec *codec, int requested_subsampling, codec_t force_conv_to)
const AVCodec *codec, int requested_subsampling, codec_t force_conv_to)
{
list<enum AVPixelFormat> fmts;
@@ -835,12 +835,12 @@ static list<enum AVPixelFormat> get_available_pix_fmts(struct video_desc in_desc
sort(available_formats.begin(), available_formats.end(), [bits_per_comp, is_rgb, preferred_subsampling](enum AVPixelFormat a, enum AVPixelFormat b) {
const struct AVPixFmtDescriptor *pda = av_pix_fmt_desc_get(a);
const struct AVPixFmtDescriptor *pdb = av_pix_fmt_desc_get(b);
#if defined(FF_API_PLUS1_MINUS1)
#if LIBAVUTIL_VERSION_MAJOR >= 56
int deptha = pda->comp[0].depth;
int depthb = pdb->comp[0].depth;
#else
int deptha = pda->comp[0].depth_minus1;
int depthb = pdb->comp[0].depth_minus1;
int deptha = pda->comp[0].depth_minus1 + 1;
int depthb = pdb->comp[0].depth_minus1 + 1;
#endif
#if defined(AV_PIX_FMT_FLAG_RGB)
bool rgba = pda->flags & AV_PIX_FMT_FLAG_RGB;
@@ -903,7 +903,7 @@ ADD_TO_PARAM("lavc-use-codec",
* requested_subsampling.
*/
list<enum AVPixelFormat> get_requested_pix_fmts(struct video_desc in_desc,
AVCodec *codec, int requested_subsampling) {
const AVCodec *codec, int requested_subsampling) {
codec_t force_conv_to = VIDEO_CODEC_NONE; // if non-zero, use only this codec as a target
// of UG conversions (before FFMPEG conversion)
// or (likely) no conversion at all
@@ -1013,7 +1013,7 @@ static bool configure_with(struct state_video_compress_libav *s, struct video_de
int ret;
codec_t ug_codec = VIDEO_CODEC_NONE;
AVPixelFormat pix_fmt;
AVCodec *codec = nullptr;
const AVCodec *codec = nullptr;
#ifdef HAVE_SWSCALE
sws_freeContext(s->sws_ctx);
s->sws_ctx = nullptr;