diff options
author | Vitor Sessak <vitor1001@gmail.com> | 2009-10-18 16:29:10 +0000 |
---|---|---|
committer | Vitor Sessak <vitor1001@gmail.com> | 2009-10-18 16:29:10 +0000 |
commit | a0228397af9e6da22a4dd6da1b2833480e1ed7d5 (patch) | |
tree | 4b68022da44a540e051aa2509d9a22c6e9efa1e7 | |
parent | 8da1d52cc112090eea226f4b0216da7fc683fc0b (diff) | |
download | ffmpeg-a0228397af9e6da22a4dd6da1b2833480e1ed7d5.tar.gz |
Replace big square-root table by a call to ff_sqrt(). Based on a patch
by Reimar Döffinger.
Originally committed as revision 20281 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/roqaudioenc.c | 21 |
1 files 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; i<MAX_DPCM; i++) { - int s= ff_sqrt(i); - int mid= s*s + s; - dpcmValues[i]= s + (i>mid); - } -} - 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: |