]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/fdctref.c
better non conformant divx packed bitstream detection, so unpacked (no b frames)...
[ffmpeg] / libavcodec / fdctref.c
index 5038e67538f21a9fb536d6fc38a3626ef9ff4c11..d728727ce64707c16078604ee2c8200ffa9a6ba0 100644 (file)
@@ -1,4 +1,7 @@
-/* fdctref.c, forward discrete cosine transform, double precision           */
+/**
+ * @file fdctref.c
+ * forward discrete cosine transform, double precision.
+ */
 
 /* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
 
@@ -29,8 +32,6 @@
 
 #include <math.h>
 
-// #include "config.h"
-
 #ifndef PI
 # ifdef M_PI
 #  define PI M_PI
@@ -105,6 +106,7 @@ short *block;
                s += c[i][5] * tmp[8 * 5 + j];
                s += c[i][6] * tmp[8 * 6 + j];
                s += c[i][7] * tmp[8 * 7 + j];
+               s*=8.0;
 
                block[8 * i + j] = (short)floor(s + 0.499999);
 /*
@@ -118,3 +120,39 @@ short *block;
  */
       }
 }
+
+/* perform IDCT matrix multiply for 8x8 coefficient block */
+
+void idct(block)
+short *block;
+{
+  int i, j, k, v;
+  double partial_product;
+  double tmp[64];
+
+  for (i=0; i<8; i++)
+    for (j=0; j<8; j++)
+    {
+      partial_product = 0.0;
+
+      for (k=0; k<8; k++)
+        partial_product+= c[k][j]*block[8*i+k];
+
+      tmp[8*i+j] = partial_product;
+    }
+
+  /* Transpose operation is integrated into address mapping by switching 
+     loop order of i and j */
+
+  for (j=0; j<8; j++)
+    for (i=0; i<8; i++)
+    {
+      partial_product = 0.0;
+
+      for (k=0; k<8; k++)
+        partial_product+= c[k][i]*tmp[8*k+j];
+
+      v = (int) floor(partial_product+0.5);
+      block[8*i+j] = v;
+    }
+}