mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
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.
This commit is contained in:
@@ -103,8 +103,6 @@ struct SwsContext *sws_getContextFromCmdLine(int srcW, int srcH,
|
||||
|
||||
dfmt = imgfmt2pixfmt(dstFormat);
|
||||
sfmt = imgfmt2pixfmt(srcFormat);
|
||||
if (srcFormat == IMGFMT_RGB8 || srcFormat == IMGFMT_BGR8)
|
||||
sfmt = PIX_FMT_PAL8;
|
||||
sws_getFlagsAndFilterFromCmdLine(&flags, &srcFilterParam, &dstFilterParam);
|
||||
|
||||
return sws_getContext(srcW, srcH, sfmt, dstW, dstH, dfmt, flags,
|
||||
@@ -176,8 +174,6 @@ static void mp_sws_set_conv(struct SwsContext *sws, struct mp_image *dst,
|
||||
struct mp_image *src, int my_sws_flags)
|
||||
{
|
||||
enum PixelFormat s_fmt = imgfmt2pixfmt(src->imgfmt);
|
||||
if (src->imgfmt == IMGFMT_RGB8 || src->imgfmt == IMGFMT_BGR8)
|
||||
s_fmt = PIX_FMT_PAL8;
|
||||
int s_csp = mp_csp_to_sws_colorspace(mp_image_csp(src));
|
||||
int s_range = mp_image_levels(src) == MP_CSP_LEVELS_PC;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user