mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 03:01:03 +00:00
gst/: fix deserialization to have similar semantics to cast's, and check if the value is fittable into the target siz...
Original commit message from CVS: * gst/gstcaps.c: (gst_caps_from_string_inplace): * gst/gststructure.c: * gst/gstvalue.c: (gst_value_deserialize_int_helper): fix deserialization to have similar semantics to cast's, and check if the value is fittable into the target size, instead of doing a G_MIN/G_MAX comparison * testsuite/caps/Makefile.am: * testsuite/caps/caps.h: add caps that specify rgb bit masks using 0xFF...
This commit is contained in:
parent
ad5dda4de5
commit
8b0fc062fb
8 changed files with 58 additions and 14 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2005-06-22 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* gst/gstcaps.c: (gst_caps_from_string_inplace):
|
||||
* gst/gststructure.c:
|
||||
* gst/gstvalue.c: (gst_value_deserialize_int_helper):
|
||||
fix deserialization to have similar semantics to cast's,
|
||||
and check if the value is fittable into the target size,
|
||||
instead of doing a G_MIN/G_MAX comparison
|
||||
* testsuite/caps/Makefile.am:
|
||||
* testsuite/caps/caps.h:
|
||||
add caps that specify rgb bit masks using 0xFF...
|
||||
|
||||
2005-06-22 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* gst/gstvalue.c:
|
||||
|
|
|
@ -1413,6 +1413,7 @@ gst_caps_from_string_inplace (GstCaps * caps, const gchar * string)
|
|||
|
||||
structure = gst_structure_from_string (string, &s);
|
||||
if (structure == NULL) {
|
||||
GST_LOG ("no structure parsed from string %s\n", string);
|
||||
return FALSE;
|
||||
}
|
||||
gst_caps_append_structure (caps, structure);
|
||||
|
@ -1423,6 +1424,7 @@ gst_caps_from_string_inplace (GstCaps * caps, const gchar * string)
|
|||
s++;
|
||||
structure = gst_structure_from_string (s, &s);
|
||||
if (structure == NULL) {
|
||||
GST_LOG ("no structure parsed from string %s\n", s);
|
||||
return FALSE;
|
||||
}
|
||||
gst_caps_append_structure (caps, structure);
|
||||
|
@ -1431,6 +1433,7 @@ gst_caps_from_string_inplace (GstCaps * caps, const gchar * string)
|
|||
}
|
||||
|
||||
if (*s != 0) {
|
||||
GST_LOG ("string %s is not at 0 byte after parsing\n", s);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1469,7 +1469,7 @@ gst_structure_parse_value (gchar * str,
|
|||
* @end: FIXME, deduce from code
|
||||
*
|
||||
* Creates a #GstStructure from a string representation.
|
||||
*
|
||||
*
|
||||
* Returns: a new #GstStructure
|
||||
*/
|
||||
GstStructure *
|
||||
|
|
|
@ -1019,10 +1019,11 @@ gst_value_serialize_ ## _type (const GValue * value) \
|
|||
|
||||
static gboolean
|
||||
gst_value_deserialize_int_helper (long long *to, const char *s, long long min,
|
||||
long long max)
|
||||
long long max, int size)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
char *end;
|
||||
long long mask = -1;
|
||||
|
||||
*to = gst_strtoll (s, &end, 0);
|
||||
if (*end == 0) {
|
||||
|
@ -1046,8 +1047,23 @@ gst_value_deserialize_int_helper (long long *to, const char *s, long long min,
|
|||
}
|
||||
}
|
||||
if (ret) {
|
||||
if (*to < min || *to > max) {
|
||||
ret = FALSE;
|
||||
/* by definition, a long long fits into a long long; so ignore those */
|
||||
if (size != sizeof (mask)) {
|
||||
if (*to >= 0) {
|
||||
/* for positive numbers, we create a mask of 1's outside of the range
|
||||
* and 0's inside the range. An and will thus keep only 1 bits
|
||||
* outside of the range */
|
||||
mask <<= (size * 8);
|
||||
if ((mask & *to) != 0) {
|
||||
ret = FALSE;
|
||||
}
|
||||
} else {
|
||||
/* for negative numbers, we do a 2's complement version */
|
||||
mask <<= ((size * 8) - 1);
|
||||
if ((mask & *to) != mask) {
|
||||
ret = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -1060,9 +1076,11 @@ static gboolean \
|
|||
gst_value_deserialize_ ## _type (GValue * dest, const char *s) \
|
||||
{ \
|
||||
long long x; \
|
||||
g ## _type y; \
|
||||
\
|
||||
if (gst_value_deserialize_int_helper (&x, s, G_MIN ## _macro, G_MAX ## _macro)) { \
|
||||
g_value_set_ ## _type (dest, x); \
|
||||
if (gst_value_deserialize_int_helper (&x, s, G_MIN ## _macro, G_MAX ## _macro, sizeof (g ##_type))) { \
|
||||
y = x; \
|
||||
g_value_set_ ## _type (dest, y); \
|
||||
return TRUE; \
|
||||
} else { \
|
||||
return FALSE; \
|
||||
|
@ -1121,18 +1139,19 @@ gst_value_deserialize_ ## _type (GValue * dest, const char *s) \
|
|||
gst_value_register (&gst_value); \
|
||||
} G_STMT_END
|
||||
|
||||
CREATE_SERIALIZATION (int, INT)
|
||||
CREATE_SERIALIZATION (int64, INT64)
|
||||
CREATE_SERIALIZATION (long, LONG)
|
||||
CREATE_USERIALIZATION (uint, UINT)
|
||||
CREATE_USERIALIZATION (uint64, UINT64)
|
||||
CREATE_USERIALIZATION (ulong, ULONG)
|
||||
CREATE_SERIALIZATION (int, INT);
|
||||
CREATE_SERIALIZATION (int64, INT64);
|
||||
CREATE_SERIALIZATION (long, LONG);
|
||||
|
||||
CREATE_USERIALIZATION (uint, UINT);
|
||||
CREATE_USERIALIZATION (uint64, UINT64);
|
||||
CREATE_USERIALIZATION (ulong, ULONG);
|
||||
|
||||
/**********
|
||||
* double *
|
||||
**********/
|
||||
static int
|
||||
gst_value_compare_double (const GValue * value1, const GValue * value2)
|
||||
static int
|
||||
gst_value_compare_double (const GValue * value1, const GValue * value2)
|
||||
{
|
||||
if (value1->data[0].v_double > value2->data[0].v_double)
|
||||
return GST_VALUE_GREATER_THAN;
|
||||
|
|
|
@ -12,6 +12,7 @@ tests_pass = \
|
|||
fixed \
|
||||
fraction-convert \
|
||||
fraction-multiply-and-zero \
|
||||
fromstring \
|
||||
intersect2 \
|
||||
caps \
|
||||
value_compare \
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
include this file */
|
||||
|
||||
static const gchar *caps_list[] = {
|
||||
/*
|
||||
"audio/x-adpcm, layout=(string)quicktime; audio/x-adpcm, layout=(string)quicktime; audio/x-adpcm, layout=(string)wav; audio/x-adpcm, layout=(string)wav; audio/x-adpcm, layout=(string)dk3; audio/x-adpcm, layout=(string)dk3; audio/x-adpcm, layout=(string)dk4; audio/x-adpcm, layout=(string)dk4; audio/x-adpcm, layout=(string)westwood; audio/x-adpcm, layout=(string)westwood; audio/x-adpcm, layout=(string)smjpeg; audio/x-adpcm, layout=(string)smjpeg; audio/x-adpcm, layout=(string)microsoft; audio/x-adpcm, layout=(string)microsoft; audio/x-adpcm, layout=(string)4xm; audio/x-adpcm, layout=(string)4xm; audio/x-adpcm, layout=(string)xa; audio/x-adpcm, layout=(string)xa; audio/x-adpcm, layout=(string)adx; audio/x-adpcm, layout=(string)adx; audio/x-adpcm, layout=(string)ea; audio/x-adpcm, layout=(string)ea; audio/x-adpcm, layout=(string)g726; audio/x-adpcm, layout=(string)g726",
|
||||
"video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)I420; video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)YUY2; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)24, depth=(int)24, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, endianness=(int)4321; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)24, depth=(int)24, red_mask=(int)255, green_mask=(int)65280, blue_mask=(int)16711680, endianness=(int)4321; video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)Y42B; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)32, depth=(int)24, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, endianness=(int)4321; video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)YUV9; video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)Y41B; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)16, depth=(int)16, red_mask=(int)63488, green_mask=(int)2016, blue_mask=(int)31, endianness=(int)1234; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)16, depth=(int)15, red_mask=(int)31744, green_mask=(int)992, blue_mask=(int)31, endianness=(int)1234",
|
||||
"video/x-raw-yuv, format=(fourcc){ YUY2, I420 }, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]; video/x-jpeg, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-divx, divxversion=(int)[ 3, 5 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-xvid, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-3ivx, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-msmpeg, msmpegversion=(int)[ 41, 43 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/mpeg, mpegversion=(int)1, systemstream=(boolean)false, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-dv, systemstream=(boolean)false, width=(int)720, height=(int){ 576, 480 }; video/x-huffyuv, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]",
|
||||
|
@ -12,6 +13,9 @@ static const gchar *caps_list[] = {
|
|||
"video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)-16777216, green_mask=(int)16711680, blue_mask=(int)65280, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]",
|
||||
"video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]",
|
||||
"video/x-raw-yuv, format=(fourcc){ I420 }, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]",
|
||||
*/
|
||||
"video/x-raw-rgb, bpp = (int) 32, depth = (int) 24, endianness = (int) BIG_ENDIAN, red_mask = (int) 0x000000FF, framerate = (double) [ 0, max ]",
|
||||
"video/x-raw-rgb, bpp = (int) 32, depth = (int) 24, endianness = (int) BIG_ENDIAN, red_mask = (int) 0xFF000000, framerate = (double) [ 0, max ]",
|
||||
"ANY",
|
||||
"EMPTY"
|
||||
};
|
||||
|
|
|
@ -12,6 +12,7 @@ tests_pass = \
|
|||
fixed \
|
||||
fraction-convert \
|
||||
fraction-multiply-and-zero \
|
||||
fromstring \
|
||||
intersect2 \
|
||||
caps \
|
||||
value_compare \
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
include this file */
|
||||
|
||||
static const gchar *caps_list[] = {
|
||||
/*
|
||||
"audio/x-adpcm, layout=(string)quicktime; audio/x-adpcm, layout=(string)quicktime; audio/x-adpcm, layout=(string)wav; audio/x-adpcm, layout=(string)wav; audio/x-adpcm, layout=(string)dk3; audio/x-adpcm, layout=(string)dk3; audio/x-adpcm, layout=(string)dk4; audio/x-adpcm, layout=(string)dk4; audio/x-adpcm, layout=(string)westwood; audio/x-adpcm, layout=(string)westwood; audio/x-adpcm, layout=(string)smjpeg; audio/x-adpcm, layout=(string)smjpeg; audio/x-adpcm, layout=(string)microsoft; audio/x-adpcm, layout=(string)microsoft; audio/x-adpcm, layout=(string)4xm; audio/x-adpcm, layout=(string)4xm; audio/x-adpcm, layout=(string)xa; audio/x-adpcm, layout=(string)xa; audio/x-adpcm, layout=(string)adx; audio/x-adpcm, layout=(string)adx; audio/x-adpcm, layout=(string)ea; audio/x-adpcm, layout=(string)ea; audio/x-adpcm, layout=(string)g726; audio/x-adpcm, layout=(string)g726",
|
||||
"video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)I420; video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)YUY2; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)24, depth=(int)24, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, endianness=(int)4321; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)24, depth=(int)24, red_mask=(int)255, green_mask=(int)65280, blue_mask=(int)16711680, endianness=(int)4321; video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)Y42B; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)32, depth=(int)24, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, endianness=(int)4321; video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)YUV9; video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)Y41B; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)16, depth=(int)16, red_mask=(int)63488, green_mask=(int)2016, blue_mask=(int)31, endianness=(int)1234; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)16, depth=(int)15, red_mask=(int)31744, green_mask=(int)992, blue_mask=(int)31, endianness=(int)1234",
|
||||
"video/x-raw-yuv, format=(fourcc){ YUY2, I420 }, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]; video/x-jpeg, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-divx, divxversion=(int)[ 3, 5 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-xvid, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-3ivx, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-msmpeg, msmpegversion=(int)[ 41, 43 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/mpeg, mpegversion=(int)1, systemstream=(boolean)false, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-dv, systemstream=(boolean)false, width=(int)720, height=(int){ 576, 480 }; video/x-huffyuv, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]",
|
||||
|
@ -12,6 +13,9 @@ static const gchar *caps_list[] = {
|
|||
"video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)-16777216, green_mask=(int)16711680, blue_mask=(int)65280, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]",
|
||||
"video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]",
|
||||
"video/x-raw-yuv, format=(fourcc){ I420 }, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]",
|
||||
*/
|
||||
"video/x-raw-rgb, bpp = (int) 32, depth = (int) 24, endianness = (int) BIG_ENDIAN, red_mask = (int) 0x000000FF, framerate = (double) [ 0, max ]",
|
||||
"video/x-raw-rgb, bpp = (int) 32, depth = (int) 24, endianness = (int) BIG_ENDIAN, red_mask = (int) 0xFF000000, framerate = (double) [ 0, max ]",
|
||||
"ANY",
|
||||
"EMPTY"
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue