diff options
author | wm4 <wm4@nowhere> | 2012-11-05 19:27:38 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-01-13 17:39:31 +0100 |
commit | 06ccd9f6716ffb5220941bea12f345154545862e (patch) | |
tree | 26c2ebdd4e202d0888e76737d79fa9888f4f096d /video/decode/vd_lavc.c | |
parent | 42e0afe641de6eb15d89164e82671b6207402190 (diff) | |
download | mpv-06ccd9f6716ffb5220941bea12f345154545862e.tar.bz2 mpv-06ccd9f6716ffb5220941bea12f345154545862e.tar.xz |
video: simplify decoder pixel format handling
Simplify the decoder pixel format handling by making it handle only
the case vd_lavc needs: a video stream always decodes to a single
pixel format.
Remove the handling for multiple pixel formats, and remove the
codecs.conf pixel format declarations that are left.
Remove the handling of "ambiguous" pixel formats like YV12 vs. I420 (via
VDCTRL_QUERY_FORMAT etc.). This is only a problem if the video chain
supports I420, but not YV12, which doesn't seem to be the case anywhere,
and in fact would not have any advantage.
Make the "flip" flag a global per-codec flag, rather than a pixel format
specific flag. (Some ffmpeg decoders still return a flipped image, so
this has to be done manually.) Also fix handling of the flip operation:
do not overwrite the global flip option, and make the --flip option
invert the codec flip option rather than overriding it.
Diffstat (limited to 'video/decode/vd_lavc.c')
-rw-r--r-- | video/decode/vd_lavc.c | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 2f661dfdd1..41286141ab 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -408,23 +408,11 @@ static int init_vo(sh_video_t *sh, enum PixelFormat pix_fmt) sh->disp_h = height; ctx->pix_fmt = pix_fmt; ctx->best_csp = pixfmt2imgfmt(pix_fmt); - const unsigned int *supported_fmts; - if (ctx->best_csp == IMGFMT_YV12) - supported_fmts = (const unsigned int[]){ - IMGFMT_YV12, IMGFMT_I420, IMGFMT_IYUV, 0xffffffff - }; - else if (ctx->best_csp == IMGFMT_422P) - supported_fmts = (const unsigned int[]){ - IMGFMT_422P, IMGFMT_YV12, IMGFMT_I420, IMGFMT_IYUV, 0xffffffff - }; - else - supported_fmts = (const unsigned int[]){ctx->best_csp, 0xffffffff}; sh->colorspace = avcol_spc_to_mp_csp(avctx->colorspace); sh->color_range = avcol_range_to_mp_csp_levels(avctx->color_range); - if (!mpcodecs_config_vo(sh, sh->disp_w, sh->disp_h, supported_fmts, - ctx->best_csp)) + if (!mpcodecs_config_vo(sh, sh->disp_w, sh->disp_h, ctx->best_csp)) return -1; ctx->vo_initialized = 1; } @@ -726,6 +714,8 @@ static struct mp_image *decode(struct sh_video *sh, struct demux_packet *packet, if (!mpi->planes[0]) return NULL; + assert(mpi->imgfmt == pixfmt2imgfmt(avctx->pix_fmt)); + if (ctx->best_csp == IMGFMT_422P && mpi->chroma_y_shift == 1) { // we have 422p but user wants 420p mpi->stride[1] *= 2; @@ -777,24 +767,6 @@ static int control(sh_video_t *sh, int cmd, void *arg) vd_ffmpeg_ctx *ctx = sh->context; AVCodecContext *avctx = ctx->avctx; switch (cmd) { - case VDCTRL_QUERY_FORMAT: { - int format = (*((int *)arg)); - if (format == ctx->best_csp) - return CONTROL_TRUE; - // possible conversions: - switch (format) { - case IMGFMT_YV12: - case IMGFMT_IYUV: - case IMGFMT_I420: - // "converted" using pointer/stride modification - if (ctx->best_csp == IMGFMT_YV12) - return CONTROL_TRUE; // u/v swap - if (ctx->best_csp == IMGFMT_422P && !ctx->do_dr1) - return CONTROL_TRUE; // half stride - break; - } - return CONTROL_FALSE; - } case VDCTRL_RESYNC_STREAM: avcodec_flush_buffers(avctx); return CONTROL_TRUE; |