History

Merge remote-tracking branch 'qatar/master'

* qatar/master: Remove ffmpeg. aacenc: Simplify windowing aacenc: Move saved overlap samples to the beginning of the same buffer as incoming samples. aacenc: Deinterleave input samples before processing. aacenc: Store channel count in AACEncContext. aacenc: Move Q^3/4 calculation to it's own table aacenc: Request normalized float samples instead of converting s16 samples to float. aacpsy: Replace an if with FFMAX in LAME windowing. aacenc: cosmetics, replace 'rd' with 'bits' in codebook_trellis_rate to make it more clear what is being calculated. aacpsy: cosmetics, change a FIXME to a NOTE about subshort comparisons aacenc: cosmetics: move init() and end() to the bottom of the file. aacenc: aac_encode_init() cleanup XWD encoder and decoder vc1: don't read the interpfrm and bfraction elements for interlaced frames mxfdec: fix memleak on mxf_read_close() westwood: split the AUD and VQA demuxers into separate files. Conflicts: .gitignore Changelog Makefile configure doc/ffmpeg.texi ffmpeg.c libavcodec/Makefile libavcodec/aacenc.c libavcodec/allcodecs.c libavcodec/avcodec.h libavcodec/version.h libavformat/Makefile libavformat/img2.c

Michael Niedermayer committed 14 years ago

Commit 0bb57f82 parents b955d40 0fec2cb20 files · +1027 −342Browse files

Showing the changes to libavcodec/aaccoder.c (1 of 20 files). Show all

Unified · Split

libavcodec/aaccoder.c+18−17
@@ -110,14 +110,15 @@ static av_always_inline float quantize_and_encode_band_cost_template( · 109 unmodified lines
110110 int *bits, int BT_ZERO, int BT_UNSIGNED,
111111 int BT_PAIR, int BT_ESC)
112112 {
113− const float IQ = ff_aac_pow2sf_tab[POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
114− const float Q = ff_aac_pow2sf_tab[POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];
113+ const int q_idx = POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512;
114+ const float Q = ff_aac_pow2sf_tab [q_idx];
115+ const float Q34 = ff_aac_pow34sf_tab[q_idx];
116+ const float IQ = ff_aac_pow2sf_tab [POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
115117 const float CLIPPED_ESCAPE = 165140.0f*IQ;
116118 int i, j;
117119 float cost = 0;
118120 const int dim = BT_PAIR ? 2 : 4;
119121 int resbits = 0;
120− const float Q34 = sqrtf(Q * sqrtf(Q));
121122 const int range = aac_cb_range[cb];
122123 const int maxval = aac_cb_maxval[cb];
123124 int off;
@@ -420,7 +421,7 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 296 unmodified lines
420421 const int run_esc = (1 << run_bits) - 1;
421422 int idx, ppos, count;
422423 int stackrun[120], stackcb[120], stack_len;
423− float next_minrd = INFINITY;
424+ float next_minbits = INFINITY;
424425 int next_mincb = 0;
425426
426427 abs_pow34_v(s->scoefs, sce->coeffs, 1024);
@@ -434,7 +435,7 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 7 unmodified lines
434435 size = sce->ics.swb_sizes[swb];
435436 if (sce->zeroes[win*16 + swb]) {
436437 float cost_stay_here = path[swb][0].cost;
437− float cost_get_here = next_minrd + run_bits + 4;
438+ float cost_get_here = next_minbits + run_bits + 4;
438439 if ( run_value_bits[sce->ics.num_windows == 8][path[swb][0].run]
439440 != run_value_bits[sce->ics.num_windows == 8][path[swb][0].run+1])
440441 cost_stay_here += run_bits;
@@ -447,7 +448,7 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 6 unmodified lines
447448 path[swb+1][0].cost = cost_stay_here;
448449 path[swb+1][0].run = path[swb][0].run + 1;
449450 }
450− next_minrd = path[swb+1][0].cost;
451+ next_minbits = path[swb+1][0].cost;
451452 next_mincb = 0;
452453 for (cb = 1; cb < 12; cb++) {
453454 path[swb+1][cb].cost = 61450;
@@ -455,10 +456,10 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 1 unmodified line
455456 path[swb+1][cb].run = 0;
456457 }
457458 } else {
458− float minrd = next_minrd;
459+ float minbits = next_minbits;
459460 int mincb = next_mincb;
460461 int startcb = sce->band_type[win*16+swb];
461− next_minrd = INFINITY;
462+ next_minbits = INFINITY;
462463 next_mincb = 0;
463464 for (cb = 0; cb < startcb; cb++) {
464465 path[swb+1][cb].cost = 61450;
@@ -467,15 +468,15 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 2 unmodified lines
467468 }
468469 for (cb = startcb; cb < 12; cb++) {
469470 float cost_stay_here, cost_get_here;
470− float rd = 0.0f;
471+ float bits = 0.0f;
471472 for (w = 0; w < group_len; w++) {
472− rd += quantize_band_cost(s, sce->coeffs + start + w*128,
473− s->scoefs + start + w*128, size,
474− sce->sf_idx[(win+w)*16+swb], cb,
475− 0, INFINITY, NULL);
473+ bits += quantize_band_cost(s, sce->coeffs + start + w*128,
474+ s->scoefs + start + w*128, size,
475+ sce->sf_idx[(win+w)*16+swb], cb,
476+ 0, INFINITY, NULL);
476477 }
477− cost_stay_here = path[swb][cb].cost + rd;
478− cost_get_here = minrd + rd + run_bits + 4;
478+ cost_stay_here = path[swb][cb].cost + bits;
479+ cost_get_here = minbits + bits + run_bits + 4;
479480 if ( run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run]
480481 != run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run+1])
481482 cost_stay_here += run_bits;
@@ -488,8 +489,8 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 6 unmodified lines
488489 path[swb+1][cb].cost = cost_stay_here;
489490 path[swb+1][cb].run = path[swb][cb].run + 1;
490491 }
491− if (path[swb+1][cb].cost < next_minrd) {
492− next_minrd = path[swb+1][cb].cost;
492+ if (path[swb+1][cb].cost < next_minbits) {
493+ next_minbits = path[swb+1][cb].cost;
493494 next_mincb = cb;
494495 }
495496 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t