[FFmpeg-devel] [PATCH] Handle AAC in RM similar to other audio codecs

Kostya kostya.shishkov
Wed Feb 4 08:06:59 CET 2009


On Tue, Feb 03, 2009 at 05:23:59PM +0200, Kostya wrote:
> On Tue, Feb 03, 2009 at 02:06:40PM +0100, Michael Niedermayer wrote:
> > On Tue, Feb 03, 2009 at 09:57:02AM +0200, Kostya wrote:
> > > With this patch RM demuxer handles AAC in the same way as other audio codecs -
> > > it loads it into temporary buffer and passes chunks from it as requested.
> > > (Demuxer still should be cleaned, refactored and maybe rewritten from scratch)
> > > 
> > > This patch also fixes -an behaviour with AAC sound.
> > 
> > your patch makes the demuxer more complex not less
> > also it appears that an additional copy pass is added (if so this is a
> > immedeate reason for rejection)
> 
> Another reason to rewrite this demuxer from scratch...

Well, how's this approach (like video frames)?
I think I can convert other audio codec handling to be like this
(hence no temporary buffer and one copy less for them). 
-------------- next part --------------
Index: libavformat/rmdec.c
===================================================================
--- libavformat/rmdec.c	(revision 16915)
+++ libavformat/rmdec.c	(working copy)
@@ -631,15 +631,26 @@
         } else if (st->codec->codec_id == CODEC_ID_AAC) {
             int x;
             rm->audio_stream_num = st->index;
+            if(rm->remaining_len > 0){
+                rm->remaining_len -= ast->sub_packet_lengths[ast->sub_packet_h];
+                av_get_packet(pb, pkt, ast->sub_packet_lengths[ast->sub_packet_h++]);
+            }else{
             ast->sub_packet_cnt = (get_be16(pb) & 0xf0) >> 4;
             if (ast->sub_packet_cnt) {
-                for (x = 0; x < ast->sub_packet_cnt; x++)
+                int asize = 0;
+                for (x = 0; x < ast->sub_packet_cnt; x++){
                     ast->sub_packet_lengths[x] = get_be16(pb);
+                    asize += ast->sub_packet_lengths[x];
+                }
                 // Release first audio packet
-                rm->audio_pkt_cnt = ast->sub_packet_cnt - 1;
+                asize -= ast->sub_packet_lengths[0];
                 av_get_packet(pb, pkt, ast->sub_packet_lengths[0]);
+                rm->remaining_len = asize;
+                rm->current_stream = st->id;
+                ast->sub_packet_h = 1;
                 *flags = 2; // Mark first packet as keyframe
             }
+            }
         } else {
             av_get_packet(pb, pkt, len);
             rm_ac3_swap_bytes(st, pkt);



More information about the ffmpeg-devel mailing list