changeset 85:86ce11c6b8c3 trunk

[svn] - Imported a few changes from alac decoder 0.1.3 - Added myself to AUTHORS
author js
date Wed, 04 Oct 2006 21:01:38 -0700
parents fa9e4ed85309
children 60cf31332daa
files AUTHORS ChangeLog src/alac/demux.c src/alac/demux.h src/alac/plugin.c
diffstat 5 files changed, 74 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/AUTHORS	Wed Oct 04 18:42:11 2006 -0700
+++ b/AUTHORS	Wed Oct 04 21:01:38 2006 -0700
@@ -8,6 +8,7 @@
 William Pitcock <nenolod@nenolod.net>
 Derek Pomery <nemo@m8y.org>
 Mohammed Sameer <msameer@foolab.org>
+Jonathan Schleifer <js@h3c.de>
 Stephen Sokolow <deitarion@gmail.com>
 Tony Vroon <chainsaw@gentoo.org>
 Yoshiki Yazawa <yaz@cc.or.rim.jp>
--- a/ChangeLog	Wed Oct 04 18:42:11 2006 -0700
+++ b/ChangeLog	Wed Oct 04 21:01:38 2006 -0700
@@ -1,3 +1,11 @@
+2006-10-05 01:42:11 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [168]
+  - try this
+  
+  trunk/src/alac/demux.c |    8 +++++++-
+  1 file changed, 7 insertions(+), 1 deletion(-)
+
+
 2006-10-05 01:24:55 +0000  Jonathan Schleifer <js@h3c.de>
   revision [166]
   The same change like for the FT8 MODs, but this time for FT6 MODs.
--- a/src/alac/demux.c	Wed Oct 04 18:42:11 2006 -0700
+++ b/src/alac/demux.c	Wed Oct 04 21:01:38 2006 -0700
@@ -150,7 +150,7 @@
 
 }
 
-static void read_chunk_stsd(qtmovie_t *qtmovie, size_t chunk_len)
+static int read_chunk_stsd(qtmovie_t *qtmovie, size_t chunk_len)
 {
     unsigned int i;
     uint32_t numentries;
@@ -169,9 +169,7 @@
     size_remaining -= 4;
 
     if (numentries != 1)
-    {
-        return;
-    }
+        return 0;
 
     for (i = 0; i < numentries; i++)
     {
@@ -192,7 +190,7 @@
 
         version = stream_read_uint16(qtmovie->stream);
         if (version != 1)
-		return;
+		return 0;
         entry_remaining -= 2;
 
         /* revision level */
@@ -243,12 +241,15 @@
         if (entry_remaining)
             stream_skip(qtmovie->stream, entry_remaining);
 
+	qtmovie->res->format_read = 1;
         if (qtmovie->res->format != MAKEFOURCC('a','l','a','c'))
 	{
 	    qtmovie->isfilenotalac = 1;
-            return;
+            return 0;
 	}
     }
+
+    return 1;
 }
 
 static void read_chunk_stts(qtmovie_t *qtmovie, size_t chunk_len)
@@ -323,7 +324,7 @@
         stream_skip(qtmovie->stream, size_remaining);
 }
 
-static void read_chunk_stbl(qtmovie_t *qtmovie, size_t chunk_len)
+static int read_chunk_stbl(qtmovie_t *qtmovie, size_t chunk_len)
 {
     size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
 
@@ -334,14 +335,15 @@
 
         sub_chunk_len = stream_read_uint32(qtmovie->stream);
         if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining)
-            return;
+            return 0;
 
         sub_chunk_id = stream_read_uint32(qtmovie->stream);
 
         switch (sub_chunk_id)
         {
         case MAKEFOURCC('s','t','s','d'):
-            read_chunk_stsd(qtmovie, sub_chunk_len);
+            if (read_chunk_stsd(qtmovie, sub_chunk_len) == 0)
+	    	return 0;
             break;
         case MAKEFOURCC('s','t','t','s'):
             read_chunk_stts(qtmovie, sub_chunk_len);
@@ -355,23 +357,25 @@
             stream_skip(qtmovie->stream, sub_chunk_len - 8);
             break;
         default:
-            return;
+            return 0;
         }
 
         size_remaining -= sub_chunk_len;
     }
