]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
float_to_int16_interleave: change src to an array of pointers instead of assuming...
authorlorenm <lorenm@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Wed, 16 Jul 2008 00:50:12 +0000 (00:50 +0000)
committerlorenm <lorenm@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Wed, 16 Jul 2008 00:50:12 +0000 (00:50 +0000)
this has no immediate effect, but will allow it to be used in more codecs.

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@14252 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavcodec/dsputil.c
libavcodec/dsputil.h
libavcodec/i386/dsputil_mmx.c
libavcodec/vorbis_dec.c

index 212e2415da92db49b8dec303223966f81c77aa1a..a9661eb2b5ef65a486a581d6c57811c90f66d8b3 100644 (file)
@@ -3962,17 +3962,17 @@ void ff_float_to_int16_c(int16_t *dst, const float *src, long len){
         dst[i] = float_to_int16_one(src+i);
 }
 
-void ff_float_to_int16_interleave_c(int16_t *dst, const float *src, long len, int channels){
+void ff_float_to_int16_interleave_c(int16_t *dst, const float **src, long len, int channels){
     int i,j,c;
     if(channels==2){
         for(i=0; i<len; i++){
-            dst[2*i]   = float_to_int16_one(src+i);
-            dst[2*i+1] = float_to_int16_one(src+i+len);
+            dst[2*i]   = float_to_int16_one(src[0]+i);
+            dst[2*i+1] = float_to_int16_one(src[1]+i);
         }
     }else{
-        for(c=0; c<channels; c++, src+=len)
+        for(c=0; c<channels; c++)
             for(i=0, j=c; i<len; i++, j+=channels)
-                dst[j] = float_to_int16_one(src+i);
+                dst[j] = float_to_int16_one(src[c]+i);
     }
 }
 
index e44eaa2c489b80c7a44e1cd557bd8307bd9c809a..7a47b87b447fb575aaceec15431ad22a8d022583 100644 (file)
@@ -372,7 +372,7 @@ typedef struct DSPContext {
     /* C version: convert floats from the range [384.0,386.0] to ints in [-32768,32767]
      * simd versions: convert floats from [-32768.0,32767.0] without rescaling and arrays are 16byte aligned */
     void (*float_to_int16)(int16_t *dst, const float *src, long len);
-    void (*float_to_int16_interleave)(int16_t *dst, const float *src, long len, int channels);
+    void (*float_to_int16_interleave)(int16_t *dst, const float **src, long len, int channels);
 
     /* (I)DCT */
     void (*fdct)(DCTELEM *block/* align 16*/);
index c5070239363540024a87bacb73825b373caf2a80..90865e80c7b6db022530a2a87670c90dd473b5f7 100644 (file)
@@ -2156,32 +2156,32 @@ static void float_to_int16_sse2(int16_t *dst, const float *src, long len){
 
 #define FLOAT_TO_INT16_INTERLEAVE(cpu, body) \
 /* gcc pessimizes register allocation if this is in the same function as float_to_int16_interleave_sse2*/\
-static av_noinline void float_to_int16_interleave2_##cpu(int16_t *dst, const float *src, long len, int channels){\
-    DECLARE_ALIGNED_16(int16_t, tmp[len*channels]);\
+static av_noinline void float_to_int16_interleave2_##cpu(int16_t *dst, const float **src, long len, int channels){\
+    DECLARE_ALIGNED_16(int16_t, tmp[len]);\
     int i,j,c;\
-    float_to_int16_##cpu(tmp, src, len*channels);\
     for(c=0; c<channels; c++){\
-        int16_t *ptmp = tmp+c*len;\
+        float_to_int16_##cpu(tmp, src[c], len);\
         for(i=0, j=c; i<len; i++, j+=channels)\
-            dst[j] = ptmp[i];\
+            dst[j] = tmp[i];\
     }\
 }\
 \
-static void float_to_int16_interleave_##cpu(int16_t *dst, const float *src, long len, int channels){\
+static void float_to_int16_interleave_##cpu(int16_t *dst, const float **src, long len, int channels){\
     if(channels==1)\
-        float_to_int16_##cpu(dst, src, len);\
+        float_to_int16_##cpu(dst, src[0], len);\
     else if(channels>2)\
         float_to_int16_interleave2_##cpu(dst, src, len, channels);\
     else{\
-        float *src1;\
+        const float *src0 = src[0];\
+        const float *src1 = src[1];\
         asm volatile(\
             "shl $2, %0 \n"\
             "add %0, %1 \n"\
             "add %0, %2 \n"\
-            "lea (%2,%0), %3 \n"\
+            "add %0, %3 \n"\
             "neg %0 \n"\
             body\
-            :"+r"(len), "+r"(dst), "+r"(src), "=r"(src1)\
+            :"+r"(len), "+r"(dst), "+r"(src0), "+r"(src1)\
         );\
     }\
 }
index a338141b92fc6edb85f7ba69250c28a5eb8d67f7..0f0c17b617d229c4a7bfa207aedaf34591344fa2 100644 (file)
@@ -1553,6 +1553,8 @@ static int vorbis_decode_frame(AVCodecContext *avccontext,
 {
     vorbis_context *vc = avccontext->priv_data ;
     GetBitContext *gb = &(vc->gb);
+    const float *channel_ptrs[vc->audio_channels];
+    int i;
 
     int_fast16_t len;
 
@@ -1579,7 +1581,9 @@ static int vorbis_decode_frame(AVCodecContext *avccontext,
 
     AV_DEBUG("parsed %d bytes %d bits, returned %d samples (*ch*bits) \n", get_bits_count(gb)/8, get_bits_count(gb)%8, len);
 
-    vc->dsp.float_to_int16_interleave(data, vc->channel_residues, len, vc->audio_channels);
+    for(i=0; i<vc->audio_channels; i++)
+        channel_ptrs[i] = vc->channel_residues+i*len;
+    vc->dsp.float_to_int16_interleave(data, channel_ptrs, len, vc->audio_channels);
     *data_size=len*2*vc->audio_channels;
 
     return buf_size ;