Mercurial > libavcodec.hg
comparison aaccoder.c @ 11762:91b9bd17e79c libavcodec
aacenc: Trellis over scalefactors using an estimated codebook rather than every codebook.
The minimal codebook to encode the band without clipping is used (as is done in the TLS).
| author | alexc |
|---|---|
| date | Tue, 25 May 2010 18:31:55 +0000 |
| parents | 418455c7e31f |
| children | 3fee94a43e64 |
comparison
equal
deleted
inserted
replaced
| 11761:418455c7e31f | 11762:91b9bd17e79c |
|---|---|
| 566 //maximum scalefactor index is when maximum coefficient after quantizing is still not zero | 566 //maximum scalefactor index is when maximum coefficient after quantizing is still not zero |
| 567 maxscale = av_clip_uint8(log2(qmax)*4 + 6 + SCALE_ONE_POS - SCALE_DIV_512); | 567 maxscale = av_clip_uint8(log2(qmax)*4 + 6 + SCALE_ONE_POS - SCALE_DIV_512); |
| 568 minscale = av_clip(minscale - q0, 0, TRELLIS_STATES - 1); | 568 minscale = av_clip(minscale - q0, 0, TRELLIS_STATES - 1); |
| 569 maxscale = av_clip(maxscale - q0, 0, TRELLIS_STATES); | 569 maxscale = av_clip(maxscale - q0, 0, TRELLIS_STATES); |
| 570 for (q = minscale; q < maxscale; q++) { | 570 for (q = minscale; q < maxscale; q++) { |
| 571 float dists[12], dist; | 571 float dist = 0; |
| 572 memset(dists, 0, sizeof(dists)); | 572 int cb = find_min_book(sce->sf_idx[w*16+g], sce->ics.group_len[w], sce->ics.swb_sizes[g], s->scoefs+start); |
| 573 for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { | 573 for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { |
| 574 FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; | 574 FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; |
| 575 int cb; | 575 dist += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g], |
| 576 for (cb = 0; cb <= ESC_BT; cb++) | |
| 577 dists[cb] += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g], | |
| 578 q + q0, cb, lambda / band->threshold, INFINITY, NULL); | 576 q + q0, cb, lambda / band->threshold, INFINITY, NULL); |
| 579 } | 577 } |
| 580 dist = dists[0]; | |
| 581 for (i = 1; i <= ESC_BT; i++) | |
| 582 dist = FFMIN(dist, dists[i]); | |
| 583 minrd = FFMIN(minrd, dist); | 578 minrd = FFMIN(minrd, dist); |
| 584 | 579 |
| 585 for (i = 0; i < q1 - q0; i++) { | 580 for (i = 0; i < q1 - q0; i++) { |
| 586 float cost; | 581 float cost; |
| 587 if (isinf(paths[idx - 1][i].cost)) | 582 if (isinf(paths[idx - 1][i].cost)) |
