michael@0: /* michael@0: * Copyright (c) 2010 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: michael@0: #include michael@0: michael@0: void vp8_short_fdct4x4_c(short *input, short *output, int pitch) michael@0: { michael@0: int i; michael@0: int a1, b1, c1, d1; michael@0: short *ip = input; michael@0: short *op = output; michael@0: michael@0: for (i = 0; i < 4; i++) michael@0: { michael@0: a1 = ((ip[0] + ip[3]) * 8); michael@0: b1 = ((ip[1] + ip[2]) * 8); michael@0: c1 = ((ip[1] - ip[2]) * 8); michael@0: d1 = ((ip[0] - ip[3]) * 8); michael@0: michael@0: op[0] = a1 + b1; michael@0: op[2] = a1 - b1; michael@0: michael@0: op[1] = (c1 * 2217 + d1 * 5352 + 14500)>>12; michael@0: op[3] = (d1 * 2217 - c1 * 5352 + 7500)>>12; michael@0: michael@0: ip += pitch / 2; michael@0: op += 4; michael@0: michael@0: } michael@0: ip = output; michael@0: op = output; michael@0: for (i = 0; i < 4; i++) michael@0: { michael@0: a1 = ip[0] + ip[12]; michael@0: b1 = ip[4] + ip[8]; michael@0: c1 = ip[4] - ip[8]; michael@0: d1 = ip[0] - ip[12]; michael@0: michael@0: op[0] = ( a1 + b1 + 7)>>4; michael@0: op[8] = ( a1 - b1 + 7)>>4; michael@0: michael@0: op[4] =((c1 * 2217 + d1 * 5352 + 12000)>>16) + (d1!=0); michael@0: op[12] = (d1 * 2217 - c1 * 5352 + 51000)>>16; michael@0: michael@0: ip++; michael@0: op++; michael@0: } michael@0: } michael@0: michael@0: void vp8_short_fdct8x4_c(short *input, short *output, int pitch) michael@0: { michael@0: vp8_short_fdct4x4_c(input, output, pitch); michael@0: vp8_short_fdct4x4_c(input + 4, output + 16, pitch); michael@0: } michael@0: michael@0: void vp8_short_walsh4x4_c(short *input, short *output, int pitch) michael@0: { michael@0: int i; michael@0: int a1, b1, c1, d1; michael@0: int a2, b2, c2, d2; michael@0: short *ip = input; michael@0: short *op = output; michael@0: michael@0: michael@0: for (i = 0; i < 4; i++) michael@0: { michael@0: a1 = ((ip[0] + ip[2]) * 4); michael@0: d1 = ((ip[1] + ip[3]) * 4); michael@0: c1 = ((ip[1] - ip[3]) * 4); michael@0: b1 = ((ip[0] - ip[2]) * 4); michael@0: michael@0: op[0] = a1 + d1 + (a1!=0); michael@0: op[1] = b1 + c1; michael@0: op[2] = b1 - c1; michael@0: op[3] = a1 - d1; michael@0: ip += pitch / 2; michael@0: op += 4; michael@0: } michael@0: michael@0: ip = output; michael@0: op = output; michael@0: michael@0: for (i = 0; i < 4; i++) michael@0: { michael@0: a1 = ip[0] + ip[8]; michael@0: d1 = ip[4] + ip[12]; michael@0: c1 = ip[4] - ip[12]; michael@0: b1 = ip[0] - ip[8]; michael@0: michael@0: a2 = a1 + d1; michael@0: b2 = b1 + c1; michael@0: c2 = b1 - c1; michael@0: d2 = a1 - d1; michael@0: michael@0: a2 += a2<0; michael@0: b2 += b2<0; michael@0: c2 += c2<0; michael@0: d2 += d2<0; michael@0: michael@0: op[0] = (a2+3) >> 3; michael@0: op[4] = (b2+3) >> 3; michael@0: op[8] = (c2+3) >> 3; michael@0: op[12]= (d2+3) >> 3; michael@0: michael@0: ip++; michael@0: op++; michael@0: } michael@0: }