/*1* AAC encoder quantization2* Copyright (C) 2015 Claudio Freire3*4* This file is part of FFmpeg.5*6* FFmpeg is free software; you can redistribute it and/or7* modify it under the terms of the GNU Lesser General Public8* License as published by the Free Software Foundation; either9* version 2.1 of the License, or (at your option) any later version.10*11* FFmpeg is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU14* Lesser General Public License for more details.15*16* You should have received a copy of the GNU Lesser General Public17* License along with FFmpeg; if not, write to the Free Software18* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA19*/2021/**22* @file23* AAC encoder quantization misc reusable function templates24* @author Claudio Freire ( klaussfreire gmail com )25*/2627#ifndef AVCODEC_AACENC_QUANTIZATION_MISC_H28#define AVCODEC_AACENC_QUANTIZATION_MISC_H2930static inline float quantize_band_cost_cached(struct AACEncContext *s, int w, int g, const float *in,31const float *scaled, int size, int scale_idx,32int cb, const float lambda, const float uplim,33int *bits, float *energy, int rtz)34{35AACQuantizeBandCostCacheEntry *entry;36av_assert1(scale_idx >= 0 && scale_idx < 256);37entry = &s->quantize_band_cost_cache[scale_idx][w*16+g];38if (entry->bits < 0 || entry->cb != cb || entry->rtz != rtz) {39entry->rd = quantize_band_cost(s, in, scaled, size, scale_idx,40cb, lambda, uplim, &entry->bits, &entry->energy, rtz);41entry->cb = cb;42entry->rtz = rtz;43}44if (bits)45*bits = entry->bits;46if (energy)47*energy = entry->energy;48return entry->rd;49}5051#endif /* AVCODEC_AACENC_QUANTIZATION_MISC_H */525354