diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2003-10-02 22:33:55 +0000 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2003-10-02 22:33:55 +0000 |
commit | cf24628385a4104e8e2cb7f361ee014b1020e2dd (patch) | |
tree | 5e19a9ebdcce0b77160680e7f0b5a4fdb5e80bc5 /libavformat | |
parent | 5aa0a6449435473d8ed531a6eee85857abb8e158 (diff) | |
download | ffmpeg-cf24628385a4104e8e2cb7f361ee014b1020e2dd.tar.gz |
fixed time base and sample rate handling
Originally committed as revision 2336 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/nut.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/libavformat/nut.c b/libavformat/nut.c index 20d0e61975..3eaeff5f71 100644 --- a/libavformat/nut.c +++ b/libavformat/nut.c @@ -25,7 +25,6 @@ /* * TODO: * - checksumming - * - correct rate denom/nom and sample_mul * - correct timestamp handling * - index writing * - info and index packet reading support @@ -240,6 +239,8 @@ static int nut_write_header(AVFormatContext *s) /* stream headers */ for (i = 0; i < s->nb_streams; i++) { + int nom, denom; + codec = &s->streams[i]->codec; put_be64(bc, STREAM_STARTCODE); @@ -252,17 +253,21 @@ static int nut_write_header(AVFormatContext *s) { int tmp = codec_get_bmp_tag(codec->codec_id); put_bi(bc, tmp); + nom = codec->frame_rate; + denom = codec->frame_rate_base; } else if (codec->codec_type == CODEC_TYPE_AUDIO) { int tmp = codec_get_wav_tag(codec->codec_id); put_bi(bc, tmp); + nom = codec->sample_rate/8; + denom = 8; } put_v(bc, codec->bit_rate); put_v(bc, 0); /* no language code */ - put_v(bc, codec->frame_rate_base); - put_v(bc, codec->frame_rate); - put_v(bc, 0); /* timestamp_shift */ + put_v(bc, nom); + put_v(bc, denom); + put_v(bc, 0); /* msb timestamp_shift */ put_v(bc, 0); /* shuffle type */ put_byte(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */ @@ -271,7 +276,7 @@ static int nut_write_header(AVFormatContext *s) switch(codec->codec_type) { case CODEC_TYPE_AUDIO: - put_v(bc, codec->sample_rate / (double)(codec->frame_rate_base / codec->frame_rate)); + put_v(bc, (codec->sample_rate * denom) / nom); put_v(bc, codec->channels); put_be32(bc, 0); /* FIXME: checksum */ break; @@ -432,7 +437,7 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap) /* stream header */ for (cur_stream = 0; cur_stream < nb_streams; cur_stream++) { - int class; + int class, nom, denom; AVStream *st; tmp = get_be64(bc); @@ -464,8 +469,8 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap) } s->bit_rate += get_v(bc); get_b(bc, NULL, 0); /* language code */ - st->codec.frame_rate_base = get_v(bc); - st->codec.frame_rate = get_v(bc); + nom = get_v(bc); + denom = get_v(bc); get_v(bc); /* FIXME: msb timestamp base */ get_v(bc); /* shuffle type */ get_byte(bc); /* flags */ @@ -480,10 +485,13 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap) get_v(bc); /* aspected h */ get_v(bc); /* csp type */ get_be32(bc); /* checksum */ + + st->codec.frame_rate = nom; + st->codec.frame_rate_base = denom; } if (class == 32) /* AUDIO */ { - st->codec.sample_rate = get_v(bc) * (double)(st->codec.frame_rate_base / st->codec.frame_rate); + st->codec.sample_rate = (get_v(bc) * nom) / denom; st->codec.channels = get_v(bc); get_be32(bc); /* checksum */ } |