Commit 81c4e9b8 authored by vitor's avatar vitor

Replace big square-root table by a call to ff_sqrt(). Based on a patch

by Reimar Döffinger.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@20281 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent dfce2bd0
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#define MAX_DPCM (127*127) #define MAX_DPCM (127*127)
static unsigned char dpcmValues[MAX_DPCM];
typedef struct typedef struct
...@@ -37,18 +36,6 @@ typedef struct ...@@ -37,18 +36,6 @@ typedef struct
short lastSample[2]; short lastSample[2];
} ROQDPCMContext; } 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) static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx)
{ {
ROQDPCMContext *context = avctx->priv_data; ROQDPCMContext *context = avctx->priv_data;
...@@ -66,8 +53,6 @@ static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx) ...@@ -66,8 +53,6 @@ static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx)
return -1; return -1;
} }
roq_dpcm_table_init();
avctx->frame_size = ROQ_FIRST_FRAME_SIZE; avctx->frame_size = ROQ_FIRST_FRAME_SIZE;
context->lastSample[0] = context->lastSample[1] = 0; context->lastSample[0] = context->lastSample[1] = 0;
...@@ -92,8 +77,10 @@ static unsigned char dpcm_predict(short *previous, short current) ...@@ -92,8 +77,10 @@ static unsigned char dpcm_predict(short *previous, short current)
if (diff >= MAX_DPCM) if (diff >= MAX_DPCM)
result = 127; result = 127;
else else {
result = dpcmValues[diff]; result = ff_sqrt(diff);
result += diff > result*result+result;
}
/* See if this overflows */ /* See if this overflows */
retry: retry:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment