Browse code

avformat/rmdec: Move MLTI handling out of ff_rm_read_mdpr_codecdata()

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

Michael Niedermayer authored on 2015/08/14 10:20:40
Showing 1 changed files
... ...
@@ -327,20 +327,6 @@ int ff_rm_read_mdpr_codecdata(AVFormatContext *s, AVIOContext *pb,
327 327
     codec_pos = avio_tell(pb);
328 328
     v = avio_rb32(pb);
329 329
 
330
-    if (v == MKBETAG('M', 'L', 'T', 'I')) {
331
-        int number_of_streams = avio_rb16(pb);
332
-        int number_of_mdpr;
333
-        int i;
334
-        for (i = 0; i<number_of_streams; i++)
335
-            avio_rb16(pb);
336
-        number_of_mdpr = avio_rb16(pb);
337
-        if (number_of_mdpr != 1) {
338
-            avpriv_request_sample(s, "MLTI with multiple MDPR");
339
-        }
340
-        avio_rb32(pb);
341
-        v = avio_rb32(pb);
342
-    }
343
-
344 330
     if (v == MKTAG(0xfd, 'a', 'r', '.')) {
345 331
         /* ra type header */
346 332
         if (rm_read_audio_stream_info(s, pb, st, rst, 0))
... ...
@@ -514,6 +500,7 @@ static int rm_read_header(AVFormatContext *s)
514 514
     char buf[128], mime[128];
515 515
     int flags = 0;
516 516
     int ret = -1;
517
+    unsigned size, v;
517 518
 
518 519
     tag = avio_rl32(pb);
519 520
     if (tag == MKTAG('.', 'r', 'a', 0xfd)) {
... ...
@@ -584,8 +571,28 @@ static int rm_read_header(AVFormatContext *s)
584 584
             st->priv_data = ff_rm_alloc_rmstream();
585 585
             if (!st->priv_data)
586 586
                 return AVERROR(ENOMEM);
587
+
588
+            size = avio_rb32(pb);
589
+
590
+            ffio_ensure_seekback(pb, 4);
591
+            v = avio_rb32(pb);
592
+            if (v == MKBETAG('M', 'L', 'T', 'I')) {
593
+                int number_of_streams = avio_rb16(pb);
594
+                int number_of_mdpr;
595
+                int i;
596
+                for (i = 0; i<number_of_streams; i++)
597
+                    avio_rb16(pb);
598
+                number_of_mdpr = avio_rb16(pb);
599
+                if (number_of_mdpr != 1) {
600
+                    avpriv_request_sample(s, "MLTI with multiple (%d) MDPR", number_of_mdpr);
601
+                }
602
+                avio_rb32(pb);
603
+                size -= 4+2+2*number_of_streams+2+4;
604
+            } else
605
+                avio_skip(pb, -4);
606
+
587 607
             if (ff_rm_read_mdpr_codecdata(s, s->pb, st, st->priv_data,
588
-                                          avio_rb32(pb), mime) < 0)
608
+                                          size, mime) < 0)
589 609
                 goto fail;
590 610
             break;
591 611
         case MKTAG('D', 'A', 'T', 'A'):