src/dctexample.c
changeset 253 e3aa70211aee
parent 227 f2a4f54d3fc8
--- a/src/dctexample.c	Sun Dec 14 20:00:34 2008 +0000
+++ b/src/dctexample.c	Mon Dec 15 01:06:43 2008 +0000
@@ -131,6 +131,17 @@
     float input_dct[64];
     float output_dct[64];
     float output[64];
+    float quantize[64] = {
+        20, 14, 13, 20, 30, 50, 64, 76, 
+        15, 15, 18, 24, 33, 73, 75, 69, 
+        18, 16, 20, 30, 50, 71, 86, 70, 
+        18, 21, 28, 36, 64, 109, 100, 78, 
+        23, 28, 46, 70, 85, 136, 129, 96, 
+        30, 44, 69, 80, 101, 130, 141, 115, 
+        61, 80, 98, 109, 129, 151, 150, 126, 
+        90, 115, 119, 123, 140, 125, 129, 124 };
+
+
     struct bitmap obmap;
     int i,j,k;
 
@@ -153,6 +164,33 @@
         }
 
     mydct(input, input_dct);
+
+    {
+        FILE *odct, *ifile, *qtable, *qfile;
+        odct = fopen("dct.txt", "wt");
+        ifile = fopen("ifile.txt", "wt");
+        qtable = fopen("qtable.txt", "wt");
+        qfile = fopen("qfile.txt", "wt");
+        for(j=0;j < 8; ++j)
+        {
+            fprintf(odct, "<tr>\n");
+            fprintf(ifile, "<tr>\n");
+            fprintf(qtable, "<tr>\n");
+            fprintf(qfile, "<tr>\n");
+            for(i=0;i < 8; ++i)
+            {
+                fprintf(odct, "<td>%.2f\n", input_dct[j*8+i]);
+                fprintf(ifile, "<td>%.0f\n", input[j*8+i]);
+                fprintf(qtable, "<td>%.0f\n", quantize[j*8+i]);
+                fprintf(qfile, "<td>%i\n", lrint(input_dct[j*8+i]/quantize[j*8+i]));
+            }
+        }
+        fclose(odct);
+        fclose(ifile);
+        fclose(qtable);
+        fclose(qfile);
+    }
+
     myidct(input_dct, input_test);
 
     obmap = bitmap_alloc(1, 64+7, 64+7);