OSDN Git Service

Fix av_find_best_stream when using a program
authorBalint Marton <cus@passwd.hu>
Wed, 16 Feb 2011 00:17:13 +0000 (00:17 +0000)
committerMans Rullgard <mans@mansr.com>
Wed, 16 Feb 2011 11:47:42 +0000 (11:47 +0000)
The current implementation has a bug, it is returning the stream index
in the found program, and not the stream index in the list of all
streams. The attached patch fixes this issue.

Signed-off-by: Mans Rullgard <mans@mansr.com>
libavformat/utils.c

index 225b9f2..be4d6f7 100644 (file)
@@ -2529,7 +2529,7 @@ int av_find_best_stream(AVFormatContext *ic,
         if (best_count >= st->codec_info_nb_frames)
             continue;
         best_count = st->codec_info_nb_frames;
-        ret = i;
+        ret = program ? program[i] : i;
         best_decoder = decoder;
         if (program && i == nb_streams - 1 && ret < 0) {
             program = NULL;