37 #ifndef AVCODEC_AACCODER_TRELLIS_H
38 #define AVCODEC_AACCODER_TRELLIS_H
60 int win,
int group_len,
const float lambda)
67 const int run_esc = (1 <<
run_bits) - 1;
69 int stackrun[120], stackcb[120], stack_len;
76 path[0][
cb].
cost = run_bits+4;
80 for (swb = 0; swb < max_sfb; swb++) {
82 if (sce->
zeroes[win*16 + swb]) {
83 float cost_stay_here = path[swb][0].
cost;
84 float cost_get_here = next_minbits + run_bits + 4;
88 if (cost_get_here < cost_stay_here) {
89 path[swb+1][0].
prev_idx = next_mincb;
90 path[swb+1][0].
cost = cost_get_here;
91 path[swb+1][0].
run = 1;
94 path[swb+1][0].
cost = cost_stay_here;
95 path[swb+1][0].
run = path[swb][0].
run + 1;
97 next_minbits = path[swb+1][0].
cost;
100 path[swb+1][
cb].
cost = 61450;
102 path[swb+1][
cb].
run = 0;
105 float minbits = next_minbits;
106 int mincb = next_mincb;
107 int startcb = sce->
band_type[win*16+swb];
111 for (cb = 0; cb < startcb; cb++) {
112 path[swb+1][
cb].
cost = 61450;
114 path[swb+1][
cb].
run = 0;
117 float cost_stay_here, cost_get_here;
120 path[swb+1][
cb].
cost = 61450;
122 path[swb+1][
cb].
run = 0;
125 for (w = 0; w < group_len; w++) {
127 &s->
scoefs[start + w*128], size,
132 cost_stay_here = path[swb][
cb].
cost + bits;
133 cost_get_here = minbits + bits + run_bits + 4;
137 if (cost_get_here < cost_stay_here) {
139 path[swb+1][
cb].
cost = cost_get_here;
140 path[swb+1][
cb].
run = 1;
143 path[swb+1][
cb].
cost = cost_stay_here;
146 if (path[swb+1][cb].cost < next_minbits) {
147 next_minbits = path[swb+1][
cb].
cost;
159 if (path[max_sfb][cb].cost < path[max_sfb][idx].cost)
165 stackrun[stack_len] = path[ppos][
cb].
run;
166 stackcb [stack_len] =
cb;
168 ppos -= path[ppos][
cb].
run;
173 for (i = stack_len - 1; i >= 0; i--) {
177 memset(sce->
zeroes + win*16 + start, !cb, count);
179 for (j = 0; j <
count; j++) {
183 while (count >= run_esc) {
static const uint8_t *const run_value_bits[2]
static const uint8_t aac_cb_out_map[CB_TOT_ALL]
Map to convert values from BandCodingPath index to a codebook index.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
static float win(SuperEqualizerContext *s, float n, int N)
static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, int win, int group_len, const float lambda)
int prev_idx
pointer to the previous path point
static double cb(void *priv, double x, double y)
static const uint8_t run_bits[7][16]
static const uint8_t aac_cb_in_map[CB_TOT_ALL+1]
Inverse map to convert from codebooks to BandCodingPath indices.
uint8_t max_sfb
number of scalefactor bands per group
void(* abs_pow34)(float *out, const float *in, const int size)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
AAC definitions and structures.
static int quantize_band_cost_bits(struct AACEncContext *s, const float *in, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits, float *energy, int rtz)
Libavcodec external API header.
IndividualChannelStream ics
This file contains a template for the codebook_trellis_rate selector function.
const uint8_t * swb_sizes
table of scalefactor band sizes for a particular window
#define CB_TOT_ALL
Total number of codebooks, including special ones.
uint8_t zeroes[128]
band is not coded (used by encoder)
int sf_idx[128]
scalefactor indices (used by encoder)
INTFLOAT coeffs[1024]
coefficients for IMDCT, maybe processed
Single Channel Element - used for both SCE and LFE elements.
enum BandType band_type[128]
band types
float scoefs[1024]
scaled coefficients