diff options
author | Michael Niedermayer | 2012-03-06 03:56:25 +0100 |
---|---|---|
committer | Michael Niedermayer | 2012-03-06 06:03:32 +0100 |
commit | f095391a140ed3f379e1fb16605fac821c3e6660 (patch) | |
tree | 6b0be38bffb002457cba26183c57e56d5d464551 /libavformat/aiffdec.c | |
parent | 01606d10e600c4794d89490e731c321fb73a5141 (diff) | |
parent | 632eb1bbae473f7105e0ec6556cb040ea6d30910 (diff) |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (31 commits)
cdxl demux: do not create packets with uninitialized data at EOF.
Replace computations of remaining bits with calls to get_bits_left().
amrnb/amrwb: Remove get_bits usage.
cosmetics: reindent
avformat: do not require a pixel/sample format if there is no decoder
avformat: do not fill-in audio packet duration in compute_pkt_fields()
lavf: Use av_get_audio_frame_duration() in get_audio_frame_size()
dca_parser: parse the sample rate and frame durations
libspeexdec: do not set AVCodecContext.frame_size
libopencore-amr: do not set AVCodecContext.frame_size
alsdec: do not set AVCodecContext.frame_size
siff: do not set AVCodecContext.frame_size
amr demuxer: do not set AVCodecContext.frame_size.
aiffdec: do not set AVCodecContext.frame_size
mov: do not set AVCodecContext.frame_size
ape: do not set AVCodecContext.frame_size.
rdt: remove workaround for infinite loop with aac
avformat: do not require frame_size in avformat_find_stream_info() for CELT
avformat: do not require frame_size in avformat_find_stream_info() for MP1/2/3
avformat: do not require frame_size in avformat_find_stream_info() for AAC
...
Conflicts:
doc/APIchanges
libavcodec/Makefile
libavcodec/avcodec.h
libavcodec/h264.c
libavcodec/h264_ps.c
libavcodec/utils.c
libavcodec/version.h
libavcodec/x86/dsputil_mmx.c
libavformat/utils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/aiffdec.c')
-rw-r--r-- | libavformat/aiffdec.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index 239fca3452..d57ba005ff 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -32,6 +32,7 @@ typedef struct { int64_t data_end; + int block_duration; } AIFFInputContext; static enum CodecID aiff_codec_get_id(int bps) @@ -87,9 +88,12 @@ static void get_meta(AVFormatContext *s, const char *key, int size) } /* Returns the number of sound data frames or negative on error */ -static unsigned int get_aiff_header(AVIOContext *pb, AVCodecContext *codec, - int size, unsigned version) +static unsigned int get_aiff_header(AVFormatContext *s, int size, + unsigned version) { + AVIOContext *pb = s->pb; + AVCodecContext *codec = s->streams[0]->codec; + AIFFInputContext *aiff = s->priv_data; int exp; uint64_t val; double sample_rate; @@ -117,26 +121,27 @@ static unsigned int get_aiff_header(AVIOContext *pb, AVCodecContext *codec, case CODEC_ID_PCM_S16BE: codec->codec_id = aiff_codec_get_id(codec->bits_per_coded_sample); codec->bits_per_coded_sample = av_get_bits_per_sample(codec->codec_id); + aiff->block_duration = 1; break; case CODEC_ID_ADPCM_IMA_QT: codec->block_align = 34*codec->channels; - codec->frame_size = 64; + aiff->block_duration = 64; break; case CODEC_ID_MACE3: codec->block_align = 2*codec->channels; - codec->frame_size = 6; + aiff->block_duration = 6; break; case CODEC_ID_MACE6: codec->block_align = 1*codec->channels; - codec->frame_size = 6; + aiff->block_duration = 6; break; case CODEC_ID_GSM: codec->block_align = 33; - codec->frame_size = 160; + aiff->block_duration = 160; break; case CODEC_ID_QCELP: codec->block_align = 35; - codec->frame_size= 160; + aiff->block_duration = 160; break; default: break; @@ -146,6 +151,7 @@ static unsigned int get_aiff_header(AVIOContext *pb, AVCodecContext *codec, /* Need the codec type */ codec->codec_id = aiff_codec_get_id(codec->bits_per_coded_sample); codec->bits_per_coded_sample = av_get_bits_per_sample(codec->codec_id); + aiff->block_duration = 1; } /* Block align needs to be computed in all cases, as the definition @@ -153,8 +159,8 @@ static unsigned int get_aiff_header(AVIOContext *pb, AVCodecContext *codec, if (!codec->block_align) codec->block_align = (codec->bits_per_coded_sample * codec->channels) >> 3; - codec->bit_rate = (codec->frame_size ? codec->sample_rate/codec->frame_size : - codec->sample_rate) * (codec->block_align << 3); + codec->bit_rate = codec->sample_rate * (codec->block_align << 3) / + aiff->block_duration; /* Chunk is over */ if (size) @@ -215,7 +221,7 @@ static int aiff_read_header(AVFormatContext *s) switch (tag) { case MKTAG('C', 'O', 'M', 'M'): /* Common chunk */ /* Then for the complete header info */ - st->nb_frames = get_aiff_header(pb, st->codec, size, version); + st->nb_frames = get_aiff_header(s, size, version); if (st->nb_frames < 0) return st->nb_frames; if (offset > 0) // COMM is after SSND @@ -279,8 +285,7 @@ got_sound: /* Now positioned, get the sound data start and end */ avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); st->start_time = 0; - st->duration = st->codec->frame_size ? - st->nb_frames * st->codec->frame_size : st->nb_frames; + st->duration = st->nb_frames * aiff->block_duration; /* Position the stream at the first block */ avio_seek(pb, offset, SEEK_SET); @@ -315,6 +320,7 @@ static int aiff_read_packet(AVFormatContext *s, /* Only one stream in an AIFF file */ pkt->stream_index = 0; + pkt->duration = (res / st->codec->block_align) * aiff->block_duration; return 0; } |