summaryrefslogtreecommitdiffstats
path: root/video/csputils.c
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2020-12-02 01:34:42 +0100
committerNiklas Haas <git@haasn.xyz>2020-12-02 01:36:29 +0100
commita74b6619f2aed42c2a6416ae0d798b95760f6a14 (patch)
tree7081c03eef183bc7905104a9d9edcee9ce37e9ea /video/csputils.c
parentf16c6472a1d7b3506f561a1e1d0b2e9675ca06ea (diff)
downloadmpv-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.
Diffstat (limited to 'video/csputils.c')
-rw-r--r--video/csputils.c7
1 files changed, 6 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])