1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 09:02:38 +00:00

csputils: add MP_CSP_TRC_ST428 as defined in ST 428-1

This commit is contained in:
Kacper Michajłow 2023-01-24 07:54:01 +01:00 committed by Leo Izen
parent c31e145e1f
commit cb9ba6cb26
4 changed files with 15 additions and 0 deletions

View File

@ -87,6 +87,7 @@ const struct m_opt_choice_alternatives mp_csp_trc_names[] = {
{"v-log", MP_CSP_TRC_V_LOG},
{"s-log1", MP_CSP_TRC_S_LOG1},
{"s-log2", MP_CSP_TRC_S_LOG2},
{"st428", MP_CSP_TRC_ST428},
{0}
};
@ -208,6 +209,7 @@ enum mp_csp_trc avcol_trc_to_mp_csp_trc(int avtrc)
case AVCOL_TRC_GAMMA28: return MP_CSP_TRC_GAMMA28;
case AVCOL_TRC_SMPTEST2084: return MP_CSP_TRC_PQ;
case AVCOL_TRC_ARIB_STD_B67: return MP_CSP_TRC_HLG;
case AVCOL_TRC_SMPTE428: return MP_CSP_TRC_ST428;
default: return MP_CSP_TRC_AUTO;
}
}
@ -260,6 +262,7 @@ int mp_csp_trc_to_avcol_trc(enum mp_csp_trc trc)
case MP_CSP_TRC_GAMMA28: return AVCOL_TRC_GAMMA28;
case MP_CSP_TRC_PQ: return AVCOL_TRC_SMPTEST2084;
case MP_CSP_TRC_HLG: return AVCOL_TRC_ARIB_STD_B67;
case MP_CSP_TRC_ST428: return AVCOL_TRC_SMPTE428;
default: return AVCOL_TRC_UNSPECIFIED;
}
}

View File

@ -89,6 +89,7 @@ enum mp_csp_trc {
MP_CSP_TRC_V_LOG,
MP_CSP_TRC_S_LOG1,
MP_CSP_TRC_S_LOG2,
MP_CSP_TRC_ST428,
MP_CSP_TRC_COUNT
};

View File

@ -422,6 +422,9 @@ void pass_linearize(struct gl_shader_cache *sc, enum mp_csp_trc trc)
" %s(lessThanEqual(vec3(%f), color.rgb))); \n",
SLOG_Q, SLOG_P, SLOG_C, SLOG_A, SLOG_B, SLOG_K2, gl_sc_bvec(sc, 3), SLOG_Q);
break;
case MP_CSP_TRC_ST428:
GLSL(color.rgb = vec3(52.37/48.0) * pow(color.rgb, vec3(2.6)););
break;
default:
abort();
}
@ -512,6 +515,9 @@ void pass_delinearize(struct gl_shader_cache *sc, enum mp_csp_trc trc)
" %s(lessThanEqual(vec3(0.0), color.rgb))); \n",
SLOG_P, SLOG_Q, SLOG_A / M_LN10, SLOG_K2, SLOG_B, SLOG_C, gl_sc_bvec(sc, 3));
break;
case MP_CSP_TRC_ST428:
GLSL(color.rgb = pow(color.rgb * vec3(48.0/52.37), vec3(1.0/2.6)););
break;
default:
abort();
}

View File

@ -110,6 +110,11 @@ enum pl_color_transfer mp_trc_to_pl(enum mp_csp_trc trc)
case MP_CSP_TRC_V_LOG: return PL_COLOR_TRC_V_LOG;
case MP_CSP_TRC_S_LOG1: return PL_COLOR_TRC_S_LOG1;
case MP_CSP_TRC_S_LOG2: return PL_COLOR_TRC_S_LOG2;
#if PL_API_VER >= 240
case MP_CSP_TRC_ST428: return PL_COLOR_TRC_ST428;
#else
case MP_CSP_TRC_ST428: return PL_COLOR_TRC_UNKNOWN;
#endif
case MP_CSP_TRC_COUNT: return PL_COLOR_TRC_COUNT;
}