media/libvpx/vp8/common/idctllm.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libvpx/vp8/common/idctllm.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,204 @@
     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 +/****************************************************************************
    1.16 + * Notes:
    1.17 + *
    1.18 + * This implementation makes use of 16 bit fixed point verio of two multiply
    1.19 + * constants:
    1.20 + *         1.   sqrt(2) * cos (pi/8)
    1.21 + *         2.   sqrt(2) * sin (pi/8)
    1.22 + * Becuase the first constant is bigger than 1, to maintain the same 16 bit
    1.23 + * fixed point precision as the second one, we use a trick of
    1.24 + *         x * a = x + x*(a-1)
    1.25 + * so
    1.26 + *         x * sqrt(2) * cos (pi/8) = x + x * (sqrt(2) *cos(pi/8)-1).
    1.27 + **************************************************************************/
    1.28 +static const int cospi8sqrt2minus1 = 20091;
    1.29 +static const int sinpi8sqrt2      = 35468;
    1.30 +
    1.31 +void vp8_short_idct4x4llm_c(short *input, unsigned char *pred_ptr,
    1.32 +                            int pred_stride, unsigned char *dst_ptr,
    1.33 +                            int dst_stride)
    1.34 +{
    1.35 +    int i;
    1.36 +    int r, c;
    1.37 +    int a1, b1, c1, d1;
    1.38 +    short output[16];
    1.39 +    short *ip = input;
    1.40 +    short *op = output;
    1.41 +    int temp1, temp2;
    1.42 +    int shortpitch = 4;
    1.43 +
    1.44 +    for (i = 0; i < 4; i++)
    1.45 +    {
    1.46 +        a1 = ip[0] + ip[8];
    1.47 +        b1 = ip[0] - ip[8];
    1.48 +
    1.49 +        temp1 = (ip[4] * sinpi8sqrt2) >> 16;
    1.50 +        temp2 = ip[12] + ((ip[12] * cospi8sqrt2minus1) >> 16);
    1.51 +        c1 = temp1 - temp2;
    1.52 +
    1.53 +        temp1 = ip[4] + ((ip[4] * cospi8sqrt2minus1) >> 16);
    1.54 +        temp2 = (ip[12] * sinpi8sqrt2) >> 16;
    1.55 +        d1 = temp1 + temp2;
    1.56 +
    1.57 +        op[shortpitch*0] = a1 + d1;
    1.58 +        op[shortpitch*3] = a1 - d1;
    1.59 +
    1.60 +        op[shortpitch*1] = b1 + c1;
    1.61 +        op[shortpitch*2] = b1 - c1;
    1.62 +
    1.63 +        ip++;
    1.64 +        op++;
    1.65 +    }
    1.66 +
    1.67 +    ip = output;
    1.68 +    op = output;
    1.69 +
    1.70 +    for (i = 0; i < 4; i++)
    1.71 +    {
    1.72 +        a1 = ip[0] + ip[2];
    1.73 +        b1 = ip[0] - ip[2];
    1.74 +
    1.75 +        temp1 = (ip[1] * sinpi8sqrt2) >> 16;
    1.76 +        temp2 = ip[3] + ((ip[3] * cospi8sqrt2minus1) >> 16);
    1.77 +        c1 = temp1 - temp2;
    1.78 +
    1.79 +        temp1 = ip[1] + ((ip[1] * cospi8sqrt2minus1) >> 16);
    1.80 +        temp2 = (ip[3] * sinpi8sqrt2) >> 16;
    1.81 +        d1 = temp1 + temp2;
    1.82 +
    1.83 +
    1.84 +        op[0] = (a1 + d1 + 4) >> 3;
    1.85 +        op[3] = (a1 - d1 + 4) >> 3;
    1.86 +
    1.87 +        op[1] = (b1 + c1 + 4) >> 3;
    1.88 +        op[2] = (b1 - c1 + 4) >> 3;
    1.89 +
    1.90 +        ip += shortpitch;
    1.91 +        op += shortpitch;
    1.92 +    }
    1.93 +
    1.94 +    ip = output;
    1.95 +    for (r = 0; r < 4; r++)
    1.96 +    {
    1.97 +        for (c = 0; c < 4; c++)
    1.98 +        {
    1.99 +            int a = ip[c] + pred_ptr[c] ;
   1.100 +
   1.101 +            if (a < 0)
   1.102 +                a = 0;
   1.103 +
   1.104 +            if (a > 255)
   1.105 +                a = 255;
   1.106 +
   1.107 +            dst_ptr[c] = (unsigned char) a ;
   1.108 +        }
   1.109 +        ip += 4;
   1.110 +        dst_ptr += dst_stride;
   1.111 +        pred_ptr += pred_stride;
   1.112 +    }
   1.113 +}
   1.114 +
   1.115 +void vp8_dc_only_idct_add_c(short input_dc, unsigned char *pred_ptr,
   1.116 +                            int pred_stride, unsigned char *dst_ptr,
   1.117 +                            int dst_stride)
   1.118 +{
   1.119 +    int a1 = ((input_dc + 4) >> 3);
   1.120 +    int r, c;
   1.121 +
   1.122 +    for (r = 0; r < 4; r++)
   1.123 +    {
   1.124 +        for (c = 0; c < 4; c++)
   1.125 +        {
   1.126 +            int a = a1 + pred_ptr[c] ;
   1.127 +
   1.128 +            if (a < 0)
   1.129 +                a = 0;
   1.130 +
   1.131 +            if (a > 255)
   1.132 +                a = 255;
   1.133 +
   1.134 +            dst_ptr[c] = (unsigned char) a ;
   1.135 +        }
   1.136 +
   1.137 +        dst_ptr += dst_stride;
   1.138 +        pred_ptr += pred_stride;
   1.139 +    }
   1.140 +
   1.141 +}
   1.142 +
   1.143 +void vp8_short_inv_walsh4x4_c(short *input, short *mb_dqcoeff)
   1.144 +{
   1.145 +    short output[16];
   1.146 +    int i;
   1.147 +    int a1, b1, c1, d1;
   1.148 +    int a2, b2, c2, d2;
   1.149 +    short *ip = input;
   1.150 +    short *op = output;
   1.151 +
   1.152 +    for (i = 0; i < 4; i++)
   1.153 +    {
   1.154 +        a1 = ip[0] + ip[12];
   1.155 +        b1 = ip[4] + ip[8];
   1.156 +        c1 = ip[4] - ip[8];
   1.157 +        d1 = ip[0] - ip[12];
   1.158 +
   1.159 +        op[0] = a1 + b1;
   1.160 +        op[4] = c1 + d1;
   1.161 +        op[8] = a1 - b1;
   1.162 +        op[12] = d1 - c1;
   1.163 +        ip++;
   1.164 +        op++;
   1.165 +    }
   1.166 +
   1.167 +    ip = output;
   1.168 +    op = output;
   1.169 +
   1.170 +    for (i = 0; i < 4; i++)
   1.171 +    {
   1.172 +        a1 = ip[0] + ip[3];
   1.173 +        b1 = ip[1] + ip[2];
   1.174 +        c1 = ip[1] - ip[2];
   1.175 +        d1 = ip[0] - ip[3];
   1.176 +
   1.177 +        a2 = a1 + b1;
   1.178 +        b2 = c1 + d1;
   1.179 +        c2 = a1 - b1;
   1.180 +        d2 = d1 - c1;
   1.181 +
   1.182 +        op[0] = (a2 + 3) >> 3;
   1.183 +        op[1] = (b2 + 3) >> 3;
   1.184 +        op[2] = (c2 + 3) >> 3;
   1.185 +        op[3] = (d2 + 3) >> 3;
   1.186 +
   1.187 +        ip += 4;
   1.188 +        op += 4;
   1.189 +    }
   1.190 +
   1.191 +    for(i = 0; i < 16; i++)
   1.192 +    {
   1.193 +        mb_dqcoeff[i * 16] = output[i];
   1.194 +    }
   1.195 +}
   1.196 +
   1.197 +void vp8_short_inv_walsh4x4_1_c(short *input, short *mb_dqcoeff)
   1.198 +{
   1.199 +    int i;
   1.200 +    int a1;
   1.201 +
   1.202 +    a1 = ((input[0] + 3) >> 3);
   1.203 +    for(i = 0; i < 16; i++)
   1.204 +    {
   1.205 +        mb_dqcoeff[i * 16] = a1;
   1.206 +    }
   1.207 +}

mercurial