Originally committed as revision 19379 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -457,15 +457,6 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce · 456 unmodified lines | |||
| 457 | } | 457 | } |
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | static void encode_window_bands_info_fixed(AACEncContext *s, | ||
| 461 | SingleChannelElement *sce, | ||
| 462 | int win, int group_len, | ||
| 463 | const float lambda) | ||
| 464 | { | ||
| 465 | encode_window_bands_info(s, sce, win, group_len, 1.0f); | ||
| 466 | } | ||
| 467 | |||
| 468 | |||
| 469 | typedef struct TrellisPath { | 460 | typedef struct TrellisPath { |
| 470 | float cost; | 461 | float cost; |
| 471 | int prev; | 462 | int prev; |
| @@ -700,7 +691,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, · 228 unmodified lines | |||
| 700 | sce->ics.swb_sizes[g], | 691 | sce->ics.swb_sizes[g], |
| 701 | sce->sf_idx[w*16+g], | 692 | sce->sf_idx[w*16+g], |
| 702 | ESC_BT, | 693 | ESC_BT, |
| 703 | 1.0, | 694 | lambda, |
| 704 | INFINITY, | 695 | INFINITY, |
| 705 | &b); | 696 | &b); |
| 706 | bb += b; | 697 | bb += b; |
| @@ -710,7 +701,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, · 3 unmodified lines | |||
| 710 | minbits = bb; | 701 | minbits = bb; |
| 711 | } | 702 | } |
| 712 | } | 703 | } |
| 713 | dists[w*16+g] = mindist - minbits; | 704 | dists[w*16+g] = (mindist - minbits) / lambda; |
| 714 | bits = minbits; | 705 | bits = minbits; |
| 715 | if (prev != -1) { | 706 | if (prev != -1) { |
| 716 | bits += ff_aac_scalefactor_bits[sce->sf_idx[w*16+g] - prev + SCALE_DIFF_ZERO]; | 707 | bits += ff_aac_scalefactor_bits[sce->sf_idx[w*16+g] - prev + SCALE_DIFF_ZERO]; |
| @@ -870,12 +861,12 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 153 unmodified lines | |||
| 870 | sce->ics.swb_sizes[g], | 861 | sce->ics.swb_sizes[g], |
| 871 | scf, | 862 | scf, |
| 872 | ESC_BT, | 863 | ESC_BT, |
| 873 | 1.0, | 864 | lambda, |
| 874 | INFINITY, | 865 | INFINITY, |
| 875 | &b); | 866 | &b); |
| 876 | dist -= b; | 867 | dist -= b; |
| 877 | } | 868 | } |
| 878 | dist *= 1.0f/512.0f; | 869 | dist *= 1.0f / 512.0f / lambda; |
| 879 | quant_max = quant(maxq[w*16+g], ff_aac_pow2sf_tab[200 - scf + SCALE_ONE_POS - SCALE_DIV_512]); | 870 | quant_max = quant(maxq[w*16+g], ff_aac_pow2sf_tab[200 - scf + SCALE_ONE_POS - SCALE_DIV_512]); |
| 880 | if (quant_max >= 8191) { // too much, return to the previous quantizer | 871 | if (quant_max >= 8191) { // too much, return to the previous quantizer |
| 881 | sce->sf_idx[w*16+g] = prev_scf; | 872 | sce->sf_idx[w*16+g] = prev_scf; |
| @@ -1019,7 +1010,7 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe, · 137 unmodified lines | |||
| 1019 | AACCoefficientsEncoder ff_aac_coders[] = { | 1010 | AACCoefficientsEncoder ff_aac_coders[] = { |
| 1020 | { | 1011 | { |
| 1021 | search_for_quantizers_faac, | 1012 | search_for_quantizers_faac, |
| 1022 | encode_window_bands_info_fixed, | 1013 | encode_window_bands_info, |
| 1023 | quantize_and_encode_band, | 1014 | quantize_and_encode_band, |
| 1024 | // search_for_ms, | 1015 | // search_for_ms, |
| 1025 | }, | 1016 | }, |
| @@ -583,6 +583,7 @@ static int aac_encode_frame(AVCodecContext *avctx, · 582 unmodified lines | |||
| 583 | if (!(avctx->flags & CODEC_FLAG_QSCALE)) { | 583 | if (!(avctx->flags & CODEC_FLAG_QSCALE)) { |
| 584 | float ratio = avctx->bit_rate * 1024.0f / avctx->sample_rate / avctx->frame_bits; | 584 | float ratio = avctx->bit_rate * 1024.0f / avctx->sample_rate / avctx->frame_bits; |
| 585 | s->lambda *= ratio; | 585 | s->lambda *= ratio; |
| 586 | s->lambda = fminf(s->lambda, 65536.f); | ||
| 586 | } | 587 | } |
| 587 | 588 | ||
| 588 | if (avctx->frame_bits > 6144*avctx->channels) | 589 | if (avctx->frame_bits > 6144*avctx->channels) |