changeset 1261:a1bd63b7b24f trunk

[svn] - complete tuple for AAC files (tuple->length)
author nenolod
date Thu, 15 Jun 2006 19:55:29 -0700
parents bf0664762d4a
children 186f774fa30b
files ChangeLog Plugins/Input/aac/src/libmp4.c
diffstat 2 files changed, 46 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Jun 15 19:06:40 2006 -0700
+++ b/ChangeLog	Thu Jun 15 19:55:29 2006 -0700
@@ -1,3 +1,12 @@
+2006-06-16 02:06:40 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [1434]
+  - remove unused code (causes a crash on some GTKs, eww!)
+  
+
+  Changes:        Modified:
+  +1 -4           trunk/Plugins/Input/mpg123/configure.c  
+
+
 2006-06-16 01:41:54 +0000  William Pitcock <nenolod@nenolod.net>
   revision [1432]
   - I hate libflac's inconsistent API!
--- a/Plugins/Input/aac/src/libmp4.c	Thu Jun 15 19:06:40 2006 -0700
+++ b/Plugins/Input/aac/src/libmp4.c	Thu Jun 15 19:55:29 2006 -0700
@@ -285,7 +285,43 @@
 		g_free(mp4cb);
 		vfs_fclose(mp4fh);
 	} else {
+		gint mp4track= getAACTrack(mp4file);
+		gint numSamples = mp4ff_num_samples(mp4file, mp4track);
+		guint framesize = 1024;
+		gulong samplerate;
+		gchar channels;
+		gint msDuration;
+		mp4AudioSpecificConfig mp4ASC;
 		gchar *tmpval;
+		guchar *buffer = NULL;
+		guint bufferSize = 0;
+		faacDecHandle decoder;
+
+		decoder = faacDecOpen();
+		mp4ff_get_decoder_config(mp4file, mp4track, &buffer, &bufferSize);
+
+		if ( !buffer ) {
+			faacDecClose(decoder);
+			return FALSE;
+		}
+		if ( faacDecInit2(decoder, buffer, bufferSize, 
+				  &samplerate, &channels) < 0 ) {
+			faacDecClose(decoder);
+
+			return FALSE;
+		}
+
+		/* Add some hacks for SBR profile */
+		if (AudioSpecificConfig(buffer, bufferSize, &mp4ASC) >= 0) {
+			if (mp4ASC.frameLengthFlag == 1) framesize = 960;
+			if (mp4ASC.sbr_present_flag == 1) framesize *= 2;
+		}
+			
+		g_free(buffer);
+
+		faacDecClose(decoder);
+
+		msDuration = ((float)numSamples * (float)(framesize - 1.0)/(float)samplerate) * 1000;
 
 		input = bmp_title_input_new();
 
@@ -304,6 +340,7 @@
 		input->file_name = g_path_get_basename(filename);
 		input->file_path = g_path_get_dirname(filename);
 		input->file_ext = extname(filename);
+		input->length = msDuration;
 
 		free (mp4cb);
 		vfs_fclose(mp4fh);
@@ -408,8 +445,6 @@
 		if(xmmstitle == NULL)
 			xmmstitle = g_strdup(filename);
 
-		mp4_ip.set_info(xmmstitle, -1, -1, samplerate, channels);
-
 		decoder = faacDecOpen();
 		mp4ff_get_decoder_config(mp4file, mp4track, &buffer, &bufferSize);
 		if ( !buffer ) {
@@ -431,7 +466,6 @@
 			
 		g_free(buffer);
 		if( !channels ) {
-			g_print("Number of Channels not supported\n");
 			faacDecClose(decoder);
 
 			return FALSE;