From 3382a6f6e48c7e093c2b7e0e4a0e28b60a084358 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 8 Jun 2013 01:35:44 +0200 Subject: video: add a new method to configure filters and VOs The filter chain and the video ouputs have config() functions. They are strictly limited to transfering the video size and format. Other parameters (like color levels) have to be transferred separately. Improve upon this by introducing a separate set of reconfig() functions, which use mp_image_params to carry format parameters. This struct contains all image format related parameters from config(), plus additional parameters such as colorspace. Change vf_rotate to use it, as well as vo_opengl. vf_rotate is just an example/test case, but vo_opengl will need it later. The intention is also to get rid of VOCTRL_SET_YUV_COLORSPACE. This information is now handed to the VOs via reconfig(). The getter, VOCTRL_GET_YUV_COLORSPACE, will still be needed though. --- video/decode/vd_lavc.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'video/decode/vd_lavc.c') diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 1f5ae68bbf..f67e6dfbe6 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -436,10 +436,19 @@ static int init_vo(sh_video_t *sh, AVFrame *frame) ctx->pix_fmt = pix_fmt; ctx->best_csp = pixfmt2imgfmt(pix_fmt); - sh->colorspace = avcol_spc_to_mp_csp(ctx->avctx->colorspace); - sh->color_range = avcol_range_to_mp_csp_levels(ctx->avctx->color_range); + ctx->image_params = (struct mp_image_params) { + .imgfmt = ctx->best_csp, + .w = width, + .h = height, + // Ideally, we should also set aspect ratio, but we aren't there yet + // - so vd.c calculates display size from sh->aspect. + .d_w = width, + .d_h = height, + .colorspace = avcol_spc_to_mp_csp(ctx->avctx->colorspace), + .colorlevels = avcol_range_to_mp_csp_levels(ctx->avctx->color_range), + }; - if (!mpcodecs_config_vo(sh, sh->disp_w, sh->disp_h, ctx->best_csp)) + if (mpcodecs_reconfig_vo(sh, &ctx->image_params) < 0) return -1; ctx->vo_initialized = 1; @@ -690,8 +699,8 @@ static int decode(struct sh_video *sh, struct demux_packet *packet, struct mp_image *mpi = image_from_decoder(sh); assert(mpi->planes[0]); - mpi->colorspace = sh->colorspace; - mpi->levels = sh->color_range; + mpi->colorspace = ctx->image_params.colorspace; + mpi->levels = ctx->image_params.colorlevels; *out_image = mpi; return 1; @@ -745,7 +754,8 @@ static int control(sh_video_t *sh, int cmd, void *arg) *(int *)arg = delay; return CONTROL_TRUE; case VDCTRL_REINIT_VO: - mpcodecs_config_vo(sh, sh->disp_w, sh->disp_h, ctx->best_csp); + if (ctx->vo_initialized) + mpcodecs_reconfig_vo(sh, &ctx->image_params); return true; } return CONTROL_UNKNOWN; -- cgit v1.2.3