mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-15 22:01:27 +00:00
gst/typefind/gsttypefindfunctions.c: Bunch of small clean-ups: use gst_type_find_suggest_simple(); don't copy caps fo...
Original commit message from CVS: * gst/typefind/gsttypefindfunctions.c: (aac_type_find), (mp3_type_find), (musepack_type_find), (MULTIPART_MAX_HEADER_SIZE), (mpeg_sys_type_find), (mpeg_ts_type_find), (mpeg4_video_type_find), (h264_video_type_find), (mpeg_video_stream_type_find), (dv_type_find), (mmsh_type_find): Bunch of small clean-ups: use gst_type_find_suggest_simple(); don't copy caps for no good reason (this may be desirable to make it easier to detect leaks, but then it should probably be done for all caps in the typefinder somewhere).
This commit is contained in:
parent
ec07ea9905
commit
93db55c074
2 changed files with 43 additions and 71 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2008-06-04 Tim-Philipp Müller <tim.muller at collabora co uk>
|
||||||
|
|
||||||
|
* gst/typefind/gsttypefindfunctions.c: (aac_type_find),
|
||||||
|
(mp3_type_find), (musepack_type_find), (MULTIPART_MAX_HEADER_SIZE),
|
||||||
|
(mpeg_sys_type_find), (mpeg_ts_type_find), (mpeg4_video_type_find),
|
||||||
|
(h264_video_type_find), (mpeg_video_stream_type_find),
|
||||||
|
(dv_type_find), (mmsh_type_find):
|
||||||
|
Bunch of small clean-ups: use gst_type_find_suggest_simple(); don't
|
||||||
|
copy caps for no good reason (this may be desirable to make it easier
|
||||||
|
to detect leaks, but then it should probably be done for all caps
|
||||||
|
in the typefinder somewhere).
|
||||||
|
|
||||||
2008-06-04 Peter Kjellerstedt <pkj@axis.com>
|
2008-06-04 Peter Kjellerstedt <pkj@axis.com>
|
||||||
|
|
||||||
* tests/check/Makefile.am:
|
* tests/check/Makefile.am:
|
||||||
|
|
|
@ -577,29 +577,22 @@ aac_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
|
|
||||||
snc = GST_READ_UINT16_BE (c.data + len);
|
snc = GST_READ_UINT16_BE (c.data + len);
|
||||||
if ((snc & 0xfff6) == 0xfff0) {
|
if ((snc & 0xfff6) == 0xfff0) {
|
||||||
gint mpegversion = (c.data[1] & 0x08) ? 2 : 4;
|
gint mpegversion;
|
||||||
GstCaps *caps = gst_caps_new_simple ("audio/mpeg",
|
|
||||||
"framed", G_TYPE_BOOLEAN, FALSE,
|
|
||||||
"mpegversion", G_TYPE_INT, mpegversion,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, caps);
|
mpegversion = (c.data[1] & 0x08) ? 2 : 4;
|
||||||
gst_caps_unref (caps);
|
|
||||||
GST_DEBUG ("Found second ADTS-%d syncpoint at offset 0x%"
|
GST_DEBUG ("Found second ADTS-%d syncpoint at offset 0x%"
|
||||||
G_GINT64_MODIFIER "x, framelen %u", mpegversion, c.offset, len);
|
G_GINT64_MODIFIER "x, framelen %u", mpegversion, c.offset, len);
|
||||||
|
gst_type_find_suggest_simple (tf, GST_TYPE_FIND_LIKELY, "audio/mpeg",
|
||||||
|
"framed", G_TYPE_BOOLEAN, FALSE,
|
||||||
|
"mpegversion", G_TYPE_INT, mpegversion, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG ("No next frame found... (should have been at 0x%x)", len);
|
GST_DEBUG ("No next frame found... (should have been at 0x%x)", len);
|
||||||
} else if (!memcmp (c.data, "ADIF", 4)) {
|
} else if (!memcmp (c.data, "ADIF", 4)) {
|
||||||
/* ADIF header */
|
/* ADIF header */
|
||||||
GstCaps *caps = gst_caps_new_simple ("audio/mpeg",
|
gst_type_find_suggest_simple (tf, GST_TYPE_FIND_LIKELY, "audio/mpeg",
|
||||||
"framed", G_TYPE_BOOLEAN, FALSE,
|
"framed", G_TYPE_BOOLEAN, FALSE, "mpegversion", G_TYPE_INT, 4, NULL);
|
||||||
"mpegversion", G_TYPE_INT, 4,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, caps);
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -949,16 +942,10 @@ mp3_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
|
|
||||||
suggest:
|
suggest:
|
||||||
{
|
{
|
||||||
GstCaps *caps;
|
g_return_if_fail (layer >= 1 && layer <= 3);
|
||||||
|
|
||||||
g_assert (layer > 0);
|
gst_type_find_suggest_simple (tf, prob, "audio/mpeg",
|
||||||
|
"mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, layer, NULL);
|
||||||
caps = gst_caps_make_writable (MP3_CAPS);
|
|
||||||
gst_structure_set (gst_caps_get_structure (caps, 0), "layer",
|
|
||||||
G_TYPE_INT, layer, NULL);
|
|
||||||
gst_type_find_suggest (tf, prob, caps);
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -988,15 +975,8 @@ musepack_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (streamversion != -1) {
|
if (streamversion != -1) {
|
||||||
GstCaps *caps;
|
gst_type_find_suggest_simple (tf, prop, "audio/x-musepack",
|
||||||
|
"streamversion", G_TYPE_INT, streamversion, NULL);
|
||||||
caps = gst_caps_make_writable (MUSEPACK_CAPS);
|
|
||||||
gst_structure_set (gst_caps_get_structure (caps, 0), "streamversion",
|
|
||||||
G_TYPE_INT, streamversion, NULL);
|
|
||||||
|
|
||||||
gst_type_find_suggest (tf, prop, caps);
|
|
||||||
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1206,10 +1186,7 @@ multipart_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
}
|
}
|
||||||
if (*x == '\n' &&
|
if (*x == '\n' &&
|
||||||
!g_ascii_strncasecmp ("content-type:", (gchar *) x + 1, 13)) {
|
!g_ascii_strncasecmp ("content-type:", (gchar *) x + 1, 13)) {
|
||||||
GstCaps *caps = gst_caps_copy (MULTIPART_CAPS);
|
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MULTIPART_CAPS);
|
||||||
|
|
||||||
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, caps);
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1457,7 +1434,6 @@ mpeg_sys_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
return;
|
return;
|
||||||
suggest:
|
suggest:
|
||||||
{
|
{
|
||||||
GstCaps *caps = gst_caps_copy (MPEG_SYS_CAPS);
|
|
||||||
guint prob;
|
guint prob;
|
||||||
|
|
||||||
prob = GST_TYPE_FIND_POSSIBLE + (10 * (pack_headers + pes_headers));
|
prob = GST_TYPE_FIND_POSSIBLE + (10 * (pack_headers + pes_headers));
|
||||||
|
@ -1470,10 +1446,9 @@ suggest:
|
||||||
GST_LOG ("Suggesting MPEG %d system stream, %d packs, %d pes, prob %u%%\n",
|
GST_LOG ("Suggesting MPEG %d system stream, %d packs, %d pes, prob %u%%\n",
|
||||||
mpegversion, pack_headers, pes_headers, prob);
|
mpegversion, pack_headers, pes_headers, prob);
|
||||||
|
|
||||||
gst_structure_set (gst_caps_get_structure (caps, 0), "mpegversion",
|
gst_type_find_suggest_simple (tf, prob, "video/mpeg",
|
||||||
G_TYPE_INT, mpegversion, NULL);
|
"systemstream", G_TYPE_BOOLEAN, TRUE,
|
||||||
gst_type_find_suggest (tf, prob, caps);
|
"mpegversion", G_TYPE_INT, mpegversion, NULL);
|
||||||
gst_caps_unref (caps);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1551,18 +1526,15 @@ mpeg_ts_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
found = mpeg_ts_probe_headers (tf, skipped, pack_sizes[p]);
|
found = mpeg_ts_probe_headers (tf, skipped, pack_sizes[p]);
|
||||||
if (found >= GST_MPEGTS_TYPEFIND_MIN_HEADERS) {
|
if (found >= GST_MPEGTS_TYPEFIND_MIN_HEADERS) {
|
||||||
gint probability;
|
gint probability;
|
||||||
GstCaps *caps = gst_caps_copy (MPEGTS_CAPS);
|
|
||||||
|
|
||||||
gst_structure_set (gst_caps_get_structure (caps, 0), "packetsize",
|
|
||||||
G_TYPE_INT, pack_sizes[p], NULL);
|
|
||||||
|
|
||||||
/* found at least 4 headers. 10 headers = MAXIMUM probability.
|
/* found at least 4 headers. 10 headers = MAXIMUM probability.
|
||||||
* Arbitrarily, I assigned 10% probability for each header we
|
* Arbitrarily, I assigned 10% probability for each header we
|
||||||
* found, 40% -> 100% */
|
* found, 40% -> 100% */
|
||||||
probability = MIN (10 * found, GST_TYPE_FIND_MAXIMUM);
|
probability = MIN (10 * found, GST_TYPE_FIND_MAXIMUM);
|
||||||
|
|
||||||
gst_type_find_suggest (tf, probability, caps);
|
gst_type_find_suggest_simple (tf, probability, "video/mpegts",
|
||||||
gst_caps_unref (caps);
|
"systemstream", G_TYPE_BOOLEAN, TRUE,
|
||||||
|
"packetsize", G_TYPE_INT, pack_sizes[p], NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1605,10 +1577,8 @@ mpeg4_video_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
seen_vos = TRUE;
|
seen_vos = TRUE;
|
||||||
} else if (sc >= 0x20 && sc <= 0x2F) { /* video_object_layer_start_code */
|
} else if (sc >= 0x20 && sc <= 0x2F) { /* video_object_layer_start_code */
|
||||||
if (seen_vos) {
|
if (seen_vos) {
|
||||||
GstCaps *caps = gst_caps_copy (MPEG4_VIDEO_CAPS);
|
gst_type_find_suggest (tf, GST_TYPE_FIND_NEARLY_CERTAIN,
|
||||||
|
MPEG4_VIDEO_CAPS);
|
||||||
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM - 1, caps);
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
return;
|
return;
|
||||||
} else
|
} else
|
||||||
return;
|
return;
|
||||||
|
@ -1674,10 +1644,8 @@ h264_video_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
|
|
||||||
if ((stat_slice > 4 || (stat_dpa > 4 && stat_dpb > 4 && stat_dpc > 4)) &&
|
if ((stat_slice > 4 || (stat_dpa > 4 && stat_dpb > 4 && stat_dpc > 4)) &&
|
||||||
stat_idr >= 1 && stat_sps >= 1 && stat_pps >= 1) {
|
stat_idr >= 1 && stat_sps >= 1 && stat_pps >= 1) {
|
||||||
GstCaps *caps = gst_caps_copy (H264_VIDEO_CAPS);
|
gst_type_find_suggest (tf, GST_TYPE_FIND_NEARLY_CERTAIN,
|
||||||
|
H264_VIDEO_CAPS);
|
||||||
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM - 1, caps);
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1770,7 +1738,6 @@ mpeg_video_stream_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
|
|
||||||
if (found > 0 || seen_seq) {
|
if (found > 0 || seen_seq) {
|
||||||
GstTypeFindProbability probability = 0;
|
GstTypeFindProbability probability = 0;
|
||||||
GstCaps *caps;
|
|
||||||
|
|
||||||
GST_LOG ("Found %d pictures, seq:%d, gop:%d", found, seen_seq, seen_gop);
|
GST_LOG ("Found %d pictures, seq:%d, gop:%d", found, seen_seq, seen_gop);
|
||||||
|
|
||||||
|
@ -1793,10 +1760,9 @@ mpeg_video_stream_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
else if (seen_seq)
|
else if (seen_seq)
|
||||||
probability = GST_TYPE_FIND_POSSIBLE - 20;
|
probability = GST_TYPE_FIND_POSSIBLE - 20;
|
||||||
|
|
||||||
caps = gst_caps_copy (MPEG_VIDEO_CAPS);
|
gst_type_find_suggest_simple (tf, probability, "video/mpeg",
|
||||||
gst_caps_set_simple (caps, "mpegversion", G_TYPE_INT, 1, NULL);
|
"systemstream", G_TYPE_BOOLEAN, FALSE,
|
||||||
gst_type_find_suggest (tf, probability, caps);
|
"mpegversion", G_TYPE_INT, 1, NULL);
|
||||||
gst_caps_unref (caps);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2378,19 +2344,17 @@ dv_type_find (GstTypeFind * tf, gpointer private)
|
||||||
/* check for DIF and DV flag */
|
/* check for DIF and DV flag */
|
||||||
if (data && (data[0] == 0x1f) && (data[1] == 0x07) && (data[2] == 0x00) &&
|
if (data && (data[0] == 0x1f) && (data[1] == 0x07) && (data[2] == 0x00) &&
|
||||||
((data[4] & 0x01) == 0)) {
|
((data[4] & 0x01) == 0)) {
|
||||||
gchar *format;
|
const gchar *format;
|
||||||
GstCaps *caps = gst_caps_copy (DV_CAPS);
|
|
||||||
|
|
||||||
if (data[3] & 0x80) {
|
if (data[3] & 0x80) {
|
||||||
format = "PAL";
|
format = "PAL";
|
||||||
} else {
|
} else {
|
||||||
format = "NTSC";
|
format = "NTSC";
|
||||||
}
|
}
|
||||||
gst_structure_set (gst_caps_get_structure (caps, 0), "format",
|
|
||||||
G_TYPE_STRING, format, NULL);
|
|
||||||
|
|
||||||
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, caps);
|
gst_type_find_suggest_simple (tf, GST_TYPE_FIND_MAXIMUM, "video/x-dv",
|
||||||
gst_caps_unref (caps);
|
"systemstream", G_TYPE_BOOLEAN, TRUE,
|
||||||
|
"format", G_TYPE_STRING, format, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2783,11 +2747,7 @@ mmsh_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
if (data && data[0] == 0x24 && data[1] == 0x48 &&
|
if (data && data[0] == 0x24 && data[1] == 0x48 &&
|
||||||
GST_READ_UINT16_LE (data + 2) > 2 + 2 + 4 + 2 + 2 + 16 &&
|
GST_READ_UINT16_LE (data + 2) > 2 + 2 + 4 + 2 + 2 + 16 &&
|
||||||
memcmp (data + 2 + 2 + 4 + 2 + 2, asf_marker, 16) == 0) {
|
memcmp (data + 2 + 2 + 4 + 2 + 2, asf_marker, 16) == 0) {
|
||||||
GstCaps *caps = gst_caps_copy (MMSH_CAPS);
|
gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, MMSH_CAPS);
|
||||||
|
|
||||||
gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, caps);
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue