diff options
author | Rostislav Pehlivanov <atomnuker@gmail.com> | 2015-08-21 21:36:06 +0100 |
---|---|---|
committer | Rostislav Pehlivanov <atomnuker@gmail.com> | 2015-08-21 21:36:06 +0100 |
commit | 5df166e4305498d58db0350f78f7fade1ec0c029 (patch) | |
tree | 02ab5c045408a45fb5a04c4b824e2740dfb5b4cf /libavcodec/aacenc_tns.c | |
parent | 88a5f93f629a6eca96c348c40902a541f10ef467 (diff) | |
download | ffmpeg-5df166e4305498d58db0350f78f7fade1ec0c029.tar.gz |
aacenc_tns: re-enable coefficient compression
This time in a platform/compiler-generic way.
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Diffstat (limited to 'libavcodec/aacenc_tns.c')
-rw-r--r-- | libavcodec/aacenc_tns.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/libavcodec/aacenc_tns.c b/libavcodec/aacenc_tns.c index fd20923d7f..3b6e835067 100644 --- a/libavcodec/aacenc_tns.c +++ b/libavcodec/aacenc_tns.c @@ -49,12 +49,16 @@ static inline void conv_to_float(float *arr, int32_t *cof, int num) /* Input: quantized 4 bit coef, output: 1 if first (MSB) 2 bits are the same */ static inline int coef_test_compression(int coef) { - int res = 0; - /*coef = coef >> 3; - res += ffs(coef); - coef = coef >> 1; - res += ffs(coef);*/ - return 0; + int tmp = coef >> 2; + int res = ff_ctz(tmp); + if (res > 1) + return 1; /* ...00 -> compressable */ + else if (res == 1) + return 0; /* ...10 -> uncompressable */ + else if (ff_ctz(tmp >> 1) > 0) + return 0; /* ...0 1 -> uncompressable */ + else + return 1; /* ...1 1 -> compressable */ } static inline int compress_coef(int *coefs, int num) @@ -62,7 +66,7 @@ static inline int compress_coef(int *coefs, int num) int i, res = 0; for (i = 0; i < num; i++) res += coef_test_compression(coefs[i]); - return 0; + return res == num ? 1 : 0; } /** |