mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 16:26:39 +00:00
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
This commit is contained in:
parent
fa66fa64c5
commit
96bbccf5ef
2 changed files with 23 additions and 5 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
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
|
||||||
|
|
||||||
2004-01-11 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
2004-01-11 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||||
|
|
||||||
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps):
|
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps):
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
#define g_print(x...)
|
#define g_print(...)
|
||||||
|
|
||||||
#define QTDEMUX_GUINT32_GET(a) GUINT32_FROM_BE(*(guint32 *)(a))
|
#define QTDEMUX_GUINT32_GET(a) GUINT32_FROM_BE(*(guint32 *)(a))
|
||||||
#define QTDEMUX_GUINT16_GET(a) GUINT16_FROM_BE(*(guint16 *)(a))
|
#define QTDEMUX_GUINT16_GET(a) GUINT16_FROM_BE(*(guint16 *)(a))
|
||||||
|
@ -77,8 +77,11 @@ struct _QtDemuxStream {
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
float fps;
|
float fps;
|
||||||
|
|
||||||
double rate;
|
double rate;
|
||||||
int n_channels;
|
int n_channels;
|
||||||
|
guint bytes_per_frame;
|
||||||
|
guint samples_per_packet;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum QtDemuxState {
|
enum QtDemuxState {
|
||||||
|
@ -477,6 +480,7 @@ static void gst_qtdemux_loop_header (GstElement *element)
|
||||||
cur_offset = gst_bytestream_tell(qtdemux->bs);
|
cur_offset = gst_bytestream_tell(qtdemux->bs);
|
||||||
if(offset != cur_offset){
|
if(offset != cur_offset){
|
||||||
GST_DEBUG ("seeking to offset %d",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);
|
ret = gst_bytestream_seek(qtdemux->bs, offset, GST_SEEK_METHOD_SET);
|
||||||
GST_DEBUG ("seek returned %d",ret);
|
GST_DEBUG ("seek returned %d",ret);
|
||||||
return;
|
return;
|
||||||
|
@ -1296,9 +1300,14 @@ static void qtdemux_parse_trak(GstQTDemux *qtdemux, GNode *trak)
|
||||||
|
|
||||||
if(version == 0x00010000){
|
if(version == 0x00010000){
|
||||||
g_print("samples/packet: %d\n", QTDEMUX_GUINT32_GET(stsd->data+offset + 20));
|
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/packet: %d\n", QTDEMUX_GUINT32_GET(stsd->data+offset + 24));
|
||||||
g_print("bytes/frame: %d\n", QTDEMUX_GUINT32_GET(stsd->data+offset + 28));
|
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));
|
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,
|
stream->caps = qtdemux_audio_caps(qtdemux,
|
||||||
|
@ -1425,14 +1434,16 @@ done:
|
||||||
}
|
}
|
||||||
samples[j].chunk = j;
|
samples[j].chunk = j;
|
||||||
samples[j].offset = chunk_offset;
|
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;
|
samples[j].sample_index = sample_index;
|
||||||
sample_index += samples_per_chunk;
|
sample_index += samples_per_chunk;
|
||||||
if(j>=n_samples)goto done2;
|
if(j>=n_samples)goto done2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
done2:
|
done2:
|
||||||
|
|
||||||
n_sample_times = QTDEMUX_GUINT32_GET(stts->data + 12);
|
n_sample_times = QTDEMUX_GUINT32_GET(stts->data + 12);
|
||||||
g_print("n_sample_times = %d\n",n_sample_times);
|
g_print("n_sample_times = %d\n",n_sample_times);
|
||||||
timestamp = 0;
|
timestamp = 0;
|
||||||
|
@ -1449,13 +1460,14 @@ done2:
|
||||||
|
|
||||||
samples[index].timestamp = timestamp;
|
samples[index].timestamp = timestamp;
|
||||||
size = samples[index+1].sample_index - samples[index].sample_index;
|
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;
|
timestamp += time;
|
||||||
samples[index].duration = time;
|
samples[index].duration = time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
done2:
|
||||||
#if 0
|
#if 0
|
||||||
for(i=0;i<n_samples;i++){
|
for(i=0;i<n_samples;i++){
|
||||||
g_print("%d: %d %d %d %d %" G_GUINT64_FORMAT "\n",i,
|
g_print("%d: %d %d %d %d %" G_GUINT64_FORMAT "\n",i,
|
||||||
|
|
Loading…
Reference in a new issue