From 1ff6a1c8c7eae341a4052b115083005663c44503 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 16 Oct 2017 16:56:24 +0200 Subject: video: make previously added hwdec params mechanism more generic The mechanism introduced in b135af6842bf assumed AVHWFramesContext would be enough. Apparently it's not - the intended use with Rockchip (not Rokchip btw.) requires accessing actual frame data in order to access the AVDRMFrameDescriptor struct. Just pass the entire mp_image to the new function. This is more flexible, although it slightly worries me that it will be less reusable for things which require setting up mp_image_params before any real frames are processed (such as filters). --- video/mp_image.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'video/mp_image.c') diff --git a/video/mp_image.c b/video/mp_image.c index 18d700df15..63670a6726 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -855,15 +855,6 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *src) if (src->repeat_pict == 1) dst->fields |= MP_IMGFIELD_REPEAT_FIRST; - if (src->hw_frames_ctx) { - AVHWFramesContext *fctx = (void *)src->hw_frames_ctx->data; - dst->params.hw_subfmt = pixfmt2imgfmt(fctx->sw_format); - const struct hwcontext_fns *fns = - hwdec_get_hwcontext_fns(fctx->device_ctx->type); - if (fns && fns->complete_image_params) - fns->complete_image_params(fctx, &dst->params); - } - dst->params.color = (struct mp_colorspace){ .space = avcol_spc_to_mp_csp(src->colorspace), .levels = avcol_range_to_mp_csp_levels(src->color_range), @@ -888,6 +879,15 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *src) dst->icc_profile = av_buffer_ref(sd->buf); #endif + if (dst->hwctx) { + AVHWFramesContext *fctx = (void *)dst->hwctx->data; + dst->params.hw_subfmt = pixfmt2imgfmt(fctx->sw_format); + const struct hwcontext_fns *fns = + hwdec_get_hwcontext_fns(fctx->device_ctx->type); + if (fns && fns->complete_image_params) + fns->complete_image_params(dst); + } + return mp_image_new_ref(dst); } -- cgit v1.2.3