gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-


From: Sandro Santilli
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-468-gbfc794c
Date: Tue, 12 Jul 2011 08:24:03 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  bfc794c3074ad787031015d456209f5c3b3c1818 (commit)
      from  7c5c916511fe5813adb2e3db3d95a1d8e9bd605a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=bfc794c3074ad787031015d456209f5c3b3c1818


commit bfc794c3074ad787031015d456209f5c3b3c1818
Author: Jonas 'Sortie' Termansen <address@hidden>
Date:   Sat Jul 9 19:05:25 2011 +0200

    Don't memcpy data if you need to endian-swap it anyways.
    
    Formerly, the code memcpy'd the data to a new buffer,
    and then endian-swapped it, thus doing twice the work.
    Now it should do the endian-swapping during the copy phase.
    The compiler will usually optimize the byte swap into a single
    rot8 instruction - I assume BE CPUs have the same instruction.

diff --git a/libmedia/AudioDecoderSimple.cpp b/libmedia/AudioDecoderSimple.cpp
index 80a2e0f..0415c4c 100644
--- a/libmedia/AudioDecoderSimple.cpp
+++ b/libmedia/AudioDecoderSimple.cpp
@@ -370,7 +370,7 @@ AudioDecoderSimple::decode(const boost::uint8_t* input, 
boost::uint32_t inputSiz
 {
 
        unsigned char* decodedData = NULL;
-       int outsize = 0;
+       boost::uint32_t outsize = 0;
 
     switch (_codec) {
        case AUDIO_CODEC_ADPCM:
@@ -405,10 +405,11 @@ AudioDecoderSimple::decode(const boost::uint8_t* input, 
boost::uint32_t inputSiz
                        outsize = inputSize * (_stereo ? 4 : 2);
 
                } else {
+                       // Allocate a destination buffer
                        // Read 16-bit data into buffer
                        decodedData = new unsigned char[inputSize];
-                       memcpy((char *)decodedData, input, inputSize);
-
+                       outsize = inputSize;
+                       
                        // Convert 16-bit little-endian data to host-endian.
 
                        // Runtime detection of host endianness costs almost
@@ -423,19 +424,30 @@ AudioDecoderSimple::decode(const boost::uint8_t* input, 
boost::uint32_t inputSiz
                        } u = { 0x0001 };
 
                        switch (u.c.c0) {
+                               default:        // Impossible
+                                       log_error(_("Host endianness not 
detected in AudioDecoderSimple"));
+                                       // Just carry on anyway...
                                case 0x01:      // Little-endian host: sample 
is already native.
+                                       // If the input data is the output 
data, then we probably
+                                       // can't move the data faster than 
memcpy.
+                                       memcpy((char *)decodedData, input, 
inputSize);
                                        break;
                                case 0x00:  // Big-endian host
                                        // Swap sample bytes to get big-endian 
format.
                                        assert((inputSize & 1) == 0);
-                                       for (unsigned i = 0; i < inputSize; 
i+=2)
+
+                                       // Cast the buffers to help the 
compiler understand that we
+                                       // swapping 16-bit words. This should 
produce a single-instruction
+                                       // swap for each 16-bit word.
+                                       const boost::uint16_t* input16 = 
reinterpret_cast<const boost::uint16_t*>(input);
+                                       boost::uint16_t* decodedData16 = 
reinterpret_cast<boost::uint16_t*>(decodedData);
+                                       unsigned inputSize16 = inputSize / 
sizeof(boost::uint16_t);
+                                       for ( unsigned i = 0; i < inputSize16; 
i++ )
                                        {
-                                               std::swap(decodedData[i], 
decodedData[i+1]);
+                                               boost::uint16_t sample = 
input16[i];
+                                               decodedData16[i] = ((sample << 
8) & 0xFF00) | ((sample >> 8) & 0x00FF);
                                        }
                                        break;
-                       default:        // Impossible
-                                       log_error(_("Host endianness not 
detected in AudioDecoderSimple"));
-                                       // Just carry on anyway...
                        }
                }
                break;

-----------------------------------------------------------------------

Summary of changes:
 libmedia/AudioDecoderSimple.cpp |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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