diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2012-01-11 10:22:47 -0500 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2012-03-03 17:03:27 -0500 |
commit | ea289186f04fa8b9f2cc3bc1aba1cb239ab56f47 (patch) | |
tree | cb64dac5deff6614f0645954c065268fffeee7bb /libavformat/electronicarts.c | |
parent | 01be6fa926dc3de593756ffd1e09f9523be5fd00 (diff) | |
download | ffmpeg-ea289186f04fa8b9f2cc3bc1aba1cb239ab56f47.tar.gz |
ea: fix audio pts
The time base is 1 / sample_rate, not 90000.
Several more codecs encode the sample count in the first 4 bytes of the
chunk, so we set the durations accordingly. Also, we can set start_time and
packet duration instead of keeping track of the sample count in the demuxer.
Diffstat (limited to 'libavformat/electronicarts.c')
-rw-r--r-- | libavformat/electronicarts.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c index 6a07dac7e8..47ef40f69d 100644 --- a/libavformat/electronicarts.c +++ b/libavformat/electronicarts.c @@ -70,7 +70,6 @@ typedef struct EaDemuxContext { enum CodecID audio_codec; int audio_stream_index; - int audio_frame_counter; int bytes; int sample_rate; @@ -469,7 +468,7 @@ static int ea_read_header(AVFormatContext *s) st->codec->bits_per_coded_sample / 4; st->codec->block_align = st->codec->channels*st->codec->bits_per_coded_sample; ea->audio_stream_index = st->index; - ea->audio_frame_counter = 0; + st->start_time = 0; } return 1; @@ -513,24 +512,26 @@ static int ea_read_packet(AVFormatContext *s, if (ret < 0) return ret; pkt->stream_index = ea->audio_stream_index; - pkt->pts = 90000; - pkt->pts *= ea->audio_frame_counter; - pkt->pts /= ea->sample_rate; switch (ea->audio_codec) { case CODEC_ID_ADPCM_EA: - /* 2 samples/byte, 1 or 2 samples per frame depending - * on stereo; chunk also has 12-byte header */ - ea->audio_frame_counter += ((chunk_size - 12) * 2) / - ea->num_channels; + case CODEC_ID_ADPCM_EA_R1: + case CODEC_ID_ADPCM_EA_R2: + case CODEC_ID_ADPCM_IMA_EA_EACS: + pkt->duration = AV_RL32(pkt->data); + break; + case CODEC_ID_ADPCM_EA_R3: + pkt->duration = AV_RB32(pkt->data); + break; + case CODEC_ID_ADPCM_IMA_EA_SEAD: + pkt->duration = ret * 2 / ea->num_channels; break; case CODEC_ID_PCM_S16LE_PLANAR: case CODEC_ID_MP3: - ea->audio_frame_counter += num_samples; + pkt->duration = num_samples; break; default: - ea->audio_frame_counter += chunk_size / - (ea->bytes * ea->num_channels); + pkt->duration = chunk_size / (ea->bytes * ea->num_channels); } packet_read = 1; |