[FFmpeg-cvslog] ea: fix audio pts

Justin Ruggles git at videolan.org
Sun Mar 4 04:47:43 CET 2012


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Wed Jan 11 10:22:47 2012 -0500| [ea289186f04fa8b9f2cc3bc1aba1cb239ab56f47] | committer: Justin Ruggles

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.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ea289186f04fa8b9f2cc3bc1aba1cb239ab56f47
---

 libavformat/electronicarts.c |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c
index 6a07dac..47ef40f 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;



More information about the ffmpeg-cvslog mailing list