decoder/ffmpeg: move code to IsAudio()

This commit is contained in:
Max Kellermann 2016-07-27 14:58:41 +02:00
parent 70986bc120
commit d1c5bb956a
1 changed files with 8 additions and 2 deletions

View File

@ -76,13 +76,19 @@ ffmpeg_init(gcc_unused const config_param &param)
return true; return true;
} }
gcc_pure
static bool
IsAudio(const AVStream &stream)
{
return stream.codec->codec_type == AVMEDIA_TYPE_AUDIO;
}
gcc_pure gcc_pure
static int static int
ffmpeg_find_audio_stream(const AVFormatContext &format_context) ffmpeg_find_audio_stream(const AVFormatContext &format_context)
{ {
for (unsigned i = 0; i < format_context.nb_streams; ++i) for (unsigned i = 0; i < format_context.nb_streams; ++i)
if (format_context.streams[i]->codec->codec_type == if (IsAudio(*format_context.streams[i]))
AVMEDIA_TYPE_AUDIO)
return i; return i;
return -1; return -1;