diff options
Diffstat (limited to 'celt/bands.c')
-rw-r--r-- | celt/bands.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/celt/bands.c b/celt/bands.c index 868a98dc..09e743da 100644 --- a/celt/bands.c +++ b/celt/bands.c @@ -1361,6 +1361,18 @@ static unsigned quant_band_stereo(struct band_ctx *ctx, celt_norm *X, celt_norm return cm; } +static void special_hybrid_folding(const CELTMode *m, celt_norm *norm, celt_norm *norm2, int start, int M, int dual_stereo) +{ + int n1, n2; + const opus_int16 * OPUS_RESTRICT eBands = m->eBands; + n1 = M*(eBands[start+1]-eBands[start]); + n2 = M*(eBands[start+2]-eBands[start+1]); + /* Duplicate enough of the first band folding data to be able to fold the second band. + Copies no data for CELT-only mode. */ + OPUS_COPY(&norm[n1], &norm[2*n1 - n2], n2-n1); + if (dual_stereo) + OPUS_COPY(&norm2[n1], &norm2[2*n1 - n2], n2-n1); +} void quant_all_bands(int encode, const CELTMode *m, int start, int end, celt_norm *X_, celt_norm *Y_, unsigned char *collapse_masks, @@ -1472,8 +1484,15 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, b = 0; } +#ifdef ENABLE_UPDATE_DRAFT + if (resynth && (M*eBands[i]-N >= M*eBands[start] || i==start+1) && (update_lowband || lowband_offset==0)) + lowband_offset = i; + if (i == start+1) + special_hybrid_folding(m, norm, norm2, start, M, dual_stereo); +#else if (resynth && M*eBands[i]-N >= M*eBands[start] && (update_lowband || lowband_offset==0)) lowband_offset = i; +#endif tf_change = tf_res[i]; ctx.tf_change = tf_change; @@ -1499,7 +1518,11 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, fold_start = lowband_offset; while(M*eBands[--fold_start] > effective_lowband+norm_offset); fold_end = lowband_offset-1; +#ifdef ENABLE_UPDATE_DRAFT + while(++fold_end < i && M*eBands[fold_end] < effective_lowband+norm_offset+N); +#else while(M*eBands[++fold_end] < effective_lowband+norm_offset+N); +#endif x_cm = y_cm = 0; fold_i = fold_start; do { x_cm |= collapse_masks[fold_i*C+0]; @@ -1575,6 +1598,8 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, ctx = ctx_save; OPUS_COPY(X, X_save, N); OPUS_COPY(Y, Y_save, N); + if (i == start+1) + special_hybrid_folding(m, norm, norm2, start, M, dual_stereo); /* Encode and round up. */ ctx.theta_round = 1; x_cm = quant_band_stereo(&ctx, X, Y, N, b, B, |