summaryrefslogtreecommitdiff
path: root/vp8/encoder/dct.c
diff options
context:
space:
mode:
Diffstat (limited to 'vp8/encoder/dct.c')
-rw-r--r--vp8/encoder/dct.c144
1 files changed, 119 insertions, 25 deletions
diff --git a/vp8/encoder/dct.c b/vp8/encoder/dct.c
index c15437f3e..c2f2d1117 100644
--- a/vp8/encoder/dct.c
+++ b/vp8/encoder/dct.c
@@ -10,7 +10,123 @@
#include <math.h>
-#include "vpx_config.h"
+#include "vpx_ports/config.h"
+
+
+
+
+
+
+void vp8_short_fdct8x8_c(short *block, short *coefs, int pitch)
+{
+ int j1, i, j, k;
+ float b[8];
+ float b1[8];
+ float d[8][8];
+ float f0 = (float) .7071068;
+ float f1 = (float) .4903926;
+ float f2 = (float) .4619398;
+ float f3 = (float) .4157348;
+ float f4 = (float) .3535534;
+ float f5 = (float) .2777851;
+ float f6 = (float) .1913417;
+ float f7 = (float) .0975452;
+ pitch = pitch / 2;
+ for (i = 0, k = 0; i < 8; i++, k += pitch)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ b[j] = (float)( block[k + j]<<3);
+ }
+ /* Horizontal transform */
+ for (j = 0; j < 4; j++)
+ {
+ j1 = 7 - j;
+ b1[j] = b[j] + b[j1];
+ b1[j1] = b[j] - b[j1];
+ }
+ b[0] = b1[0] + b1[3];
+ b[1] = b1[1] + b1[2];
+ b[2] = b1[1] - b1[2];
+ b[3] = b1[0] - b1[3];
+ b[4] = b1[4];
+ b[5] = (b1[6] - b1[5]) * f0;
+ b[6] = (b1[6] + b1[5]) * f0;
+ b[7] = b1[7];
+ d[i][0] = (b[0] + b[1]) * f4;
+ d[i][4] = (b[0] - b[1]) * f4;
+ d[i][2] = b[2] * f6 + b[3] * f2;
+ d[i][6] = b[3] * f6 - b[2] * f2;
+ b1[4] = b[4] + b[5];
+ b1[7] = b[7] + b[6];
+ b1[5] = b[4] - b[5];
+ b1[6] = b[7] - b[6];
+ d[i][1] = b1[4] * f7 + b1[7] * f1;
+ d[i][5] = b1[5] * f3 + b1[6] * f5;
+ d[i][7] = b1[7] * f7 - b1[4] * f1;
+ d[i][3] = b1[6] * f3 - b1[5] * f5;
+ }
+ /* Vertical transform */
+ for (i = 0; i < 8; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ j1 = 7 - j;
+ b1[j] = d[j][i] + d[j1][i];
+ b1[j1] = d[j][i] - d[j1][i];
+ }
+ b[0] = b1[0] + b1[3];
+ b[1] = b1[1] + b1[2];
+ b[2] = b1[1] - b1[2];
+ b[3] = b1[0] - b1[3];
+ b[4] = b1[4];
+ b[5] = (b1[6] - b1[5]) * f0;
+ b[6] = (b1[6] + b1[5]) * f0;
+ b[7] = b1[7];
+ d[0][i] = (b[0] + b[1]) * f4;
+ d[4][i] = (b[0] - b[1]) * f4;
+ d[2][i] = b[2] * f6 + b[3] * f2;
+ d[6][i] = b[3] * f6 - b[2] * f2;
+ b1[4] = b[4] + b[5];
+ b1[7] = b[7] + b[6];
+ b1[5] = b[4] - b[5];
+ b1[6] = b[7] - b[6];
+ d[1][i] = b1[4] * f7 + b1[7] * f1;
+ d[5][i] = b1[5] * f3 + b1[6] * f5;
+ d[7][i] = b1[7] * f7 - b1[4] * f1;
+ d[3][i] = b1[6] * f3 - b1[5] * f5;
+ }
+ for (i = 0; i < 8; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ *(coefs + j + i * 8) = (short) floor(d[i][j] +0.5);
+ }
+ }
+ return;
+}
+
+
+
+void vp8_short_fhaar2x2_c(short *input, short *output, int pitch) //pitch = 8
+{
+ /* [1 1 ; 1 -1] orthogonal transform */
+ /* use position: 0,1, 4, 8 */
+ int i;
+ short *ip1 = input;
+ short *op1 = output;
+ for (i = 0; i < 16; i++)
+ {
+ op1[i] = 0;
+ }
+
+ op1[0]=(ip1[0] + ip1[1] + ip1[4] + ip1[8] + 1)>>1;
+ op1[1]=(ip1[0] - ip1[1] + ip1[4] - ip1[8])>>1;
+ op1[4]=(ip1[0] + ip1[1] - ip1[4] - ip1[8])>>1;
+ op1[8]=(ip1[0] - ip1[1] - ip1[4] + ip1[8])>>1;
+
+}
+
void vp8_short_fdct4x4_c(short *input, short *output, int pitch)
{
int i;
@@ -20,17 +136,11 @@ void vp8_short_fdct4x4_c(short *input, short *output, int pitch)
for (i = 0; i < 4; i++)
{
-#if CONFIG_EXTEND_QRANGE
a1 = ((ip[0] + ip[3])<<5);
b1 = ((ip[1] + ip[2])<<5);
c1 = ((ip[1] - ip[2])<<5);
d1 = ((ip[0] - ip[3])<<5);
-#else
- a1 = ((ip[0] + ip[3])<<3);
- b1 = ((ip[1] + ip[2])<<3);
- c1 = ((ip[1] - ip[2])<<3);
- d1 = ((ip[0] - ip[3])<<3);
-#endif
+
op[0] = a1 + b1;
op[2] = a1 - b1;
@@ -78,22 +188,12 @@ void vp8_short_walsh4x4_c(short *input, short *output, int pitch)
for (i = 0; i < 4; i++)
{
-#if !CONFIG_EXTEND_QRANGE
- a1 = ((ip[0] + ip[2])<<2);
- d1 = ((ip[1] + ip[3])<<2);
- c1 = ((ip[1] - ip[3])<<2);
- b1 = ((ip[0] - ip[2])<<2);
-
- op[0] = a1 + d1 + (a1!=0);
-#else
a1 = ((ip[0] + ip[2]));
d1 = ((ip[1] + ip[3]));
c1 = ((ip[1] - ip[3]));
b1 = ((ip[0] - ip[2]));
-
op[0] = a1 + d1;
-#endif
op[1] = b1 + c1;
op[2] = b1 - c1;
op[3] = a1 - d1;
@@ -121,17 +221,11 @@ void vp8_short_walsh4x4_c(short *input, short *output, int pitch)
c2 += c2<0;
d2 += d2<0;
-#if !CONFIG_EXTEND_QRANGE
- op[0] = (a2+3) >> 3;
- op[4] = (b2+3) >> 3;
- op[8] = (c2+3) >> 3;
- op[12]= (d2+3) >> 3;
-#else
op[0] = (a2+1) >> 2;
op[4] = (b2+1) >> 2;
op[8] = (c2+1) >> 2;
op[12]= (d2+1) >> 2;
-#endif
+
ip++;
op++;
}