diff options
author | Benjamin Otte <otte@gnome.org> | 2004-01-11 17:49:56 +0000 |
---|---|---|
committer | Benjamin Otte <otte@gnome.org> | 2004-01-11 17:49:56 +0000 |
commit | 96bbccf5ef4a625f953477f0b12c20040b61ed31 (patch) | |
tree | 984c7c5e9d55a5849b1189cad882be76be150840 /gst | |
parent | fa66fa64c5db783088aaa9341d653375edc64c3f (diff) | |
download | gst-plugins-bad-96bbccf5ef4a625f953477f0b12c20040b61ed31.tar.gz gst-plugins-bad-96bbccf5ef4a625f953477f0b12c20040b61ed31.tar.bz2 gst-plugins-bad-96bbccf5ef4a625f953477f0b12c20040b61ed31.zip |
gst/qtdemux/qtdemux.c: fix audio chunk size/timestamp calculation
Original commit message from CVS:
2004-01-11 Benjamin Otte <in7y118@public.uni-hamburg.de>
* gst/qtdemux/qtdemux.c: (gst_qtdemux_loop_header),
(qtdemux_parse_trak):
fix audio chunk size/timestamp calculation
Diffstat (limited to 'gst')
-rw-r--r-- | gst/qtdemux/qtdemux.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index fa90ad31..cf9bd351 100644 --- a/gst/qtdemux/qtdemux.c +++ b/gst/qtdemux/qtdemux.c @@ -26,7 +26,7 @@ #include <string.h> #include <zlib.h> -#define g_print(x...) +#define g_print(...) #define QTDEMUX_GUINT32_GET(a) GUINT32_FROM_BE(*(guint32 *)(a)) #define QTDEMUX_GUINT16_GET(a) GUINT16_FROM_BE(*(guint16 *)(a)) @@ -77,8 +77,11 @@ struct _QtDemuxStream { int width; int height; float fps; + double rate; int n_channels; + guint bytes_per_frame; + guint samples_per_packet; }; enum QtDemuxState { @@ -477,6 +480,7 @@ static void gst_qtdemux_loop_header (GstElement *element) cur_offset = gst_bytestream_tell(qtdemux->bs); if(offset != cur_offset){ GST_DEBUG ("seeking to offset %d",offset); + g_print ("seeking to offset %d\n",offset); ret = gst_bytestream_seek(qtdemux->bs, offset, GST_SEEK_METHOD_SET); GST_DEBUG ("seek returned %d",ret); return; @@ -1296,9 +1300,14 @@ static void qtdemux_parse_trak(GstQTDemux *qtdemux, GNode *trak) if(version == 0x00010000){ g_print("samples/packet: %d\n", QTDEMUX_GUINT32_GET(stsd->data+offset + 20)); + stream->samples_per_packet = QTDEMUX_GUINT32_GET(stsd->data+offset + 20); g_print("bytes/packet: %d\n", QTDEMUX_GUINT32_GET(stsd->data+offset + 24)); g_print("bytes/frame: %d\n", QTDEMUX_GUINT32_GET(stsd->data+offset + 28)); + stream->bytes_per_frame = QTDEMUX_GUINT32_GET(stsd->data+offset + 28); g_print("bytes/sample: %d\n", QTDEMUX_GUINT32_GET(stsd->data+offset + 32)); + } else { + stream->bytes_per_frame = stream->n_channels * QTDEMUX_GUINT16_GET(stsd->data+offset + 10); + stream->samples_per_packet = 1; } stream->caps = qtdemux_audio_caps(qtdemux, @@ -1425,14 +1434,16 @@ done: } samples[j].chunk = j; samples[j].offset = chunk_offset; - samples[j].size = samples_per_chunk * stream->n_channels * sample_width; + samples[j].size = samples_per_chunk * stream->bytes_per_frame / stream->samples_per_packet; + samples[j].duration = samples_per_chunk * GST_SECOND / stream->rate; + samples[j].timestamp = j == 0 ? 0 : samples[j - 1].timestamp + samples[j - 1].duration; samples[j].sample_index = sample_index; sample_index += samples_per_chunk; if(j>=n_samples)goto done2; } } +/* done2: - n_sample_times = QTDEMUX_GUINT32_GET(stts->data + 12); g_print("n_sample_times = %d\n",n_sample_times); timestamp = 0; @@ -1449,13 +1460,14 @@ done2: samples[index].timestamp = timestamp; size = samples[index+1].sample_index - samples[index].sample_index; - time = (GST_SECOND * duration * samples[index].size)/stream->timescale ; + time = GST_SECOND / stream->rate; //(GST_SECOND * duration * samples[index].size)/stream->timescale ; timestamp += time; samples[index].duration = time; } } +*/ } - +done2: #if 0 for(i=0;i<n_samples;i++){ g_print("%d: %d %d %d %d %" G_GUINT64_FORMAT "\n",i, |