diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-10-20 19:30:04 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-10-20 19:30:04 +0100 |
| commit | 58f53485bb112896a9446771acfa2abe0a528cec (patch) | |
| tree | f34f14aa40f8ce0854f104fbabccd4f756bafd3d /src/lib/ffmpeg_decoder.cc | |
| parent | 6e8e4f7ae9a9ae243a1b7d9e17f6b6cacae277b3 (diff) | |
Try to clean up stream handling wrt audio channel counts.
Diffstat (limited to 'src/lib/ffmpeg_decoder.cc')
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 51 |
1 files changed, 12 insertions, 39 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 4b0594add..d93b023c3 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -109,43 +109,30 @@ FFmpegDecoder::setup_general () /* Find video, audio and subtitle streams and choose the first of each */ for (uint32_t i = 0; i < _format_context->nb_streams; ++i) { - if (_format_context->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { + AVStream* s = _format_context->streams[i]; + if (s->codec->codec_type == AVMEDIA_TYPE_VIDEO) { _video_stream = i; - } else if (_format_context->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) { + } else if (s->codec->codec_type == AVMEDIA_TYPE_AUDIO) { if (_audio_stream == -1) { _audio_stream = i; } - _audio_streams.push_back (Stream (stream_name (_format_context->streams[i]), i)); - } else if (_format_context->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { + _audio_streams.push_back (AudioStream (stream_name (s), i, s->codec->channels)); + } else if (s->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { if (_subtitle_stream == -1) { _subtitle_stream = i; } - _subtitle_streams.push_back (Stream (stream_name (_format_context->streams[i]), i)); + _subtitle_streams.push_back (SubtitleStream (stream_name (s), i)); } } /* Now override audio and subtitle streams with those from the Film, if it has any */ - if (_fs->audio_stream() != -1) { - vector<Stream>::iterator i = _audio_streams.begin (); - while (i != _audio_streams.end() && i->id != _fs->audio_stream()) { - ++i; - } - - if (i != _audio_streams.end()) { - _audio_stream = _fs->audio_stream (); - } + if (_fs->audio_stream_index() != -1) { + _audio_stream = _fs->audio_stream_decoder_id (); } - if (_fs->subtitle_stream() != -1) { - vector<Stream>::iterator i = _subtitle_streams.begin (); - while (i != _subtitle_streams.end() && i->id != _fs->subtitle_stream()) { - ++i; - } - - if (i != _subtitle_streams.end()) { - _subtitle_stream = _fs->subtitle_stream (); - } + if (_fs->subtitle_stream_index() != -1) { + _subtitle_stream = _fs->subtitle_stream_decoder_id (); } if (_video_stream < 0) { @@ -394,32 +381,18 @@ FFmpegDecoder::has_subtitles () const return (_subtitle_stream != -1); } -vector<Stream> +vector<AudioStream> FFmpegDecoder::audio_streams () const { return _audio_streams; } -vector<Stream> +vector<SubtitleStream> FFmpegDecoder::subtitle_streams () const { return _subtitle_streams; } -void -FFmpegDecoder::set_audio_stream (int s) -{ - _audio_stream = s; - setup_audio (); -} - -void -FFmpegDecoder::set_subtitle_stream (int s) -{ - _subtitle_stream = s; - setup_subtitle (); -} - string FFmpegDecoder::stream_name (AVStream* s) const { |
