1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

aaccoder: add intensity stereo support to encode_window_bands_info quantizer

This commit adds support for both PNS and IS (intensity stereo) codebooks to the
encode_window_bands_info() quantizer, used by the faast, faac and anmr non-default,
native coders. This does not mean that both extensions now work with those coders,
some are simply unsuited and will trigger an assertion in the encoder while
others simply ignore the changed scalefactor indices and band types.
This commit simply adds support for encoding said band types with the alternative
coders. Future commits to the coders will be required to make them suitable.

Reviewed-by: Claudio Freire <klaussfreire@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Rostislav Pehlivanov 2015-06-26 21:16:33 +01:00 committed by Michael Niedermayer
parent 305859c0d4
commit 55397b0e76

View File

@ -338,7 +338,7 @@ typedef struct BandCodingPath {
static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce, static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce,
int win, int group_len, const float lambda) int win, int group_len, const float lambda)
{ {
BandCodingPath path[120][CB_TOT]; BandCodingPath path[120][CB_TOT_ALL];
int w, swb, cb, start, size; int w, swb, cb, start, size;
int i, j; int i, j;
const int max_sfb = sce->ics.max_sfb; const int max_sfb = sce->ics.max_sfb;
@ -351,7 +351,7 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce
abs_pow34_v(s->scoefs, sce->coeffs, 1024); abs_pow34_v(s->scoefs, sce->coeffs, 1024);
start = win*128; start = win*128;
for (cb = 0; cb < CB_TOT; cb++) { for (cb = 0; cb < CB_TOT_ALL; cb++) {
path[0][cb].cost = 0.0f; path[0][cb].cost = 0.0f;
path[0][cb].prev_idx = -1; path[0][cb].prev_idx = -1;
path[0][cb].run = 0; path[0][cb].run = 0;
@ -359,7 +359,7 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce
for (swb = 0; swb < max_sfb; swb++) { for (swb = 0; swb < max_sfb; swb++) {
size = sce->ics.swb_sizes[swb]; size = sce->ics.swb_sizes[swb];
if (sce->zeroes[win*16 + swb]) { if (sce->zeroes[win*16 + swb]) {
for (cb = 0; cb < CB_TOT; cb++) { for (cb = 0; cb < CB_TOT_ALL; cb++) {
path[swb+1][cb].prev_idx = cb; path[swb+1][cb].prev_idx = cb;
path[swb+1][cb].cost = path[swb][cb].cost; path[swb+1][cb].cost = path[swb][cb].cost;
path[swb+1][cb].run = path[swb][cb].run + 1; path[swb+1][cb].run = path[swb][cb].run + 1;
@ -369,9 +369,16 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce
int mincb = next_mincb; int mincb = next_mincb;
next_minrd = INFINITY; next_minrd = INFINITY;
next_mincb = 0; next_mincb = 0;
for (cb = 0; cb < CB_TOT; cb++) { for (cb = 0; cb < CB_TOT_ALL; cb++) {
float cost_stay_here, cost_get_here; float cost_stay_here, cost_get_here;
float rd = 0.0f; float rd = 0.0f;
if (cb >= 12 && sce->band_type[win*16+swb] < aac_cb_out_map[cb] ||
cb < aac_cb_in_map[sce->band_type[win*16+swb]] && sce->band_type[win*16+swb] > aac_cb_out_map[cb]) {
path[swb+1][cb].prev_idx = -1;
path[swb+1][cb].cost = INFINITY;
path[swb+1][cb].run = path[swb][cb].run + 1;
continue;
}
for (w = 0; w < group_len; w++) { for (w = 0; w < group_len; w++) {
FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(win+w)*16+swb]; FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(win+w)*16+swb];
rd += quantize_band_cost(s, sce->coeffs + start + w*128, rd += quantize_band_cost(s, sce->coeffs + start + w*128,
@ -405,11 +412,12 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce
//convert resulting path from backward-linked list //convert resulting path from backward-linked list
stack_len = 0; stack_len = 0;
idx = 0; idx = 0;
for (cb = 1; cb < CB_TOT; cb++) for (cb = 1; cb < CB_TOT_ALL; cb++)
if (path[max_sfb][cb].cost < path[max_sfb][idx].cost) if (path[max_sfb][cb].cost < path[max_sfb][idx].cost)
idx = cb; idx = cb;
ppos = max_sfb; ppos = max_sfb;
while (ppos > 0) { while (ppos > 0) {
av_assert1(idx >= 0);
cb = idx; cb = idx;
stackrun[stack_len] = path[ppos][cb].run; stackrun[stack_len] = path[ppos][cb].run;
stackcb [stack_len] = cb; stackcb [stack_len] = cb;
@ -440,7 +448,7 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce
static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce,
int win, int group_len, const float lambda) int win, int group_len, const float lambda)
{ {
BandCodingPath path[120][CB_TOT]; BandCodingPath path[120][CB_TOT_ALL];
int w, swb, cb, start, size; int w, swb, cb, start, size;
int i, j; int i, j;
const int max_sfb = sce->ics.max_sfb; const int max_sfb = sce->ics.max_sfb;