mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 23:36:38 +00:00
typefinding: detect enhanced AC-3
https://bugzilla.gnome.org/show_bug.cgi?id=623846
This commit is contained in:
parent
ec3c19189d
commit
aad661ec77
1 changed files with 56 additions and 21 deletions
|
@ -1158,6 +1158,10 @@ static GstStaticCaps ac3_caps = GST_STATIC_CAPS ("audio/x-ac3");
|
||||||
|
|
||||||
#define AC3_CAPS (gst_static_caps_get(&ac3_caps))
|
#define AC3_CAPS (gst_static_caps_get(&ac3_caps))
|
||||||
|
|
||||||
|
static GstStaticCaps eac3_caps = GST_STATIC_CAPS ("audio/x-eac3");
|
||||||
|
|
||||||
|
#define EAC3_CAPS (gst_static_caps_get(&eac3_caps))
|
||||||
|
|
||||||
struct ac3_frmsize
|
struct ac3_frmsize
|
||||||
{
|
{
|
||||||
unsigned short bit_rate;
|
unsigned short bit_rate;
|
||||||
|
@ -1219,6 +1223,10 @@ ac3_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (c.data[0] == 0x0b && c.data[1] == 0x77) {
|
if (c.data[0] == 0x0b && c.data[1] == 0x77) {
|
||||||
|
guint bsid = (c.data[5] >> 3) & 0x1F;
|
||||||
|
|
||||||
|
if (bsid <= 8) {
|
||||||
|
/* ac3 */
|
||||||
guint fscod = (c.data[4] >> 6) & 0x03;
|
guint fscod = (c.data[4] >> 6) & 0x03;
|
||||||
guint frmsizecod = c.data[4] & 0x3f;
|
guint frmsizecod = c.data[4] & 0x3f;
|
||||||
|
|
||||||
|
@ -1227,8 +1235,8 @@ ac3_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
guint frame_size;
|
guint frame_size;
|
||||||
|
|
||||||
frame_size = ac3_frmsizecod_tbl[frmsizecod].frm_size[fscod];
|
frame_size = ac3_frmsizecod_tbl[frmsizecod].frm_size[fscod];
|
||||||
GST_LOG ("possible frame sync at offset %" G_GUINT64_FORMAT ", size=%u",
|
GST_LOG ("possible AC3 frame sync at offset %"
|
||||||
c.offset, frame_size);
|
G_GUINT64_FORMAT ", size=%u", c.offset, frame_size);
|
||||||
if (data_scan_ctx_ensure_data (tf, &c_next, (frame_size * 2) + 5)) {
|
if (data_scan_ctx_ensure_data (tf, &c_next, (frame_size * 2) + 5)) {
|
||||||
data_scan_ctx_advance (tf, &c_next, frame_size * 2);
|
data_scan_ctx_advance (tf, &c_next, frame_size * 2);
|
||||||
|
|
||||||
|
@ -1239,7 +1247,7 @@ ac3_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
if (fscod == fscod2 && frmsizecod == frmsizecod2) {
|
if (fscod == fscod2 && frmsizecod == frmsizecod2) {
|
||||||
GstTypeFindProbability prob;
|
GstTypeFindProbability prob;
|
||||||
|
|
||||||
GST_LOG ("found second frame, looks good");
|
GST_LOG ("found second AC3 frame, looks good");
|
||||||
if (c.offset == 0)
|
if (c.offset == 0)
|
||||||
prob = GST_TYPE_FIND_MAXIMUM;
|
prob = GST_TYPE_FIND_MAXIMUM;
|
||||||
else
|
else
|
||||||
|
@ -1249,7 +1257,34 @@ ac3_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GST_LOG ("no second frame found, false sync");
|
GST_LOG ("no second AC3 frame found, false sync");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* eac3 */
|
||||||
|
DataScanCtx c_next = c;
|
||||||
|
guint frame_size;
|
||||||
|
|
||||||
|
frame_size = ((((c.data[2] & 0x07) << 8) +
|
||||||
|
(c.data[3] & 0xff)) + 1) << 1;
|
||||||
|
GST_LOG ("possible E-AC3 frame sync at offset %"
|
||||||
|
G_GUINT64_FORMAT ", size=%u", c.offset, frame_size);
|
||||||
|
if (data_scan_ctx_ensure_data (tf, &c_next, (frame_size * 2) + 5)) {
|
||||||
|
data_scan_ctx_advance (tf, &c_next, frame_size * 2);
|
||||||
|
|
||||||
|
if (c_next.data[0] == 0x0b && c_next.data[1] == 0x77) {
|
||||||
|
GstTypeFindProbability prob;
|
||||||
|
|
||||||
|
GST_LOG ("found second E-AC3 frame, looks good");
|
||||||
|
if (c.offset == 0)
|
||||||
|
prob = GST_TYPE_FIND_MAXIMUM;
|
||||||
|
else
|
||||||
|
prob = GST_TYPE_FIND_NEARLY_CERTAIN;
|
||||||
|
|
||||||
|
gst_type_find_suggest (tf, prob, EAC3_CAPS);
|
||||||
|
} else {
|
||||||
|
GST_LOG ("no second E-AC3 frame found, false sync");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3873,7 +3908,7 @@ plugin_init (GstPlugin * plugin)
|
||||||
"s3m", "stm", "stx", "ult", "xm", NULL
|
"s3m", "stm", "stx", "ult", "xm", NULL
|
||||||
};
|
};
|
||||||
static const gchar *mp3_exts[] = { "mp3", "mp2", "mp1", "mpga", NULL };
|
static const gchar *mp3_exts[] = { "mp3", "mp2", "mp1", "mpga", NULL };
|
||||||
static const gchar *ac3_exts[] = { "ac3", NULL };
|
static const gchar *ac3_exts[] = { "ac3", "eac3", NULL };
|
||||||
static const gchar *dts_exts[] = { "dts", NULL };
|
static const gchar *dts_exts[] = { "dts", NULL };
|
||||||
static const gchar *gsm_exts[] = { "gsm", NULL };
|
static const gchar *gsm_exts[] = { "gsm", NULL };
|
||||||
static const gchar *musepack_exts[] = { "mpc", "mpp", "mp+", NULL };
|
static const gchar *musepack_exts[] = { "mpc", "mpp", "mp+", NULL };
|
||||||
|
|
Loading…
Reference in a new issue