From aa6ba6372c627bc602647d225bdfb076f93bd291 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 19 Dec 2012 12:04:38 +0100 Subject: mp_image: change how palette is handled According to DOCS/OUTDATED-tech/colorspaces.txt, the following formats are supposed to be palettized: IMGFMT_BGR8 IMGFMT_RGB8, IMGFMT_BGR4_CHAR IMGFMT_RGB4_CHAR IMGFMT_BGR4 IMGFMT_RGB4 Of these, only BGR8 and RGB8 are actually treated as palettized in some way. ffmpeg has only one palettized format (AV_PIX_FMT_PAL8), and IMGFMT_BGR8 was inconsistently mapped to packed non-palettized RGB formats too (AV_PIX_FMT_BGR8). Moreover, vf_scale.c contained messy hacks to generate a palette when AV_PIX_FMT_BGR8 is output. (libswscale does not support AV_PIX_FMT_PAL8 output in the first place.) Get rid of all of this, and introduce IMGFMT_PAL8, which directly maps to AV_PIX_FMT_PAL8. Remove the palette creation code from vf_scale.c. IMGFMT_BGR8 maps to AV_PIX_FMT_RGB8 (don't ask me why it's swapped), without any palette use. Enabling it in vo_x11 or using it as vf_scale input seems to give correct results. --- video/out/vo_lavc.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'video/out/vo_lavc.c') diff --git a/video/out/vo_lavc.c b/video/out/vo_lavc.c index a9cb0624ac..cdb7f71797 100644 --- a/video/out/vo_lavc.c +++ b/video/out/vo_lavc.c @@ -87,8 +87,7 @@ static void uninit(struct vo *vo) if (vc->lastimg) { // palette hack - if (vc->lastimg->imgfmt == IMGFMT_RGB8 - || vc->lastimg->imgfmt == IMGFMT_BGR8) + if (vc->lastimg->imgfmt == IMGFMT_PAL8) vc->lastimg->planes[1] = NULL; free_mp_image(vc->lastimg); vc->lastimg = NULL; @@ -175,9 +174,8 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, vc->lastimg = alloc_mpi(width, height, format); // palette hack - if (vc->lastimg->imgfmt == IMGFMT_RGB8 || - vc->lastimg->imgfmt == IMGFMT_BGR8) - vc->lastimg->planes[1] = talloc_zero_size(vc, 1024); + if (vc->lastimg->imgfmt == IMGFMT_PAL8) + vc->lastimg->planes[1] = talloc_zero_size(vc, MP_PALETTE_SIZE); return 0; @@ -461,9 +459,8 @@ static void draw_image(struct vo *vo, mp_image_t *mpi) vc->lastimg_wants_osd = true; // palette hack - if (vc->lastimg->imgfmt == IMGFMT_RGB8 || - vc->lastimg->imgfmt == IMGFMT_BGR8) - memcpy(vc->lastimg->planes[1], mpi->planes[1], 1024); + if (vc->lastimg->imgfmt == IMGFMT_PAL8) + memcpy(vc->lastimg->planes[1], mpi->planes[1], MP_PALETTE_SIZE); vc->lastframeipts = vc->lastipts = frameipts; if (ectx->options->rawts && vc->lastipts < 0) { -- cgit v1.2.3