diff options
author | wm4 <wm4@nowhere> | 2012-12-23 20:03:30 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-01-13 20:04:11 +0100 |
commit | 8751a0e261c0c7150874f78b23c7f1d3539883b5 (patch) | |
tree | be72a06e1d1470cf968835e432c19f6d3a0e49b2 /video/decode | |
parent | 0c5311f17cb9078f0ddde7c41cad61d00aea4a94 (diff) | |
download | mpv-8751a0e261c0c7150874f78b23c7f1d3539883b5.tar.bz2 mpv-8751a0e261c0c7150874f78b23c7f1d3539883b5.tar.xz |
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
Diffstat (limited to 'video/decode')
-rw-r--r-- | video/decode/lavc.h | 1 | ||||
-rw-r--r-- | video/decode/vd_lavc.c | 19 |
2 files changed, 9 insertions, 11 deletions
diff --git a/video/decode/lavc.h b/video/decode/lavc.h index a355f61310..df3f97ef87 100644 --- a/video/decode/lavc.h +++ b/video/decode/lavc.h @@ -21,7 +21,6 @@ typedef struct ffmpeg_ctx { double inv_qp_sum; AVRational last_sample_aspect_ratio; enum AVDiscard skip_frame; - int rawvideo_fmt; AVCodec *software_fallback; struct FramePool *dr1_buffer_pool; struct mp_image_pool *non_dr1_pool; diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 24c3ba4e36..bf4cd42ba3 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -244,7 +244,6 @@ static int init(sh_video_t *sh) AVCodec *lavc_codec = NULL; ctx = sh->context = talloc_zero(NULL, vd_ffmpeg_ctx); - ctx->rawvideo_fmt = PIX_FMT_NONE; ctx->non_dr1_pool = talloc_steal(ctx, mp_image_pool_new(16)); if (sh->codec->dll) { @@ -264,10 +263,6 @@ static int init(sh_video_t *sh) uninit(sh); return 0; } - } else if (!IMGFMT_IS_HWACCEL(sh->format)) { - ctx->rawvideo_fmt = imgfmt2pixfmt(sh->format); - if (ctx->rawvideo_fmt != PIX_FMT_NONE) - lavc_codec = avcodec_find_decoder_by_name("rawvideo"); } if (!lavc_codec) { uninit(sh); @@ -358,11 +353,7 @@ static int init_avctx(sh_video_t *sh, AVCodec *lavc_codec, struct hwdec *hwdec) if (lavc_param->gray) avctx->flags |= CODEC_FLAG_GRAY; avctx->flags2 |= lavc_param->fast; - if (ctx->rawvideo_fmt == PIX_FMT_NONE) { - avctx->codec_tag = sh->format; - } else { - avctx->pix_fmt = ctx->rawvideo_fmt; - } + avctx->codec_tag = sh->format; if (sh->gsh->lavf_codec_tag) avctx->codec_tag = sh->gsh->lavf_codec_tag; avctx->stream_codec_tag = sh->video.fccHandler; @@ -440,6 +431,14 @@ static int init_avctx(sh_video_t *sh, AVCodec *lavc_codec, struct hwdec *hwdec) } break; + case MKTAG('M', 'P', 'v', 'f'): + avctx->codec_tag = 0; + avctx->pix_fmt = imgfmt2pixfmt(sh->imgfmt); + break; + case MKTAG('M', 'P', 'r', 'v'): + avctx->codec_tag = sh->imgfmt; + break; + default: if (!sh->bih || sh->bih->biSize <= sizeof(*sh->bih)) break; |