[FFmpeg-devel] [PATCH 05/11] aacenc: add support for coding of intensity stereo scalefactor indices
Claudio Freire
klaussfreire at gmail.com
Mon Jun 29 07:23:33 CEST 2015
Seems straightforward enough. LGTM.
On Fri, Jun 26, 2015 at 5:16 PM, Rostislav Pehlivanov
<atomnuker at gmail.com> wrote:
> This commit adds support for the coding of intensity stereo scalefactor indices. It does not do any marking of such bands and as such does no functional changes to the encoder. It removes any old twoloop specific code for PNS and moves it into a seperate function which handles setting of scalefactor indices for PNS and IS bands.
> ---
> libavcodec/aaccoder.c | 37 +++++++++++++++++++++++++++++++++++++
> libavcodec/aacenc.c | 6 +++++-
> 2 files changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
> index 3c90d27..02ffe17 100644
> --- a/libavcodec/aaccoder.c
> +++ b/libavcodec/aaccoder.c
> @@ -607,6 +607,43 @@ typedef struct TrellisPath {
> #define TRELLIS_STAGES 121
> #define TRELLIS_STATES (SCALE_MAX_DIFF+1)
>
> +static void set_special_band_scalefactors(AACEncContext *s, SingleChannelElement *sce)
> +{
> + int w, g, start = 0;
> + int minscaler_n = sce->sf_idx[0], minscaler_i = sce->sf_idx[0];
> + int bands = 0;
> +
> + for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
> + start = 0;
> + for (g = 0; g < sce->ics.num_swb; g++) {
> + if (sce->band_type[w*16+g] == INTENSITY_BT || sce->band_type[w*16+g] == INTENSITY_BT2) {
> + sce->sf_idx[w*16+g] = av_clip(ceilf(log2f(sce->is_ener[w*16+g])*2), -155, 100);
> + minscaler_i = FFMIN(minscaler_i, sce->sf_idx[w*16+g]);
> + bands++;
> + } else if (sce->band_type[w*16+g] == NOISE_BT) {
> + sce->sf_idx[w*16+g] = av_clip(4+log2f(sce->pns_ener[w*16+g])*2, -100, 155);
> + minscaler_n = FFMIN(minscaler_n, sce->sf_idx[w*16+g]);
> + bands++;
> + }
> + start += sce->ics.swb_sizes[g];
> + }
> + }
> +
> + if (!bands)
> + return;
> +
> + /* Clip the scalefactor indices */
> + for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
> + for (g = 0; g < sce->ics.num_swb; g++) {
> + if (sce->band_type[w*16+g] == INTENSITY_BT || sce->band_type[w*16+g] == INTENSITY_BT2) {
> + sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler_i, minscaler_i + SCALE_MAX_DIFF);
> + } else if (sce->band_type[w*16+g] == NOISE_BT) {
> + sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler_n, minscaler_n + SCALE_MAX_DIFF);
> + }
> + }
> + }
> +}
> +
> static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s,
> SingleChannelElement *sce,
> const float lambda)
> diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
> index 897c3a1..3a512ff 100644
> --- a/libavcodec/aacenc.c
> +++ b/libavcodec/aacenc.c
> @@ -389,7 +389,7 @@ static void encode_scale_factors(AVCodecContext *avctx, AACEncContext *s,
> SingleChannelElement *sce)
> {
> int diff, off_sf = sce->sf_idx[0], off_pns = sce->sf_idx[0] - NOISE_OFFSET;
> - int noise_flag = 1;
> + int off_is = 0, noise_flag = 1;
> int i, w;
>
> for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
> @@ -402,6 +402,10 @@ static void encode_scale_factors(AVCodecContext *avctx, AACEncContext *s,
> put_bits(&s->pb, NOISE_PRE_BITS, diff + NOISE_PRE);
> continue;
> }
> + } else if (sce->band_type[w*16 + i] == INTENSITY_BT ||
> + sce->band_type[w*16 + i] == INTENSITY_BT2) {
> + diff = sce->sf_idx[w*16 + i] - off_is;
> + off_is = sce->sf_idx[w*16 + i];
> } else {
> diff = sce->sf_idx[w*16 + i] - off_sf;
> off_sf = sce->sf_idx[w*16 + i];
> --
> 2.1.4
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
More information about the ffmpeg-devel
mailing list