diff options
author | Rostislav Pehlivanov <atomnuker@gmail.com> | 2017-02-11 00:25:07 +0000 |
---|---|---|
committer | Rostislav Pehlivanov <atomnuker@gmail.com> | 2017-02-14 06:15:36 +0000 |
commit | 07b78340dd1e6a8147585e31b2dae106d608eca2 (patch) | |
tree | 715de22fb49090d42c1e9b954739978fb262d38d /libavcodec/opus_pvq.c | |
parent | e538108c219d7b3628a9ec33d85bf252ee70c957 (diff) | |
download | ffmpeg-07b78340dd1e6a8147585e31b2dae106d608eca2.tar.gz |
opus_celt: rename structures to better names and reorganize them
This is meant to be applied on top of my previous patch which
split PVQ into celt_pvq.c and made opus_celt.h
Essentially nothing has been changed other than renaming CeltFrame
to CeltBlock (CeltFrame had absolutely nothing at all to do with
a frame) and CeltContext to CeltFrame.
3 variables have been put in CeltFrame as they make more sense
there rather than being passed around as arguments.
The coefficients have been moved to the CeltBlock structure
(why the hell were they in CeltContext and not in CeltFrame??).
Now the encoder would be able to use the exact context the decoder
uses (plus a couple of extra fields in there).
FATE passes, no slowdowns, etc.
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Diffstat (limited to 'libavcodec/opus_pvq.c')
-rw-r--r-- | libavcodec/opus_pvq.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/libavcodec/opus_pvq.c b/libavcodec/opus_pvq.c index b4e23c86b8..ddc5fc2895 100644 --- a/libavcodec/opus_pvq.c +++ b/libavcodec/opus_pvq.c @@ -375,7 +375,7 @@ static uint32_t celt_alg_unquant(OpusRangeCoder *rc, float *X, uint32_t N, uint3 return celt_extract_collapse_mask(y, N, blocks); } -uint32_t ff_celt_decode_band(CeltContext *s, OpusRangeCoder *rc, const int band, +uint32_t ff_celt_decode_band(CeltFrame *f, OpusRangeCoder *rc, const int band, float *X, float *Y, int N, int b, uint32_t blocks, float *lowband, int duration, float *lowband_out, int level, float gain, float *lowband_scratch, int fill) @@ -403,9 +403,9 @@ uint32_t ff_celt_decode_band(CeltContext *s, OpusRangeCoder *rc, const int band, float *x = X; for (i = 0; i <= dualstereo; i++) { int sign = 0; - if (s->remaining2 >= 1<<3) { + if (f->remaining2 >= 1<<3) { sign = ff_opus_rc_get_raw(rc, 1); - s->remaining2 -= 1 << 3; + f->remaining2 -= 1 << 3; b -= 1 << 3; } x[0] = sign ? -1.0f : 1.0f; @@ -417,7 +417,7 @@ uint32_t ff_celt_decode_band(CeltContext *s, OpusRangeCoder *rc, const int band, } if (!dualstereo && level == 0) { - int tf_change = s->tf_change[band]; + int tf_change = f->tf_change[band]; int k; if (tf_change > 0) recombine = tf_change; @@ -454,7 +454,7 @@ uint32_t ff_celt_decode_band(CeltContext *s, OpusRangeCoder *rc, const int band, /* Reorganize the samples in time order instead of frequency order */ if (B0 > 1 && lowband) - celt_deinterleave_hadamard(s->scratch, lowband, N_B >> recombine, + celt_deinterleave_hadamard(f->scratch, lowband, N_B >> recombine, B0 << recombine, longblocks); } @@ -485,7 +485,7 @@ uint32_t ff_celt_decode_band(CeltContext *s, OpusRangeCoder *rc, const int band, pulse_cap = ff_celt_log_freq_range[band] + duration * 8; offset = (pulse_cap >> 1) - (dualstereo && N == 2 ? CELT_QTHETA_OFFSET_TWOPHASE : CELT_QTHETA_OFFSET); - qn = (dualstereo && band >= s->intensitystereo) ? 1 : + qn = (dualstereo && band >= f->intensity_stereo) ? 1 : celt_compute_qn(N, b, offset, pulse_cap, dualstereo); tell = opus_rc_tell_frac(rc); if (qn != 1) { @@ -501,7 +501,7 @@ uint32_t ff_celt_decode_band(CeltContext *s, OpusRangeCoder *rc, const int band, /* NOTE: Renormalising X and Y *may* help fixed-point a bit at very high rate. Let's do that at higher complexity */ } else if (dualstereo) { - inv = (b > 2 << 3 && s->remaining2 > 2 << 3) ? ff_opus_rc_dec_log(rc, 2) : 0; + inv = (b > 2 << 3 && f->remaining2 > 2 << 3) ? ff_opus_rc_dec_log(rc, 2) : 0; itheta = 0; } qalloc = opus_rc_tell_frac(rc) - tell; @@ -542,7 +542,7 @@ uint32_t ff_celt_decode_band(CeltContext *s, OpusRangeCoder *rc, const int band, sbits = (itheta != 0 && itheta != 16384) ? 1 << 3 : 0; mbits -= sbits; c = (itheta > 8192); - s->remaining2 -= qalloc+sbits; + f->remaining2 -= qalloc+sbits; x2 = c ? Y : X; y2 = c ? X : Y; @@ -551,7 +551,7 @@ uint32_t ff_celt_decode_band(CeltContext *s, OpusRangeCoder *rc, const int band, sign = 1 - 2 * sign; /* We use orig_fill here because we want to fold the side, but if itheta==16384, we'll have cleared the low bits of fill. */ - cm = ff_celt_decode_band(s, rc, band, x2, NULL, N, mbits, blocks, + cm = ff_celt_decode_band(f, rc, band, x2, NULL, N, mbits, blocks, lowband, duration, lowband_out, level, gain, lowband_scratch, orig_fill); /* We don't split N=2 bands, so cm is either 1 or 0 (for a fold-collapse), @@ -588,7 +588,7 @@ uint32_t ff_celt_decode_band(CeltContext *s, OpusRangeCoder *rc, const int band, } mbits = av_clip((b - delta) / 2, 0, b); sbits = b - mbits; - s->remaining2 -= qalloc; + f->remaining2 -= qalloc; if (lowband && !dualstereo) next_lowband2 = lowband + N; /* >32-bit split case */ @@ -600,40 +600,40 @@ uint32_t ff_celt_decode_band(CeltContext *s, OpusRangeCoder *rc, const int band, else next_level = level + 1; - rebalance = s->remaining2; + rebalance = f->remaining2; if (mbits >= sbits) { /* In stereo mode, we do not apply a scaling to the mid * because we need the normalized mid for folding later */ - cm = ff_celt_decode_band(s, rc, band, X, NULL, N, mbits, blocks, + cm = ff_celt_decode_band(f, rc, band, X, NULL, N, mbits, blocks, lowband, duration, next_lowband_out1, next_level, dualstereo ? 1.0f : (gain * mid), lowband_scratch, fill); - rebalance = mbits - (rebalance - s->remaining2); + rebalance = mbits - (rebalance - f->remaining2); if (rebalance > 3 << 3 && itheta != 0) sbits += rebalance - (3 << 3); /* For a stereo split, the high bits of fill are always zero, * so no folding will be done to the side. */ - cm |= ff_celt_decode_band(s, rc, band, Y, NULL, N, sbits, blocks, + cm |= ff_celt_decode_band(f, rc, band, Y, NULL, N, sbits, blocks, next_lowband2, duration, NULL, next_level, gain * side, NULL, fill >> blocks) << ((B0 >> 1) & (dualstereo - 1)); } else { /* For a stereo split, the high bits of fill are always zero, * so no folding will be done to the side. */ - cm = ff_celt_decode_band(s, rc, band, Y, NULL, N, sbits, blocks, + cm = ff_celt_decode_band(f, rc, band, Y, NULL, N, sbits, blocks, next_lowband2, duration, NULL, next_level, gain * side, NULL, fill >> blocks) << ((B0 >> 1) & (dualstereo - 1)); - rebalance = sbits - (rebalance - s->remaining2); + rebalance = sbits - (rebalance - f->remaining2); if (rebalance > 3 << 3 && itheta != 16384) mbits += rebalance - (3 << 3); /* In stereo mode, we do not apply a scaling to the mid because * we need the normalized mid for folding later */ - cm |= ff_celt_decode_band(s, rc, band, X, NULL, N, mbits, blocks, + cm |= ff_celt_decode_band(f, rc, band, X, NULL, N, mbits, blocks, lowband, duration, next_lowband_out1, next_level, dualstereo ? 1.0f : (gain * mid), lowband_scratch, fill); @@ -643,19 +643,19 @@ uint32_t ff_celt_decode_band(CeltContext *s, OpusRangeCoder *rc, const int band, /* This is the basic no-split case */ uint32_t q = celt_bits2pulses(cache, b); uint32_t curr_bits = celt_pulses2bits(cache, q); - s->remaining2 -= curr_bits; + f->remaining2 -= curr_bits; /* Ensures we can never bust the budget */ - while (s->remaining2 < 0 && q > 0) { - s->remaining2 += curr_bits; + while (f->remaining2 < 0 && q > 0) { + f->remaining2 += curr_bits; curr_bits = celt_pulses2bits(cache, --q); - s->remaining2 -= curr_bits; + f->remaining2 -= curr_bits; } if (q != 0) { /* Finally do the actual quantization */ cm = celt_alg_unquant(rc, X, N, (q < 8) ? q : (8 + (q & 7)) << ((q >> 3) - 1), - s->spread, blocks, gain); + f->spread, blocks, gain); } else { /* If there's no pulse, fill the band anyway */ int j; @@ -668,13 +668,13 @@ uint32_t ff_celt_decode_band(CeltContext *s, OpusRangeCoder *rc, const int band, if (!lowband) { /* Noise */ for (j = 0; j < N; j++) - X[j] = (((int32_t)celt_rng(s)) >> 20); + X[j] = (((int32_t)celt_rng(f)) >> 20); cm = cm_mask; } else { /* Folded spectrum */ for (j = 0; j < N; j++) { /* About 48 dB below the "normal" folding level */ - X[j] = lowband[j] + (((celt_rng(s)) & 0x8000) ? 1.0f / 256 : -1.0f / 256); + X[j] = lowband[j] + (((celt_rng(f)) & 0x8000) ? 1.0f / 256 : -1.0f / 256); } cm = fill; } @@ -697,7 +697,7 @@ uint32_t ff_celt_decode_band(CeltContext *s, OpusRangeCoder *rc, const int band, /* Undo the sample reorganization going from time order to frequency order */ if (B0 > 1) - celt_interleave_hadamard(s->scratch, X, N_B>>recombine, + celt_interleave_hadamard(f->scratch, X, N_B>>recombine, B0<<recombine, longblocks); /* Undo time-freq changes that we did earlier */ |