Originally committed as revision 19378 to svn://svn.ffmpeg.org/ffmpeg/trunk
Showing the changes to libavcodec/aaccoder.c (1 of 4 files). Show all
Unified · Split
| @@ -84,9 +84,8 @@ static void abs_pow34_v(float *out, const float *in, const int size) · 83 unmodified lines | |||
| 84 | { | 84 | { |
| 85 | #ifndef USE_REALLY_FULL_SEARCH | 85 | #ifndef USE_REALLY_FULL_SEARCH |
| 86 | int i; | 86 | int i; |
| 87 | for (i = 0; i < size; i++) { | 87 | for (i = 0; i < size; i++) |
| 88 | out[i] = pow(fabsf(in[i]), 0.75); | 88 | out[i] = pow(fabsf(in[i]), 0.75); |
| 89 | } | ||
| 90 | #endif /* USE_REALLY_FULL_SEARCH */ | 89 | #endif /* USE_REALLY_FULL_SEARCH */ |
| 91 | } | 90 | } |
| 92 | 91 | ||
| @@ -141,9 +140,8 @@ static float quantize_band_cost(struct AACEncContext *s, const float *in, · 48 unmodified lines | |||
| 141 | #ifndef USE_REALLY_FULL_SEARCH | 140 | #ifndef USE_REALLY_FULL_SEARCH |
| 142 | int (*quants)[2] = &s->qcoefs[i]; | 141 | int (*quants)[2] = &s->qcoefs[i]; |
| 143 | mincost = 0.0f; | 142 | mincost = 0.0f; |
| 144 | for (j = 0; j < dim; j++) { | 143 | for (j = 0; j < dim; j++) |
| 145 | mincost += in[i+j]*in[i+j]*lambda; | 144 | mincost += in[i+j]*in[i+j]*lambda; |
| 146 | } | ||
| 147 | minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40; | 145 | minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40; |
| 148 | minbits = ff_aac_spectral_bits[cb-1][minidx]; | 146 | minbits = ff_aac_spectral_bits[cb-1][minidx]; |
| 149 | mincost += minbits; | 147 | mincost += minbits; |
| @@ -256,9 +254,8 @@ static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb, · 106 unmodified lines | |||
| 256 | #ifndef USE_REALLY_FULL_SEARCH | 254 | #ifndef USE_REALLY_FULL_SEARCH |
| 257 | int (*quants)[2] = &s->qcoefs[i]; | 255 | int (*quants)[2] = &s->qcoefs[i]; |
| 258 | mincost = 0.0f; | 256 | mincost = 0.0f; |
| 259 | for (j = 0; j < dim; j++) { | 257 | for (j = 0; j < dim; j++) |
| 260 | mincost += in[i+j]*in[i+j]*lambda; | 258 | mincost += in[i+j]*in[i+j]*lambda; |
| 261 | } | ||
| 262 | minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40; | 259 | minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40; |
| 263 | minbits = ff_aac_spectral_bits[cb-1][minidx]; | 260 | minbits = ff_aac_spectral_bits[cb-1][minidx]; |
| 264 | mincost += minbits; | 261 | mincost += minbits; |
| @@ -429,10 +426,9 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce · 164 unmodified lines | |||
| 429 | //convert resulting path from backward-linked list | 426 | //convert resulting path from backward-linked list |
| 430 | stack_len = 0; | 427 | stack_len = 0; |
| 431 | idx = 0; | 428 | idx = 0; |
| 432 | for (cb = 1; cb < 12; cb++) { | 429 | for (cb = 1; cb < 12; cb++) |
| 433 | if (path[max_sfb][cb].cost < path[max_sfb][idx].cost) | 430 | if (path[max_sfb][cb].cost < path[max_sfb][idx].cost) |
| 434 | idx = cb; | 431 | idx = cb; |
| 435 | } | ||
| 436 | ppos = max_sfb; | 432 | ppos = max_sfb; |
| 437 | while (ppos > 0) { | 433 | while (ppos > 0) { |
| 438 | cb = idx; | 434 | cb = idx; |
| @@ -523,7 +519,8 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 84 unmodified lines | |||
| 523 | nz = 1; | 519 | nz = 1; |
| 524 | for (i = 0; i < sce->ics.swb_sizes[g]; i++) { | 520 | for (i = 0; i < sce->ics.swb_sizes[g]; i++) { |
| 525 | float t = fabsf(coefs[w2*128+i]); | 521 | float t = fabsf(coefs[w2*128+i]); |
| 526 | if (t > 0.0f) qmin = fminf(qmin, t); | 522 | if (t > 0.0f) |
| 523 | qmin = fminf(qmin, t); | ||
| 527 | qmax = fmaxf(qmax, t); | 524 | qmax = fmaxf(qmax, t); |
| 528 | } | 525 | } |
| 529 | } | 526 | } |
| @@ -540,10 +537,9 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 10 unmodified lines | |||
| 540 | for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { | 537 | for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { |
| 541 | FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; | 538 | FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; |
| 542 | int cb; | 539 | int cb; |
| 543 | for (cb = 0; cb <= ESC_BT; cb++) { | 540 | for (cb = 0; cb <= ESC_BT; cb++) |
| 544 | dists[cb] += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g], | 541 | dists[cb] += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g], |
| 545 | q, cb, lambda / band->threshold, INFINITY, NULL); | 542 | q, cb, lambda / band->threshold, INFINITY, NULL); |
| 546 | } | ||
| 547 | } | 543 | } |
| 548 | dist = dists[0]; | 544 | dist = dists[0]; |
| 549 | for (i = 1; i <= ESC_BT; i++) | 545 | for (i = 1; i <= ESC_BT; i++) |
| @@ -725,22 +721,19 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, · 175 unmodified lines | |||
| 725 | } | 721 | } |
| 726 | } | 722 | } |
| 727 | if (tbits > destbits) { | 723 | if (tbits > destbits) { |
| 728 | for (i = 0; i < 128; i++) { | 724 | for (i = 0; i < 128; i++) |
| 729 | if (sce->sf_idx[i] < 218 - qstep) { | 725 | if (sce->sf_idx[i] < 218 - qstep) |
| 730 | sce->sf_idx[i] += qstep; | 726 | sce->sf_idx[i] += qstep; |
| 731 | } | ||
| 732 | } | ||
| 733 | } else { | 727 | } else { |
| 734 | for (i = 0; i < 128; i++) { | 728 | for (i = 0; i < 128; i++) |
| 735 | if (sce->sf_idx[i] > 60 - qstep) { | 729 | if (sce->sf_idx[i] > 60 - qstep) |
| 736 | sce->sf_idx[i] -= qstep; | 730 | sce->sf_idx[i] -= qstep; |
| 737 | } | ||
| 738 | } | ||
| 739 | } | 731 | } |
| 740 | qstep >>= 1; | 732 | qstep >>= 1; |
| 741 | if (!qstep && tbits > destbits*1.02) | 733 | if (!qstep && tbits > destbits*1.02) |
| 742 | qstep = 1; | 734 | qstep = 1; |
| 743 | if (sce->sf_idx[0] >= 217)break; | 735 | if (sce->sf_idx[0] >= 217) |
| 736 | break; | ||
| 744 | } while (qstep); | 737 | } while (qstep); |
| 745 | 738 | ||
| 746 | fflag = 0; | 739 | fflag = 0; |
| @@ -916,7 +909,8 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 169 unmodified lines | |||
| 916 | else | 909 | else |
| 917 | minq = FFMIN(minq, sce->sf_idx[i]); | 910 | minq = FFMIN(minq, sce->sf_idx[i]); |
| 918 | } | 911 | } |
| 919 | if (minq == INT_MAX) minq = 0; | 912 | if (minq == INT_MAX) |
| 913 | minq = 0; | ||
| 920 | minq = FFMIN(minq, SCALE_MAX_POS); | 914 | minq = FFMIN(minq, SCALE_MAX_POS); |
| 921 | maxsf = FFMIN(minq + SCALE_MAX_DIFF, SCALE_MAX_POS); | 915 | maxsf = FFMIN(minq + SCALE_MAX_DIFF, SCALE_MAX_POS); |
| 922 | for (i = 126; i >= 0; i--) { | 916 | for (i = 126; i >= 0; i--) { |
| @@ -951,7 +945,8 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s, · 28 unmodified lines | |||
| 951 | } | 945 | } |
| 952 | } | 946 | } |
| 953 | for (i = 0; i < 128; i++) { | 947 | for (i = 0; i < 128; i++) { |
| 954 | sce->sf_idx[i] = 140;//av_clip(sce->sf_idx[i], minq, minq + SCALE_MAX_DIFF - 1); | 948 | sce->sf_idx[i] = 140; |
| 949 | //av_clip(sce->sf_idx[i], minq, minq + SCALE_MAX_DIFF - 1); | ||
| 955 | } | 950 | } |
| 956 | //set the same quantizers inside window groups | 951 | //set the same quantizers inside window groups |
| 957 | for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) | 952 | for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) |