/** * function for decoding joint stereo data * * @param q pointer to the COOKContext * @param mlt_buffer1 pointer to left channel mlt coefficients * @param mlt_buffer2 pointer to right channel mlt coefficients */ static int joint_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer_left, float *mlt_buffer_right) { int i, j, res; int decouple_tab[SUBBAND_SIZE] = { 0 }; float *decode_buffer = q->decode_buffer_0; int idx, cpl_tmp; float f1, f2; const float *cplscale; memset(decode_buffer, 0, sizeof(q->decode_buffer_0)); /* Make sure the buffers are zeroed out. */ memset(mlt_buffer_left, 0, 1024 * sizeof(*mlt_buffer_left)); memset(mlt_buffer_right, 0, 1024 * sizeof(*mlt_buffer_right)); if ((res = decouple_info(q, p, decouple_tab)) < 0) return res; if ((res = mono_decode(q, p, decode_buffer)) < 0) return res; /* The two channels are stored interleaved in decode_buffer. */ for (i = 0; i < p->js_subband_start; i++) { for (j = 0; j < SUBBAND_SIZE; j++) { mlt_buffer_left[i * 20 + j] = decode_buffer[i * 40 + j]; mlt_buffer_right[i * 20 + j] = decode_buffer[i * 40 + 20 + j]; } } /* When we reach js_subband_start (the higher frequencies) the coefficients are stored in a coupling scheme. */ idx = (1 << p->js_vlc_bits) - 1; for (i = p->js_subband_start; i < p->subbands; i++) { cpl_tmp = cplband[i]; idx -= decouple_tab[cpl_tmp]; cplscale = q->cplscales[p->js_vlc_bits - 2]; // choose decoupler table f1 = cplscale[decouple_tab[cpl_tmp] + 1]; f2 = cplscale[idx]; q->decouple(q, p, i, f1, f2, decode_buffer, mlt_buffer_left, mlt_buffer_right); idx = (1 << p->js_vlc_bits) - 1; } return 0; }
static void joint_decode(COOKContext *q, float* mlt_buffer1, float* mlt_buffer2) { int i,j; int decouple_tab[SUBBAND_SIZE]; float decode_buffer[1060]; int idx, cpl_tmp,tmp_idx; float f1,f2; float* cplscale; memset(decouple_tab, 0, sizeof(decouple_tab)); memset(decode_buffer, 0, sizeof(decode_buffer)); /* Make sure the buffers are zeroed out. */ memset(mlt_buffer1,0, 1024*sizeof(float)); memset(mlt_buffer2,0, 1024*sizeof(float)); decouple_info(q, decouple_tab); mono_decode(q, decode_buffer); /* The two channels are stored interleaved in decode_buffer. */ for (i=0 ; i<q->js_subband_start ; i++) { for (j=0 ; j<SUBBAND_SIZE ; j++) { mlt_buffer1[i*20+j] = decode_buffer[i*40+j]; mlt_buffer2[i*20+j] = decode_buffer[i*40+20+j]; } } /* When we reach js_subband_start (the higher frequencies) the coefficients are stored in a coupling scheme. */ idx = (1 << q->js_vlc_bits) - 1; for (i=q->js_subband_start ; i<q->subbands ; i++) { cpl_tmp = cplband[i]; idx -=decouple_tab[cpl_tmp]; cplscale = (float*)cplscales[q->js_vlc_bits-2]; //choose decoupler table f1 = cplscale[decouple_tab[cpl_tmp]]; f2 = cplscale[idx-1]; for (j=0 ; j<SUBBAND_SIZE ; j++) { tmp_idx = ((q->js_subband_start + i)*20)+j; mlt_buffer1[20*i + j] = f1 * decode_buffer[tmp_idx]; mlt_buffer2[20*i + j] = f2 * decode_buffer[tmp_idx]; } idx = (1 << q->js_vlc_bits) - 1; } }