[FFmpeg-devel] [PATCH] ffmpeg.c: Strip off ADTS Header from AAC audio as it is needed only in TS and not needed in 3GP, MP4, FLV, ISM formats

Chiranjeevi Melam cmelam at rgbnetworks.com
Tue Aug 30 00:50:31 CEST 2011


Hi,
As per feedback, moved this feature to ffmpeg/libavcodec/aac_adtstoasc_bsf.c file and created a new function " SkipADTSHeader" in the file ffmpeg/libavcodec/aac_adtstoasc_bsf.c.
Thanks,
Chiru


diff --git a/ffmpeg/ffmpeg_orig.c b/ffmpeg/ffmpeg.c
index 95b3252..d44a09f 100755
--- a/ffmpeg/ffmpeg_orig.c
+++ b/ffmpeg/ffmpeg.c
@@ -1828,6 +1828,12 @@ static int output_packet(InputStream *ist, int ist_index,
                             opkt.size = data_size;
                         }

+                                               if(ost->st->codec->codec_id == CODEC_ID_AAC) {
+                            if(!strcmp(input_files[ist->file_index]->iformat->name, "mpegts") && strcmp(output_files[ost->file_index]->oformat->name, "mpegts") ) {
+                                                               SkipADTSHeader(&opkt, data_size, audio_size);
+                                                       }
+                                               }
+
                         if (os->oformat->flags & AVFMT_RAWPICTURE) {
                             /* store AVPicture in AVPacket, as expected by the output format */
                             avpicture_fill(&pict, opkt.data, ost->st->codec->pix_fmt, ost->st->codec->width, ost->st->codec->height);



diff --git a/ffmpeg/libavcodec/aac_adtstoasc_bsf_orig.c b/ffmpeg/libavcodec/aac_adtstoasc_bsf.c
index 6558c02..cb5cc61 100755
--- a/ffmpeg/libavcodec/aac_adtstoasc_bsf_orig.c
+++ b/ffmpeg/libavcodec/aac_adtstoasc_bsf.c
@@ -26,6 +26,8 @@
 #include "mpeg4audio.h"
 #include "internal.h"

+int SkipADTSHeader(AVPacket *o_pkt, int dsize, int asize);
+
 typedef struct AACBSFContext {
     int first_frame_done;
 } AACBSFContext;
@@ -107,6 +109,21 @@ static int aac_adtstoasc_filter(AVBitStreamFilterContext *bsfc,
     return 0;
 }

+int SkipADTSHeader(AVPacket *o_pkt, int datasize, int audiosize)
+{
+       int32_t offset = 7;
+               if(o_pkt->data[0] == 0xff && (o_pkt->data[1] & 0xf0) == 0xf0) {
+                       // skip ADTS CRC
+            if((o_pkt->data[1] & 0x1) == 0x00)
+                               offset += 2;
+            o_pkt->data  += offset;
+            o_pkt->size  -= offset;
+            datasize  -= offset;
+            audiosize -= offset;
+               }
+       return 0;
+}
+
 AVBitStreamFilter ff_aac_adtstoasc_bsf = {
     "aac_adtstoasc",
     sizeof(AACBSFContext),


-----Original Message-----
From: ffmpeg-devel-bounces at ffmpeg.org [mailto:ffmpeg-devel-bounces at ffmpeg.org] On Behalf Of Michael Niedermayer
Sent: Wednesday, August 24, 2011 2:07 PM
To: FFmpeg development discussions and patches
Subject: Re: [FFmpeg-devel] [PATCH] ffmpeg.c: Strip off ADTS Header from AAC audio as it is needed only in TS and not needed in 3GP, MP4, FLV, ISM formats

On Wed, Aug 24, 2011 at 05:04:21PM +0000, Chiranjeevi Melam wrote:
> All,
> The patch is to strip off ADTS Header from AAC audio as it is needed only in TS and not needed in 3GP, MP4, FLV, ISM formats.
> Thanks,
> Chiru

Please see:
"[PATCH]AAC audio: Skip ADTS Header when copied from TS container to Non-TS containers"

for review and comments

I am not against the patch if there is a problem with doing it with a bitstream filter or in the muxer, but if there is, iam not aware of it

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated form of tyranny and slavery out of the most extreme liberty. -- Plato


More information about the ffmpeg-devel mailing list