+
+    return 1;
 }
 
-static void read_chunk_minf(qtmovie_t *qtmovie, size_t chunk_len)
+static int read_chunk_minf(qtmovie_t *qtmovie, size_t chunk_len)
 {
     size_t dinf_size, stbl_size;
     size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
 
     if (stream_read_uint32(qtmovie->stream) != 16)
-        return;
+        return 0;
 
     if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('s','m','h','d'))
-        return;
+        return 0;
 
     /* now skip the rest */
     stream_skip(qtmovie->stream, 16 - 8);
@@ -381,7 +385,7 @@
   /**** DINF CHUNK ****/
     dinf_size = stream_read_uint32(qtmovie->stream);
     if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('d','i','n','f'))
-        return;
+        return 0;
 
     /* skip it */
     stream_skip(qtmovie->stream, dinf_size - 8);
@@ -392,16 +396,19 @@
   /**** SAMPLE TABLE ****/
     stbl_size = stream_read_uint32(qtmovie->stream);
     if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('s','t','b','l'))
-        return;
+        return 0;
 
-    read_chunk_stbl(qtmovie, stbl_size);
+    if (read_chunk_stbl(qtmovie, stbl_size) == 0)
+	return 0;
     size_remaining -= stbl_size;
 
     if (size_remaining)
         stream_skip(qtmovie->stream, size_remaining);
+
+    return 1;
 }
 
-static void read_chunk_mdia(qtmovie_t *qtmovie, size_t chunk_len)
+static int read_chunk_mdia(qtmovie_t *qtmovie, size_t chunk_len)
 {
     size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
 
@@ -412,7 +419,7 @@
 
         sub_chunk_len = stream_read_uint32(qtmovie->stream);
         if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining)
-            return;
+            return 0;
 
         sub_chunk_id = stream_read_uint32(qtmovie->stream);
 
@@ -425,18 +432,21 @@
             read_chunk_hdlr(qtmovie, sub_chunk_len);
             break;
         case MAKEFOURCC('m','i','n','f'):
-            read_chunk_minf(qtmovie, sub_chunk_len);
+            if (read_chunk_minf(qtmovie, sub_chunk_len) == 0)
+	        return 0;
             break;
         default:
-            return;
+            return 0;
         }
 
         size_remaining -= sub_chunk_len;
     }
+
+    return 1;
 }
 
 /* 'trak' - a movie track - contains other atoms */
-static void read_chunk_trak(qtmovie_t *qtmovie, size_t chunk_len)
+static int read_chunk_trak(qtmovie_t *qtmovie, size_t chunk_len)
 {
     size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
 
@@ -447,7 +457,7 @@
 
         sub_chunk_len = stream_read_uint32(qtmovie->stream);
         if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining)
-            return;
+            return 0;
 
         sub_chunk_id = stream_read_uint32(qtmovie->stream);
 
@@ -457,17 +467,20 @@
             read_chunk_tkhd(qtmovie, sub_chunk_len);
             break;
         case MAKEFOURCC('m','d','i','a'):
-            read_chunk_mdia(qtmovie, sub_chunk_len);
+            if (read_chunk_mdia(qtmovie, sub_chunk_len) == 0)
+	    	return 0;
             break;
         case MAKEFOURCC('e','d','t','s'):
             read_chunk_edts(qtmovie, sub_chunk_len);
             break;
         default:
-            return;
+            return 0;
         }
 
         size_remaining -= sub_chunk_len;
     }
+
+    return 1;
 }
 
 /* 'mvhd' movie header atom */
