Adding code to od_intra.c for updating and printing the intra predictors.
authorNathan E. Egge <negge@dgql.org>
Mon, 6 May 2013 18:39:25 +0000 (14:39 -0400)
committerNathan E. Egge <negge@dgql.org>
Mon, 6 May 2013 18:39:25 +0000 (14:39 -0400)
tools/intra_pred.c
tools/intra_trace.c
tools/od_intra.c
tools/od_intra.h
tools/od_intra_data.c

index 9812043..71d782e 100644 (file)
@@ -371,70 +371,6 @@ static void comp_predictors(const prob_ctx *_prob,solve_ctx _sol[NUM_PROCS],
 #endif
 }
 
-static void update_predictors(int _mode,double *_beta_0,double *_beta_1,
- int _mask[B_SZ*B_SZ*4*B_SZ*B_SZ]){
-  int i;
-  int j;
-  for(i=0;i<B_SZ*B_SZ;i++){
-    int y;
-    int x;
-    int by;
-    int bx;
-    int n;
-    y=i/B_SZ;
-    x=i%B_SZ;
-#if B_SZ==4
-    NE_PRED_OFFSETS_4x4[_mode][y][x]=_beta_0[i];
-#elif B_SZ==8
-    NE_PRED_OFFSETS_8x8[_mode][y][x]=_beta_0[i];
-#elif B_SZ==16
-    NE_PRED_OFFSETS_16x16[_mode][y][x]=_beta_0[i];
-#else
-# error "Need predictors for this block size."
-#endif
-    n=0;
-    for(by=0;by<=1;by++){
-      for(bx=0;bx<=(1-by)<<1;bx++){
-        for(j=0;j<B_SZ*B_SZ;j++){
-          int v;
-          int u;
-          int ij;
-          v=j/B_SZ;
-          u=j%B_SZ;
-         ij=4*B_SZ*B_SZ*i+(3*by+bx)*B_SZ*B_SZ+j;
-          if(_mask[ij]){
-#if B_SZ==4
-            NE_PRED_WEIGHTS_4x4[_mode][y][x][n]=_beta_1[ij];
-            NE_PRED_PARAMX_4x4[_mode][y][x][n]=B_SZ*bx+u;
-            NE_PRED_PARAMY_4x4[_mode][y][x][n]=B_SZ*by+v;
-#elif B_SZ==8
-            NE_PRED_WEIGHTS_8x8[_mode][y][x][n]=_beta_1[ij];
-            NE_PRED_PARAMX_8x8[_mode][y][x][n]=B_SZ*bx+u;
-            NE_PRED_PARAMY_8x8[_mode][y][x][n]=B_SZ*by+v;
-#elif B_SZ==16
-            NE_PRED_WEIGHTS_16x16[_mode][y][x][n]=_beta_1[ij];
-            NE_PRED_PARAMX_16x16[_mode][y][x][n]=B_SZ*bx+u;
-            NE_PRED_PARAMY_16x16[_mode][y][x][n]=B_SZ*by+v;
-#else
-# error "Need predictors for this block size."
-#endif
-            n++;
-          }
-        }
-      }
-    }
-#if B_SZ==4
-    NE_PRED_MULTS_4x4[_mode][y][x]=n;
-#elif B_SZ==8
-    NE_PRED_MULTS_8x8[_mode][y][x]=n;
-#elif B_SZ==16
-    NE_PRED_MULTS_16x16[_mode][y][x]=n;
-#else
-# error "Need predictors for this block size."
-#endif
-  }
-}
-
 #if PRINT_PROGRESS
 static void print_progress(FILE *_fp,const char *_proc){
   int tid;
@@ -814,7 +750,7 @@ int main(int _argc,const char *_argv[]){
       solve_ctx_clear(&sol[i]);
     }
 #if PRINT_BETAS
-    print_betas(stderr);
+    print_predictors(stderr);
 #endif
   }
   for(i=0;i<NUM_PROCS;i++){
index 7cd8cf7..9e53fb7 100644 (file)
@@ -192,7 +192,7 @@ static void intra_trace_ctx_step(intra_trace_ctx *_ctx,od_rgba16_image *_image,
     for(j=0;j<2*B_SZ;j++){
       for(i=0;i<2*B_SZ;i++){
         od_coeff v;
-       v=(_ctx->img.post[2*B_SZ*j+i]+INPUT_SCALE*128+INPUT_SCALE/2)/INPUT_SCALE;
+        v=(_ctx->img.post[2*B_SZ*j+i]+INPUT_SCALE*128+INPUT_SCALE/2)/INPUT_SCALE;
         if(_ctx->min[m]>v){
           _ctx->min[m]=v;
         }
index aa11d72..4fe57e1 100644 (file)
@@ -78,7 +78,7 @@ static void ne_intra_pred16x16_mult(double *_pred,int _pred_stride,
         x=NE_PRED_PARAMX_16x16[_mode][j][i][k];
         y=NE_PRED_PARAMY_16x16[_mode][j][i][k];
         _pred[_pred_stride*j+i]+=_coeff[_coeff_stride*(y-16)+(x-16)]*
-        NE_PRED_WEIGHTS_16x16[_mode][j][i][k];
+         NE_PRED_WEIGHTS_16x16[_mode][j][i][k];
       }
     }
   }
@@ -90,7 +90,71 @@ const ne_intra_mult_func NE_INTRA_MULT[OD_NBSIZES]={
   ne_intra_pred16x16_mult
 };
 
-void print_betas(FILE *_fp){
+void update_predictors(int _mode,double *_beta_0,double *_beta_1,
+ int _mask[B_SZ*B_SZ*4*B_SZ*B_SZ]){
+  int i;
+  int j;
+  for(i=0;i<B_SZ*B_SZ;i++){
+    int y;
+    int x;
+    int by;
+    int bx;
+    int n;
+    y=i/B_SZ;
+    x=i%B_SZ;
+#if B_SZ==4
+    NE_PRED_OFFSETS_4x4[_mode][y][x]=_beta_0[i];
+#elif B_SZ==8
+    NE_PRED_OFFSETS_8x8[_mode][y][x]=_beta_0[i];
+#elif B_SZ==16
+    NE_PRED_OFFSETS_16x16[_mode][y][x]=_beta_0[i];
+#else
+# error "Need predictors for this block size."
+#endif
+    n=0;
+    for(by=0;by<=1;by++){
+      for(bx=0;bx<=(1-by)<<1;bx++){
+        for(j=0;j<B_SZ*B_SZ;j++){
+          int v;
+          int u;
+          int ij;
+          v=j/B_SZ;
+          u=j%B_SZ;
+          ij=4*B_SZ*B_SZ*i+(3*by+bx)*B_SZ*B_SZ+j;
+          if(_mask[ij]){
+#if B_SZ==4
+            NE_PRED_WEIGHTS_4x4[_mode][y][x][n]=_beta_1[ij];
+            NE_PRED_PARAMX_4x4[_mode][y][x][n]=B_SZ*bx+u;
+            NE_PRED_PARAMY_4x4[_mode][y][x][n]=B_SZ*by+v;
+#elif B_SZ==8
+            NE_PRED_WEIGHTS_8x8[_mode][y][x][n]=_beta_1[ij];
+            NE_PRED_PARAMX_8x8[_mode][y][x][n]=B_SZ*bx+u;
+            NE_PRED_PARAMY_8x8[_mode][y][x][n]=B_SZ*by+v;
+#elif B_SZ==16
+            NE_PRED_WEIGHTS_16x16[_mode][y][x][n]=_beta_1[ij];
+            NE_PRED_PARAMX_16x16[_mode][y][x][n]=B_SZ*bx+u;
+            NE_PRED_PARAMY_16x16[_mode][y][x][n]=B_SZ*by+v;
+#else
+# error "Need predictors for this block size."
+#endif
+            n++;
+          }
+        }
+      }
+    }
+#if B_SZ==4
+    NE_PRED_MULTS_4x4[_mode][y][x]=n;
+#elif B_SZ==8
+    NE_PRED_MULTS_8x8[_mode][y][x]=n;
+#elif B_SZ==16
+    NE_PRED_MULTS_16x16[_mode][y][x]=n;
+#else
+# error "Need predictors for this block size."
+#endif
+  }
+}
+
+void print_predictors(FILE *_fp){
   int m;
   int j;
   int i;
@@ -235,3 +299,90 @@ void print_betas(FILE *_fp){
   fprintf(_fp,"};\n");
   fflush(_fp);
 }
+
+void print_predictors_nonsparse(FILE *_fp){
+  int m;
+  int i;
+  int j;
+  int k;
+  int l;
+  int bx;
+  int by;
+  fprintf(_fp,"double NE_PRED_OFFSETS_%ix%i[OD_INTRA_NMODES][%i][%i]={\n",
+   B_SZ,B_SZ,B_SZ,B_SZ);
+  for(m=0;m<OD_INTRA_NMODES;m++){
+    fprintf(_fp,"/* Mode %i */\n  {\n",m);
+    for(j=0;j<B_SZ;j++){
+      fprintf(_fp,"    {");
+      for(i=0;i<B_SZ;i++){
+#if B_SZ==4
+        fprintf(_fp,"%s  %- 24.18G",i>0?",":"",NE_PRED_OFFSETS_4x4[m][j][i]);
+#elif B_SZ==8
+        fprintf(_fp,"%s  %- 24.18G",i>0?",":"",NE_PRED_OFFSETS_8x8[m][j][i]);
+#elif B_SZ==16
+        fprintf(_fp,"%s  %- 24.18G",i>0?",":"",NE_PRED_OFFSETS_16x16[m][j][i]);
+#else
+# error "Unsupported block size."
+#endif
+      }
+      fprintf(_fp,"  }%s\n",j<B_SZ-1?",":"");
+    }
+    fprintf(_fp,"  }%s\n",m<OD_INTRA_NMODES-1?",":"");
+  }
+  fprintf(_fp,"};\n");
+  fprintf(_fp,
+   "double NE_PRED_WEIGHTS_%ix%i[OD_INTRA_NMODES][%i][%i][2*%i][3*%i]={\n",
+   B_SZ,B_SZ,B_SZ,B_SZ,B_SZ,B_SZ);
+  for(m=0;m<OD_INTRA_NMODES;m++){
+    fprintf(_fp,"  {\n");
+    for(j=0;j<B_SZ;j++){
+      fprintf(_fp,"    {\n");
+      for(i=0;i<B_SZ;i++){
+        double w[2*B_SZ][3*B_SZ];
+        fprintf(_fp,"/* Mode %i (%i,%i) */\n      {\n",m,j,i);
+        for(k=0;k<2*B_SZ;k++){
+          for(l=0;l<3*B_SZ;l++){
+            w[k][l]=0;
+          }
+        }
+#if B_SZ==4
+        for(k=0;k<NE_PRED_MULTS_4x4[m][j][i];k++){
+          int u=NE_PRED_PARAMX_4x4[m][j][i][k];
+          int v=NE_PRED_PARAMY_4x4[m][j][i][k];
+          w[v][u]=NE_PRED_WEIGHTS_4x4[m][j][i][k];
+        }
+#elif B_SZ==8
+        for(k=0;k<NE_PRED_MULTS_8x8[m][j][i];k++){
+          int u=NE_PRED_PARAMX_8x8[m][j][i][k];
+          int v=NE_PRED_PARAMY_8x8[m][j][i][k];
+          w[v][u]=NE_PRED_WEIGHTS_8x8[m][j][i][k];
+        }
+#elif B_SZ==16
+        for(k=0;k<NE_PRED_MULTS_16x16[m][j][i];k++){
+          int u=NE_PRED_PARAMX_16x16[m][j][i][k];
+          int v=NE_PRED_PARAMY_16x16[m][j][i][k];
+          w[v][u]=NE_PRED_WEIGHTS_16x16[m][j][i][k];
+        }
+#else
+# error "Unsupported block size."
+#endif
+        for(by=0;by<=1;by++){
+          for(k=0;k<B_SZ;k++){
+            fprintf(_fp,"        {");
+            for(bx=0;bx<=(1-by)<<1;bx++){
+              for(l=0;l<B_SZ;l++){
+                fprintf(_fp,"%s  %- 24.18G",bx>0||l>0?",":"",
+                 w[B_SZ*by+k][B_SZ*bx+l]);
+              }
+            }
+            fprintf(_fp,"  }%s\n",by<1||k<B_SZ-1?",":"");
+          }
+        }
+        fprintf(_fp,"      }%s\n",i<B_SZ-1?",":"");
+      }
+      fprintf(_fp,"    }%s\n",j<B_SZ-1?",":"");
+    }
+    fprintf(_fp,"  }%s\n",m<OD_INTRA_NMODES-1?",":"");
+  }
+  fprintf(_fp,"};\n");
+}
index 388ff90..e2b99e9 100644 (file)
@@ -54,6 +54,9 @@ extern int NE_PRED_MULTS_16x16[OD_INTRA_NMODES][16][16];
 extern int NE_PRED_PARAMX_16x16[OD_INTRA_NMODES][16][16][4*16*16];
 extern int NE_PRED_PARAMY_16x16[OD_INTRA_NMODES][16][16][4*16*16];
 
-void print_betas(FILE *_fp);
+void update_predictors(int _mode,double *_beta_0,double *_beta_1,
+ int _mask[B_SZ*B_SZ*4*B_SZ*B_SZ]);
+void print_predictors(FILE *_fp);
+void print_predictors_nonsparse(FILE *_fp);
 
 #endif
index bb790a2..f79472b 100644 (file)
@@ -1,4 +1,5 @@
-#include "stats_tools.h"
+#include "od_defs.h"
+#include "od_intra.h"
 
 double NE_PRED_OFFSETS_4x4[OD_INTRA_NMODES][4][4]={
 /* Mode 0 */