Browse code

seek based on currently active stream fixes seeking in ffwma2_broken.wma which had some "empty" streams

Originally committed as revision 7666 to svn://svn.ffmpeg.org/ffmpeg/trunk

Michael Niedermayer authored on 2007/01/23 23:22:25
Showing 1 changed files
... ...
@@ -1959,7 +1959,18 @@ static int decode_thread(void *arg)
1959 1959
         }
1960 1960
 #endif
1961 1961
         if (is->seek_req) {
1962
-            ret = av_seek_frame(is->ic, -1, is->seek_pos, is->seek_flags);
1962
+            int stream_index= -1;
1963
+            int64_t seek_target= is->seek_pos;
1964
+
1965
+            if     (is->   video_stream >= 0) stream_index= is->   video_stream;
1966
+            else if(is->   audio_stream >= 0) stream_index= is->   audio_stream;
1967
+            else if(is->subtitle_stream >= 0) stream_index= is->subtitle_stream;
1968
+
1969
+            if(stream_index>=0){
1970
+                seek_target= av_rescale_q(seek_target, AV_TIME_BASE_Q, ic->streams[stream_index]->time_base);
1971
+            }
1972
+
1973
+            ret = av_seek_frame(is->ic, stream_index, seek_target, is->seek_flags);
1963 1974
             if (ret < 0) {
1964 1975
                 fprintf(stderr, "%s: error while seeking\n", is->ic->filename);
1965 1976
             }else{