summaryrefslogtreecommitdiff
path: root/libavcodec/aacenc_quantization.h
diff options
context:
space:
mode:
authorClaudio Freire <klaussfreire@gmail.com>2015-09-15 03:59:45 -0300
committerClaudio Freire <klaussfreire@gmail.com>2015-09-16 23:14:26 -0300
commit8df9bf8e39b5f38c75d63c0ef17965382e634b1c (patch)
treed9350e8cc6d1c1543facb7c58e477e669cc411f9 /libavcodec/aacenc_quantization.h
parent344d519040f03515bb915bf418f3ab9e38ada33b (diff)
downloadffmpeg-8df9bf8e39b5f38c75d63c0ef17965382e634b1c.tar.gz
AAC encoder: refactor to resynchronize MIPS port
This patch refactors the AAC coders to reuse code between the MIPS port and the regular, portable C code. There were two main functions that had to use hand-optimized versions of quantization code: - search_for_quantizers_twoloop - codebook_trellis_rate Those two were split into their own template header files so they can be inlined inside both the MIPS port and the generic code. In each context, they'll link to their specialized implementations, and thus be optimized by the compiler. This approach I believe is better than maintaining several copies of each function. As past experience has proven, having to keep those in sync was error prone. In this way, they will remain in sync by default. Also, an implementation of the dequantized output argument for the optimized quantize_and_encode functions is included in the patch. While the current implementation of search_for_pred still isn't using it, future iterations of main prediction probably will. It should not imply any measurable performance hit while not being used.
Diffstat (limited to 'libavcodec/aacenc_quantization.h')
-rw-r--r--libavcodec/aacenc_quantization.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/libavcodec/aacenc_quantization.h b/libavcodec/aacenc_quantization.h
index b514954e4d..6776dc37f7 100644
--- a/libavcodec/aacenc_quantization.h
+++ b/libavcodec/aacenc_quantization.h
@@ -249,6 +249,20 @@ static inline float quantize_band_cost(struct AACEncContext *s, const float *in,
cb, lambda, uplim, bits, rtz);
}
+static inline int quantize_band_cost_bits(struct AACEncContext *s, const float *in,
+ const float *scaled, int size, int scale_idx,
+ int cb, const float lambda, const float uplim,
+ int *bits, int rtz)
+{
+ int _bits;
+ quantize_and_encode_band_cost(s, NULL, in, NULL, scaled, size, scale_idx,
+ cb, 0.0f, uplim, &_bits, rtz);
+ if (bits) {
+ *bits = _bits;
+ }
+ return _bits;
+}
+
static inline void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb,
const float *in, float *out, int size, int scale_idx,
int cb, const float lambda, int rtz)