From 8751a0e261c0c7150874f78b23c7f1d3539883b5 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 23 Dec 2012 20:03:30 +0100 Subject: 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. --- video/img_fourcc.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 video/img_fourcc.h (limited to 'video/img_fourcc.h') diff --git a/video/img_fourcc.h b/video/img_fourcc.h new file mode 100644 index 0000000000..fecb13f297 --- /dev/null +++ b/video/img_fourcc.h @@ -0,0 +1,57 @@ +#ifndef MPV_IMG_FOURCC_H +#define MPV_IMG_FOURCC_H + +#include + +#define MP_FOURCC(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((unsigned)(d)<<24)) + +#if BYTE_ORDER == BIG_ENDIAN +#define MP_FOURCC_E(a,b,c,d) MP_FOURCC(a,b,c,d) +#else +#define MP_FOURCC_E(a,b,c,d) MP_FOURCC(d,c,b,a) +#endif + +#define MP_FOURCC_RGB8 MP_FOURCC_E(8, 'B', 'G', 'R') +#define MP_FOURCC_RGB12 MP_FOURCC_E(12, 'B', 'G', 'R') +#define MP_FOURCC_RGB15 MP_FOURCC_E(15, 'B', 'G', 'R') +#define MP_FOURCC_RGB16 MP_FOURCC_E(16, 'B', 'G', 'R') +#define MP_FOURCC_RGB24 MP_FOURCC_E(24, 'B', 'G', 'R') +#define MP_FOURCC_RGB32 MP_FOURCC_E('A', 'B', 'G', 'R') + +#define MP_FOURCC_BGR8 MP_FOURCC_E(8, 'R', 'G', 'B') +#define MP_FOURCC_BGR12 MP_FOURCC_E(12, 'R', 'G', 'B') +#define MP_FOURCC_BGR15 MP_FOURCC_E(15, 'R', 'G', 'B') +#define MP_FOURCC_BGR16 MP_FOURCC_E(16, 'R', 'G', 'B') +#define MP_FOURCC_BGR24 MP_FOURCC_E(24, 'R', 'G', 'B') +#define MP_FOURCC_BGR32 MP_FOURCC_E('A', 'R', 'G', 'B') + +#define MP_FOURCC_YVU9 MP_FOURCC('Y', 'U', 'V', '9') +#define MP_FOURCC_YUV9 MP_FOURCC('Y', 'V', 'U', '9') +#define MP_FOURCC_YV12 MP_FOURCC('Y', 'V', '1', '2') +#define MP_FOURCC_I420 MP_FOURCC('I', '4', '2', '0') +#define MP_FOURCC_IYUV MP_FOURCC('I', 'Y', 'U', 'V') +#define MP_FOURCC_Y800 MP_FOURCC('Y', '8', '0', '0') +#define MP_FOURCC_Y8 MP_FOURCC('Y', '8', ' ', ' ') +#define MP_FOURCC_NV12 MP_FOURCC('N', 'V', '1', '2') +#define MP_FOURCC_NV21 MP_FOURCC('N', 'V', '2', '1') + +#define MP_FOURCC_UYVY MP_FOURCC('U', 'Y', 'V', 'Y') +#define MP_FOURCC_YUY2 MP_FOURCC('Y', 'U', 'Y', '2') + +#define MP_FOURCC_MJPEG MP_FOURCC('M', 'J', 'P', 'G') + +/* mplayer internal FourCCs + * see codecs.conf/vd_lavc.c + */ + +// lavc raw video decoder uses fourcc specified in sh_video->imgfmt +#define MP_FOURCC_RAWVIDEO MP_FOURCC('M', 'P', 'r', 'v') + +// lavc raw video decoder uses image format (IMGFMT_*) in sh_video->imgfmt +#define MP_FOURCC_IMGFMT MP_FOURCC('M', 'P', 'v', 'f') + +// NOTE: no "HM12" decoder exists, as vd_hmblck has been removed +// likely breaks video with some TV cards +#define MP_FOURCC_HM12 0x32314D48 + +#endif -- cgit v1.2.3