gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash/server/swf tag_loaders.cpp [release-0-8-0]


From: Tomas Groth
Subject: [Gnash-commit] gnash/server/swf tag_loaders.cpp [release-0-8-0]
Date: Fri, 08 Jun 2007 00:45:30 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Branch:         release-0-8-0
Changes by:     Tomas Groth <tgc>       07/06/08 00:45:30

Modified files:
        server/swf     : tag_loaders.cpp 

Log message:
        Another attempt at getting adpcm-stream decoding working - not quite 
there yet.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.cpp?cvsroot=gnash&only_with_tag=release-0-8-0&r1=1.111.4.1&r2=1.111.4.2

Patches:
Index: tag_loaders.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/tag_loaders.cpp,v
retrieving revision 1.111.4.1
retrieving revision 1.111.4.2
diff -u -b -r1.111.4.1 -r1.111.4.2
--- tag_loaders.cpp     7 Jun 2007 22:15:47 -0000       1.111.4.1
+++ tag_loaders.cpp     8 Jun 2007 00:45:30 -0000       1.111.4.2
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: tag_loaders.cpp,v 1.111.4.1 2007/06/07 22:15:47 tgc Exp $ */
+/* $Id: tag_loaders.cpp,v 1.111.4.2 2007/06/08 00:45:30 tgc Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1030,7 +1030,7 @@
 
 // Forward declaration
 static void sound_expand(stream *in, sound_handler::format_type &format,
-       bool sample_16bit, bool stereo,
+       bool sample_16bit, bool stereo, unsigned int &sample_count,
        unsigned char* &data, unsigned &data_bytes);
 
 // Common data
@@ -1053,7 +1053,7 @@
        int     sample_rate = in->read_uint(2); // multiples of 5512.5
        bool    sample_16bit = in->read_uint(1) ? true : false;
        bool    stereo = in->read_uint(1) ? true : false;
-       int     sample_count = in->read_u32();
+       unsigned int    sample_count = in->read_u32();
 
        IF_VERBOSE_PARSE
        (
@@ -1083,7 +1083,7 @@
 
            // sound_expand allocates storage for data[].
            // and modifies 3 parameters: format, data and data_bytes.
-           sound_expand(in, format, sample_16bit, stereo, data, data_bytes);
+           sound_expand(in, format, sample_16bit, stereo, sample_count, data, 
data_bytes);
 
            int handler_id = handler->create_sound(
                data,
@@ -1151,6 +1151,7 @@
 static sound_handler::format_type stream_input_format;
 static bool stream_input_is16bit;
 static bool stream_input_stereo;
+static unsigned int stream_input_sample_count;
 
 // Load a SoundStreamHead(2) tag.
 void
@@ -1181,8 +1182,12 @@
     // checks if this is a new streams header or just one in the row
     if (format == 0 && sample_rate == 0 && !sample_16bit && !stereo) return;
 
-    int sample_count = in->read_u32();
-    if (format == 2) garbage = in->read_uint(16);
+    unsigned int sample_count = in->read_u16();
+       int latency = 0;
+    if (format == sound_handler::FORMAT_MP3) {
+               latency = in->read_s16();
+               garbage = in->read_uint(16);
+       }
 
     IF_VERBOSE_PARSE
     (
@@ -1209,6 +1214,7 @@
     stream_input_format = format;
     stream_input_is16bit = sample_16bit;
     stream_input_stereo = stereo;
+       stream_input_sample_count = sample_count;
 
     // Tell create_sound what format it will be receiving, in case it cares
     // at this stage.
@@ -1259,12 +1265,10 @@
     // The format in the input file is in stream_input_*
     sound_handler::format_type format = stream_input_format;
 
-    unsigned sample_count = data_bytes;
-    if (stream_input_stereo)  sample_count /= 2;
-    if (stream_input_is16bit) sample_count /= 2;
+    unsigned int sample_count = stream_input_sample_count;
 
     sound_expand(in, format,
-                stream_input_is16bit, stream_input_stereo,
+                stream_input_is16bit, stream_input_stereo, sample_count,
                 data, data_bytes);
     // "format" now reflects what we hand(ed) to the sound drivers.
     // "data_bytes" now reflects the size of the uncompressed data.
@@ -1292,7 +1296,7 @@
 // on exit it reflects the number of bytes that "data" now points to.
 static void
 sound_expand(stream *in, sound_handler::format_type &format,
-       bool sample_16bit, bool stereo,
+       bool sample_16bit, bool stereo, unsigned int &sample_count,
        unsigned char* &data, unsigned &data_bytes)
 {
     // Make sure that an unassigned pointer cannot get through
@@ -1303,9 +1307,9 @@
     case sound_handler::FORMAT_ADPCM:
       {
        // Uncompress the ADPCM before handing data to host.
-       unsigned sample_count = data_bytes / (stereo ? 4 : 2);
+       if (sample_count == 0) sample_count = data_bytes / ( stereo ? 4 : 2 );
        adpcm_expand(data, in, sample_count, stereo);
-       data_bytes = sample_count * (stereo ? 4 : 2) * (sample_16bit ? 2 : 1);
+       data_bytes = sample_count * (stereo ? 4 : 2);
        format = sound_handler::FORMAT_NATIVE16;
        break;
       }
@@ -1319,9 +1323,9 @@
        } else {
            // Convert 8-bit signed to 16-bit range
            // Allocate as many shorts as there are samples
-           unsigned sample_count = data_bytes / (stereo ? 2 : 1);
+           if (sample_count == 0) sample_count = data_bytes / (stereo ? 2 : 1);
            u8_expand(data, in, sample_count, stereo);
-               data_bytes = sample_count * (stereo ? 4 : 2) * 2;
+               data_bytes = sample_count * (stereo ? 4 : 2);
        }
        format = sound_handler::FORMAT_NATIVE16;
        break;
@@ -1333,9 +1337,9 @@
        {
            // Convert 8-bit signed to 16-bit range
            // Allocate as many shorts as there are 8-bit samples
-           unsigned sample_count = data_bytes / (stereo ? 2 : 1);
+           if (sample_count == 0) sample_count = data_bytes / (stereo ? 2 : 1);
            u8_expand(data, in, sample_count, stereo);
-               data_bytes = sample_count * (stereo ? 4 : 2) * 2;
+               data_bytes = sample_count * (stereo ? 4 : 2);
 
        } else {
            // Read 16-bit data into buffer




reply via email to

[Prev in Thread] Current Thread [Next in Thread]