From a0228397af9e6da22a4dd6da1b2833480e1ed7d5 Mon Sep 17 00:00:00 2001 From: Vitor Sessak Date: Sun, 18 Oct 2009 16:29:10 +0000 Subject: [PATCH] =?UTF-8?q?Replace=20big=20square-root=20table=20by=20a=20?= =?UTF-8?q?call=20to=20ff=5Fsqrt().=20Based=20on=20a=20patch=20by=20Reimar?= =?UTF-8?q?=20D=C3=B6ffinger.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Originally committed as revision 20281 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/roqaudioenc.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/libavcodec/roqaudioenc.c b/libavcodec/roqaudioenc.c index 9cff80c0aa..acb1b5f5a6 100644 --- a/libavcodec/roqaudioenc.c +++ b/libavcodec/roqaudioenc.c @@ -29,7 +29,6 @@ #define MAX_DPCM (127*127) -static unsigned char dpcmValues[MAX_DPCM]; typedef struct @@ -37,18 +36,6 @@ typedef struct short lastSample[2]; } ROQDPCMContext; -static av_cold void roq_dpcm_table_init(void) -{ - int i; - - /* Create a table of quick DPCM values */ - for (i=0; imid); - } -} - static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx) { ROQDPCMContext *context = avctx->priv_data; @@ -66,8 +53,6 @@ static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx) return -1; } - roq_dpcm_table_init(); - avctx->frame_size = ROQ_FIRST_FRAME_SIZE; context->lastSample[0] = context->lastSample[1] = 0; @@ -92,8 +77,10 @@ static unsigned char dpcm_predict(short *previous, short current) if (diff >= MAX_DPCM) result = 127; - else - result = dpcmValues[diff]; + else { + result = ff_sqrt(diff); + result += diff > result*result+result; + } /* See if this overflows */ retry: