* 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
Showing the changes to libavcodec/aaccoder.c (1 of 20 files). Show all
Unified · Split
| @@ -110,14 +110,15 @@ static av_always_inline float quantize_and_encode_band_cost_template( · 109 unmodified lines | ||
| 110 | 110 | int *bits, int BT_ZERO, int BT_UNSIGNED, |
| 111 | 111 | int BT_PAIR, int BT_ESC) |
| 112 | 112 | { |
| 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]; | |
| 115 | 117 | const float CLIPPED_ESCAPE = 165140.0f*IQ; |
| 116 | 118 | int i, j; |
| 117 | 119 | float cost = 0; |
| 118 | 120 | const int dim = BT_PAIR ? 2 : 4; |
| 119 | 121 | int resbits = 0; |
| 120 | − const float Q34 = sqrtf(Q * sqrtf(Q)); | |
| 121 | 122 | const int range = aac_cb_range[cb]; |
| 122 | 123 | const int maxval = aac_cb_maxval[cb]; |
| 123 | 124 | int off; |
| @@ -420,7 +421,7 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 296 unmodified lines | ||
| 420 | 421 | const int run_esc = (1 << run_bits) - 1; |
| 421 | 422 | int idx, ppos, count; |
| 422 | 423 | int stackrun[120], stackcb[120], stack_len; |
| 423 | − float next_minrd = INFINITY; | |
| 424 | + float next_minbits = INFINITY; | |
| 424 | 425 | int next_mincb = 0; |
| 425 | 426 | |
| 426 | 427 | abs_pow34_v(s->scoefs, sce->coeffs, 1024); |
| @@ -434,7 +435,7 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 7 unmodified lines | ||
| 434 | 435 | size = sce->ics.swb_sizes[swb]; |
| 435 | 436 | if (sce->zeroes[win*16 + swb]) { |
| 436 | 437 | 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; | |
| 438 | 439 | if ( run_value_bits[sce->ics.num_windows == 8][path[swb][0].run] |
| 439 | 440 | != run_value_bits[sce->ics.num_windows == 8][path[swb][0].run+1]) |
| 440 | 441 | cost_stay_here += run_bits; |
| @@ -447,7 +448,7 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 6 unmodified lines | ||
| 447 | 448 | path[swb+1][0].cost = cost_stay_here; |
| 448 | 449 | path[swb+1][0].run = path[swb][0].run + 1; |
| 449 | 450 | } |
| 450 | − next_minrd = path[swb+1][0].cost; | |
| 451 | + next_minbits = path[swb+1][0].cost; | |
| 451 | 452 | next_mincb = 0; |
| 452 | 453 | for (cb = 1; cb < 12; cb++) { |
| 453 | 454 | path[swb+1][cb].cost = 61450; |
| @@ -455,10 +456,10 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 1 unmodified line | ||
| 455 | 456 | path[swb+1][cb].run = 0; |
| 456 | 457 | } |
| 457 | 458 | } else { |
| 458 | − float minrd = next_minrd; | |
| 459 | + float minbits = next_minbits; | |
| 459 | 460 | int mincb = next_mincb; |
| 460 | 461 | int startcb = sce->band_type[win*16+swb]; |
| 461 | − next_minrd = INFINITY; | |
| 462 | + next_minbits = INFINITY; | |
| 462 | 463 | next_mincb = 0; |
| 463 | 464 | for (cb = 0; cb < startcb; cb++) { |
| 464 | 465 | path[swb+1][cb].cost = 61450; |
| @@ -467,15 +468,15 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 2 unmodified lines | ||
| 467 | 468 | } |
| 468 | 469 | for (cb = startcb; cb < 12; cb++) { |
| 469 | 470 | float cost_stay_here, cost_get_here; |
| 470 | − float rd = 0.0f; | |
| 471 | + float bits = 0.0f; | |
| 471 | 472 | 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); | |
| 476 | 477 | } |
| 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; | |
| 479 | 480 | if ( run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run] |
| 480 | 481 | != run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run+1]) |
| 481 | 482 | cost_stay_here += run_bits; |
| @@ -488,8 +489,8 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 6 unmodified lines | ||
| 488 | 489 | path[swb+1][cb].cost = cost_stay_here; |
| 489 | 490 | path[swb+1][cb].run = path[swb][cb].run + 1; |
| 490 | 491 | } |
| 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; | |
| 493 | 494 | next_mincb = cb; |
| 494 | 495 | } |
| 495 | 496 | } |