Commit a9b864b8 authored by Koen Vos's avatar Koen Vos Committed by Jean-Marc Valin
Browse files

Cleaner way to take into account the prediction for stereo width

parent 42f1e3d6
......@@ -252,7 +252,7 @@ opus_int silk_Encode(
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+delay ] = samplesIn[ 2 * n + 1 ];
buf[ n+delay ] = samplesIn[ 2 * n + 1 ];
}
silk_memcpy(buf, &psEnc->state_Fxx[ 1 ].sCmn.delayBuf[MAX_ENCODER_DELAY-delay], delay*sizeof(opus_int16));
ret += silk_resampler( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state,
......@@ -455,7 +455,7 @@ opus_int silk_Encode(
encControl->allowBandwidthSwitch = psEnc->allowBandwidthSwitch;
encControl->inWBmodeWithoutVariableLP = psEnc->state_Fxx[ 0 ].sCmn.fs_kHz == 16 && psEnc->state_Fxx[ 0 ].sCmn.sLP.mode == 0;
encControl->internalSampleRate = silk_SMULBB( psEnc->state_Fxx[ 0 ].sCmn.fs_kHz, 1000 );
encControl->stereoWidth_Q14 = psEnc->sStereo.effective_width_prev_Q14;
encControl->stereoWidth_Q14 = encControl->toMono ? 0 : psEnc->sStereo.smth_width_Q14;
if( prefillFlag ) {
encControl->payloadSize_ms = tmp_payloadSize_ms;
encControl->complexity = tmp_complexity;
......
......@@ -53,7 +53,6 @@ void silk_stereo_LR_to_MS(
opus_int16 LP_mid[ MAX_FRAME_LENGTH ], HP_mid[ MAX_FRAME_LENGTH ];
opus_int16 LP_side[ MAX_FRAME_LENGTH ], HP_side[ MAX_FRAME_LENGTH ];
opus_int16 *mid = &x1[ -2 ];
opus_int16 effective_pred=0;
/* Convert to basic mid/side signals */
for( n = 0; n < frame_length + 2; n++ ) {
......@@ -140,7 +139,6 @@ void silk_stereo_LR_to_MS(
silk_stereo_quant_pred( pred_Q13, ix );
/* Collapse stereo width */
width_Q14 = 0;
effective_pred = silk_abs( pred_Q13[ 0 ] ) + silk_abs( pred_Q13[ 1 ] );
pred_Q13[ 0 ] = 0;
pred_Q13[ 1 ] = 0;
mid_side_rates_bps[ 0 ] = total_rate_bps;
......@@ -156,7 +154,6 @@ void silk_stereo_LR_to_MS(
silk_stereo_quant_pred( pred_Q13, ix );
/* Collapse stereo width */
width_Q14 = 0;
effective_pred = silk_abs( pred_Q13[ 0 ] ) + silk_abs( pred_Q13[ 1 ] );
pred_Q13[ 0 ] = 0;
pred_Q13[ 1 ] = 0;
} else if( state->smth_width_Q14 > SILK_FIX_CONST( 0.95, 14 ) ) {
......@@ -169,7 +166,6 @@ void silk_stereo_LR_to_MS(
pred_Q13[ 1 ] = silk_RSHIFT( silk_SMULBB( state->smth_width_Q14, pred_Q13[ 1 ] ), 14 );
silk_stereo_quant_pred( pred_Q13, ix );
width_Q14 = state->smth_width_Q14;
effective_pred = silk_abs( pred_Q13[ 0 ] ) + silk_abs( pred_Q13[ 1 ] );
}
if (*mid_only_flag == 0 && mid_side_rates_bps[ 1 ] < 1)
......@@ -214,15 +210,4 @@ void silk_stereo_LR_to_MS(
state->pred_prev_Q13[ 0 ] = (opus_int16)pred_Q13[ 0 ];
state->pred_prev_Q13[ 1 ] = (opus_int16)pred_Q13[ 1 ];
state->width_prev_Q14 = (opus_int16)width_Q14;
{
/* Evaluate the effective width of the SILK stereo so we can report it
for the CELT layer to partially collapse the image. We need to take
into account the prediction otherwise we risk compeltely collapsing
the HF image when doing panned mono */
opus_int32 effective_width;
effective_width = (opus_int32)state->width_prev_Q14 + silk_LSHIFT32( (opus_int32)effective_pred, 1);
effective_width += silk_RSHIFT( effective_width, 2 );
effective_width = silk_min_32(effective_width, 16384);
state->effective_width_prev_Q14 = effective_width;
}
}
......@@ -101,7 +101,6 @@ typedef struct {
opus_int32 mid_side_amp_Q0[ 4 ];
opus_int16 smth_width_Q14;
opus_int16 width_prev_Q14;
opus_int16 effective_width_prev_Q14;
opus_int8 predIx[ MAX_FRAMES_PER_PACKET ][ 2 ][ 3 ];
opus_int8 mid_only_flags[ MAX_FRAMES_PER_PACKET ];
} stereo_enc_state;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment