summaryrefslogtreecommitdiffstats
path: root/stream/tv.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-12-23 20:03:30 +0100
committerwm4 <wm4@nowhere>2013-01-13 20:04:11 +0100
commit8751a0e261c0c7150874f78b23c7f1d3539883b5 (patch)
treebe72a06e1d1470cf968835e432c19f6d3a0e49b2 /stream/tv.c
parent0c5311f17cb9078f0ddde7c41cad61d00aea4a94 (diff)
downloadmpv-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 'stream/tv.c')
-rw-r--r--stream/tv.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/stream/tv.c b/stream/tv.c
index e5e64dd636..a9bc535cee 100644
--- a/stream/tv.c
+++ b/stream/tv.c
@@ -42,7 +42,7 @@
#include "demux/stheader.h"
#include "audio/format.h"
-#include "video/img_format.h"
+#include "video/img_fourcc.h"
#include "libavutil/avstring.h"
#include "osdep/timer.h"
@@ -409,14 +409,14 @@ static int open_tv(tvi_handle_t *tvh)
int i;
const tvi_functions_t *funcs = tvh->functions;
static const int tv_fmt_list[] = {
- IMGFMT_YV12,
- IMGFMT_I420,
- IMGFMT_UYVY,
- IMGFMT_YUY2,
- IMGFMT_RGB32,
- IMGFMT_RGB24,
- IMGFMT_RGB16,
- IMGFMT_RGB15
+ MP_FOURCC_YV12,
+ MP_FOURCC_I420,
+ MP_FOURCC_UYVY,
+ MP_FOURCC_YUY2,
+ MP_FOURCC_RGB32,
+ MP_FOURCC_RGB24,
+ MP_FOURCC_RGB16,
+ MP_FOURCC_RGB15
};
if (funcs->control(tvh->priv, TVI_CONTROL_IS_VIDEO, 0) != TVI_CONTROL_TRUE)
@@ -437,16 +437,16 @@ static int open_tv(tvi_handle_t *tvh)
{
switch(tvh->tv_param->outfmt)
{
- case IMGFMT_YV12:
- case IMGFMT_I420:
- case IMGFMT_UYVY:
- case IMGFMT_YUY2:
- case IMGFMT_RGB32:
- case IMGFMT_RGB24:
- case IMGFMT_BGR32:
- case IMGFMT_BGR24:
- case IMGFMT_BGR16:
- case IMGFMT_BGR15:
+ case MP_FOURCC_YV12:
+ case MP_FOURCC_I420:
+ case MP_FOURCC_UYVY:
+ case MP_FOURCC_YUY2:
+ case MP_FOURCC_RGB32:
+ case MP_FOURCC_RGB24:
+ case MP_FOURCC_BGR32:
+ case MP_FOURCC_BGR24:
+ case MP_FOURCC_BGR16:
+ case MP_FOURCC_BGR15:
break;
default:
mp_tmsg(MSGT_TV, MSGL_ERR,
@@ -715,9 +715,10 @@ static demuxer_t* demux_open_tv(demuxer_t *demuxer)
sh_video = new_sh_video(demuxer, 0);
/* get IMAGE FORMAT */
- funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FORMAT, &sh_video->format);
-// if (IMGFMT_IS_RGB(sh_video->format) || IMGFMT_IS_BGR(sh_video->format))
-// sh_video->format = 0x0;
+ int fourcc;
+ funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FORMAT, &fourcc);
+ sh_video->format = MP_FOURCC_RAWVIDEO;
+ sh_video->imgfmt = fourcc;
/* set FPS and FRAMETIME */