mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
value: Fixed serialization for short fourccs.
"Y16 " and "Y8 " were not displayed properly because the space character is not alnum. A unit test is also included. Fixes bug #621282.
This commit is contained in:
parent
ad9f5e11d0
commit
ab0763f0e8
2 changed files with 63 additions and 8 deletions
|
@ -683,10 +683,16 @@ gst_value_transform_fourcc_string (const GValue * src_value,
|
|||
{
|
||||
guint32 fourcc = src_value->data[0].v_int;
|
||||
|
||||
if (g_ascii_isprint ((fourcc >> 0) & 0xff) &&
|
||||
g_ascii_isprint ((fourcc >> 8) & 0xff) &&
|
||||
g_ascii_isprint ((fourcc >> 16) & 0xff) &&
|
||||
g_ascii_isprint ((fourcc >> 24) & 0xff)) {
|
||||
gchar fourcc_char[4] = {
|
||||
(fourcc >> 0) & 0xff,
|
||||
(fourcc >> 8) & 0xff,
|
||||
(fourcc >> 16) & 0xff,
|
||||
(fourcc >> 24) & 0xff
|
||||
};
|
||||
if ((g_ascii_isalnum (fourcc_char[0]) || fourcc_char[0] == ' ') &&
|
||||
(g_ascii_isalnum (fourcc_char[1]) || fourcc_char[1] == ' ') &&
|
||||
(g_ascii_isalnum (fourcc_char[2]) || fourcc_char[2] == ' ') &&
|
||||
(g_ascii_isalnum (fourcc_char[3]) || fourcc_char[3] == ' ')) {
|
||||
dest_value->data[0].v_pointer =
|
||||
g_strdup_printf ("%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
|
||||
} else {
|
||||
|
@ -707,10 +713,16 @@ gst_value_serialize_fourcc (const GValue * value)
|
|||
{
|
||||
guint32 fourcc = value->data[0].v_int;
|
||||
|
||||
if (g_ascii_isalnum ((fourcc >> 0) & 0xff) &&
|
||||
g_ascii_isalnum ((fourcc >> 8) & 0xff) &&
|
||||
g_ascii_isalnum ((fourcc >> 16) & 0xff) &&
|
||||
g_ascii_isalnum ((fourcc >> 24) & 0xff)) {
|
||||
gchar fourcc_char[4] = {
|
||||
(fourcc >> 0) & 0xff,
|
||||
(fourcc >> 8) & 0xff,
|
||||
(fourcc >> 16) & 0xff,
|
||||
(fourcc >> 24) & 0xff
|
||||
};
|
||||
if ((g_ascii_isalnum (fourcc_char[0]) || fourcc_char[0] == ' ') &&
|
||||
(g_ascii_isalnum (fourcc_char[1]) || fourcc_char[1] == ' ') &&
|
||||
(g_ascii_isalnum (fourcc_char[2]) || fourcc_char[2] == ' ') &&
|
||||
(g_ascii_isalnum (fourcc_char[3]) || fourcc_char[3] == ' ')) {
|
||||
return g_strdup_printf ("%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
|
||||
} else {
|
||||
return g_strdup_printf ("0x%08x", fourcc);
|
||||
|
|
|
@ -24,6 +24,48 @@
|
|||
#include <gst/check/gstcheck.h>
|
||||
|
||||
|
||||
GST_START_TEST (test_serialize_fourcc)
|
||||
{
|
||||
int i;
|
||||
|
||||
guint32 fourccs[] = {
|
||||
GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
|
||||
GST_MAKE_FOURCC ('Y', '8', '0', '0'),
|
||||
GST_MAKE_FOURCC ('Y', '8', ' ', ' '),
|
||||
GST_MAKE_FOURCC ('Y', '1', '6', ' '),
|
||||
GST_MAKE_FOURCC ('Y', 'U', 'Y', '_'),
|
||||
GST_MAKE_FOURCC ('Y', 'U', 'Y', '#'),
|
||||
};
|
||||
gint fourccs_size = sizeof (fourccs) / sizeof (fourccs[0]);
|
||||
const gchar *fourcc_strings[] = {
|
||||
"YUY2",
|
||||
"Y800",
|
||||
"Y8 ",
|
||||
"Y16 ",
|
||||
"0x5f595559", /* Ascii values of YUY_ */
|
||||
"0x23595559", /* Ascii values of YUY# */
|
||||
};
|
||||
gint fourcc_strings_size =
|
||||
sizeof (fourcc_strings) / sizeof (fourcc_strings[0]);
|
||||
|
||||
fail_unless (fourccs_size == fourcc_strings_size);
|
||||
|
||||
for (i = 0; i < fourccs_size; ++i) {
|
||||
gchar *str;
|
||||
GValue value = { 0 };
|
||||
g_value_init (&value, GST_TYPE_FOURCC);
|
||||
|
||||
gst_value_set_fourcc (&value, fourccs[i]);
|
||||
str = gst_value_serialize (&value);
|
||||
|
||||
fail_unless (strcmp (str, fourcc_strings[i]) == 0);
|
||||
|
||||
g_free (str);
|
||||
}
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_deserialize_buffer)
|
||||
{
|
||||
GValue value = { 0 };
|
||||
|
@ -1762,6 +1804,7 @@ gst_value_suite (void)
|
|||
TCase *tc_chain = tcase_create ("general");
|
||||
|
||||
suite_add_tcase (s, tc_chain);
|
||||
tcase_add_test (tc_chain, test_serialize_fourcc);
|
||||
tcase_add_test (tc_chain, test_deserialize_buffer);
|
||||
tcase_add_test (tc_chain, test_serialize_buffer);
|
||||
tcase_add_test (tc_chain, test_deserialize_gint);
|
||||
|
|
Loading…
Reference in a new issue