shithub: aacdec

Download patch

ref: fccac308645a539807dd5916d9e66ac1e02f70c2
parent: 3cccff77ee05fa0751e7cee0f3e0aef040973450
author: menno <menno>
date: Thu Aug 15 13:41:44 EDT 2002

Removed seeking to test if the buggy part has something to do with that

--- a/plugins/in_mp4/aacinfo.c
+++ b/plugins/in_mp4/aacinfo.c
@@ -16,13 +16,11 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: aacinfo.c,v 1.1 2002/08/14 17:55:49 menno Exp $
+** $Id: aacinfo.c,v 1.2 2002/08/15 17:41:44 menno Exp $
 **/
 
-#ifdef _WIN32
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#endif
 #include <malloc.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -70,12 +68,11 @@
     return 0;
 }
 
-static int read_ADTS_header(FILE *file, faadAACInfo *info, unsigned long **seek_table,
-                            int *seek_table_len, int use_seek_table)
+static int read_ADTS_header(FILE *file, faadAACInfo *info)
 {
     /* Get ADTS header data */
     unsigned char buffer[ADTS_MAX_SIZE];
-    int frames, framesinsec=0, t_framelength = 0, frame_length, sr_idx = 0, ID;
+    int frames, t_framelength = 0, frame_length, sr_idx = 0, ID;
     int second = 0, pos;
     float frames_per_sec = 0;
     unsigned long bytes;
@@ -84,7 +81,7 @@
     info->headertype = 2;
 
     /* Read all frames to ensure correct time and bitrate */
-    for (frames = 0; /* */; frames++, framesinsec++)
+    for (frames = 0; /* */; frames++)
     {
         bytes = fread(buffer, 1, ADTS_MAX_SIZE, file);
 
@@ -121,28 +118,11 @@
 
         t_framelength += frame_length;
 
-        if (framesinsec > 43)
-            framesinsec = 0;
-
         pos = ftell(file) - ADTS_MAX_SIZE;
 
-        if (framesinsec == 0 && use_seek_table)
-        {
-            tmp_seek_table = (unsigned long*)realloc(tmp_seek_table, (second+1) * sizeof(unsigned long));
-            tmp_seek_table[second] = pos;
-        }
-        if (framesinsec == 0)
-            second++;
-
         fseek(file, frame_length - ADTS_MAX_SIZE, SEEK_CUR);
     }
 
-	if(seek_table_len)
-	{
-		*seek_table_len = second;
-		*seek_table = tmp_seek_table;
-	}
-
     if (frames > 0)
     {
         info->sampling_rate = sample_rates[sr_idx];
@@ -158,13 +138,11 @@
     return 0;
 }
 
-int get_AAC_format(char *filename, faadAACInfo *info,
-                   unsigned long **seek_table, int *seek_table_len,
-                   int use_seek_table)
+int get_AAC_format(char *filename, faadAACInfo *info)
 {
     unsigned long tagsize;
     FILE *file;
-	char buffer[10];
+    char buffer[10];
     unsigned long file_len;
     unsigned char adxx_id[5];
     unsigned long tmp;
@@ -184,7 +162,7 @@
     tmp = fread(buffer, 10, 1, file);
 
     if (StringComp(buffer, "ID3", 3) == 0)
-	{
+    {
         /* high bit is not used */
         tagsize = (buffer[6] << 21) | (buffer[7] << 14) |
             (buffer[8] <<  7) | (buffer[9] <<  0);
@@ -207,7 +185,7 @@
     if (StringComp(adxx_id, "AD", 2) == 0)
     {
         /* We think its an ADIF header, but check the rest just to make sure */
-		tmp = fread(adxx_id + 2, 2, 1, file);
+        tmp = fread(adxx_id + 2, 2, 1, file);
 
         if (StringComp(adxx_id, "ADIF", 4) == 0)
         {
@@ -221,9 +199,7 @@
         {
             /* ADTS  header located */
             fseek(file, tagsize, SEEK_SET);
-
-            read_ADTS_header(file, info, seek_table, seek_table_len,
-                use_seek_table);
+            read_ADTS_header(file, info);
         } else {
             /* Unknown/headerless AAC file, assume format: */
             info->version = 2;
@@ -239,4 +215,3 @@
 
     return 0;
 }
-
--- a/plugins/in_mp4/aacinfo.h
+++ b/plugins/in_mp4/aacinfo.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: aacinfo.h,v 1.1 2002/08/14 17:55:49 menno Exp $
+** $Id: aacinfo.h,v 1.2 2002/08/15 17:41:44 menno Exp $
 **/
 
 #ifndef AACINFO_INCLUDED
@@ -32,13 +32,9 @@
     int headertype;
 } faadAACInfo;
 
-int get_AAC_format(char *filename, faadAACInfo *info,
-                   unsigned long **seek_table, int *seek_table_len,
-                   int use_seek_table);
+int get_AAC_format(char *filename, faadAACInfo *info);
 
 static int read_ADIF_header(FILE *file, faadAACInfo *info);
-static int read_ADTS_header(FILE *file, faadAACInfo *info,
-                            unsigned long **seek_table, int *seek_table_len,
-                            int use_seek_table);
+static int read_ADTS_header(FILE *file, faadAACInfo *info);
 
 #endif
--- a/plugins/in_mp4/in_mp4.c
+++ b/plugins/in_mp4/in_mp4.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: in_mp4.c,v 1.14 2002/08/14 17:55:20 menno Exp $
+** $Id: in_mp4.c,v 1.15 2002/08/15 17:41:44 menno Exp $
 **/
 
 #define WIN32_LEAN_AND_MEAN
@@ -86,8 +86,6 @@
     long bytes_consumed;
     unsigned char *buffer;
     long seconds;
-    unsigned long *seek_table;
-    int seek_table_len;
     faadAACInfo aacInfo;
 } state;
 
@@ -237,7 +235,7 @@
     case WM_INITDIALOG:
         info_text = malloc(1024*sizeof(char));
 
-        get_AAC_format(info_fn, &aacInfo, NULL, NULL, 0);
+        get_AAC_format(info_fn, &aacInfo);
 
         sprintf(info_text, "%s AAC %s, %d sec, %d kbps, %d Hz",
             (aacInfo.version==2)?"MPEG-2":"MPEG-4", get_ot_string(aacInfo.object_type),
@@ -262,7 +260,7 @@
 
 int infoDlg(char *fn, HWND hwndParent)
 {
-    if(StringComp(fn + strlen(fn) - 3, "aac", 3) == 0)
+    if(StringComp(fn + strlen(fn) - 3, "AAC", 3) == 0)
     {
         lstrcpy(info_fn, fn);
 
@@ -300,7 +298,7 @@
         case IDOK:
             m_show_errors = SendMessage(GetDlgItem(hwndDlg, IDC_ERROR), BM_GETCHECK, 0, 0);
             m_priority = SendMessage(GetDlgItem(hwndDlg, IDC_PRIORITY), TBM_GETPOS, 0, 0);
-            for (i = 0; i < 3; i++)
+            for (i = 0; i < 5; i++)
             {
                 int set = SendMessage(GetDlgItem(hwndDlg, res_id_table[i]), BM_GETCHECK, 0, 0);
                 if (set)
@@ -339,11 +337,11 @@
 
 int isourfile(char *fn)
 {
-    if(StringComp(fn + strlen(fn) - 3, "mp4", 3) == 0)
+    if(StringComp(fn + strlen(fn) - 3, "MP4", 3) == 0)
     {
         return 1;
     }
-    if(StringComp(fn + strlen(fn) - 3, "aac", 3) == 0)
+    if(StringComp(fn + strlen(fn) - 3, "AAC", 3) == 0)
     {
         return 1;
     }
@@ -363,17 +361,10 @@
     mp4state.channels = 0;
     mp4state.samplerate = 0;
     mp4state.filetype = 0;
-    mp4state.seek_table_len = 0;
 
-    if (mp4state.seek_table)
-    {
-        free(mp4state.seek_table);
-        mp4state.seek_table = NULL;
-    }
-
     strcpy(mp4state.filename, fn);
 
-    if(StringComp(fn + strlen(fn) - 3, "aac", 3) == 0)
+    if(StringComp(fn + strlen(fn) - 3, "AAC", 3) == 0)
         mp4state.filetype = 1;
 
     mp4state.hDecoder = faacDecOpen();
@@ -387,8 +378,7 @@
     {
         long pos, tmp, read;
 
-        get_AAC_format(mp4state.filename, &mp4state.aacInfo,
-            &mp4state.seek_table, &mp4state.seek_table_len, 1);
+        get_AAC_format(mp4state.filename, &mp4state.aacInfo);
 
         mp4state.aacfile = fopen(mp4state.filename, "rb");
         if (!mp4state.aacfile)
@@ -440,10 +430,7 @@
 
         avg_bitrate = mp4state.aacInfo.bitrate;
 
-        if (mp4state.aacInfo.headertype == 2)
-            module.is_seekable = 1;
-        else
-            module.is_seekable = 0;
+        module.is_seekable = 0;
     } else {
         mp4state.mp4file = MP4Read(mp4state.filename, 0);
         if (!mp4state.mp4file)
@@ -604,13 +591,6 @@
     else
         MP4Close(mp4state.mp4file);
 
-    if (mp4state.seek_table)
-    {
-        free(mp4state.seek_table);
-        mp4state.seek_table = NULL;
-        mp4state.seek_table_len = 0;
-    }
-
     module.outMod->Close();
     module.SAVSADeInit();
 }
@@ -619,7 +599,7 @@
 {
     long msDuration = 0;
 
-    if(StringComp(fn + strlen(fn) - 3, "mp4", 3) == 0)
+    if(StringComp(fn + strlen(fn) - 3, "MP4", 3) == 0)
     {
         int track;
         MP4Duration length;
@@ -645,7 +625,7 @@
         return msDuration;
     } else {
         faadAACInfo aacInfo;
-        get_AAC_format(fn, &aacInfo, NULL, NULL, 0);
+        get_AAC_format(fn, &aacInfo);
 
         return aacInfo.length;
     }
@@ -829,6 +809,7 @@
     return 0;
 }
 
+#if 0
 int aac_seek(int pos_ms)
 {
     int read;
@@ -845,6 +826,7 @@
 
     return 0;
 }
+#endif
 
 DWORD WINAPI AACPlayThread(void *b)
 {
@@ -859,6 +841,7 @@
 
     while (!*((int *)b))
     {
+#if 0
         /* seeking */
         if (mp4state.seek_needed != -1)
         {
@@ -871,6 +854,7 @@
             mp4state.decode_pos_ms = ms;
             mp4state.seek_needed = -1;
         }
+#endif
 
         if (done)
         {
@@ -976,13 +960,6 @@
         } else {
             Sleep(10);
         }
-    }
-
-    if (mp4state.seek_table)
-    {
-        free(mp4state.seek_table);
-        mp4state.seek_table = NULL;
-        mp4state.seek_table_len = 0;
     }
 
 	PlayThreadAlive = 0;
--- a/plugins/in_mp4/utils.c
+++ b/plugins/in_mp4/utils.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: utils.c,v 1.2 2002/08/14 17:55:20 menno Exp $
+** $Id: utils.c,v 1.3 2002/08/15 17:41:44 menno Exp $
 **/
 
 #define WIN32_LEAN_AND_MEAN
@@ -31,8 +31,8 @@
 
     while (len--)
     {
-        c1 = *str1++;
-        c2 = *str2++;
+        c1 = tolower(*str1++);
+        c2 = tolower(*str2++);
 
         if (c1 == 0 || c1 != c2)
             break;