summaryrefslogtreecommitdiffstats
path: root/video/out/vo_sdl.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 /video/out/vo_sdl.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 'video/out/vo_sdl.c')
-rw-r--r--video/out/vo_sdl.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c
index c3ed3c6774..d760aff50c 100644
--- a/video/out/vo_sdl.c
+++ b/video/out/vo_sdl.c
@@ -54,11 +54,11 @@ struct formatmap_entry {
int is_rgba;
};
const struct formatmap_entry formats[] = {
- {SDL_PIXELFORMAT_YV12, IMGFMT_YV12, 0},
- {SDL_PIXELFORMAT_IYUV, IMGFMT_IYUV, 0},
- {SDL_PIXELFORMAT_YUY2, IMGFMT_YUY2, 0},
+ {SDL_PIXELFORMAT_YV12, IMGFMT_420P, 0},
+ {SDL_PIXELFORMAT_IYUV, IMGFMT_420P, 0},
+ {SDL_PIXELFORMAT_YUY2, IMGFMT_YUYV, 0},
{SDL_PIXELFORMAT_UYVY, IMGFMT_UYVY, 0},
- {SDL_PIXELFORMAT_YVYU, IMGFMT_YVYU, 0},
+ //{SDL_PIXELFORMAT_YVYU, IMGFMT_YVYU, 0},
#if BYTE_ORDER == BIG_ENDIAN
{SDL_PIXELFORMAT_RGBX8888, IMGFMT_RGBA, 0}, // has no alpha -> bad for OSD
{SDL_PIXELFORMAT_BGRX8888, IMGFMT_BGRA, 0}, // has no alpha -> bad for OSD
@@ -172,6 +172,7 @@ struct priv {
int renderer_index;
SDL_RendererInfo renderer_info;
SDL_Texture *tex;
+ int tex_swapped;
mp_image_t texmpi;
mp_image_t *ssmpi;
struct mp_rect src_rect;
@@ -427,6 +428,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
return -1;
}
+ vc->tex_swapped = texfmt == SDL_PIXELFORMAT_YV12;
vc->tex = SDL_CreateTexture(vc->renderer, texfmt,
SDL_TEXTUREACCESS_STREAMING, width, height);
if (!vc->tex) {
@@ -878,7 +880,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
texmpi->planes[0] = pixels;
texmpi->stride[0] = pitch;
if (texmpi->num_planes == 3) {
- if (texmpi->imgfmt == IMGFMT_YV12) {
+ if (vc->tex_swapped) {
texmpi->planes[2] =
((Uint8 *) texmpi->planes[0] + texmpi->h * pitch);
texmpi->stride[2] = pitch / 2;