mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 16:08:51 +00:00
Interpret BLOCKDURATION and set buffer duration accordingly, enable demuxing of TTA audio from matroska, fixes bugs #...
Original commit message from CVS: Interpret BLOCKDURATION and set buffer duration accordingly, enable demuxing of TTA audio from matroska, fixes bugs #148950 and #148951.
This commit is contained in:
parent
f7233f132c
commit
ad0c06763d
3 changed files with 60 additions and 30 deletions
|
@ -2,6 +2,12 @@
|
||||||
|
|
||||||
* gst/matroska/matroska-demux.c: (gst_matroska_demux_parse_blockgroup),
|
* gst/matroska/matroska-demux.c: (gst_matroska_demux_parse_blockgroup),
|
||||||
send vorbis headers at the beginning of a stream, fixes bug #141554.
|
send vorbis headers at the beginning of a stream, fixes bug #141554.
|
||||||
|
Interpret BLOCKDURATION and set buffer duration accordingly, fixes
|
||||||
|
bug #148950.
|
||||||
|
* gst/matroska/matroska-demux.c: (gst_matroska_demux_audio_caps),
|
||||||
|
(gst_matroska_demux_plugin_init):
|
||||||
|
* gst/matroska/matroska-ids.h:
|
||||||
|
enable demuxing of TTA audio streams, fixes bug #148951.
|
||||||
* gst/typefind/gsttypefindfunctions.c: (tta_type_find), (plugin_init),
|
* gst/typefind/gsttypefindfunctions.c: (tta_type_find), (plugin_init),
|
||||||
enable typefinding for TTA audio files, fixes bug #148711.
|
enable typefinding for TTA audio files, fixes bug #148711.
|
||||||
|
|
||||||
|
|
|
@ -312,6 +312,7 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux)
|
||||||
demux->src[demux->num_streams] = context;
|
demux->src[demux->num_streams] = context;
|
||||||
context->index = demux->num_streams;
|
context->index = demux->num_streams;
|
||||||
context->type = 0; /* no type yet */
|
context->type = 0; /* no type yet */
|
||||||
|
context->default_duration = 0;
|
||||||
demux->num_streams++;
|
demux->num_streams++;
|
||||||
|
|
||||||
/* start with the master */
|
/* start with the master */
|
||||||
|
@ -1756,7 +1757,13 @@ gst_matroska_demux_parse_blockgroup (GstMatroskaDemux * demux,
|
||||||
{
|
{
|
||||||
GstEbmlRead *ebml = GST_EBML_READ (demux);
|
GstEbmlRead *ebml = GST_EBML_READ (demux);
|
||||||
gboolean res = TRUE;
|
gboolean res = TRUE;
|
||||||
|
gboolean readblock = FALSE;
|
||||||
guint32 id;
|
guint32 id;
|
||||||
|
guint64 block_duration = 0;
|
||||||
|
GstBuffer *buf = NULL;
|
||||||
|
gint stream = 0, n, laces = 0;
|
||||||
|
guint size = 0, *lace_size = NULL;
|
||||||
|
gint64 time = 0;
|
||||||
|
|
||||||
while (res) {
|
while (res) {
|
||||||
if (!(id = gst_ebml_peek_id (ebml, &demux->level_up))) {
|
if (!(id = gst_ebml_peek_id (ebml, &demux->level_up))) {
|
||||||
|
@ -1772,11 +1779,8 @@ gst_matroska_demux_parse_blockgroup (GstMatroskaDemux * demux,
|
||||||
* of the harder things, so this code is a bit complicated.
|
* of the harder things, so this code is a bit complicated.
|
||||||
* See http://www.matroska.org/ for documentation. */
|
* See http://www.matroska.org/ for documentation. */
|
||||||
case GST_MATROSKA_ID_BLOCK:{
|
case GST_MATROSKA_ID_BLOCK:{
|
||||||
GstBuffer *buf;
|
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gint64 time;
|
gint flags = 0;
|
||||||
guint size, *lace_size = NULL;
|
|
||||||
gint n, stream, flags, laces = 0;
|
|
||||||
guint64 num;
|
guint64 num;
|
||||||
|
|
||||||
if (!gst_ebml_read_buffer (ebml, &id, &buf)) {
|
if (!gst_ebml_read_buffer (ebml, &id, &buf)) {
|
||||||
|
@ -1921,39 +1925,15 @@ gst_matroska_demux_parse_blockgroup (GstMatroskaDemux * demux,
|
||||||
gst_pad_push (demux->src[stream]->pad, GST_DATA (priv));
|
gst_pad_push (demux->src[stream]->pad, GST_DATA (priv));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res) {
|
readblock = TRUE;
|
||||||
for (n = 0; n < laces; n++) {
|
|
||||||
GstBuffer *sub = gst_buffer_create_sub (buf,
|
|
||||||
GST_BUFFER_SIZE (buf) - size,
|
|
||||||
lace_size[n]);
|
|
||||||
|
|
||||||
if (cluster_time != GST_CLOCK_TIME_NONE) {
|
|
||||||
if (time < 0 && (-time) > cluster_time)
|
|
||||||
GST_BUFFER_TIMESTAMP (sub) = cluster_time;
|
|
||||||
else
|
|
||||||
GST_BUFFER_TIMESTAMP (sub) = cluster_time + time;
|
|
||||||
}
|
|
||||||
/* FIXME: duration */
|
|
||||||
|
|
||||||
gst_pad_push (demux->src[stream]->pad, GST_DATA (sub));
|
|
||||||
|
|
||||||
size -= lace_size[n];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (lace_size);
|
|
||||||
gst_buffer_unref (buf);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case GST_MATROSKA_ID_BLOCKDURATION:{
|
case GST_MATROSKA_ID_BLOCKDURATION:{
|
||||||
guint64 num;
|
if (!gst_ebml_read_uint (ebml, &id, &block_duration)) {
|
||||||
|
|
||||||
if (!gst_ebml_read_uint (ebml, &id, &num)) {
|
|
||||||
res = FALSE;
|
res = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
GST_WARNING ("FIXME: implement support for BlockDuration");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_MATROSKA_ID_REFERENCEBLOCK:{
|
case GST_MATROSKA_ID_REFERENCEBLOCK:{
|
||||||
|
@ -1987,6 +1967,40 @@ gst_matroska_demux_parse_blockgroup (GstMatroskaDemux * demux,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (res && readblock) {
|
||||||
|
guint64 duration = 0;
|
||||||
|
|
||||||
|
if (block_duration) {
|
||||||
|
duration = block_duration * demux->time_scale;
|
||||||
|
} else if (demux->src[stream]->default_duration) {
|
||||||
|
duration = demux->src[stream]->default_duration;
|
||||||
|
}
|
||||||
|
for (n = 0; n < laces; n++) {
|
||||||
|
GstBuffer *sub = gst_buffer_create_sub (buf,
|
||||||
|
GST_BUFFER_SIZE (buf) - size,
|
||||||
|
lace_size[n]);
|
||||||
|
|
||||||
|
if (cluster_time != GST_CLOCK_TIME_NONE) {
|
||||||
|
if (time < 0 && (-time) > cluster_time)
|
||||||
|
GST_BUFFER_TIMESTAMP (sub) = cluster_time;
|
||||||
|
else
|
||||||
|
GST_BUFFER_TIMESTAMP (sub) = cluster_time + time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* do all laces have the same lenght? */
|
||||||
|
if (duration) {
|
||||||
|
GST_BUFFER_DURATION (sub) = duration / laces;
|
||||||
|
}
|
||||||
|
gst_pad_push (demux->src[stream]->pad, GST_DATA (sub));
|
||||||
|
|
||||||
|
size -= lace_size[n];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (readblock)
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
g_free (lace_size);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2644,6 +2658,14 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext * audiocontext,
|
||||||
|
|
||||||
caps = gst_caps_new_simple ("audio/mpeg",
|
caps = gst_caps_new_simple ("audio/mpeg",
|
||||||
"mpegversion", G_TYPE_INT, mpegversion, NULL);
|
"mpegversion", G_TYPE_INT, mpegversion, NULL);
|
||||||
|
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_TTA)) {
|
||||||
|
if (audiocontext != NULL) {
|
||||||
|
caps = gst_caps_new_simple ("audio/x-raw-tta",
|
||||||
|
"width", G_TYPE_INT, audiocontext->bitdepth, NULL);
|
||||||
|
} else {
|
||||||
|
caps = gst_caps_from_string ("audio/x-raw-tta, "
|
||||||
|
"width = (int) { 8, 16, 24 }");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
GST_WARNING ("Unknown codec '%s', cannot build Caps", codec_id);
|
GST_WARNING ("Unknown codec '%s', cannot build Caps", codec_id);
|
||||||
g_print ("Codec=%s\n", codec_id);
|
g_print ("Codec=%s\n", codec_id);
|
||||||
|
@ -2742,6 +2764,7 @@ gst_matroska_demux_plugin_init (GstPlugin * plugin)
|
||||||
GST_MATROSKA_CODEC_ID_AUDIO_AC3,
|
GST_MATROSKA_CODEC_ID_AUDIO_AC3,
|
||||||
GST_MATROSKA_CODEC_ID_AUDIO_ACM,
|
GST_MATROSKA_CODEC_ID_AUDIO_ACM,
|
||||||
GST_MATROSKA_CODEC_ID_AUDIO_VORBIS,
|
GST_MATROSKA_CODEC_ID_AUDIO_VORBIS,
|
||||||
|
GST_MATROSKA_CODEC_ID_AUDIO_TTA,
|
||||||
GST_MATROSKA_CODEC_ID_AUDIO_MPEG2, GST_MATROSKA_CODEC_ID_AUDIO_MPEG4,
|
GST_MATROSKA_CODEC_ID_AUDIO_MPEG2, GST_MATROSKA_CODEC_ID_AUDIO_MPEG4,
|
||||||
/* TODO: AC3-9/10, Real, Musepack, Quicktime */
|
/* TODO: AC3-9/10, Real, Musepack, Quicktime */
|
||||||
/* FILLME */
|
/* FILLME */
|
||||||
|
|
|
@ -149,6 +149,7 @@
|
||||||
#define GST_MATROSKA_CODEC_ID_AUDIO_ACM "A_MS/ACM"
|
#define GST_MATROSKA_CODEC_ID_AUDIO_ACM "A_MS/ACM"
|
||||||
#define GST_MATROSKA_CODEC_ID_AUDIO_MPEG2 "A_AAC/MPEG2/"
|
#define GST_MATROSKA_CODEC_ID_AUDIO_MPEG2 "A_AAC/MPEG2/"
|
||||||
#define GST_MATROSKA_CODEC_ID_AUDIO_MPEG4 "A_AAC/MPEG4/"
|
#define GST_MATROSKA_CODEC_ID_AUDIO_MPEG4 "A_AAC/MPEG4/"
|
||||||
|
#define GST_MATROSKA_CODEC_ID_AUDIO_TTA "A_TTA1"
|
||||||
/* TODO: AC3-9/10 (?), Real, Musepack, Quicktime */
|
/* TODO: AC3-9/10 (?), Real, Musepack, Quicktime */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue