[Mplayer-cvslog] CVS: main dec_audio.c,1.88,1.89

Atmosfear atmos4 at mplayer.dev.hu
Sun Mar 24 04:08:23 CET 2002


Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv19869

Modified Files:
	dec_audio.c 
Log Message:
Support for decoder specific config from mp4 header for AAC decoder.


Index: dec_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/dec_audio.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- dec_audio.c	19 Mar 2002 21:48:44 -0000	1.88
+++ dec_audio.c	24 Mar 2002 03:08:20 -0000	1.89
@@ -842,42 +842,54 @@
   faacDecConfigurationPtr faac_conf;
   faac_hdec = faacDecOpen();
 
+  if(faac_buffer == NULL)
+    faac_buffer = (unsigned char*)calloc(1,FAAD_BUFFLEN);
+  demux_read_data(sh_audio->ds, faac_buffer, FAAD_BUFFLEN);
+
+  // If we don't get the ES descriptor, try manual config
+  if(!sh_audio->codecdata_len) {
 #if 1
-  /* Set the default object type and samplerate */
-  /* This is useful for RAW AAC files */
-  faac_conf = faacDecGetCurrentConfiguration(faac_hdec);
-  if(sh_audio->samplerate)
-    faac_conf->defSampleRate = sh_audio->samplerate;
-   /* XXX: FAAD support FLOAT output, how do we handle
-    * that (FAAD_FMT_FLOAT)? ::atmos
-    */
-  if(sh_audio->samplesize)
-    switch(sh_audio->samplesize){
-      case 1: // 8Bit
-	mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: 8Bit samplesize not supported by FAAD, assuming 16Bit!\n");
-      default:
-      case 2: // 16Bit
-	faac_conf->outputFormat = FAAD_FMT_16BIT;
-	break;
-      case 3: // 24Bit
-	faac_conf->outputFormat = FAAD_FMT_24BIT;
-	break;
-      case 4: // 32Bit
-	faac_conf->outputFormat = FAAD_FMT_32BIT;
-	break;
-    }
-  //faac_conf->defObjectType = LTP; // => MAIN, LC, SSR, LTP available.
+    /* Set the default object type and samplerate */
+    /* This is useful for RAW AAC files */
+    faac_conf = faacDecGetCurrentConfiguration(faac_hdec);
+    if(sh_audio->samplerate)
+      faac_conf->defSampleRate = sh_audio->samplerate;
+    /* XXX: FAAD support FLOAT output, how do we handle
+      * that (FAAD_FMT_FLOAT)? ::atmos
+      */
+    if(sh_audio->samplesize)
+      switch(sh_audio->samplesize){
+	case 1: // 8Bit
+	  mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: 8Bit samplesize not supported by FAAD, assuming 16Bit!\n");
+	default:
+	case 2: // 16Bit
+	  faac_conf->outputFormat = FAAD_FMT_16BIT;
+	  break;
+	case 3: // 24Bit
+	  faac_conf->outputFormat = FAAD_FMT_24BIT;
+	  break;
+	case 4: // 32Bit
+	  faac_conf->outputFormat = FAAD_FMT_32BIT;
+	  break;
+      }
+    //faac_conf->defObjectType = LTP; // => MAIN, LC, SSR, LTP available.
 
-  faacDecSetConfiguration(faac_hdec, faac_conf);
+    faacDecSetConfiguration(faac_hdec, faac_conf);
 #endif
 
-  if(faac_buffer == NULL)
-    faac_buffer = (unsigned char*)malloc(FAAD_BUFFLEN);
-  memset(faac_buffer, 0, FAAD_BUFFLEN);
-  demux_read_data(sh_audio->ds, faac_buffer, FAAD_BUFFLEN);
+    /* init the codec */
+    faac_bytesconsumed = faacDecInit(faac_hdec, faac_buffer,
+       &faac_samplerate, &faac_channels);
+
+  } else { // We have ES DS in codecdata
+    /*int i;
+    for(i = 0; i < sh_audio->codecdata_len; i++)
+      printf("codecdata_dump %d: 0x%02X\n", i, sh_audio->codecdata[i]);*/
 
-  /* init the codec */
-  if((faac_bytesconsumed = faacDecInit(faac_hdec, faac_buffer, &faac_samplerate, &faac_channels)) < 0) {
+    faac_bytesconsumed = faacDecInit2(faac_hdec, sh_audio->codecdata,
+       sh_audio->codecdata_len,	&faac_samplerate, &faac_channels);
+  }
+  if(faac_bytesconsumed < 0) {
     mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: Failed to initialize the decoder!\n"); // XXX: deal with cleanup!
     faacDecClose(faac_hdec);
     free(faac_buffer);
@@ -890,9 +902,9 @@
     sh_audio->samplerate = faac_samplerate;
     if(!sh_audio->i_bps) {
       mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: compressed input bitrate missing, assuming 128kbit/s!\n");
-      sh_audio->i_bps = 128*1000/8; // XXX: HACK!!! There's currently no way to get bitrate from libfaad2! ::atmos
+      sh_audio->i_bps = 128*1000/8; // XXX: HACK!!! ::atmos
     } else 
-      mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: got %dkbit/s rate from MP4 header!\n",sh_audio->i_bps*8/1000);
+      mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: got %dkbit/s bitrate from MP4 header!\n",sh_audio->i_bps*8/1000);
   }  
 	    
 } break;		




More information about the MPlayer-cvslog mailing list