[FFmpeg-devel] [PATCHv2] avcodec/dcaenc: avoid wasteful cos calls
Ganesh Ajjanagadde
gajjanagadde at gmail.com
Thu Dec 10 01:36:26 CET 2015
cos has symmetry; use this.
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
---
libavcodec/dcaenc.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c
index 5a6bdac..6fcfb1a 100644
--- a/libavcodec/dcaenc.c
+++ b/libavcodec/dcaenc.c
@@ -169,8 +169,16 @@ static int encode_init(AVCodecContext *avctx)
if (!cos_table[0]) {
int j, k;
- for (i = 0; i < 2048; i++) {
+ cos_table[0] = 0x7fffffff;
+ cos_table[512] = 0;
+ cos_table[1024] = -cos_table[0];
+ for (i = 1; i < 512; i++) {
cos_table[i] = (int32_t)(0x7fffffff * cos(M_PI * i / 1024));
+ cos_table[1024-i] = -cos_table[i];
+ cos_table[1024+i] = -cos_table[i];
+ cos_table[2048-i] = cos_table[i];
+ }
+ for (i = 0; i < 2048; i++) {
cb_to_level[i] = (int32_t)(0x7fffffff * pow(10, -0.005 * i));
}
--
2.6.3
More information about the ffmpeg-devel
mailing list