Exemple #1
0
 void decodeSBR(BitStream inStream, SampleFrequency sf, int count, bool stereo, bool crc, bool downSampled, bool smallFrames)
 {
     if (sbr == null)
     {
         sbr = new SBR(smallFrames, elementInstanceTag == ELEMENT_CPE, sf, downSampled);
     }
     throw new NotImplementedException();
     //sbr.decode(inStream, count);
 }
        //  public void reset() {
        //    Arrays.fill(v, 0);
        //  }

        public void sbr_qmf_synthesis_32(SBR sbr, float[, ,] X, float[] output)
        {
            throw new NotImplementedException();
            //float[] x1 = new float[32], x2 = new float[32];
            //float scale = 1.f/64.f;
            //int n, k, out = 0;
            //int l;


            ///* qmf subsample l */
            //for(l = 0; l<sbr.numTimeSlotsRate; l++) {
            //  /* shift buffer v */
            //  /* buffer is not shifted, we are using a ringbuffer */
            //  //memmove(qmfs.v + 64, qmfs.v, (640-64)*sizeof(real_t));

            //  /* calculate 64 samples */
            //  /* complex pre-twiddle */
            //  for(k = 0; k<32; k++) {
            //    x1[k] = (X[l,k,0]*qmf32_pre_twiddle[k,0])-(X[l,k,1]*qmf32_pre_twiddle[k,1]);
            //    x2[k] = (X[l,k,1]*qmf32_pre_twiddle[k,0])+(X[l,k,0]*qmf32_pre_twiddle[k,1]);

            //    x1[k] *= scale;
            //    x2[k] *= scale;
            //  }

            //  /* transform */
            //  DCT4_32(x1, x1);
            //  DST4_32(x2, x2);

            //  for(n = 0; n<32; n++) {
            //    this.v[this.v_index+n] = this.v[this.v_index+640+n] = -x1[n]+x2[n];
            //    this.v[this.v_index+63-n] = this.v[this.v_index+640+63-n] = x1[n]+x2[n];
            //  }

            //  /* calculate 32 output samples and window */
            //  for(k = 0; k<32; k++) {
            //    output[out++] = (this.v[this.v_index+k]*qmf_c[2*k])
            //      +(this.v[this.v_index+96+k]*qmf_c[64+2*k])
            //      +(this.v[this.v_index+128+k]*qmf_c[128+2*k])
            //      +(this.v[this.v_index+224+k]*qmf_c[192+2*k])
            //      +(this.v[this.v_index+256+k]*qmf_c[256+2*k])
            //      +(this.v[this.v_index+352+k]*qmf_c[320+2*k])
            //      +(this.v[this.v_index+384+k]*qmf_c[384+2*k])
            //      +(this.v[this.v_index+480+k]*qmf_c[448+2*k])
            //      +(this.v[this.v_index+512+k]*qmf_c[512+2*k])
            //      +(this.v[this.v_index+608+k]*qmf_c[576+2*k]);
            //  }

            //  /* update ringbuffer index */
            //  this.v_index -= 64;
            //  if(this.v_index<0)
            //    this.v_index = (640-64);
            //}
        }
        public void sbr_qmf_analysis_32(SBR sbr, float[] input, float[, ,] X, int offset, int kx)
        {
            float[] u        = new float[64];
            float[] in_real  = new float[32], in_imag = new float[32];
            float[] out_real = new float[32], out_imag = new float[32];
            int     inNum    = 0;
            int     l;

            // qmf subsample l
            for (l = 0; l < sbr.numTimeSlotsRate; l++)
            {
                int n;

                // shift input buffer x
                // input buffer is not shifted anymore, x is implemented as double ringbuffer
                //memmove(qmfa.x + 32, qmfa.x, (320-32)*sizeof(real_t));

                // add new samples to input buffer x
                for (n = 32 - 1; n >= 0; n--)
                {
                    this.x[this.x_index + n] = this.x[this.x_index + n + 320] = input[inNum++];
                }

                // window and summation to create array u
                for (n = 0; n < 64; n++)
                {
                    u[n] = (this.x[this.x_index + n] * qmf_c[2 * n])
                           + (this.x[this.x_index + n + 64] * qmf_c[2 * (n + 64)])
                           + (this.x[this.x_index + n + 128] * qmf_c[2 * (n + 128)])
                           + (this.x[this.x_index + n + 192] * qmf_c[2 * (n + 192)])
                           + (this.x[this.x_index + n + 256] * qmf_c[2 * (n + 256)]);
                }

                // update ringbuffer index
                this.x_index -= 32;
                if (this.x_index < 0)
                {
                    this.x_index = (320 - 32);
                }

                // calculate 32 subband samples by introducing X
                // Reordering of data moved from DCT_IV to here
                in_imag[31] = u[1];
                in_real[0]  = u[0];
                for (n = 1; n < 31; n++)
                {
                    in_imag[31 - n] = u[n + 1];
                    in_real[n]      = -u[64 - n];
                }
                in_imag[0]  = u[32];
                in_real[31] = -u[33];

                // dct4_kernel is DCT_IV without reordering which is done before and after FFT
                throw new NotImplementedException();
                // DCT.dct4_kernel(in_real, in_imag, out_real, out_imag);

                // Reordering of data moved from DCT_IV to here
                for (n = 0; n < 16; n++)
                {
                    if (2 * n + 1 < kx)
                    {
                        X[l + offset, 2 * n, 0]     = 2.0f * out_real[n];
                        X[l + offset, 2 * n, 1]     = 2.0f * out_imag[n];
                        X[l + offset, 2 * n + 1, 0] = -2.0f * out_imag[31 - n];
                        X[l + offset, 2 * n + 1, 1] = -2.0f * out_real[31 - n];
                    }
                    else
                    {
                        if (2 * n < kx)
                        {
                            X[l + offset, 2 * n, 0] = 2.0f * out_real[n];
                            X[l + offset, 2 * n, 1] = 2.0f * out_imag[n];
                        }
                        else
                        {
                            X[l + offset, 2 * n, 0] = 0;
                            X[l + offset, 2 * n, 1] = 0;
                        }
                        X[l + offset, 2 * n + 1, 0] = 0;
                        X[l + offset, 2 * n + 1, 1] = 0;
                    }
                }
            }
        }
        public void sbr_qmf_synthesis_64(SBR sbr, float[, ,] X, float[] output)
        {
            throw new NotImplementedException();
            //float[] in_real1 = new float[32], in_imag1 = new float[32], out_real1 = new float[32], out_imag1 = new float[32];
            //float[] in_real2 = new float[32], in_imag2 = new float[32], out_real2 = new float[32], out_imag2 = new float[32];
            //float[,] pX;
            //float scale = 1.f/64.f;
            //int n, k, out = 0;
            //int l;


            ///* qmf subsample l */
            //for(l = 0; l<sbr.numTimeSlotsRate; l++) {
            //  /* shift buffer v */
            //  /* buffer is not shifted, we use double ringbuffer */
            //  //memmove(qmfs.v + 128, qmfs.v, (1280-128)*sizeof(real_t));

            //  /* calculate 128 samples */
            //  pX = X[l];

            //  in_imag1[31] = scale*pX[1,0];
            //  in_real1[0] = scale*pX[0,0];
            //  in_imag2[31] = scale*pX[63-1,1];
            //  in_real2[0] = scale*pX[63-0,1];
            //  for(k = 1; k<31; k++) {
            //    in_imag1[31-k] = scale*pX[2*k+1,0];
            //    in_real1[     k] = scale*pX[2*k,0];
            //    in_imag2[31-k] = scale*pX[63-(2*k+1),1];
            //    in_real2[     k] = scale*pX[63-(2*k),1];
            //  }
            //  in_imag1[0] = scale*pX[63,0];
            //  in_real1[31] = scale*pX[62,0];
            //  in_imag2[0] = scale*pX[63-63,1];
            //  in_real2[31] = scale*pX[63-62,1];

            //  // dct4_kernel is DCT_IV without reordering which is done before and after FFT
            //  DCT.dct4_kernel(in_real1, in_imag1, out_real1, out_imag1);
            //  DCT.dct4_kernel(in_real2, in_imag2, out_real2, out_imag2);

            //  int pring_buffer_1 = v_index; //*v
            //  int pring_buffer_3 = pring_buffer_1+1280;
            //  //        ptemp_1 = x1;
            //  //        ptemp_2 = x2;

            //  for(n = 0; n<32; n++) {
            //    // pring_buffer_3 and pring_buffer_4 are needed only for double ring buffer
            //    v[pring_buffer_1+2*n] = v[pring_buffer_3+2*n] = out_real2[n]-out_real1[n];
            //    v[pring_buffer_1+127-2*n] = v[pring_buffer_3+127-2*n] = out_real2[n]+out_real1[n];
            //    v[pring_buffer_1+2*n+1] = v[pring_buffer_3+2*n+1] = out_imag2[31-n]+out_imag1[31-n];
            //    v[pring_buffer_1+127-(2*n+1)] = v[pring_buffer_3+127-(2*n+1)] = out_imag2[31-n]-out_imag1[31-n];
            //  }

            //  pring_buffer_1 = v_index; //*v

            //  /* calculate 64 output samples and window */
            //  for(k = 0; k<64; k++) {
            //    output[out++]
            //      = (v[pring_buffer_1+k+0]*qmf_c[k+0])
            //      +(v[pring_buffer_1+k+192]*qmf_c[k+64])
            //      +(v[pring_buffer_1+k+256]*qmf_c[k+128])
            //      +(v[pring_buffer_1+k+(256+192)]*qmf_c[k+192])
            //      +(v[pring_buffer_1+k+512]*qmf_c[k+256])
            //      +(v[pring_buffer_1+k+(512+192)]*qmf_c[k+320])
            //      +(v[pring_buffer_1+k+768]*qmf_c[k+384])
            //      +(v[pring_buffer_1+k+(768+192)]*qmf_c[k+448])
            //      +(v[pring_buffer_1+k+1024]*qmf_c[k+512])
            //      +(v[pring_buffer_1+k+(1024+192)]*qmf_c[k+576]);
            //  }

            //  /* update ringbuffer index */
            //  this.v_index -= 128;
            //  if(this.v_index<0)
            //    this.v_index = (1280-128);
            //}
        }