mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 10:40:34 +00:00
pbutils: Don't include default vp9 parameters in resulting codec mime string
According to the document defining the vp9 codec string, the optional fields should all be present only if at least one of them has a non-default value. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5719>
This commit is contained in:
parent
b299760325
commit
36f653fdc5
2 changed files with 34 additions and 6 deletions
|
@ -2471,7 +2471,8 @@ vp9_caps_get_mime_codec (GstCaps * caps)
|
|||
GstStructure *caps_st;
|
||||
const char *profile_str, *chroma_format_str, *colorimetry_str;
|
||||
guint bitdepth_luma, bitdepth_chroma;
|
||||
guint8 profile = -1, chroma_format = -1, level = -1;
|
||||
guint8 profile = -1, chroma_format = -1, level = -1, color_primaries =
|
||||
-1, color_transfer = -1, color_matrix = -1;
|
||||
gboolean video_full_range;
|
||||
GstVideoColorimetry cinfo = { 0, };
|
||||
GString *codec_string;
|
||||
|
@ -2539,11 +2540,16 @@ vp9_caps_get_mime_codec (GstCaps * caps)
|
|||
goto done;
|
||||
}
|
||||
|
||||
/* optional but all or nothing */
|
||||
g_string_append_printf (codec_string, ".%02u.%02u.%02u.%02u.%02u",
|
||||
chroma_format, gst_video_color_primaries_to_iso (cinfo.primaries),
|
||||
gst_video_transfer_function_to_iso (cinfo.transfer),
|
||||
gst_video_color_matrix_to_iso (cinfo.matrix), video_full_range);
|
||||
/* optional but all or nothing. Include them if any parameter differs from the default value */
|
||||
color_primaries = gst_video_color_primaries_to_iso (cinfo.primaries);
|
||||
color_transfer = gst_video_transfer_function_to_iso (cinfo.transfer);
|
||||
color_matrix = gst_video_color_matrix_to_iso (cinfo.matrix);
|
||||
if (chroma_format != 1 || color_primaries != 1 || color_transfer != 1
|
||||
|| color_matrix != 1 || video_full_range) {
|
||||
g_string_append_printf (codec_string, ".%02u.%02u.%02u.%02u.%02u",
|
||||
chroma_format, color_primaries, color_transfer, color_matrix,
|
||||
video_full_range);
|
||||
}
|
||||
|
||||
done:
|
||||
return g_string_free (codec_string, FALSE);
|
||||
|
|
|
@ -1495,6 +1495,28 @@ GST_START_TEST (test_pb_utils_caps_mime_codec)
|
|||
g_free (mime_codec);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
/* vp9 with default chroma subsampling, color primaries, color transfer, color
|
||||
* matrix and luma/chroma encoded in the "legal" range*/
|
||||
caps =
|
||||
gst_caps_from_string
|
||||
("video/x-vp9, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, colorimetry=(string)bt709, alignment=(string)super-frame, profile=(string)0, codec-alpha=(boolean)false");
|
||||
mime_codec = gst_codec_utils_caps_get_mime_codec (caps);
|
||||
fail_unless_equals_string (mime_codec, "vp09.00.10.08");
|
||||
g_free (mime_codec);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
/* vp9 with non-default chroma subsampling */
|
||||
caps = gst_caps_from_string ("video/x-vp9, width=(int)640, height=(int)480, "
|
||||
"pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, "
|
||||
"chroma-format=(string)4:2:2, bit-depth-luma=(uint)8, "
|
||||
"bit-depth-chroma=(uint)8, colorimetry=(string)bt709, "
|
||||
"alignment=(string)super-frame, profile=(string)0, "
|
||||
"codec-alpha=(boolean)false");
|
||||
mime_codec = gst_codec_utils_caps_get_mime_codec (caps);
|
||||
fail_unless_equals_string (mime_codec, "vp09.00.10.08.02.01.01.01.00");
|
||||
g_free (mime_codec);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
/* mjpeg */
|
||||
caps = gst_caps_new_empty_simple ("image/jpeg");
|
||||
mime_codec = gst_codec_utils_caps_get_mime_codec (caps);
|
||||
|
|
Loading…
Reference in a new issue