Browse code

mov_chan: Pass a separate AVIOContext for reading

This fixes crashes when called from rtpdec_qt, where
AVFormatContext->pb is null, a crash present since 3bab7cd128.

Signed-off-by: Martin Storsjö <martin@martin.st>

Samuel Pitoiset authored on 2012/09/06 19:46:37
Showing 4 changed files
... ...
@@ -268,7 +268,7 @@ static int read_header(AVFormatContext *s)
268 268
             break;
269 269
 
270 270
         case MKBETAG('c','h','a','n'):
271
-            if ((ret = ff_mov_read_chan(s, st, size)) < 0)
271
+            if ((ret = ff_mov_read_chan(s, s->pb, st, size)) < 0)
272 272
                 return ret;
273 273
             break;
274 274
 
... ...
@@ -583,7 +583,7 @@ static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom)
583 583
     if (atom.size < 16)
584 584
         return 0;
585 585
 
586
-    ff_mov_read_chan(c->fc, st, atom.size - 4);
586
+    ff_mov_read_chan(c->fc, pb, st, atom.size - 4);
587 587
 
588 588
     return 0;
589 589
 }
... ...
@@ -543,9 +543,9 @@ uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id,
543 543
     return tag;
544 544
 }
545 545
 
546
-int ff_mov_read_chan(AVFormatContext *s, AVStream *st, int64_t size)
546
+int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st,
547
+                     int64_t size)
547 548
 {
548
-    AVIOContext *pb = s->pb;
549 549
     uint32_t layout_tag, bitmap, num_descr, label_mask;
550 550
     int i;
551 551
 
... ...
@@ -57,10 +57,12 @@ uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id,
57 57
  * Read 'chan' tag from the input stream.
58 58
  *
59 59
  * @param s     AVFormatContext
60
+ * @param pb    AVIOContext
60 61
  * @param st    The stream to set codec values for
61 62
  * @param size  Remaining size in the 'chan' tag
62 63
  * @return      0 if ok, or negative AVERROR code on failure
63 64
  */
64
-int ff_mov_read_chan(AVFormatContext *s, AVStream *st, int64_t size);
65
+int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st,
66
+                     int64_t size);
65 67
 
66 68
 #endif /* AVFORMAT_MOV_CHAN_H */