diff options
Diffstat (limited to 'src/opus_multistream_encoder.c')
-rw-r--r-- | src/opus_multistream_encoder.c | 562 |
1 files changed, 323 insertions, 239 deletions
diff --git a/src/opus_multistream_encoder.c b/src/opus_multistream_encoder.c index 4cddbffd..31447bf9 100644 --- a/src/opus_multistream_encoder.c +++ b/src/opus_multistream_encoder.c @@ -36,8 +36,11 @@ #include <stdarg.h> #include "float_cast.h" #include "os_support.h" -#include "analysis.h" #include "mathops.h" +#include "mdct.h" +#include "modes.h" +#include "bands.h" +#include "quant_bands.h" typedef struct { int nb_streams; @@ -57,17 +60,65 @@ static const VorbisLayout vorbis_mappings[8] = { {5, 3, {0, 6, 1, 2, 3, 4, 5, 7}}, /* 8: 7.1 surround */ }; +typedef void (*opus_copy_channel_in_func)( + opus_val16 *dst, + int dst_stride, + const void *src, + int src_stride, + int src_channel, + int frame_size +); + struct OpusMSEncoder { - TonalityAnalysisState analysis; ChannelLayout layout; int lfe_stream; + int application; int variable_duration; int surround; opus_int32 bitrate_bps; opus_val32 subframe_mem[3]; /* Encoder states go here */ + /* then opus_val32 window_mem[channels*120]; */ + /* then opus_val32 preemph_mem[channels]; */ }; +static opus_val32 *ms_get_preemph_mem(OpusMSEncoder *st) +{ + int s; + char *ptr; + int coupled_size, mono_size; + + coupled_size = opus_encoder_get_size(2); + mono_size = opus_encoder_get_size(1); + ptr = (char*)st + align(sizeof(OpusMSEncoder)); + for (s=0;s<st->layout.nb_streams;s++) + { + if (s < st->layout.nb_coupled_streams) + ptr += align(coupled_size); + else + ptr += align(mono_size); + } + return (opus_val32*)(ptr+st->layout.nb_channels*120*sizeof(opus_val32)); +} + +static opus_val32 *ms_get_window_mem(OpusMSEncoder *st) +{ + int s; + char *ptr; + int coupled_size, mono_size; + + coupled_size = opus_encoder_get_size(2); + mono_size = opus_encoder_get_size(1); + ptr = (char*)st + align(sizeof(OpusMSEncoder)); + for (s=0;s<st->layout.nb_streams;s++) + { + if (s < st->layout.nb_coupled_streams) + ptr += align(coupled_size); + else + ptr += align(mono_size); + } + return (opus_val32*)ptr; +} static int validate_encoder_layout(const ChannelLayout *layout) { @@ -88,6 +139,206 @@ static int validate_encoder_layout(const ChannelLayout *layout) return 1; } +static void channel_pos(int channels, int pos[8]) +{ + /* Position in the mix: 0 don't mix, 1: left, 2: center, 3:right */ + if (channels==4) + { + pos[0]=1; + pos[1]=3; + pos[2]=1; + pos[3]=3; + } else if (channels==3||channels==5||channels==6) + { + pos[0]=1; + pos[1]=2; + pos[2]=3; + pos[3]=1; + pos[4]=3; + pos[5]=0; + } else if (channels==7) + { + pos[0]=1; + pos[1]=2; + pos[2]=3; + pos[3]=1; + pos[4]=3; + pos[5]=2; + pos[6]=0; + } else if (channels==8) + { + pos[0]=1; + pos[1]=2; + pos[2]=3; + pos[3]=1; + pos[4]=3; + pos[5]=1; + pos[6]=3; + pos[7]=0; + } +} + +#if 1 +/* Computes a rough approximation of log2(2^a + 2^b) */ +static opus_val16 logSum(opus_val16 a, opus_val16 b) +{ + opus_val16 max; + opus_val32 diff; + opus_val16 frac; + static const opus_val16 diff_table[17] = { + QCONST16(0.5000000f, DB_SHIFT), QCONST16(0.2924813f, DB_SHIFT), QCONST16(0.1609640f, DB_SHIFT), QCONST16(0.0849625f, DB_SHIFT), + QCONST16(0.0437314f, DB_SHIFT), QCONST16(0.0221971f, DB_SHIFT), QCONST16(0.0111839f, DB_SHIFT), QCONST16(0.0056136f, DB_SHIFT), + QCONST16(0.0028123f, DB_SHIFT) + }; + int low; + if (a>b) + { + max = a; + diff = SUB32(EXTEND32(a),EXTEND32(b)); + } else { + max = b; + diff = SUB32(EXTEND32(b),EXTEND32(a)); + } + if (diff >= QCONST16(8.f, DB_SHIFT)) + return max; +#ifdef FIXED_POINT + low = SHR32(diff, DB_SHIFT-1); + frac = SHL16(diff - SHL16(low, DB_SHIFT-1), 16-DB_SHIFT); +#else + low = floor(2*diff); + frac = 2*diff - low; +#endif + return max + diff_table[low] + MULT16_16_Q15(frac, SUB16(diff_table[low+1], diff_table[low])); +} +#else +opus_val16 logSum(opus_val16 a, opus_val16 b) +{ + return log2(pow(4, a)+ pow(4, b))/2; +} +#endif + +void surround_analysis(const CELTMode *celt_mode, const void *pcm, opus_val16 *bandLogE, opus_val32 *mem, opus_val32 *preemph_mem, + int len, int overlap, int channels, int rate, opus_copy_channel_in_func copy_channel_in +) +{ + int c; + int i; + int LM; + int pos[8] = {0}; + int upsample; + int frame_size; + opus_val32 bandE[21]; + opus_val16 maskLogE[3][21]; + VARDECL(opus_val32, in); + VARDECL(opus_val16, x); + VARDECL(opus_val32, out); + SAVE_STACK; + + upsample = resampling_factor(rate); + frame_size = len*upsample; + + for (LM=0;LM<=celt_mode->maxLM;LM++) + if (celt_mode->shortMdctSize<<LM==frame_size) + break; + + ALLOC(in, frame_size+overlap, opus_val32); + ALLOC(x, len, opus_val16); + ALLOC(freq, frame_size, opus_val32); + + channel_pos(channels, pos); + + for (c=0;c<3;c++) + for (i=0;i<21;i++) + maskLogE[c][i] = -QCONST16(28.f, DB_SHIFT); + + for (c=0;c<channels;c++) + { + OPUS_COPY(in, mem+c*overlap, overlap); + (*copy_channel_in)(x, 1, pcm, channels, c, len); + preemphasis(x, in+overlap, frame_size, 1, upsample, celt_mode->preemph, preemph_mem+c, 0); + clt_mdct_forward(&celt_mode->mdct, in, freq, celt_mode->window, overlap, celt_mode->maxLM-LM, 1); + if (upsample != 1) + { + int bound = len; + for (i=0;i<bound;i++) + freq[i] *= upsample; + for (;i<frame_size;i++) + freq[i] = 0; + } + + compute_band_energies(celt_mode, freq, bandE, 21, 1, 1<<LM); + amp2Log2(celt_mode, 21, 21, bandE, bandLogE+21*c, 1); + /* Apply spreading function with -6 dB/band going up and -12 dB/band going down. */ + for (i=1;i<21;i++) + bandLogE[21*c+i] = MAX16(bandLogE[21*c+i], bandLogE[21*c+i-1]-QCONST16(1.f, DB_SHIFT)); + for (i=19;i>=0;i--) + bandLogE[21*c+i] = MAX16(bandLogE[21*c+i], bandLogE[21*c+i+1]-QCONST16(2.f, DB_SHIFT)); + if (pos[c]==1) + { + for (i=0;i<21;i++) + maskLogE[0][i] = logSum(maskLogE[0][i], bandLogE[21*c+i]); + } else if (pos[c]==3) + { + for (i=0;i<21;i++) + maskLogE[2][i] = logSum(maskLogE[2][i], bandLogE[21*c+i]); + } else if (pos[c]==2) + { + for (i=0;i<21;i++) + { + maskLogE[0][i] = logSum(maskLogE[0][i], bandLogE[21*c+i]-QCONST16(.5f, DB_SHIFT)); + maskLogE[2][i] = logSum(maskLogE[2][i], bandLogE[21*c+i]-QCONST16(.5f, DB_SHIFT)); + } + } +#if 0 + for (i=0;i<21;i++) + printf("%f ", bandLogE[21*c+i]); +//#else + float sum=0; + for (i=0;i<21;i++) + sum += bandLogE[21*c+i]; + printf("%f ", sum/21); +#endif + OPUS_COPY(mem+c*overlap, in+frame_size, overlap); + } + for (i=0;i<21;i++) + maskLogE[1][i] = MIN32(maskLogE[0][i],maskLogE[2][i]); + for (c=0;c<3;c++) + for (i=0;i<21;i++) + maskLogE[c][i] += QCONST16(.5f, DB_SHIFT)*log2(2.f/(channels-1)); +#if 0 + for (c=0;c<3;c++) + { + for (i=0;i<21;i++) + printf("%f ", maskLogE[c][i]); + } +#endif + for (c=0;c<channels;c++) + { + opus_val16 *mask; + if (pos[c]!=0) + { + mask = &maskLogE[pos[c]-1][0]; + for (i=0;i<21;i++) + bandLogE[21*c+i] = bandLogE[21*c+i] - mask[i]; + } else { + for (i=0;i<21;i++) + bandLogE[21*c+i] = 0; + } +#if 0 + for (i=0;i<21;i++) + printf("%f ", bandLogE[21*c+i]); + printf("\n"); +#endif +#if 0 + float sum=0; + for (i=0;i<21;i++) + sum += bandLogE[21*c+i]; + printf("%f ", sum/21); + printf("\n"); +#endif + } + RESTORE_STACK; +} opus_int32 opus_multistream_encoder_get_size(int nb_streams, int nb_coupled_streams) { @@ -132,7 +383,9 @@ opus_int32 opus_multistream_surround_encoder_get_size(int channels, int mapping_ return 0; size = opus_multistream_encoder_get_size(nb_streams, nb_coupled_streams); if (channels>2) - size += align(opus_encoder_get_size(2)); + { + size += channels*(120*sizeof(opus_val32) + sizeof(opus_val32)); + } return size; } @@ -161,10 +414,10 @@ static int opus_multistream_encoder_init_impl( st->layout.nb_streams = streams; st->layout.nb_coupled_streams = coupled_streams; st->subframe_mem[0]=st->subframe_mem[1]=st->subframe_mem[2]=0; - OPUS_CLEAR(&st->analysis,1); if (!surround) st->lfe_stream = -1; st->bitrate_bps = OPUS_AUTO; + st->application = application; st->variable_duration = OPUS_FRAMESIZE_ARG; for (i=0;i<st->layout.nb_channels;i++) st->layout.mapping[i] = mapping[i]; @@ -192,10 +445,8 @@ static int opus_multistream_encoder_init_impl( } if (surround) { - OpusEncoder *downmix_enc; - downmix_enc = (OpusEncoder*)ptr; - ret = opus_encoder_init(downmix_enc, Fs, 2, OPUS_APPLICATION_AUDIO); - if(ret!=OPUS_OK)return ret; + OPUS_CLEAR(ms_get_preemph_mem(st), channels); + OPUS_CLEAR(ms_get_window_mem(st), channels*120); } st->surround = surround; return OPUS_OK; @@ -339,22 +590,6 @@ OpusMSEncoder *opus_multistream_surround_encoder_create( return st; } -typedef void (*opus_copy_channel_in_func)( - opus_val16 *dst, - int dst_stride, - const void *src, - int src_stride, - int src_channel, - int frame_size -); - -typedef void (*opus_surround_downmix_funct)( - opus_val16 *dst, - const void *src, - int channels, - int frame_size -); - static void surround_rate_allocation( OpusMSEncoder *st, opus_int32 *rate, @@ -433,15 +668,11 @@ static int opus_multistream_encode_native OpusMSEncoder *st, opus_copy_channel_in_func copy_channel_in, const void *pcm, - int frame_size, + int analysis_frame_size, unsigned char *data, opus_int32 max_data_bytes, int lsb_depth, - opus_surround_downmix_funct surround_downmix -#ifndef FIXED_POINT - , downmix_func downmix - , const void *pcm_analysis -#endif + downmix_func downmix ) { opus_int32 Fs; @@ -451,31 +682,29 @@ static int opus_multistream_encode_native char *ptr; int tot_size; VARDECL(opus_val16, buf); + VARDECL(opus_val16, bandSMR); unsigned char tmp_data[MS_FRAME_TMP]; OpusRepacketizer rp; opus_int32 complexity; -#ifndef FIXED_POINT - AnalysisInfo analysis_info; -#endif const CELTMode *celt_mode; opus_int32 bitrates[256]; opus_val16 bandLogE[42]; - opus_val16 bandLogE_mono[21]; + opus_val32 *mem = NULL; + opus_val32 *preemph_mem=NULL; + int frame_size; ALLOC_STACK; + if (st->surround) + { + preemph_mem = ms_get_preemph_mem(st); + mem = ms_get_window_mem(st); + } + ptr = (char*)st + align(sizeof(OpusMSEncoder)); opus_encoder_ctl((OpusEncoder*)ptr, OPUS_GET_SAMPLE_RATE(&Fs)); opus_encoder_ctl((OpusEncoder*)ptr, OPUS_GET_COMPLEXITY(&complexity)); opus_encoder_ctl((OpusEncoder*)ptr, CELT_GET_MODE(&celt_mode)); - if (400*frame_size < Fs) - { - RESTORE_STACK; - return OPUS_BAD_ARG; - } -#ifndef FIXED_POINT - analysis_info.valid = 0; - if (complexity >= 7 && Fs==48000) { opus_int32 delay_compensation; int channels; @@ -483,13 +712,15 @@ static int opus_multistream_encode_native channels = st->layout.nb_streams + st->layout.nb_coupled_streams; opus_encoder_ctl((OpusEncoder*)ptr, OPUS_GET_LOOKAHEAD(&delay_compensation)); delay_compensation -= Fs/400; + frame_size = compute_frame_size(pcm, analysis_frame_size, + st->variable_duration, channels, Fs, st->bitrate_bps, + delay_compensation, downmix, st->subframe_mem); + } - frame_size = run_analysis(&st->analysis, celt_mode, pcm, pcm_analysis, - frame_size, st->variable_duration, channels, Fs, st->bitrate_bps, delay_compensation, lsb_depth, downmix, &analysis_info); - } else -#endif + if (400*frame_size < Fs) { - frame_size = frame_size_select(frame_size, st->variable_duration, Fs); + RESTORE_STACK; + return OPUS_BAD_ARG; } /* Validate frame_size before using it to allocate stack space. This mirrors the checks in opus_encode[_float](). */ @@ -504,42 +735,10 @@ static int opus_multistream_encode_native coupled_size = opus_encoder_get_size(2); mono_size = opus_encoder_get_size(1); + ALLOC(bandSMR, 21*st->layout.nb_channels, opus_val16); if (st->surround) { - int i; - unsigned char dummy[512]; - /* Temporary kludge -- remove */ - OpusEncoder *downmix_enc; - - ptr = (char*)st + align(sizeof(OpusMSEncoder)); - for (s=0;s<st->layout.nb_streams;s++) - { - if (s < st->layout.nb_coupled_streams) - ptr += align(coupled_size); - else - ptr += align(mono_size); - } - downmix_enc = (OpusEncoder*)ptr; - surround_downmix(buf, pcm, st->layout.nb_channels, frame_size); - opus_encoder_ctl(downmix_enc, OPUS_SET_ENERGY_SAVE(bandLogE)); - opus_encoder_ctl(downmix_enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); - opus_encoder_ctl(downmix_enc, OPUS_SET_FORCE_MODE(MODE_CELT_ONLY)); - opus_encoder_ctl(downmix_enc, OPUS_SET_FORCE_CHANNELS(2)); - opus_encode_native(downmix_enc, buf, frame_size, dummy, 512, lsb_depth -#ifndef FIXED_POINT - , &analysis_info -#endif - ); - /* Combines the left and right mask into a centre mask. We - use an approximation for the log of the sum of the energies. */ - for(i=0;i<21;i++) - { - opus_val16 diff; - diff = ABS16(SUB16(bandLogE[i], bandLogE[21+i])); - diff = diff + HALF16(diff); - diff = SHR32(HALF32(celt_exp2(-diff)), 16-DB_SHIFT); - bandLogE_mono[i] = MAX16(bandLogE[i], bandLogE[21+i]) + diff; - } + surround_analysis(celt_mode, pcm, bandSMR, mem, preemph_mem, frame_size, 120, st->layout.nb_channels, Fs, copy_channel_in); } if (max_data_bytes < 4*st->layout.nb_streams-1) @@ -563,10 +762,24 @@ static int opus_multistream_encode_native opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrates[s])); if (st->surround) { - opus_encoder_ctl(enc, OPUS_SET_FORCE_MODE(MODE_CELT_ONLY)); - opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); + opus_int32 equiv_rate; + equiv_rate = st->bitrate_bps; + if (frame_size*50 < Fs) + equiv_rate -= 60*(Fs/frame_size - 50)*st->layout.nb_channels; + if (equiv_rate > 112000) + opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); + else if (equiv_rate > 76000) + opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_SUPERWIDEBAND)); + else if (equiv_rate > 48000) + opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_WIDEBAND)); + else + opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND)); if (s < st->layout.nb_coupled_streams) + { + /* To preserve the spatial image, force stereo CELT on coupled streams */ + opus_encoder_ctl(enc, OPUS_SET_FORCE_MODE(MODE_CELT_ONLY)); opus_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(2)); + } } } @@ -578,11 +791,13 @@ static int opus_multistream_encode_native OpusEncoder *enc; int len; int curr_max; + int c1, c2; opus_repacketizer_init(&rp); enc = (OpusEncoder*)ptr; if (s < st->layout.nb_coupled_streams) { + int i; int left, right; left = get_left_channel(&st->layout, s, -1); right = get_right_channel(&st->layout, s, -1); @@ -591,28 +806,39 @@ static int opus_multistream_encode_native (*copy_channel_in)(buf+1, 2, pcm, st->layout.nb_channels, right, frame_size); ptr += align(coupled_size); - /* FIXME: This isn't correct for the coupled center channels in - 6.1 surround configuration */ if (st->surround) - opus_encoder_ctl(enc, OPUS_SET_ENERGY_MASK(bandLogE)); + { + for (i=0;i<21;i++) + { + bandLogE[i] = bandSMR[21*left+i]; + bandLogE[21+i] = bandSMR[21*right+i]; + } + } + c1 = left; + c2 = right; } else { + int i; int chan = get_mono_channel(&st->layout, s, -1); (*copy_channel_in)(buf, 1, pcm, st->layout.nb_channels, chan, frame_size); ptr += align(mono_size); if (st->surround) - opus_encoder_ctl(enc, OPUS_SET_ENERGY_MASK(bandLogE_mono)); + { + for (i=0;i<21;i++) + bandLogE[i] = bandSMR[21*chan+i]; + } + c1 = chan; + c2 = -1; } + if (st->surround) + opus_encoder_ctl(enc, OPUS_SET_ENERGY_MASK(bandLogE)); /* number of bytes left (+Toc) */ curr_max = max_data_bytes - tot_size; /* Reserve three bytes for the last stream and four for the others */ curr_max -= IMAX(0,4*(st->layout.nb_streams-s-1)-1); curr_max = IMIN(curr_max,MS_FRAME_TMP); - len = opus_encode_native(enc, buf, frame_size, tmp_data, curr_max, lsb_depth -#ifndef FIXED_POINT - , &analysis_info -#endif - ); + len = opus_encode_native(enc, buf, frame_size, tmp_data, curr_max, lsb_depth, + pcm, analysis_frame_size, c1, c2, st->layout.nb_channels, downmix); if (len<0) { RESTORE_STACK; @@ -626,50 +852,12 @@ static int opus_multistream_encode_native data += len; tot_size += len; } + /*printf("\n");*/ RESTORE_STACK; return tot_size; } -static void channel_pos(int channels, int pos[8]) -{ - /* Position in the mix: 0 don't mix, 1: left, 2: center, 3:right */ - if (channels==4) - { - pos[0]=1; - pos[1]=3; - pos[2]=1; - pos[3]=3; - } else if (channels==3||channels==5||channels==6) - { - pos[0]=1; - pos[1]=2; - pos[2]=3; - pos[3]=1; - pos[4]=3; - pos[5]=0; - } else if (channels==7) - { - pos[0]=1; - pos[1]=2; - pos[2]=3; - pos[3]=1; - pos[4]=3; - pos[5]=2; - pos[6]=0; - } else if (channels==8) - { - pos[0]=1; - pos[1]=2; - pos[2]=3; - pos[3]=1; - pos[4]=3; - pos[5]=1; - pos[6]=3; - pos[7]=0; - } -} - #if !defined(DISABLE_FLOAT_API) static void opus_copy_channel_in_float( opus_val16 *dst, @@ -690,57 +878,6 @@ static void opus_copy_channel_in_float( dst[i*dst_stride] = float_src[i*src_stride+src_channel]; #endif } - -static void opus_surround_downmix_float( - opus_val16 *dst, - const void *src, - int channels, - int frame_size -) -{ - const float *float_src; - opus_int32 i; - int pos[8] = {0}; - int c; - float_src = (const float *)src; - - channel_pos(channels, pos); - for (i=0;i<2*frame_size;i++) - dst[i]=0; - - for (c=0;c<channels;c++) - { - if (pos[c]==1) - { - for (i=0;i<frame_size;i++) -#if defined(FIXED_POINT) - dst[2*i] += SHR16(FLOAT2INT16(float_src[i*channels+c]),3); -#else - dst[2*i] += float_src[i*channels+c]; -#endif - } else if (pos[c]==3) - { - for (i=0;i<frame_size;i++) -#if defined(FIXED_POINT) - dst[2*i+1] += SHR16(FLOAT2INT16(float_src[i*channels+c]),3); -#else - dst[2*i+1] += float_src[i*channels+c]; -#endif - } else if (pos[c]==2) - { - for (i=0;i<frame_size;i++) - { -#if defined(FIXED_POINT) - dst[2*i] += SHR32(MULT16_16(QCONST16(.70711f,15), FLOAT2INT16(float_src[i*channels+c])),3+15); - dst[2*i+1] += SHR32(MULT16_16(QCONST16(.70711f,15), FLOAT2INT16(float_src[i*channels+c])),3+15); -#else - dst[2*i] += .707f*float_src[i*channels+c]; - dst[2*i+1] += .707f*float_src[i*channels+c]; -#endif - } - } - } -} #endif static void opus_copy_channel_in_short( @@ -763,57 +900,6 @@ static void opus_copy_channel_in_short( #endif } -static void opus_surround_downmix_short( - opus_val16 *dst, - const void *src, - int channels, - int frame_size -) -{ - const opus_int16 *short_src; - opus_int32 i; - int pos[8] = {0}; - int c; - short_src = (const opus_int16 *)src; - - channel_pos(channels, pos); - for (i=0;i<2*frame_size;i++) - dst[i]=0; - - for (c=0;c<channels;c++) - { - if (pos[c]==1) - { - for (i=0;i<frame_size;i++) -#if defined(FIXED_POINT) - dst[2*i] += SHR16(short_src[i*channels+c],3); -#else - dst[2*i] += (1/32768.f)*short_src[i*channels+c]; -#endif - } else if (pos[c]==3) - { - for (i=0;i<frame_size;i++) -#if defined(FIXED_POINT) - dst[2*i+1] += SHR16(short_src[i*channels+c],3); -#else - dst[2*i+1] += (1/32768.f)*short_src[i*channels+c]; -#endif - } else if (pos[c]==2) - { - for (i=0;i<frame_size;i++) - { -#if defined(FIXED_POINT) - dst[2*i] += SHR32(MULT16_16(QCONST16(.70711f,15), short_src[i*channels+c]),3+15); - dst[2*i+1] += SHR32(MULT16_16(QCONST16(.70711f,15), short_src[i*channels+c]),3+15); -#else - dst[2*i] += (.707f/32768.f)*short_src[i*channels+c]; - dst[2*i+1] += (.707f/32768.f)*short_src[i*channels+c]; -#endif - } - } - } -} - #ifdef FIXED_POINT int opus_multistream_encode( @@ -825,7 +911,7 @@ int opus_multistream_encode( ) { return opus_multistream_encode_native(st, opus_copy_channel_in_short, - pcm, frame_size, data, max_data_bytes, 16, opus_surround_downmix_short); + pcm, frame_size, data, max_data_bytes, 16, downmix_int); } #ifndef DISABLE_FLOAT_API @@ -838,7 +924,7 @@ int opus_multistream_encode_float( ) { return opus_multistream_encode_native(st, opus_copy_channel_in_float, - pcm, frame_size, data, max_data_bytes, 16, opus_surround_downmix_float); + pcm, frame_size, data, max_data_bytes, 16, downmix_float); } #endif @@ -853,9 +939,8 @@ int opus_multistream_encode_float opus_int32 max_data_bytes ) { - int channels = st->layout.nb_streams + st->layout.nb_coupled_streams; return opus_multistream_encode_native(st, opus_copy_channel_in_float, - pcm, frame_size, data, max_data_bytes, 24, opus_surround_downmix_float, downmix_float, pcm+channels*st->analysis.analysis_offset); + pcm, frame_size, data, max_data_bytes, 24, downmix_float); } int opus_multistream_encode( @@ -866,9 +951,8 @@ int opus_multistream_encode( opus_int32 max_data_bytes ) { - int channels = st->layout.nb_streams + st->layout.nb_coupled_streams; return opus_multistream_encode_native(st, opus_copy_channel_in_short, - pcm, frame_size, data, max_data_bytes, 16, opus_surround_downmix_short, downmix_int, pcm+channels*st->analysis.analysis_offset); + pcm, frame_size, data, max_data_bytes, 16, downmix_int); } #endif |