* Downscale spectral coefficients for near-clipping windows to avoid artifacts */
| 738 | * Downscale spectral coefficients for near-clipping windows to avoid artifacts |
| 739 | */ |
| 740 | static void avoid_clipping(AACEncContext *s, SingleChannelElement *sce) |
| 741 | { |
| 742 | int start, i, j, w; |
| 743 | |
| 744 | if (sce->ics.clip_avoidance_factor < 1.0f) { |
| 745 | for (w = 0; w < sce->ics.num_windows; w++) { |
| 746 | start = 0; |
| 747 | for (i = 0; i < sce->ics.max_sfb; i++) { |
| 748 | float *swb_coeffs = &sce->coeffs[start + w*128]; |
| 749 | for (j = 0; j < sce->ics.swb_sizes[i]; j++) |
| 750 | swb_coeffs[j] *= sce->ics.clip_avoidance_factor; |
| 751 | start += sce->ics.swb_sizes[i]; |
| 752 | } |
| 753 | } |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | /** |
| 758 | * Encode one channel of audio data. |