@@ -479,6 +492,15 @@
     stream_skip(qtmovie->stream, size_remaining);
 }
 
+/* 'iods' */
+static void read_chunk_iods(qtmovie_t *qtmovie, size_t chunk_len)
+{
+    /* don't need anything from here atm, skip */
+    size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
+
+    stream_skip(qtmovie->stream, size_remaining);
+}
+
 enum
 {
 	UDTA_NIL = 0,
@@ -576,7 +598,7 @@
 }
 
 /* 'moov' movie atom - contains other atoms */
-static void read_chunk_moov(qtmovie_t *qtmovie, size_t chunk_len)
+static int read_chunk_moov(qtmovie_t *qtmovie, size_t chunk_len)
 {
     size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
 
@@ -587,7 +609,7 @@
 
         sub_chunk_len = stream_read_uint32(qtmovie->stream);
         if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining)
-            return;
+            return 0;
 
         sub_chunk_id = stream_read_uint32(qtmovie->stream);
 
@@ -597,7 +619,8 @@
             read_chunk_mvhd(qtmovie, sub_chunk_len);
             break;
         case MAKEFOURCC('t','r','a','k'):
-            read_chunk_trak(qtmovie, sub_chunk_len);
+            if (read_chunk_trak(qtmovie, sub_chunk_len) == 0)
+	    	return 0;
             break;
         case MAKEFOURCC('u','d','t','a'):
             read_chunk_udta(qtmovie, sub_chunk_len);
@@ -605,18 +628,25 @@
         case MAKEFOURCC('e','l','s','t'):
             read_chunk_elst(qtmovie, sub_chunk_len);
             break;
+	case MAKEFOURCC('i','o','d','s'):
+	    read_chunk_iods(qtmovie, sub_chunk_len);
+	    break;
         default:
-            return;
+            return 0;
         }
 
         size_remaining -= sub_chunk_len;
     }
+
+    return 1;
 }
 
 static void read_chunk_mdat(qtmovie_t *qtmovie, size_t chunk_len, int skip_mdat)
 {
     size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
 
+    if (size_remaining == 0) return;
+
     qtmovie->res->mdat_len = (uint32_t)size_remaining;
     if (skip_mdat)
     {
@@ -679,7 +709,8 @@
             read_chunk_ftyp(qtmovie, chunk_len);
             break;
         case MAKEFOURCC('m','o','o','v'):
-            read_chunk_moov(qtmovie, chunk_len);
+            if (read_chunk_moov(qtmovie, chunk_len) == 0)
+	        return 0; /* failed to read moov, can't do anything */
             if (found_mdat)
             {
                 return set_saved_mdat(qtmovie);
--- a/src/alac/demux.h	Wed Oct 04 18:42:11 2006 -0700
+++ b/src/alac/demux.h	Wed Oct 04 21:01:38 2006 -0700
@@ -12,6 +12,8 @@
     stream_t *stream;
     alac_file *alac;
 
+    int format_read;
+
     uint16_t num_channels;
     uint16_t sample_size;
     uint32_t sample_rate;
--- a/src/alac/plugin.c	Wed Oct 04 18:42:11 2006 -0700
+++ b/src/alac/plugin.c	Wed Oct 04 21:01:38 2006 -0700
@@ -312,7 +312,7 @@
     TitleInput *ti;
     gchar *title;
 
-    memset(&demux_res, '\0', sizeof(demux_res_t));
+    memset(&demux_res, 0, sizeof(demux_res));
 
     set_endian();
 
@@ -320,12 +320,12 @@
     input_stream = stream_create_file(input_file, 1);
 
     if (!input_stream)
-        return 0;
+        return 1;
 
     /* if qtmovie_read returns successfully, the stream is up to
      * the movie data, which can be used directly by the decoder */
     if (!qtmovie_read(input_stream, &demux_res))
-        return 0;
+        return 1;
 
     demux_res.stream = input_stream;