changeset 18644:82263a36cfa4

fixes the infinite loop which occurs when there is a decode error in a frame. Patch by Bryan Alton < balton AH eircom POIS net > Original thread: Date: Jun 6, 2006 10:52 AM Subject: [MPlayer-dev-eng] [PATCH] fix for faad2 infinite loop after decoding error
author gpoirier
date Thu, 08 Jun 2006 06:56:13 +0000
parents 4d7478ef1713
children 8c6bdea1585c
files libmpcodecs/ad_faad.c
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/ad_faad.c	Thu Jun 08 05:39:32 2006 +0000
+++ b/libmpcodecs/ad_faad.c	Thu Jun 08 06:56:13 2006 +0000
@@ -232,7 +232,7 @@
   if(!sh->codecdata_len){
    // raw aac stream:
    do {
-    faac_sample_buffer = faacDecDecode(faac_hdec, &faac_finfo, sh->a_in_buffer+j, sh->a_in_buffer_len);
+    faac_sample_buffer = faacDecDecode(faac_hdec, &faac_finfo, sh->a_in_buffer, sh->a_in_buffer_len);
 	
     /* update buffer index after faacDecDecode */
     if(faac_finfo.bytesconsumed >= sh->a_in_buffer_len) {
@@ -245,11 +245,13 @@
     if(faac_finfo.error > 0) {
       mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: error: %s, trying to resync!\n",
               faacDecGetErrorMessage(faac_finfo.error));
-      j++;
+      sh->a_in_buffer_len--;
+      memmove(sh->a_in_buffer,&sh->a_in_buffer[1],sh->a_in_buffer_len);
+      aac_sync(sh);
       errors++;
     } else
       break;
-   } while(j < FAAD_BUFFLEN && errors < MAX_FAAD_ERRORS);	  
+   } while(errors < MAX_FAAD_ERRORS);	  
   } else {
    // packetized (.mp4) aac stream:
     unsigned char* bufptr=NULL;