vd_lavc: fixup unchecked usage of AV_CODEC_EXPORT_DATA_FILM_GRAIN

This fixes build failures with avcodec 58.113.100 or before,
matching FFmpeg release versions 4.0 to 4.3.

This flag was added in between avcodec 58.113.100 and 58.114.100
during the FFmpeg 4.4 development cycle. It lacks its own version bump,
so instead a check for the define is utilized instead.

Additionally, warn the user if they request GPU film grain with
too old of an FFmpeg.

Fixes #10088
This commit is contained in:
Jan Ekström 2022-04-13 00:44:19 +03:00
parent 1a597ea987
commit 305332f8a0
1 changed files with 7 additions and 0 deletions

View File

@ -698,6 +698,12 @@ static void init_avctx(struct mp_filter *vd)
if (lavc_codec->id == AV_CODEC_ID_H264 && lavc_param->old_x264)
av_opt_set(avctx, "x264_build", "150", AV_OPT_SEARCH_CHILDREN);
#ifndef AV_CODEC_EXPORT_DATA_FILM_GRAIN
if (ctx->opts->film_grain == 1)
MP_WARN(vd, "GPU film grain requested, but FFmpeg too old to expose "
"film grain parameters. Please update to latest master, "
"or at least to release 4.4.\n");
#else
switch(ctx->opts->film_grain) {
case 0: /*CPU*/
// default lavc flags handle film grain within the decoder.
@ -720,6 +726,7 @@ static void init_avctx(struct mp_filter *vd)
break;
}
#endif
mp_set_avopts(vd->log, avctx, lavc_param->avopts);