mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
typefinding: improve wavpack typefinder
Check for second block sync and return different probabilities depending on what we found (trumping the AAC loas typefinder's LIKELY probability after finding a second frame sync in this particular case). https://bugzilla.gnome.org/show_bug.cgi?id=687674
This commit is contained in:
parent
20c9d2d2cc
commit
bccb3feebf
1 changed files with 29 additions and 5 deletions
|
@ -1678,9 +1678,11 @@ GST_STATIC_CAPS ("audio/x-wavpack-correction, framed = (boolean) false");
|
||||||
static void
|
static void
|
||||||
wavpack_type_find (GstTypeFind * tf, gpointer unused)
|
wavpack_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
{
|
{
|
||||||
|
GstTypeFindProbability base_prob = GST_TYPE_FIND_POSSIBLE;
|
||||||
guint64 offset;
|
guint64 offset;
|
||||||
guint32 blocksize;
|
guint32 blocksize;
|
||||||
const guint8 *data;
|
const guint8 *data;
|
||||||
|
guint count_wv, count_wvc;
|
||||||
|
|
||||||
data = gst_type_find_peek (tf, 0, 32);
|
data = gst_type_find_peek (tf, 0, 32);
|
||||||
if (!data)
|
if (!data)
|
||||||
|
@ -1695,6 +1697,8 @@ wavpack_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
* work in pull-mode */
|
* work in pull-mode */
|
||||||
blocksize = GST_READ_UINT32_LE (data + 4);
|
blocksize = GST_READ_UINT32_LE (data + 4);
|
||||||
GST_LOG ("wavpack header, blocksize=0x%04x", blocksize);
|
GST_LOG ("wavpack header, blocksize=0x%04x", blocksize);
|
||||||
|
count_wv = 0;
|
||||||
|
count_wvc = 0;
|
||||||
offset = 32;
|
offset = 32;
|
||||||
while (offset < 8 + blocksize) {
|
while (offset < 8 + blocksize) {
|
||||||
guint32 sublen;
|
guint32 sublen;
|
||||||
|
@ -1720,18 +1724,38 @@ wavpack_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
switch (data[0] & 0x0f) {
|
switch (data[0] & 0x0f) {
|
||||||
case 0xa: /* ID_WV_BITSTREAM */
|
case 0xa: /* ID_WV_BITSTREAM */
|
||||||
case 0xc: /* ID_WVX_BITSTREAM */
|
case 0xc: /* ID_WVX_BITSTREAM */
|
||||||
gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, WAVPACK_CAPS);
|
++count_wv;
|
||||||
return;
|
break;
|
||||||
case 0xb: /* ID_WVC_BITSTREAM */
|
case 0xb: /* ID_WVC_BITSTREAM */
|
||||||
gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY,
|
++count_wvc;
|
||||||
WAVPACK_CORRECTION_CAPS);
|
break;
|
||||||
return;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (count_wv >= 5 || count_wvc >= 5)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
offset += sublen;
|
offset += sublen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check for second block header */
|
||||||
|
data = gst_type_find_peek (tf, 8 + blocksize, 4);
|
||||||
|
if (data != NULL && memcmp (data, "wvpk", 4) == 0) {
|
||||||
|
GST_DEBUG ("found second block sync");
|
||||||
|
base_prob = GST_TYPE_FIND_LIKELY;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_DEBUG ("wvc=%d, wv=%d", count_wvc, count_wv);
|
||||||
|
|
||||||
|
if (count_wvc > 0 && count_wvc > count_wv) {
|
||||||
|
gst_type_find_suggest (tf,
|
||||||
|
MIN (base_prob + 5 * count_wvc, GST_TYPE_FIND_NEARLY_CERTAIN),
|
||||||
|
WAVPACK_CORRECTION_CAPS);
|
||||||
|
} else if (count_wv > 0) {
|
||||||
|
gst_type_find_suggest (tf,
|
||||||
|
MIN (base_prob + 5 * count_wv, GST_TYPE_FIND_NEARLY_CERTAIN),
|
||||||
|
WAVPACK_CAPS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** application/postscrip ***/
|
/*** application/postscrip ***/
|
||||||
|
|
Loading…
Reference in a new issue