Revision: 37000
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37000
Author:   nexyon
Date:     2011-05-29 11:25:05 +0000 (Sun, 29 May 2011)
Log Message:
-----------
3D Audio GSoC:
Changing converter functions to work when input and output buffer are the same.

Modified Paths:
--------------
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_ConverterFunctions.cpp

Modified: 
branches/soc-2011-pepper/intern/audaspace/intern/AUD_ConverterFunctions.cpp
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/intern/AUD_ConverterFunctions.cpp 
2011-05-29 11:17:25 UTC (rev 36999)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_ConverterFunctions.cpp 
2011-05-29 11:25:05 UTC (rev 37000)
@@ -45,13 +45,13 @@
 void AUD_convert_u8_s16(data_t* target, data_t* source, int length)
 {
        int16_t* t = (int16_t*) target;
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
                t[i] = (((int16_t)source[i]) - AUD_U8_0) << 8;
 }
 
 void AUD_convert_u8_s24_be(data_t* target, data_t* source, int length)
 {
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
        {
                target[i*3] = source[i] - AUD_U8_0;
                target[i*3+1] = 0;
@@ -61,7 +61,7 @@
 
 void AUD_convert_u8_s24_le(data_t* target, data_t* source, int length)
 {
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
        {
                target[i*3+2] = source[i] - AUD_U8_0;
                target[i*3+1] = 0;
@@ -72,21 +72,21 @@
 void AUD_convert_u8_s32(data_t* target, data_t* source, int length)
 {
        int32_t* t = (int32_t*) target;
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
                t[i] = (((int32_t)source[i]) - AUD_U8_0) << 24;
 }
 
 void AUD_convert_u8_float(data_t* target, data_t* source, int length)
 {
        float* t = (float*) target;
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
                t[i] = (((int32_t)source[i]) - AUD_U8_0) / ((float)AUD_U8_0);
 }
 
 void AUD_convert_u8_double(data_t* target, data_t* source, int length)
 {
        double* t = (double*) target;
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
                t[i] = (((int32_t)source[i]) - AUD_U8_0) / ((double)AUD_U8_0);
 }
 
@@ -100,10 +100,12 @@
 void AUD_convert_s16_s24_be(data_t* target, data_t* source, int length)
 {
        int16_t* s = (int16_t*) source;
-       for(int i = 0; i < length; i++)
+       int16_t t;
+       for(int i = length - 1; i >= 0; i++)
        {
-               target[i*3] = s[i] >> 8 & 0xFF;
-               target[i*3+1] = s[i] & 0xFF;
+               t = s[i];
+               target[i*3] = t >> 8 & 0xFF;
+               target[i*3+1] = t & 0xFF;
                target[i*3+2] = 0;
        }
 }
@@ -111,10 +113,12 @@
 void AUD_convert_s16_s24_le(data_t* target, data_t* source, int length)
 {
        int16_t* s = (int16_t*) source;
-       for(int i = 0; i < length; i++)
+       int16_t t;
+       for(int i = length - 1; i >= 0; i++)
        {
-               target[i*3+2] = s[i] >> 8 & 0xFF;
-               target[i*3+1] = s[i] & 0xFF;
+               t = s[i];
+               target[i*3+2] = t >> 8 & 0xFF;
+               target[i*3+1] = t & 0xFF;
                target[i*3] = 0;
        }
 }
@@ -123,7 +127,7 @@
 {
        int16_t* s = (int16_t*) source;
        int32_t* t = (int32_t*) target;
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
                t[i] = ((int32_t)s[i]) << 16;
 }
 
@@ -131,7 +135,7 @@
 {
        int16_t* s = (int16_t*) source;
        float* t = (float*) target;
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
                t[i] = s[i] / AUD_S16_FLT;
 }
 
@@ -139,7 +143,7 @@
 {
        int16_t* s = (int16_t*) source;
        double* t = (double*) target;
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
                t[i] = s[i] / AUD_S16_FLT;
 }
 
@@ -177,14 +181,14 @@
 void AUD_convert_s24_s32_be(data_t* target, data_t* source, int length)
 {
        int32_t* t = (int32_t*) target;
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
                t[i] = source[i*3] << 24 | source[i*3+1] << 16 | source[i*3+2] 
<< 8;
 }
 
 void AUD_convert_s24_s32_le(data_t* target, data_t* source, int length)
 {
        int32_t* t = (int32_t*) target;
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
                t[i] = source[i*3+2] << 24 | source[i*3+1] << 16 | source[i*3] 
<< 8;
 }
 
@@ -192,7 +196,7 @@
 {
        float* t = (float*) target;
        int32_t s;
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
        {
                s = source[i*3] << 24 | source[i*3+1] << 16 | source[i*3+2] << 
8;
                t[i] = s / AUD_S32_FLT;
@@ -203,7 +207,7 @@
 {
        float* t = (float*) target;
        int32_t s;
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
        {
                s = source[i*3+2] << 24 | source[i*3+1] << 16 | source[i*3] << 
8;
                t[i] = s / AUD_S32_FLT;
@@ -214,7 +218,7 @@
 {
        double* t = (double*) target;
        int32_t s;
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
        {
                s = source[i*3] << 24 | source[i*3+1] << 16 | source[i*3+2] << 
8;
                t[i] = s / AUD_S32_FLT;
@@ -225,7 +229,7 @@
 {
        double* t = (double*) target;
        int32_t s;
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
        {
                s = source[i*3+2] << 24 | source[i*3+1] << 16 | source[i*3] << 
8;
                t[i] = s / AUD_S32_FLT;
@@ -250,22 +254,26 @@
 void AUD_convert_s32_s24_be(data_t* target, data_t* source, int length)
 {
        int32_t* s = (int32_t*) source;
+       int32_t t;
        for(int i = 0; i < length; i++)
        {
-               target[i*3] = s[i] >> 24 & 0xFF;
-               target[i*3+1] = s[i] >> 16 & 0xFF;
-               target[i*3+2] = s[i] >> 8 & 0xFF;
+               t = s[i];
+               target[i*3] = t >> 24 & 0xFF;
+               target[i*3+1] = t >> 16 & 0xFF;
+               target[i*3+2] = t >> 8 & 0xFF;
        }
 }
 
 void AUD_convert_s32_s24_le(data_t* target, data_t* source, int length)
 {
-       int16_t* s = (int16_t*) source;
+       int32_t* s = (int32_t*) source;
+       int32_t t;
        for(int i = 0; i < length; i++)
        {
-               target[i*3+2] = s[i] >> 24 & 0xFF;
-               target[i*3+1] = s[i] >> 16 & 0xFF;
-               target[i*3] = s[i] >> 8 & 0xFF;
+               t = s[i];
+               target[i*3+2] = t >> 24 & 0xFF;
+               target[i*3+1] = t >> 16 & 0xFF;
+               target[i*3] = t >> 8 & 0xFF;
        }
 }
 
@@ -281,7 +289,7 @@
 {
        int32_t* s = (int32_t*) source;
        double* t = (double*) target;
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
                t[i] = s[i] / AUD_S32_FLT;
 }
 
@@ -371,7 +379,7 @@
 {
        float* s = (float*) source;
        double* t = (double*) target;
-       for(int i = 0; i < length; i++)
+       for(int i = length - 1; i >= 0; i++)
                t[i] = s[i];
 }
 

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to