From ee9c850a00acdae06d8fe904c382182fc049a0a0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 1 Mar 2017 16:02:08 +0100 Subject: vd_lavc: log pixel format requested from decoder I find it slightly helpful in some situations. Also change the code to have a single exit path to make this easier. --- video/decode/vd_lavc.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'video') diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 8faf2dc71d..a7b05c8a35 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -821,12 +821,14 @@ static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx, ctx->hwdec_request_reinit |= ctx->hwdec_failed; ctx->hwdec_failed = false; + enum AVPixelFormat select = AV_PIX_FMT_NONE; for (int i = 0; fmt[i] != AV_PIX_FMT_NONE; i++) { if (ctx->hwdec->image_format == pixfmt2imgfmt(fmt[i])) { if (ctx->hwdec->generic_hwaccel) { if (init_generic_hwaccel(vd) < 0) break; - return fmt[i]; + select = fmt[i]; + break; } // There could be more reasons for a change, and it's possible // that we miss some. (Might also depend on the hwaccel type.) @@ -849,17 +851,25 @@ static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx, break; } } - return fmt[i]; + select = fmt[i]; + break; } } - ctx->hwdec_failed = true; - for (int i = 0; fmt[i] != AV_PIX_FMT_NONE; i++) { - const AVPixFmtDescriptor *d = av_pix_fmt_desc_get(fmt[i]); - if (d && !(d->flags & AV_PIX_FMT_FLAG_HWACCEL)) - return fmt[i]; + if (select == AV_PIX_FMT_NONE) { + ctx->hwdec_failed = true; + for (int i = 0; fmt[i] != AV_PIX_FMT_NONE; i++) { + const AVPixFmtDescriptor *d = av_pix_fmt_desc_get(fmt[i]); + if (d && !(d->flags & AV_PIX_FMT_FLAG_HWACCEL)) { + select = fmt[i]; + break; + } + } } - return AV_PIX_FMT_NONE; + + const char *name = av_get_pix_fmt_name(select); + MP_VERBOSE(vd, "Requesting pixfmt '%s' from decoder.\n", name ? name : "-"); + return select; } static int get_buffer2_hwdec(AVCodecContext *avctx, AVFrame *pic, int flags) -- cgit v1.2.3