[FFmpeg-cvslog] r16836 - trunk/libavformat/4xm.c

michael subversion
Tue Jan 27 23:14:48 CET 2009


Author: michael
Date: Tue Jan 27 23:14:48 2009
New Revision: 16836

Log:
Export all tracks (each is a different language) instead of just one.

Modified:
   trunk/libavformat/4xm.c

Modified: trunk/libavformat/4xm.c
==============================================================================
--- trunk/libavformat/4xm.c	Tue Jan 27 23:03:13 2009	(r16835)
+++ trunk/libavformat/4xm.c	Tue Jan 27 23:14:48 2009	(r16836)
@@ -66,6 +66,7 @@ typedef struct AudioTrack {
     int channels;
     int stream_index;
     int adpcm;
+    int64_t audio_pts;
 } AudioTrack;
 
 typedef struct FourxmDemuxContext {
@@ -74,9 +75,7 @@ typedef struct FourxmDemuxContext {
     int video_stream_index;
     int track_count;
     AudioTrack *tracks;
-    int selected_track;
 
-    int64_t audio_pts;
     int64_t video_pts;
     float fps;
 } FourxmDemuxContext;
@@ -104,7 +103,6 @@ static int fourxm_read_header(AVFormatCo
 
     fourxm->track_count = 0;
     fourxm->tracks = NULL;
-    fourxm->selected_track = 0;
     fourxm->fps = 1.0;
 
     /* skip the first 3 32-bit numbers */
@@ -185,6 +183,7 @@ static int fourxm_read_header(AVFormatCo
             fourxm->tracks[current_track].channels    = AV_RL32(&header[i + 36]);
             fourxm->tracks[current_track].sample_rate = AV_RL32(&header[i + 40]);
             fourxm->tracks[current_track].bits        = AV_RL32(&header[i + 44]);
+            fourxm->tracks[current_track].audio_pts   = 0;
             i += 8 + size;
 
             /* allocate a new AVStream */
@@ -225,7 +224,6 @@ static int fourxm_read_header(AVFormatCo
     av_free(header);
     /* initialize context members */
     fourxm->video_pts = -1;  /* first frame will push to 0 */
-    fourxm->audio_pts = 0;
 
     return 0;
 fail:
@@ -242,7 +240,7 @@ static int fourxm_read_packet(AVFormatCo
     unsigned int fourcc_tag;
     unsigned int size, out_size;
     int ret = 0;
-    int track_number;
+    unsigned int track_number;
     int packet_read = 0;
     unsigned char header[8];
     int audio_frame_count;
@@ -292,28 +290,28 @@ static int fourxm_read_packet(AVFormatCo
             out_size= get_le32(pb);
             size-=8;
 
-            if (track_number == fourxm->selected_track) {
+            if (track_number < fourxm->track_count) {
                 ret= av_get_packet(s->pb, pkt, size);
                 if(ret<0)
                     return AVERROR(EIO);
                 pkt->stream_index =
-                    fourxm->tracks[fourxm->selected_track].stream_index;
-                pkt->pts = fourxm->audio_pts;
+                    fourxm->tracks[track_number].stream_index;
+                pkt->pts = fourxm->tracks[track_number].audio_pts;
                 packet_read = 1;
 
                 /* pts accounting */
                 audio_frame_count = size;
-                if (fourxm->tracks[fourxm->selected_track].adpcm)
+                if (fourxm->tracks[track_number].adpcm)
                     audio_frame_count -=
-                        2 * (fourxm->tracks[fourxm->selected_track].channels);
+                        2 * (fourxm->tracks[track_number].channels);
                 audio_frame_count /=
-                      fourxm->tracks[fourxm->selected_track].channels;
-                if (fourxm->tracks[fourxm->selected_track].adpcm)
+                      fourxm->tracks[track_number].channels;
+                if (fourxm->tracks[track_number].adpcm)
                     audio_frame_count *= 2;
                 else
                     audio_frame_count /=
-                    (fourxm->tracks[fourxm->selected_track].bits / 8);
-                fourxm->audio_pts += audio_frame_count;
+                    (fourxm->tracks[track_number].bits / 8);
+                fourxm->tracks[track_number].audio_pts += audio_frame_count;
 
             } else {
                 url_fseek(pb, size, SEEK_CUR);




More information about the ffmpeg-cvslog mailing list