[Ffmpeg-cvslog] CVS: ffmpeg/libavcodec faad.c,1.10,1.11

Måns Rullgård CVS mru
Wed Feb 8 01:31:01 CET 2006


Update of /cvsroot/ffmpeg/ffmpeg/libavcodec
In directory mail:/var2/tmp/cvs-serv31380

Modified Files:
	faad.c 
Log Message:
decode adts aac streams


Index: faad.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/faad.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- faad.c	12 Jan 2006 22:43:15 -0000	1.10
+++ faad.c	8 Feb 2006 00:30:58 -0000	1.11
@@ -49,9 +49,8 @@
 typedef struct {
     void* handle;               /* dlopen handle */
     void* faac_handle;          /* FAAD library handle */
-    int frame_size;
     int sample_size;
-    int flags;
+    int init;
 
     /* faad calls */
     faacDecHandle FAADAPI (*faacDecOpen)(void);
@@ -111,17 +110,20 @@
 #endif
     int r = 0;
 
-    if (avctx->extradata)
+    if (avctx->extradata){
         r = s->faacDecInit2(s->faac_handle, (uint8_t*) avctx->extradata,
                             avctx->extradata_size,
                             &samplerate, &channels);
-    // else r = s->faacDecInit(s->faac_handle ... );
-
-    if (r < 0)
-        av_log(avctx, AV_LOG_ERROR, "faacDecInit2 failed r:%d   sr:%ld  ch:%ld  s:%d\n",
-                r, samplerate, (long)channels, avctx->extradata_size);
-    avctx->sample_rate = samplerate;
-    avctx->channels = channels;
+        if (r < 0){
+            av_log(avctx, AV_LOG_ERROR,
+                   "faacDecInit2 failed r:%d   sr:%ld  ch:%ld  s:%d\n",
+                   r, samplerate, (long)channels, avctx->extradata_size);
+        } else {
+            avctx->sample_rate = samplerate;
+            avctx->channels = channels;
+            s->init = 1;
+        }
+    }
 
     return r;
 }
@@ -155,6 +157,20 @@
         ? buf_size : (int)bytesconsumed;
 #else
 
+    if(!s->init){
+        unsigned long srate;
+        unsigned char channels;
+        int r = faacDecInit(s->faac_handle, buf, buf_size, &srate, &channels);
+        if(r < 0){
+            av_log(avctx, AV_LOG_ERROR, "faac: codec init failed: %s\n",
+                   s->faacDecGetErrorMessage(frame_info.error));
+            return 0;
+        }
+        avctx->sample_rate = srate;
+        avctx->channels = channels;
+        s->init = 1;
+    }
+
     out = s->faacDecDecode(s->faac_handle, &frame_info, (unsigned char*)buf, (unsigned long)buf_size);
 
     if (frame_info.error > 0) {





More information about the ffmpeg-cvslog mailing list