OSDN Git Service

x264 bump from r1772 to r1790
[handbrake-jp/handbrake-jp-git.git] / contrib / ffmpeg / A05-avi-seek.patch
1 Index: libavformat/avidec.c
2 ===================================================================
3 --- ffmpeg.orig/libavformat/avidec.c    (revision 22950)
4 +++ ffmpeg/libavformat/avidec.c (working copy)
5 @@ -1072,7 +1072,7 @@
6      AVIContext *avi = s->priv_data;
7      AVStream *st;
8      int i, index;
9 -    int64_t pos;
10 +    int64_t pos, min_pos;
11      AVIStream *ast;
12  
13      if (!avi->index_loaded) {
14 @@ -1109,6 +1109,7 @@
15          return 0;
16      }
17  
18 +    min_pos = pos;
19      for(i = 0; i < s->nb_streams; i++) {
20          AVStream *st2 = s->streams[i];
21          AVIStream *ast2 = st2->priv_data;
22 @@ -1129,10 +1130,20 @@
23              index=0;
24  
25          if(!avi->non_interleaved){
26 -            while(index>0 && st2->index_entries[index].pos > pos)
27 -                index--;
28 -            while(index+1 < st2->nb_index_entries && st2->index_entries[index].pos < pos)
29 -                index++;
30 +            if (flags & AVSEEK_FLAG_BACKWARD) {
31 +                while(index+1 < st2->nb_index_entries && st2->index_entries[index].pos < pos)
32 +                    index++;
33 +                while(index>0 && st2->index_entries[index].pos > pos)
34 +                    index--;
35 +                if (st2->index_entries[index].pos < min_pos)
36 +                    min_pos = st2->index_entries[index].pos;
37 +            }
38 +            else {
39 +                while(index>0 && st2->index_entries[index].pos > pos)
40 +                    index--;
41 +                while(index+1 < st2->nb_index_entries && st2->index_entries[index].pos < pos)
42 +                    index++;
43 +            }
44          }
45  
46  //        av_log(s, AV_LOG_DEBUG, "%"PRId64" %d %"PRId64"\n", timestamp, index, st2->index_entries[index].timestamp);
47 @@ -1141,7 +1152,7 @@
48      }
49  
50      /* do the seek */
51 -    url_fseek(s->pb, pos, SEEK_SET);
52 +    url_fseek(s->pb, min_pos, SEEK_SET);
53      avi->stream_index= -1;
54      return 0;
55  }