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.
This commit is contained in:
Justin Ruggles 2012-01-11 10:22:47 -05:00
parent 01be6fa926
commit ea289186f0

View File

@ -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;