diff --git a/celt/arch.h b/celt/arch.h index b5a9e6e0d..1a03bad87 100644 --- a/celt/arch.h +++ b/celt/arch.h @@ -144,6 +144,9 @@ typedef opus_val32 opus_res; #define RES2FLOAT(a) ((1.f/32768.f/256.)*(a)) #define INT16TORES(a) SHL32(EXTEND32(a), RES_SHIFT) #define ADD_RES(a, b) ADD32(a, b) +#define FLOAT2RES(a) float2int(32768.f*256.f*(a)) +#define RES2SIG(a) SHL32((a), SIG_SHIFT-RES_SHIFT) +#define MULT16_RES_Q15(a,b) MULT16_32_Q15(a,b) #else typedef opus_val16 opus_res; #define RES_SHIFT 0 @@ -153,8 +156,13 @@ typedef opus_val16 opus_res; #define RES2FLOAT(a) ((1.f/32768.f)*(a)) #define INT16TORES(a) (a) #define ADD_RES(a, b) SAT16(ADD32((a), (b))); +#define FLOAT2RES(a) FLOAT2INT16(a) +#define RES2SIG(a) SHL32(EXTEND32(a), SIG_SHIFT) +#define MULT16_RES_Q15(a,b) MULT16_16_Q15(a,b) #endif +#define RES2VAL16(a) RES2INT16(a) + #define celt_isnan(x) 0 #define Q15ONE 32767 @@ -313,6 +321,12 @@ static OPUS_INLINE int celt_isnan(float x) #define RES2FLOAT(a) (a) #define INT16TORES(a) ((a)*(1/CELT_SIG_SCALE)) #define ADD_RES(a, b) ADD32(a, b) +#define FLOAT2RES(a) (a) +#define RES2SIG(a) (CELT_SIG_SCALE*(a)) +#define MULT16_RES_Q15(a,b) MULT16_16_Q15(a,b) + +#define RES2VAL16(a) (a) + #endif /* !FIXED_POINT */ diff --git a/celt/celt.h b/celt/celt.h index 0e4d100f7..31c340139 100644 --- a/celt/celt.h +++ b/celt/celt.h @@ -139,7 +139,7 @@ typedef struct { int celt_encoder_get_size(int channels); -int celt_encode_with_ec(OpusCustomEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc); +int celt_encode_with_ec(OpusCustomEncoder * OPUS_RESTRICT st, const opus_res * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc); int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate, int channels, int arch); @@ -229,7 +229,7 @@ void validate_celt_decoder(CELTDecoder *st); int resampling_factor(opus_int32 rate); -void celt_preemphasis(const opus_val16 * OPUS_RESTRICT pcmp, celt_sig * OPUS_RESTRICT inp, +void celt_preemphasis(const opus_res * OPUS_RESTRICT pcmp, celt_sig * OPUS_RESTRICT inp, int N, int CC, int upsample, const opus_val16 *coef, celt_sig *mem, int clip); void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c index 1d0676705..176271a8e 100644 --- a/celt/celt_encoder.c +++ b/celt/celt_encoder.c @@ -513,7 +513,7 @@ static void compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig * OPUS } -void celt_preemphasis(const opus_val16 * OPUS_RESTRICT pcmp, celt_sig * OPUS_RESTRICT inp, +void celt_preemphasis(const opus_res * OPUS_RESTRICT pcmp, celt_sig * OPUS_RESTRICT inp, int N, int CC, int upsample, const opus_val16 *coef, celt_sig *mem, int clip) { int i; @@ -529,11 +529,11 @@ void celt_preemphasis(const opus_val16 * OPUS_RESTRICT pcmp, celt_sig * OPUS_RES { for (i=0;ioverlap_max, celt_maxabs16(pcm, C*(N-overlap)/st->upsample)); - st->overlap_max=celt_maxabs16(pcm+C*(N-overlap)/st->upsample, C*overlap/st->upsample); + sample_max=MAX32(st->overlap_max, celt_maxabs_res(pcm, C*(N-overlap)/st->upsample)); + st->overlap_max=celt_maxabs_res(pcm+C*(N-overlap)/st->upsample, C*overlap/st->upsample); sample_max=MAX32(sample_max, st->overlap_max); #ifdef FIXED_POINT silence = (sample_max==0); @@ -2472,7 +2472,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, } while (++cupsample, mode->preemph, st->preemph_memD, 0); + deemphasis(out_mem, (opus_res*)pcm, N, CC, st->upsample, mode->preemph, st->preemph_memD, 0); st->prefilter_period_old = st->prefilter_period; st->prefilter_gain_old = st->prefilter_gain; st->prefilter_tapset_old = st->prefilter_tapset; @@ -2544,16 +2544,43 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, #ifdef CUSTOM_MODES #ifdef FIXED_POINT +#ifdef ENABLE_RES24 +int opus_custom_encode(CELTEncoder * OPUS_RESTRICT st, const opus_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes) +{ + int j, ret, C, N; + VARDECL(opus_res, in); + ALLOC_STACK; + + if (pcm==NULL) + return OPUS_BAD_ARG; + + C = st->channels; + N = frame_size; + ALLOC(in, C*N, opus_res); + + for (j=0;jchannels; N = frame_size; - ALLOC(in, C*N, opus_int16); + ALLOC(in, C*N, opus_res); for (j=0;jnChannelsAPI == 2 && encControl->nChannelsInternal == 2 ) { opus_int id = psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded; for( n = 0; n < nSamplesFromInput; n++ ) { - buf[ n ] = samplesIn[ 2 * n ]; + buf[ n ] = RES2INT16(samplesIn[ 2 * n ]); } /* Making sure to start both resamplers from the same state when switching from mono to stereo */ if( psEnc->nPrevChannelsInternal == 1 && id==0 ) { @@ -296,7 +296,7 @@ opus_int silk_Encode( /* O Returns error co nSamplesToBuffer = psEnc->state_Fxx[ 1 ].sCmn.frame_length - psEnc->state_Fxx[ 1 ].sCmn.inputBufIx; nSamplesToBuffer = silk_min( nSamplesToBuffer, 10 * nBlocksOf10ms * psEnc->state_Fxx[ 1 ].sCmn.fs_kHz ); for( n = 0; n < nSamplesFromInput; n++ ) { - buf[ n ] = samplesIn[ 2 * n + 1 ]; + buf[ n ] = RES2INT16(samplesIn[ 2 * n + 1 ]); } ret += silk_resampler( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state, &psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx + 2 ], buf, nSamplesFromInput ); @@ -305,7 +305,7 @@ opus_int silk_Encode( /* O Returns error co } else if( encControl->nChannelsAPI == 2 && encControl->nChannelsInternal == 1 ) { /* Combine left and right channels before resampling */ for( n = 0; n < nSamplesFromInput; n++ ) { - sum = samplesIn[ 2 * n ] + samplesIn[ 2 * n + 1 ]; + sum = RES2INT16(samplesIn[ 2 * n ] + samplesIn[ 2 * n + 1 ]); buf[ n ] = (opus_int16)silk_RSHIFT_ROUND( sum, 1 ); } ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, @@ -323,7 +323,9 @@ opus_int silk_Encode( /* O Returns error co psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer; } else { celt_assert( encControl->nChannelsAPI == 1 && encControl->nChannelsInternal == 1 ); - silk_memcpy(buf, samplesIn, nSamplesFromInput*sizeof(opus_int16)); + for( n = 0; n < nSamplesFromInput; n++ ) { + buf[n] = RES2INT16(samplesIn[n]); + } ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx + 2 ], buf, nSamplesFromInput ); psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer; diff --git a/src/mapping_matrix.c b/src/mapping_matrix.c index 8f781edb5..72b759954 100644 --- a/src/mapping_matrix.c +++ b/src/mapping_matrix.c @@ -86,7 +86,7 @@ void mapping_matrix_multiply_channel_in_float( const MappingMatrix *matrix, const float *input, int input_rows, - opus_val16 *output, + opus_res *output, int output_row, int output_rows, int frame_size) @@ -108,11 +108,7 @@ void mapping_matrix_multiply_channel_in_float( matrix_data[MATRIX_INDEX(matrix->rows, output_row, col)] * input[MATRIX_INDEX(input_rows, col, i)]; } -#if defined(FIXED_POINT) - output[output_rows * i] = FLOAT2INT16((1/32768.f)*tmp); -#else - output[output_rows * i] = (1/32768.f)*tmp; -#endif + output[output_rows * i] = FLOAT2RES((1/32768.f)*tmp); } } @@ -153,7 +149,7 @@ void mapping_matrix_multiply_channel_in_short( const MappingMatrix *matrix, const opus_int16 *input, int input_rows, - opus_val16 *output, + opus_res *output, int output_row, int output_rows, int frame_size) @@ -182,7 +178,7 @@ void mapping_matrix_multiply_channel_in_short( #endif } #if defined(FIXED_POINT) - output[output_rows * i] = (opus_int16)((tmp + 64) >> 7); + output[output_rows * i] = INT16TORES((tmp + 64) >> 7); #else output[output_rows * i] = (1/(32768.f*32768.f))*tmp; #endif diff --git a/src/mapping_matrix.h b/src/mapping_matrix.h index 37f750c85..0b9ef8197 100644 --- a/src/mapping_matrix.h +++ b/src/mapping_matrix.h @@ -66,7 +66,7 @@ void mapping_matrix_multiply_channel_in_float( const MappingMatrix *matrix, const float *input, int input_rows, - opus_val16 *output, + opus_res *output, int output_row, int output_rows, int frame_size @@ -87,7 +87,7 @@ void mapping_matrix_multiply_channel_in_short( const MappingMatrix *matrix, const opus_int16 *input, int input_rows, - opus_val16 *output, + opus_res *output, int output_row, int output_rows, int frame_size diff --git a/src/opus_encoder.c b/src/opus_encoder.c index 07b521c90..f5239c2ee 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -121,7 +121,7 @@ struct OpusEncoder { int first; opus_val16 * energy_masking; StereoWidthState width_mem; - opus_val16 delay_buffer[MAX_ENCODER_BUFFER*2]; + opus_res delay_buffer[MAX_ENCODER_BUFFER*2]; #ifndef DISABLE_FLOAT_API int detected_bandwidth; int nb_no_activity_ms_Q1; @@ -328,13 +328,52 @@ static unsigned char gen_toc(int mode, int framerate, int bandwidth, int channel return toc; } -#ifndef FIXED_POINT -static void silk_biquad_float( - const opus_val16 *in, /* I: Input signal */ +#ifdef FIXED_POINT +/* Second order ARMA filter, alternative implementation */ +void silk_biquad_res( + const opus_res *in, /* I input signal */ + const opus_int32 *B_Q28, /* I MA coefficients [3] */ + const opus_int32 *A_Q28, /* I AR coefficients [2] */ + opus_int32 *S, /* I/O State vector [2] */ + opus_res *out, /* O output signal */ + const opus_int32 len, /* I signal length (must be even) */ + int stride +) +{ + /* DIRECT FORM II TRANSPOSED (uses 2 element state vector) */ + opus_int k; + opus_int32 inval, A0_U_Q28, A0_L_Q28, A1_U_Q28, A1_L_Q28, out32_Q14; + + /* Negate A_Q28 values and split in two parts */ + A0_L_Q28 = ( -A_Q28[ 0 ] ) & 0x00003FFF; /* lower part */ + A0_U_Q28 = silk_RSHIFT( -A_Q28[ 0 ], 14 ); /* upper part */ + A1_L_Q28 = ( -A_Q28[ 1 ] ) & 0x00003FFF; /* lower part */ + A1_U_Q28 = silk_RSHIFT( -A_Q28[ 1 ], 14 ); /* upper part */ + + for( k = 0; k < len; k++ ) { + /* S[ 0 ], S[ 1 ]: Q12 */ + inval = RES2INT16(in[ k*stride ]); + out32_Q14 = silk_LSHIFT( silk_SMLAWB( S[ 0 ], B_Q28[ 0 ], inval ), 2 ); + + S[ 0 ] = S[1] + silk_RSHIFT_ROUND( silk_SMULWB( out32_Q14, A0_L_Q28 ), 14 ); + S[ 0 ] = silk_SMLAWB( S[ 0 ], out32_Q14, A0_U_Q28 ); + S[ 0 ] = silk_SMLAWB( S[ 0 ], B_Q28[ 1 ], inval); + + S[ 1 ] = silk_RSHIFT_ROUND( silk_SMULWB( out32_Q14, A1_L_Q28 ), 14 ); + S[ 1 ] = silk_SMLAWB( S[ 1 ], out32_Q14, A1_U_Q28 ); + S[ 1 ] = silk_SMLAWB( S[ 1 ], B_Q28[ 2 ], inval ); + + /* Scale back to Q0 and saturate */ + out[ k*stride ] = INT16TORES( silk_SAT16( silk_RSHIFT( out32_Q14 + (1<<14) - 1, 14 ) ) ); + } +} +#else +static void silk_biquad_res( + const opus_res *in, /* I: Input signal */ const opus_int32 *B_Q28, /* I: MA coefficients [3] */ const opus_int32 *A_Q28, /* I: AR coefficients [2] */ opus_val32 *S, /* I/O: State vector [2] */ - opus_val16 *out, /* O: Output signal */ + opus_res *out, /* O: Output signal */ const opus_int32 len, /* I: Signal length (must be even) */ int stride ) @@ -368,7 +407,7 @@ static void silk_biquad_float( } #endif -static void hp_cutoff(const opus_val16 *in, opus_int32 cutoff_Hz, opus_val16 *out, opus_val32 *hp_mem, int len, int channels, opus_int32 Fs, int arch) +static void hp_cutoff(const opus_res *in, opus_int32 cutoff_Hz, opus_res *out, opus_val32 *hp_mem, int len, int channels, opus_int32 Fs, int arch) { opus_int32 B_Q28[ 3 ], A_Q28[ 2 ]; opus_int32 Fc_Q19, r_Q28, r_Q22; @@ -391,22 +430,22 @@ static void hp_cutoff(const opus_val16 *in, opus_int32 cutoff_Hz, opus_val16 *ou A_Q28[ 0 ] = silk_SMULWW( r_Q22, silk_SMULWW( Fc_Q19, Fc_Q19 ) - SILK_FIX_CONST( 2.0, 22 ) ); A_Q28[ 1 ] = silk_SMULWW( r_Q22, r_Q22 ); -#ifdef FIXED_POINT +#if defined(FIXED_POINT) && !defined(ENABLE_RES24) if( channels == 1 ) { silk_biquad_alt_stride1( in, B_Q28, A_Q28, hp_mem, out, len ); } else { silk_biquad_alt_stride2( in, B_Q28, A_Q28, hp_mem, out, len, arch ); } #else - silk_biquad_float( in, B_Q28, A_Q28, hp_mem, out, len, channels ); + silk_biquad_res( in, B_Q28, A_Q28, hp_mem, out, len, channels ); if( channels == 2 ) { - silk_biquad_float( in+1, B_Q28, A_Q28, hp_mem+2, out+1, len, channels ); + silk_biquad_res( in+1, B_Q28, A_Q28, hp_mem+2, out+1, len, channels ); } #endif } #ifdef FIXED_POINT -static void dc_reject(const opus_val16 *in, opus_int32 cutoff_Hz, opus_val16 *out, opus_val32 *hp_mem, int len, int channels, opus_int32 Fs) +static void dc_reject(const opus_res *in, opus_int32 cutoff_Hz, opus_res *out, opus_val32 *hp_mem, int len, int channels, opus_int32 Fs) { int c, i; int shift; @@ -418,10 +457,15 @@ static void dc_reject(const opus_val16 *in, opus_int32 cutoff_Hz, opus_val16 *ou for (i=0;irangeFinal = 0; @@ -1790,7 +1834,7 @@ static opus_int32 opus_encode_frame_native(OpusEncoder *st, const opus_val16 *pc ec_enc_init(&enc, data, max_data_bytes-1); - ALLOC(pcm_buf, (total_buffer+frame_size)*st->channels, opus_val16); + ALLOC(pcm_buf, (total_buffer+frame_size)*st->channels, opus_res); OPUS_COPY(pcm_buf, &st->delay_buffer[(st->encoder_buffer-total_buffer)*st->channels], total_buffer*st->channels); if (st->mode == MODE_CELT_ONLY) @@ -1866,12 +1910,7 @@ static opus_int32 opus_encode_frame_native(OpusEncoder *st, const opus_val16 *pc if (st->mode != MODE_CELT_ONLY) { opus_int32 total_bitRate, celt_rate; -#ifdef FIXED_POINT - const opus_int16 *pcm_silk; -#else - VARDECL(opus_int16, pcm_silk); - ALLOC(pcm_silk, st->channels*frame_size, opus_int16); -#endif + const opus_res *pcm_silk; /* Distribute bits between SILK and CELT */ total_bitRate = 8 * bytes_target * frame_rate; @@ -2024,23 +2063,13 @@ static opus_int32 opus_encode_frame_native(OpusEncoder *st, const opus_val16 *pc gain_fade(st->delay_buffer+prefill_offset, st->delay_buffer+prefill_offset, 0, Q15ONE, celt_mode->overlap, st->Fs/400, st->channels, celt_mode->window, st->Fs); OPUS_CLEAR(st->delay_buffer, prefill_offset); -#ifdef FIXED_POINT pcm_silk = st->delay_buffer; -#else - for (i=0;iencoder_buffer*st->channels;i++) - pcm_silk[i] = FLOAT2INT16(st->delay_buffer[i]); -#endif silk_Encode( silk_enc, &st->silk_mode, pcm_silk, st->encoder_buffer, NULL, &zero, prefill, activity ); /* Prevent a second switch in the real encode call. */ st->silk_mode.opusCanSwitch = 0; } -#ifdef FIXED_POINT pcm_silk = pcm_buf+total_buffer*st->channels; -#else - for (i=0;ichannels;i++) - pcm_silk[i] = FLOAT2INT16(pcm_buf[total_buffer*st->channels + i]); -#endif ret = silk_Encode( silk_enc, &st->silk_mode, pcm_silk, frame_size, &enc, &nBytes, 0, activity ); if( ret ) { /*fprintf (stderr, "SILK encode error: %d\n", ret);*/ @@ -2115,7 +2144,7 @@ static opus_int32 opus_encode_frame_native(OpusEncoder *st, const opus_val16 *pc celt_encoder_ctl(celt_enc, CELT_SET_PREDICTION(celt_pred)); } - ALLOC(tmp_prefill, st->channels*st->Fs/400, opus_val16); + ALLOC(tmp_prefill, st->channels*st->Fs/400, opus_res); if (st->mode != MODE_SILK_ONLY && st->mode != st->prev_mode && st->prev_mode > 0) { OPUS_COPY(tmp_prefill, &st->delay_buffer[(st->encoder_buffer-total_buffer-st->Fs/400)*st->channels], st->channels*st->Fs/400); @@ -2466,7 +2495,7 @@ opus_int32 opus_encode_float(OpusEncoder *st, const float *pcm, int analysis_fra { int i, ret; int frame_size; - VARDECL(opus_int16, in); + VARDECL(opus_res, in); ALLOC_STACK; frame_size = frame_size_select(analysis_frame_size, st->variable_duration, st->Fs); @@ -2475,10 +2504,10 @@ opus_int32 opus_encode_float(OpusEncoder *st, const float *pcm, int analysis_fra RESTORE_STACK; return OPUS_BAD_ARG; } - ALLOC(in, frame_size*st->channels, opus_int16); + ALLOC(in, frame_size*st->channels, opus_res); for (i=0;ichannels;i++) - in[i] = FLOAT2INT16(pcm[i]); + in[i] = FLOAT2RES(pcm[i]); ret = opus_encode_native(st, in, frame_size, data, max_data_bytes, 16, pcm, analysis_frame_size, 0, -2, st->channels, downmix_float, 1); RESTORE_STACK; @@ -2486,14 +2515,40 @@ opus_int32 opus_encode_float(OpusEncoder *st, const float *pcm, int analysis_fra } #endif +#ifdef ENABLE_RES24 +opus_int32 opus_encode(OpusEncoder *st, const opus_int16 *pcm, int analysis_frame_size, + unsigned char *data, opus_int32 max_data_bytes) +{ + int i, ret; + int frame_size; + VARDECL(opus_res, in); + ALLOC_STACK; + + frame_size = frame_size_select(analysis_frame_size, st->variable_duration, st->Fs); + if (frame_size <= 0) + { + RESTORE_STACK; + return OPUS_BAD_ARG; + } + ALLOC(in, frame_size*st->channels, opus_res); + + for (i=0;ichannels;i++) + in[i] = INT16TORES(pcm[i]); + ret = opus_encode_native(st, in, frame_size, data, max_data_bytes, 16, + pcm, analysis_frame_size, 0, -2, st->channels, downmix_int, 1); + RESTORE_STACK; + return ret; +} +#else opus_int32 opus_encode(OpusEncoder *st, const opus_int16 *pcm, int analysis_frame_size, - unsigned char *data, opus_int32 out_data_bytes) + unsigned char *data, opus_int32 max_data_bytes) { int frame_size; frame_size = frame_size_select(analysis_frame_size, st->variable_duration, st->Fs); - return opus_encode_native(st, pcm, frame_size, data, out_data_bytes, 16, + return opus_encode_native(st, pcm, frame_size, data, max_data_bytes, 16, pcm, analysis_frame_size, 0, -2, st->channels, downmix_int, 0); } +#endif /* ENABLE_RES24 */ #else opus_int32 opus_encode(OpusEncoder *st, const opus_int16 *pcm, int analysis_frame_size, diff --git a/src/opus_multistream_encoder.c b/src/opus_multistream_encoder.c index 1725ade75..2b77e7afb 100644 --- a/src/opus_multistream_encoder.c +++ b/src/opus_multistream_encoder.c @@ -236,7 +236,7 @@ void surround_analysis(const CELTMode *celt_mode, const void *pcm, opus_val16 *b opus_val32 bandE[21]; opus_val16 maskLogE[3][21]; VARDECL(opus_val32, in); - VARDECL(opus_val16, x); + VARDECL(opus_res, x); VARDECL(opus_val32, freq); SAVE_STACK; @@ -250,7 +250,7 @@ void surround_analysis(const CELTMode *celt_mode, const void *pcm, opus_val16 *b break; ALLOC(in, frame_size+overlap, opus_val32); - ALLOC(x, len, opus_val16); + ALLOC(x, len, opus_res); ALLOC(freq, freq_size, opus_val32); channel_pos(channels, pos); @@ -819,7 +819,7 @@ int opus_multistream_encode_native int s; char *ptr; int tot_size; - VARDECL(opus_val16, buf); + VARDECL(opus_res, buf); VARDECL(opus_val16, bandSMR); unsigned char tmp_data[MS_FRAME_TMP]; OpusRepacketizer rp; @@ -862,7 +862,7 @@ int opus_multistream_encode_native RESTORE_STACK; return OPUS_BUFFER_TOO_SMALL; } - ALLOC(buf, 2*frame_size, opus_val16); + ALLOC(buf, 2*frame_size, opus_res); coupled_size = opus_encoder_get_size(2); mono_size = opus_encoder_get_size(1); @@ -1014,7 +1014,7 @@ int opus_multistream_encode_native #if !defined(DISABLE_FLOAT_API) static void opus_copy_channel_in_float( - opus_val16 *dst, + opus_res *dst, int dst_stride, const void *src, int src_stride, @@ -1028,16 +1028,12 @@ static void opus_copy_channel_in_float( (void)user_data; float_src = (const float *)src; for (i=0;i tolerance) + if (abs(RES2INT16(a[i]) - b[i]) > tolerance) return 1; } return 0; @@ -95,14 +90,14 @@ void test_simple_matrix(void) int i, ret; opus_int32 simple_matrix_size; opus_res *input_pcm; - opus_val16 *output_val16; + opus_res *output_pcm; opus_int16 *output_int16; MappingMatrix *simple_matrix; /* Allocate input/output buffers. */ input_pcm = (opus_res *)opus_alloc(sizeof(opus_res) * SIMPLE_MATRIX_INPUT_SIZE); output_int16 = (opus_int16 *)opus_alloc(sizeof(opus_int16) * SIMPLE_MATRIX_OUTPUT_SIZE); - output_val16 = (opus_val16 *)opus_alloc(sizeof(opus_val16) * SIMPLE_MATRIX_OUTPUT_SIZE); + output_pcm = (opus_res *)opus_alloc(sizeof(opus_res) * SIMPLE_MATRIX_OUTPUT_SIZE); /* Initialize matrix */ simple_matrix_size = mapping_matrix_get_size(simple_matrix_params.rows, @@ -123,14 +118,14 @@ void test_simple_matrix(void) /* _in_short */ for (i = 0; i < SIMPLE_MATRIX_OUTPUT_SIZE; i++) - output_val16[i] = 0; + output_pcm[i] = 0; for (i = 0; i < simple_matrix->rows; i++) { mapping_matrix_multiply_channel_in_short(simple_matrix, - input_int16, simple_matrix->cols, &output_val16[i], i, + input_int16, simple_matrix->cols, &output_pcm[i], i, simple_matrix->rows, SIMPLE_MATRIX_FRAME_SIZE); } - ret = assert_is_equal(output_val16, expected_output_int16, SIMPLE_MATRIX_OUTPUT_SIZE, ERROR_TOLERANCE); + ret = assert_is_equal(output_pcm, expected_output_int16, SIMPLE_MATRIX_OUTPUT_SIZE, ERROR_TOLERANCE); if (ret) test_failed(); @@ -150,34 +145,34 @@ void test_simple_matrix(void) #if !defined(DISABLE_FLOAT_API) && !defined(FIXED_POINT) /* _in_float */ for (i = 0; i < SIMPLE_MATRIX_OUTPUT_SIZE; i++) - output_val16[i] = 0; + output_pcm[i] = 0; for (i = 0; i < simple_matrix->rows; i++) { mapping_matrix_multiply_channel_in_float(simple_matrix, - input_pcm, simple_matrix->cols, &output_val16[i], i, + input_pcm, simple_matrix->cols, &output_pcm[i], i, simple_matrix->rows, SIMPLE_MATRIX_FRAME_SIZE); } - ret = assert_is_equal(output_val16, expected_output_int16, SIMPLE_MATRIX_OUTPUT_SIZE, ERROR_TOLERANCE); + ret = assert_is_equal(output_pcm, expected_output_int16, SIMPLE_MATRIX_OUTPUT_SIZE, ERROR_TOLERANCE); if (ret) test_failed(); /* _out_float */ for (i = 0; i < SIMPLE_MATRIX_OUTPUT_SIZE; i++) - output_val16[i] = 0; + output_pcm[i] = 0; for (i = 0; i < simple_matrix->cols; i++) { mapping_matrix_multiply_channel_out_float(simple_matrix, - &input_pcm[i], i, simple_matrix->cols, output_val16, + &input_pcm[i], i, simple_matrix->cols, output_pcm, simple_matrix->rows, SIMPLE_MATRIX_FRAME_SIZE); } - ret = assert_is_equal(output_val16, expected_output_int16, SIMPLE_MATRIX_OUTPUT_SIZE, ERROR_TOLERANCE); + ret = assert_is_equal(output_pcm, expected_output_int16, SIMPLE_MATRIX_OUTPUT_SIZE, ERROR_TOLERANCE); if (ret) test_failed(); #endif opus_free(input_pcm); opus_free(output_int16); - opus_free(output_val16); + opus_free(output_pcm); opus_free(simple_matrix); }