[FFmpeg-cvslog] r20281 - trunk/libavcodec/roqaudioenc.c

vitor subversion
Sun Oct 18 18:29:11 CEST 2009


Author: vitor
Date: Sun Oct 18 18:29:10 2009
New Revision: 20281

Log:
Replace big square-root table by a call to ff_sqrt(). Based on a patch 
by Reimar D?ffinger.

Modified:
   trunk/libavcodec/roqaudioenc.c

Modified: trunk/libavcodec/roqaudioenc.c
==============================================================================
--- trunk/libavcodec/roqaudioenc.c	Sun Oct 18 18:13:29 2009	(r20280)
+++ trunk/libavcodec/roqaudioenc.c	Sun Oct 18 18:29:10 2009	(r20281)
@@ -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(
         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 
 
     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:



More information about the ffmpeg-cvslog mailing list