diff options
author | Niklas Haas <git@haasn.xyz> | 2020-12-02 01:34:42 +0100 |
---|---|---|
committer | Niklas Haas <git@haasn.xyz> | 2020-12-02 01:36:29 +0100 |
commit | a74b6619f2aed42c2a6416ae0d798b95760f6a14 (patch) | |
tree | 7081c03eef183bc7905104a9d9edcee9ce37e9ea | |
parent | f16c6472a1d7b3506f561a1e1d0b2e9675ca06ea (diff) | |
download | mpv-a74b6619f2aed42c2a6416ae0d798b95760f6a14.tar.bz2 mpv-a74b6619f2aed42c2a6416ae0d798b95760f6a14.tar.xz |
csputils: add MP_CHROMA_TOPLEFT
This is commonly used by UHD/HDR sources, and mpv hilariously ignores it
up until now, just blindly mapping it to MP_CHROMA_AUTO without even so
much as a warning message.
It would be justified to add all the other chroma locations as well, but
I'm lazy and just wanted to quickly fix this bug.
-rw-r--r-- | video/csputils.c | 7 | ||||
-rw-r--r-- | video/csputils.h | 1 | ||||
-rw-r--r-- | video/zimg.c | 1 |
3 files changed, 8 insertions, 1 deletions
diff --git a/video/csputils.c b/video/csputils.c index f9b6c98689..a77cada487 100644 --- a/video/csputils.c +++ b/video/csputils.c @@ -103,6 +103,7 @@ const struct m_opt_choice_alternatives mp_csp_light_names[] = { const struct m_opt_choice_alternatives mp_chroma_names[] = { {"unknown", MP_CHROMA_AUTO}, + {"uhd", MP_CHROMA_TOPLEFT}, {"mpeg2/4/h264",MP_CHROMA_LEFT}, {"mpeg1/jpeg", MP_CHROMA_CENTER}, {0} @@ -288,6 +289,7 @@ enum mp_csp_prim mp_csp_guess_primaries(int width, int height) enum mp_chroma_location avchroma_location_to_mp(int avloc) { switch (avloc) { + case AVCHROMA_LOC_TOPLEFT: return MP_CHROMA_TOPLEFT; case AVCHROMA_LOC_LEFT: return MP_CHROMA_LEFT; case AVCHROMA_LOC_CENTER: return MP_CHROMA_CENTER; default: return MP_CHROMA_AUTO; @@ -297,6 +299,7 @@ enum mp_chroma_location avchroma_location_to_mp(int avloc) int mp_chroma_location_to_av(enum mp_chroma_location mploc) { switch (mploc) { + case MP_CHROMA_TOPLEFT: return AVCHROMA_LOC_TOPLEFT; case MP_CHROMA_LEFT: return AVCHROMA_LOC_LEFT; case MP_CHROMA_CENTER: return AVCHROMA_LOC_CENTER; default: return AVCHROMA_LOC_UNSPECIFIED; @@ -309,8 +312,10 @@ void mp_get_chroma_location(enum mp_chroma_location loc, int *x, int *y) { *x = 0; *y = 0; - if (loc == MP_CHROMA_LEFT) + if (loc == MP_CHROMA_LEFT || loc == MP_CHROMA_TOPLEFT) *x = -1; + if (loc == MP_CHROMA_TOPLEFT) + *y = -1; } void mp_invert_matrix3x3(float m[3][3]) diff --git a/video/csputils.h b/video/csputils.h index 965c313a02..323468260f 100644 --- a/video/csputils.h +++ b/video/csputils.h @@ -186,6 +186,7 @@ bool mp_colorspace_equal(struct mp_colorspace c1, struct mp_colorspace c2); enum mp_chroma_location { MP_CHROMA_AUTO, + MP_CHROMA_TOPLEFT, // uhd MP_CHROMA_LEFT, // mpeg2/4, h264 MP_CHROMA_CENTER, // mpeg1, jpeg MP_CHROMA_COUNT, diff --git a/video/zimg.c b/video/zimg.c index a73293c8c6..e29d7c4ce7 100644 --- a/video/zimg.c +++ b/video/zimg.c @@ -123,6 +123,7 @@ static void mp_zimg_update_from_cmdline(struct mp_zimg_context *ctx) static zimg_chroma_location_e mp_to_z_chroma(enum mp_chroma_location cl) { switch (cl) { + case MP_CHROMA_TOPLEFT: return ZIMG_CHROMA_TOP_LEFT; case MP_CHROMA_LEFT: return ZIMG_CHROMA_LEFT; case MP_CHROMA_CENTER: return ZIMG_CHROMA_CENTER; default: return ZIMG_CHROMA_LEFT; |