Skip to content

Commit 64c0ba2

Browse files
committed
upipe_sws: fix missing matrix coefficients
1 parent 28f6c4c commit 64c0ba2

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

lib/upipe-swscale/upipe_sws.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -141,22 +141,15 @@ UPIPE_HELPER_INPUT(upipe_sws, urefs, nb_urefs, max_urefs, blockers, upipe_sws_ha
141141
static int upipe_sws_convert_color(struct upipe *upipe, struct uref *flow_def)
142142
{
143143
int colorspace = -1;
144-
const char *matrix_coefficients;
145-
if (ubase_check(uref_pic_flow_get_matrix_coefficients(flow_def,
146-
&matrix_coefficients))) {
147-
if (!strcmp(matrix_coefficients, "bt709"))
148-
colorspace = SWS_CS_ITU709;
149-
else if (!strcmp(matrix_coefficients, "fcc"))
150-
colorspace = SWS_CS_FCC;
151-
else if (!strcmp(matrix_coefficients, "smpte170m"))
152-
colorspace = SWS_CS_SMPTE170M;
153-
else if (!strcmp(matrix_coefficients, "smpte240m"))
154-
colorspace = SWS_CS_SMPTE240M;
155-
else if (!strcmp(matrix_coefficients, "bt2020nc"))
156-
colorspace = SWS_CS_BT2020;
157-
else
158-
upipe_warn_va(upipe, "unknown color space %s", matrix_coefficients);
159-
}
144+
if (!ubase_check(uref_pic_flow_get_matrix_coefficients_val(
145+
flow_def, &colorspace))) {
146+
const char *matrix_coefficients;
147+
if (ubase_check(uref_pic_flow_get_matrix_coefficients(
148+
flow_def, &matrix_coefficients)))
149+
upipe_warn_va(upipe, "unknown matrix coefficients %s",
150+
matrix_coefficients);
151+
} else if (colorspace > 10 || colorspace == 8)
152+
upipe_warn_va(upipe, "unknown color space %d", colorspace);
160153
return colorspace;
161154
}
162155

0 commit comments

Comments
 (0)