media/libvpx/vp8/encoder/dct.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libvpx/vp8/encoder/dct.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,116 @@
     1.4 +/*
     1.5 + *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
     1.6 + *
     1.7 + *  Use of this source code is governed by a BSD-style license
     1.8 + *  that can be found in the LICENSE file in the root of the source
     1.9 + *  tree. An additional intellectual property rights grant can be found
    1.10 + *  in the file PATENTS.  All contributing project authors may
    1.11 + *  be found in the AUTHORS file in the root of the source tree.
    1.12 + */
    1.13 +
    1.14 +
    1.15 +#include <math.h>
    1.16 +
    1.17 +void vp8_short_fdct4x4_c(short *input, short *output, int pitch)
    1.18 +{
    1.19 +    int i;
    1.20 +    int a1, b1, c1, d1;
    1.21 +    short *ip = input;
    1.22 +    short *op = output;
    1.23 +
    1.24 +    for (i = 0; i < 4; i++)
    1.25 +    {
    1.26 +        a1 = ((ip[0] + ip[3]) * 8);
    1.27 +        b1 = ((ip[1] + ip[2]) * 8);
    1.28 +        c1 = ((ip[1] - ip[2]) * 8);
    1.29 +        d1 = ((ip[0] - ip[3]) * 8);
    1.30 +
    1.31 +        op[0] = a1 + b1;
    1.32 +        op[2] = a1 - b1;
    1.33 +
    1.34 +        op[1] = (c1 * 2217 + d1 * 5352 +  14500)>>12;
    1.35 +        op[3] = (d1 * 2217 - c1 * 5352 +   7500)>>12;
    1.36 +
    1.37 +        ip += pitch / 2;
    1.38 +        op += 4;
    1.39 +
    1.40 +    }
    1.41 +    ip = output;
    1.42 +    op = output;
    1.43 +    for (i = 0; i < 4; i++)
    1.44 +    {
    1.45 +        a1 = ip[0] + ip[12];
    1.46 +        b1 = ip[4] + ip[8];
    1.47 +        c1 = ip[4] - ip[8];
    1.48 +        d1 = ip[0] - ip[12];
    1.49 +
    1.50 +        op[0]  = ( a1 + b1 + 7)>>4;
    1.51 +        op[8]  = ( a1 - b1 + 7)>>4;
    1.52 +
    1.53 +        op[4]  =((c1 * 2217 + d1 * 5352 +  12000)>>16) + (d1!=0);
    1.54 +        op[12] = (d1 * 2217 - c1 * 5352 +  51000)>>16;
    1.55 +
    1.56 +        ip++;
    1.57 +        op++;
    1.58 +    }
    1.59 +}
    1.60 +
    1.61 +void vp8_short_fdct8x4_c(short *input, short *output, int pitch)
    1.62 +{
    1.63 +    vp8_short_fdct4x4_c(input,   output,    pitch);
    1.64 +    vp8_short_fdct4x4_c(input + 4, output + 16, pitch);
    1.65 +}
    1.66 +
    1.67 +void vp8_short_walsh4x4_c(short *input, short *output, int pitch)
    1.68 +{
    1.69 +    int i;
    1.70 +    int a1, b1, c1, d1;
    1.71 +    int a2, b2, c2, d2;
    1.72 +    short *ip = input;
    1.73 +    short *op = output;
    1.74 +
    1.75 +
    1.76 +    for (i = 0; i < 4; i++)
    1.77 +    {
    1.78 +        a1 = ((ip[0] + ip[2]) * 4);
    1.79 +        d1 = ((ip[1] + ip[3]) * 4);
    1.80 +        c1 = ((ip[1] - ip[3]) * 4);
    1.81 +        b1 = ((ip[0] - ip[2]) * 4);
    1.82 +
    1.83 +        op[0] = a1 + d1 + (a1!=0);
    1.84 +        op[1] = b1 + c1;
    1.85 +        op[2] = b1 - c1;
    1.86 +        op[3] = a1 - d1;
    1.87 +        ip += pitch / 2;
    1.88 +        op += 4;
    1.89 +    }
    1.90 +
    1.91 +    ip = output;
    1.92 +    op = output;
    1.93 +
    1.94 +    for (i = 0; i < 4; i++)
    1.95 +    {
    1.96 +        a1 = ip[0] + ip[8];
    1.97 +        d1 = ip[4] + ip[12];
    1.98 +        c1 = ip[4] - ip[12];
    1.99 +        b1 = ip[0] - ip[8];
   1.100 +
   1.101 +        a2 = a1 + d1;
   1.102 +        b2 = b1 + c1;
   1.103 +        c2 = b1 - c1;
   1.104 +        d2 = a1 - d1;
   1.105 +
   1.106 +        a2 += a2<0;
   1.107 +        b2 += b2<0;
   1.108 +        c2 += c2<0;
   1.109 +        d2 += d2<0;
   1.110 +
   1.111 +        op[0] = (a2+3) >> 3;
   1.112 +        op[4] = (b2+3) >> 3;
   1.113 +        op[8] = (c2+3) >> 3;
   1.114 +        op[12]= (d2+3) >> 3;
   1.115 +
   1.116 +        ip++;
   1.117 +        op++;
   1.118 +    }
   1.119 +}

mercurial