Browse code

Revert to r17908.

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

Ronald S. Bultje authored on 2009/03/10 07:02:06
Showing 1 changed files
... ...
@@ -468,7 +468,7 @@ static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_
468 468
 skip:
469 469
             /* skip packet if unknown number */
470 470
             url_fskip(pb, len);
471
-            rm->remaining_len = 0;
471
+            rm->remaining_len -= len;
472 472
             continue;
473 473
         }
474 474
         *stream_index= i;
... ...
@@ -691,8 +691,9 @@ ff_rm_retrieve_cache (AVFormatContext *s, ByteIOContext *pb,
691 691
 static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
692 692
 {
693 693
     RMDemuxContext *rm = s->priv_data;
694
+    ByteIOContext *pb = s->pb;
694 695
     AVStream *st;
695
-    int i, len, seq = 1;
696
+    int i, len;
696 697
     int64_t timestamp, pos;
697 698
     int flags;
698 699
 
... ...
@@ -701,19 +702,37 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
701 701
         st = s->streams[rm->audio_stream_num];
702 702
         ff_rm_retrieve_cache(s, s->pb, st, st->priv_data, pkt);
703 703
     } else if (rm->old_format) {
704
-        RMStream *ast = s->streams[0]->priv_data;
705
-        int res, y, h = ast->audio_framesize ? ast->sub_packet_h : 1;
706
-
707
-        timestamp = AV_NOPTS_VALUE;
708
-        len = ast->audio_framesize ? ast->coded_framesize * h / 2 : RAW_PACKET_SIZE;
709
-        for (y = 0; y < h; y++) {
710
-            flags = !y ? 2 : 0;
711
-            res = ff_rm_parse_packet(s, s->pb, s->streams[0], ast, len, pkt,
712
-                                     &seq, &flags, &timestamp);
704
+        RMStream *ast;
705
+
706
+        st = s->streams[0];
707
+        ast = st->priv_data;
708
+        if (st->codec->codec_id == CODEC_ID_RA_288) {
709
+            int x, y;
710
+
711
+            for (y = 0; y < ast->sub_packet_h; y++)
712
+                for (x = 0; x < ast->sub_packet_h/2; x++)
713
+                    if (get_buffer(pb, ast->pkt.data+x*2*ast->audio_framesize+y*ast->coded_framesize, ast->coded_framesize) <= 0)
714
+                        return AVERROR(EIO);
715
+            rm->audio_stream_num = 0;
716
+            rm->audio_pkt_cnt = ast->sub_packet_h * ast->audio_framesize / st->codec->block_align - 1;
717
+            // Release first audio packet
718
+            av_new_packet(pkt, st->codec->block_align);
719
+            memcpy(pkt->data, ast->pkt.data, st->codec->block_align); //FIXME avoid this
720
+            pkt->flags |= PKT_FLAG_KEY; // Mark first packet as keyframe
721
+            pkt->stream_index = 0;
722
+        } else {
723
+            /* just read raw bytes */
724
+            len = RAW_PACKET_SIZE;
725
+            len= av_get_packet(pb, pkt, len);
726
+            pkt->stream_index = 0;
727
+            if (len <= 0) {
728
+                return AVERROR(EIO);
729
+            }
730
+            pkt->size = len;
713 731
         }
714
-        if (res < 0)
715
-            return res;
732
+        rm_ac3_swap_bytes(st, pkt);
716 733
     } else {
734
+        int seq=1;
717 735
 resync:
718 736
         len=sync(s, &timestamp, &flags, &i, &pos);
719 737
         if(len<0)