* 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 | int *bits, int BT_ZERO, int BT_UNSIGNED, | 110 | int *bits, int BT_ZERO, int BT_UNSIGNED, |
| 111 | int BT_PAIR, int BT_ESC) | 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]; | 113 | const int q_idx = 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]; | 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 | const float CLIPPED_ESCAPE = 165140.0f*IQ; | 117 | const float CLIPPED_ESCAPE = 165140.0f*IQ; |
| 116 | int i, j; | 118 | int i, j; |
| 117 | float cost = 0; | 119 | float cost = 0; |
| 118 | const int dim = BT_PAIR ? 2 : 4; | 120 | const int dim = BT_PAIR ? 2 : 4; |
| 119 | int resbits = 0; | 121 | int resbits = 0; |
| 120 | const float Q34 = sqrtf(Q * sqrtf(Q)); | ||
| 121 | const int range = aac_cb_range[cb]; | 122 | const int range = aac_cb_range[cb]; |
| 122 | const int maxval = aac_cb_maxval[cb]; | 123 | const int maxval = aac_cb_maxval[cb]; |
| 123 | int off; | 124 | int off; |
| @@ -420,7 +421,7 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 296 unmodified lines | |||
| 420 | const int run_esc = (1 << run_bits) - 1; | 421 | const int run_esc = (1 << run_bits) - 1; |
| 421 | int idx, ppos, count; | 422 | int idx, ppos, count; |
| 422 | int stackrun[120], stackcb[120], stack_len; | 423 | int stackrun[120], stackcb[120], stack_len; |
| 423 | float next_minrd = INFINITY; | 424 | float next_minbits = INFINITY; |
| 424 | int next_mincb = 0; | 425 | int next_mincb = 0; |
| 425 | 426 | ||
| 426 | abs_pow34_v(s->scoefs, sce->coeffs, 1024); | 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 | size = sce->ics.swb_sizes[swb]; | 435 | size = sce->ics.swb_sizes[swb]; |
| 435 | if (sce->zeroes[win*16 + swb]) { | 436 | if (sce->zeroes[win*16 + swb]) { |
| 436 | float cost_stay_here = path[swb][0].cost; | 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 | if ( run_value_bits[sce->ics.num_windows == 8][path[swb][0].run] | 439 | if ( run_value_bits[sce->ics.num_windows == 8][path[swb][0].run] |
| 439 | != run_value_bits[sce->ics.num_windows == 8][path[swb][0].run+1]) | 440 | != run_value_bits[sce->ics.num_windows == 8][path[swb][0].run+1]) |
| 440 | cost_stay_here += run_bits; | 441 | cost_stay_here += run_bits; |
| @@ -447,7 +448,7 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 6 unmodified lines | |||
| 447 | path[swb+1][0].cost = cost_stay_here; | 448 | path[swb+1][0].cost = cost_stay_here; |
| 448 | path[swb+1][0].run = path[swb][0].run + 1; | 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 | next_mincb = 0; | 452 | next_mincb = 0; |
| 452 | for (cb = 1; cb < 12; cb++) { | 453 | for (cb = 1; cb < 12; cb++) { |
| 453 | path[swb+1][cb].cost = 61450; | 454 | path[swb+1][cb].cost = 61450; |
| @@ -455,10 +456,10 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 1 unmodified line | |||
| 455 | path[swb+1][cb].run = 0; | 456 | path[swb+1][cb].run = 0; |
| 456 | } | 457 | } |
| 457 | } else { | 458 | } else { |
| 458 | float minrd = next_minrd; | 459 | float minbits = next_minbits; |
| 459 | int mincb = next_mincb; | 460 | int mincb = next_mincb; |
| 460 | int startcb = sce->band_type[win*16+swb]; | 461 | int startcb = sce->band_type[win*16+swb]; |
| 461 | next_minrd = INFINITY; | 462 | next_minbits = INFINITY; |
| 462 | next_mincb = 0; | 463 | next_mincb = 0; |
| 463 | for (cb = 0; cb < startcb; cb++) { | 464 | for (cb = 0; cb < startcb; cb++) { |
| 464 | path[swb+1][cb].cost = 61450; | 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 | for (cb = startcb; cb < 12; cb++) { | 469 | for (cb = startcb; cb < 12; cb++) { |
| 469 | float cost_stay_here, cost_get_here; | 470 | float cost_stay_here, cost_get_here; |
| 470 | float rd = 0.0f; | 471 | float bits = 0.0f; |
| 471 | for (w = 0; w < group_len; w++) { | 472 | for (w = 0; w < group_len; w++) { |
| 472 | rd += quantize_band_cost(s, sce->coeffs + start + w*128, | 473 | bits += quantize_band_cost(s, sce->coeffs + start + w*128, |
| 473 | s->scoefs + start + w*128, size, | 474 | s->scoefs + start + w*128, size, |
| 474 | sce->sf_idx[(win+w)*16+swb], cb, | 475 | sce->sf_idx[(win+w)*16+swb], cb, |
| 475 | 0, INFINITY, NULL); | 476 | 0, INFINITY, NULL); |
| 476 | } | 477 | } |
| 477 | cost_stay_here = path[swb][cb].cost + rd; | 478 | cost_stay_here = path[swb][cb].cost + bits; |
| 478 | cost_get_here = minrd + rd + run_bits + 4; | 479 | cost_get_here = minbits + bits + run_bits + 4; |
| 479 | if ( run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run] | 480 | if ( run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run] |
| 480 | != run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run+1]) | 481 | != run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run+1]) |
| 481 | cost_stay_here += run_bits; | 482 | cost_stay_here += run_bits; |
| @@ -488,8 +489,8 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 6 unmodified lines | |||
| 488 | path[swb+1][cb].cost = cost_stay_here; | 489 | path[swb+1][cb].cost = cost_stay_here; |
| 489 | path[swb+1][cb].run = path[swb][cb].run + 1; | 490 | path[swb+1][cb].run = path[swb][cb].run + 1; |
| 490 | } | 491 | } |
| 491 | if (path[swb+1][cb].cost < next_minrd) { | 492 | if (path[swb+1][cb].cost < next_minbits) { |
| 492 | next_minrd = path[swb+1][cb].cost; | 493 | next_minbits = path[swb+1][cb].cost; |
| 493 | next_mincb = cb; | 494 | next_mincb = cb; |
| 494 | } | 495 | } |
| 495 | } | 496 | } |