summaryrefslogtreecommitdiffstats
path: root/video/decode
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2022-04-11 21:36:51 +0300
committerJan Ekström <jeebjp@gmail.com>2022-04-11 23:54:22 +0300
commit1a597ea98744a92cd29e636ea440edd95ef7a142 (patch)
tree3128998b7b91814bf5b427258dd90fed54c39284 /video/decode
parenteddc0bfe25bfea9202d43189f5c2447db5a5b9f0 (diff)
downloadmpv-1a597ea98744a92cd29e636ea440edd95ef7a142.tar.bz2
mpv-1a597ea98744a92cd29e636ea440edd95ef7a142.tar.xz
vd_lavc: fix decoder initialization when no VO is available
The VO is available during decoder initialization mostly for direct rendering purposes, so if f.ex. a complex filter chain is utilized, there is no video renderer information available via mp_filter_find_stream_info during creation of the decoder filter. Thus, check for whether the VO is available before attempting to check the capabilities flag from it. Additionally - to simplify logic - makes explicitly requesting GPU film grain to always disable decoder film grain functionality. The warning is still shown if the VO is available and no support for film grain application is available. Fixes #10079
Diffstat (limited to 'video/decode')
-rw-r--r--video/decode/vd_lavc.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index c45d205f10..d6e0a0338c 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -698,13 +698,27 @@ 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);
- if (ctx->opts->film_grain != 0 /*CPU*/) {
- if (ctx->vo->driver->caps & VO_CAP_FILM_GRAIN) {
- avctx->export_side_data |= AV_CODEC_EXPORT_DATA_FILM_GRAIN;
- } else if (ctx->opts->film_grain == 1 /*GPU*/) {
- MP_WARN(vd, "GPU film grain requested, but VO does not support "
- "applying film grain, disabling.\n");
+ switch(ctx->opts->film_grain) {
+ case 0: /*CPU*/
+ // default lavc flags handle film grain within the decoder.
+ break;
+ case 1: /*GPU*/
+ if (!ctx->vo ||
+ (ctx->vo && !(ctx->vo->driver->caps & VO_CAP_FILM_GRAIN))) {
+ MP_MSG(vd, ctx->vo ? MSGL_WARN : MSGL_V,
+ "GPU film grain requested, but VO %s, expect wrong output.\n",
+ ctx->vo ?
+ "does not support applying film grain" :
+ "is not available at decoder initialization to verify support");
}
+
+ avctx->export_side_data |= AV_CODEC_EXPORT_DATA_FILM_GRAIN;
+ break;
+ default:
+ if (ctx->vo && (ctx->vo->driver->caps & VO_CAP_FILM_GRAIN))
+ avctx->export_side_data |= AV_CODEC_EXPORT_DATA_FILM_GRAIN;
+
+ break;
}
mp_set_avopts(vd->log, avctx, lavc_param->avopts);