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

Originally committed as revision 16836 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Michael Niedermayer 16 years ago
parent c58d6796a1
commit 9913860bfb
  1. 26
      libavformat/4xm.c

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

Loading…
Cancel
Save