cleanup
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 3 Aug 2004 02:34:50 +0000 (02:34 +0000)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 3 Aug 2004 02:34:50 +0000 (02:34 +0000)
Originally committed as revision 3377 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavcodec/snow.c

index 99e39a1..6b8081b 100644 (file)
@@ -1053,11 +1053,11 @@ STOP_TIMER("vertical_decompose97i")
     }
 }
 
-static void spatial_dwt(SnowContext *s, int *buffer, int width, int height, int stride){
+void ff_spatial_dwt(int *buffer, int width, int height, int stride, int type, int decomposition_count){
     int level;
     
-    for(level=0; level<s->spatial_decomposition_count; level++){
-        switch(s->spatial_decomposition_type){
+    for(level=0; level<decomposition_count; level++){
+        switch(type){
         case 0: spatial_decompose97i(buffer, width>>level, height>>level, stride<<level); break;
         case 1: spatial_decompose53i(buffer, width>>level, height>>level, stride<<level); break;
         case 2: spatial_decomposeX  (buffer, width>>level, height>>level, stride<<level); break;
@@ -1241,11 +1241,11 @@ STOP_TIMER("horizontal_compose97i")}}
     }
 }
 
-static void spatial_idwt(SnowContext *s, int *buffer, int width, int height, int stride){
+void ff_spatial_idwt(int *buffer, int width, int height, int stride, int type, int decomposition_count){
     int level;
 
-    for(level=s->spatial_decomposition_count-1; level>=0; level--){
-        switch(s->spatial_decomposition_type){
+    for(level=decomposition_count-1; level>=0; level--){
+        switch(type){
         case 0: spatial_compose97i(buffer, width>>level, height>>level, stride<<level); break;
         case 1: spatial_compose53i(buffer, width>>level, height>>level, stride<<level); break;
         case 2: spatial_composeX  (buffer, width>>level, height>>level, stride<<level); break;
@@ -2574,7 +2574,7 @@ static void calculate_vissual_weight(SnowContext *s, Plane *p){
             
             memset(s->spatial_dwt_buffer, 0, sizeof(int)*width*height);
             buf[b->width/2 + b->height/2*b->stride]= 256*256;
-            spatial_idwt(s, s->spatial_dwt_buffer, width, height, width);
+            ff_spatial_idwt(s->spatial_dwt_buffer, width, height, width, s->spatial_decomposition_type, s->spatial_decomposition_count);
             for(y=0; y<height; y++){
                 for(x=0; x<width; x++){
                     int64_t d= s->spatial_dwt_buffer[x + y*width];
@@ -2583,7 +2583,7 @@ static void calculate_vissual_weight(SnowContext *s, Plane *p){
             }
 
             b->qlog= (int)(log(352256.0/sqrt(error)) / log(pow(2.0, 1.0/QROOT))+0.5);
-            av_log(NULL, AV_LOG_DEBUG, "%d %d %d\n", level, orientation, b->qlog/*, sqrt(error)*/);
+//            av_log(NULL, AV_LOG_DEBUG, "%d %d %d\n", level, orientation, b->qlog/*, sqrt(error)*/);
         }
     }
 }
@@ -2894,7 +2894,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
             }
         }
  
-        spatial_dwt(s, s->spatial_dwt_buffer, w, h, w);
+        ff_spatial_dwt(s->spatial_dwt_buffer, w, h, w, s->spatial_decomposition_type, s->spatial_decomposition_count);
 
         for(level=0; level<s->spatial_decomposition_count; level++){
             for(orientation=level ? 1 : 0; orientation<4; orientation++){
@@ -2919,7 +2919,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
             }
         }
 
-        spatial_idwt(s, s->spatial_dwt_buffer, w, h, w);
+        ff_spatial_idwt(s->spatial_dwt_buffer, w, h, w, s->spatial_decomposition_type, s->spatial_decomposition_count);
         if(s->qlog == LOSSLESS_QLOG){
             for(y=0; y<h; y++){
                 for(x=0; x<w; x++){
@@ -3063,7 +3063,7 @@ if(!(s->avctx->debug&1024))
             }
         }
 
-        spatial_idwt(s, s->spatial_dwt_buffer, w, h, w);
+        ff_spatial_idwt(s->spatial_dwt_buffer, w, h, w, s->spatial_decomposition_type, s->spatial_decomposition_count);
         if(s->qlog == LOSSLESS_QLOG){
             for(y=0; y<h; y++){
                 for(x=0; x<w; x++){
@@ -3152,8 +3152,8 @@ int main(){
     for(i=0; i<width*height; i++)
         buffer[0][i]= buffer[1][i]= random()%54321 - 12345;
     
-    spatial_dwt(&s, buffer[0], width, height, width);
-    spatial_idwt(&s, buffer[0], width, height, width);
+    ff_spatial_dwt(buffer[0], width, height, width, s->spatial_decomposition_type, s->spatial_decomposition_count);
+    ff_spatial_idwt(buffer[0], width, height, width, s->spatial_decomposition_type, s->spatial_decomposition_count);
     
     for(i=0; i<width*height; i++)
         if(buffer[0][i]!= buffer[1][i]) printf("fsck: %d %d %d\n",i, buffer[0][i], buffer[1][i]);
@@ -3163,8 +3163,8 @@ int main(){
     for(i=0; i<width*height; i++)
         buffer[0][i]= buffer[1][i]= random()%54321 - 12345;
     
-    spatial_dwt(&s, buffer[0], width, height, width);
-    spatial_idwt(&s, buffer[0], width, height, width);
+    ff_spatial_dwt(buffer[0], width, height, width, s->spatial_decomposition_type, s->spatial_decomposition_count);
+    ff_spatial_idwt(buffer[0], width, height, width, s->spatial_decomposition_type, s->spatial_decomposition_count);
     
     for(i=0; i<width*height; i++)
         if(buffer[0][i]!= buffer[1][i]) printf("fsck: %d %d %d\n",i, buffer[0][i], buffer[1][i]);
@@ -3213,7 +3213,7 @@ int64_t g=0;
             
             memset(buffer[0], 0, sizeof(int)*width*height);
             buf[w/2 + h/2*stride]= 256*256;
-            spatial_idwt(&s, buffer[0], width, height, width);
+            ff_spatial_idwt(buffer[0], width, height, width, s->spatial_decomposition_type, s->spatial_decomposition_count);
             for(y=0; y<height; y++){
                 for(x=0; x<width; x++){
                     int64_t d= buffer[0][x + y*width];
@@ -3257,7 +3257,7 @@ int64_t g=0;
                     buffer[0][x+width*y]= 256*256*tab[(x&1) + 2*(y&1)];
                 }
             }
-            spatial_dwt(&s, buffer[0], width, height, width);
+            ff_spatial_dwt(buffer[0], width, height, width, s->spatial_decomposition_type, s->spatial_decomposition_count);
 #else
             for(y=0; y<h; y++){
                 for(x=0; x<w; x++){
@@ -3265,7 +3265,7 @@ int64_t g=0;
                     buf[x + y*stride-w]=64;
                 }
             }
-            spatial_idwt(&s, buffer[0], width, height, width);
+            ff_spatial_idwt(buffer[0], width, height, width, s->spatial_decomposition_type, s->spatial_decomposition_count);
 #endif
             for(y=0; y<height; y++){
                 for(x=0; x<width; x++){