From 9e774af4d91cb3adddfb6acc2024653620e725db Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 6 Sep 2016 22:13:56 -0400 Subject: IMAGE: Further implementation of Indeo image decoding --- image/codecs/indeo/indeo_dsp.cpp | 639 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 639 insertions(+) create mode 100644 image/codecs/indeo/indeo_dsp.cpp (limited to 'image/codecs/indeo/indeo_dsp.cpp') diff --git a/image/codecs/indeo/indeo_dsp.cpp b/image/codecs/indeo/indeo_dsp.cpp new file mode 100644 index 0000000000..88e078d5f1 --- /dev/null +++ b/image/codecs/indeo/indeo_dsp.cpp @@ -0,0 +1,639 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* VLC code + * + * Original copyright note: * Intel Indeo 4 (IV41, IV42, etc.) video decoder for ffmpeg + * written, produced, and directed by Alan Smithee + */ + +#include "image/codecs/indeo/indeo_dsp.h" + +namespace Image { +namespace Indeo { + +/** + * butterfly operation for the inverse Haar transform + */ +#define IVI_HAAR_BFLY(s1, s2, o1, o2, t) \ + t = ((s1) - (s2)) >> 1;\ + o1 = ((s1) + (s2)) >> 1;\ + o2 = (t);\ + +/** + * inverse 8-point Haar transform + */ +#define INV_HAAR8(s1, s5, s3, s7, s2, s4, s6, s8,\ + d1, d2, d3, d4, d5, d6, d7, d8,\ + t0, t1, t2, t3, t4, t5, t6, t7, t8) {\ + t1 = (s1) << 1; t5 = (s5) << 1;\ + IVI_HAAR_BFLY(t1, t5, t1, t5, t0); IVI_HAAR_BFLY(t1, s3, t1, t3, t0);\ + IVI_HAAR_BFLY(t5, s7, t5, t7, t0); IVI_HAAR_BFLY(t1, s2, t1, t2, t0);\ + IVI_HAAR_BFLY(t3, s4, t3, t4, t0); IVI_HAAR_BFLY(t5, s6, t5, t6, t0);\ + IVI_HAAR_BFLY(t7, s8, t7, t8, t0);\ + d1 = COMPENSATE(t1);\ + d2 = COMPENSATE(t2);\ + d3 = COMPENSATE(t3);\ + d4 = COMPENSATE(t4);\ + d5 = COMPENSATE(t5);\ + d6 = COMPENSATE(t6);\ + d7 = COMPENSATE(t7);\ + d8 = COMPENSATE(t8); } + +/** + * inverse 4-point Haar transform + */ +#define INV_HAAR4(s1, s3, s5, s7, d1, d2, d3, d4, t0, t1, t2, t3, t4) {\ + IVI_HAAR_BFLY(s1, s3, t0, t1, t4);\ + IVI_HAAR_BFLY(t0, s5, t2, t3, t4);\ + d1 = COMPENSATE(t2);\ + d2 = COMPENSATE(t3);\ + IVI_HAAR_BFLY(t1, s7, t2, t3, t4);\ + d3 = COMPENSATE(t2);\ + d4 = COMPENSATE(t3); } + +void IndeoDSP::ff_ivi_inverse_haar_8x8(const int32 *in, int16 *out, uint32 pitch, + const uint8 *flags) { + int i, shift, sp1, sp2, sp3, sp4; + const int32 *src; + int32 *dst; + int tmp[64]; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; + + // apply the InvHaar8 to all columns +#define COMPENSATE(x) (x) + src = in; + dst = tmp; + for (i = 0; i < 8; i++) { + if (flags[i]) { + // pre-scaling + shift = !(i & 4); + sp1 = src[ 0] << shift; + sp2 = src[ 8] << shift; + sp3 = src[16] << shift; + sp4 = src[24] << shift; + INV_HAAR8( sp1, sp2, sp3, sp4, + src[32], src[40], src[48], src[56], + dst[ 0], dst[ 8], dst[16], dst[24], + dst[32], dst[40], dst[48], dst[56], + t0, t1, t2, t3, t4, t5, t6, t7, t8); + } else + dst[ 0] = dst[ 8] = dst[16] = dst[24] = + dst[32] = dst[40] = dst[48] = dst[56] = 0; + + src++; + dst++; + } +#undef COMPENSATE + + // apply the InvHaar8 to all rows +#define COMPENSATE(x) (x) + src = tmp; + for (i = 0; i < 8; i++) { + if ( !src[0] && !src[1] && !src[2] && !src[3] + && !src[4] && !src[5] && !src[6] && !src[7]) { + memset(out, 0, 8 * sizeof(out[0])); + } else { + INV_HAAR8(src[0], src[1], src[2], src[3], + src[4], src[5], src[6], src[7], + out[0], out[1], out[2], out[3], + out[4], out[5], out[6], out[7], + t0, t1, t2, t3, t4, t5, t6, t7, t8); + } + src += 8; + out += pitch; + } +#undef COMPENSATE +} + +void IndeoDSP::ff_ivi_row_haar8(const int32 *in, int16 *out, uint32 pitch, + const uint8 *flags) { + int i; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; + + // apply the InvHaar8 to all rows +#define COMPENSATE(x) (x) + for (i = 0; i < 8; i++) { + if ( !in[0] && !in[1] && !in[2] && !in[3] + && !in[4] && !in[5] && !in[6] && !in[7]) { + memset(out, 0, 8 * sizeof(out[0])); + } else { + INV_HAAR8(in[0], in[1], in[2], in[3], + in[4], in[5], in[6], in[7], + out[0], out[1], out[2], out[3], + out[4], out[5], out[6], out[7], + t0, t1, t2, t3, t4, t5, t6, t7, t8); + } + in += 8; + out += pitch; + } +#undef COMPENSATE +} + +void IndeoDSP::ff_ivi_col_haar8(const int32 *in, int16 *out, uint32 pitch, + const uint8 *flags) { + int i; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; + + // apply the InvHaar8 to all columns +#define COMPENSATE(x) (x) + for (i = 0; i < 8; i++) { + if (flags[i]) { + INV_HAAR8(in[ 0], in[ 8], in[16], in[24], + in[32], in[40], in[48], in[56], + out[0 * pitch], out[1 * pitch], + out[2 * pitch], out[3 * pitch], + out[4 * pitch], out[5 * pitch], + out[6 * pitch], out[7 * pitch], + t0, t1, t2, t3, t4, t5, t6, t7, t8); + } else + out[0 * pitch] = out[1 * pitch] = + out[2 * pitch] = out[3 * pitch] = + out[4 * pitch] = out[5 * pitch] = + out[6 * pitch] = out[7 * pitch] = 0; + + in++; + out++; + } +#undef COMPENSATE +} + +void IndeoDSP::ff_ivi_inverse_haar_4x4(const int32 *in, int16 *out, uint32 pitch, + const uint8 *flags) { + int i, shift, sp1, sp2; + const int32 *src; + int32 *dst; + int tmp[16]; + int t0, t1, t2, t3, t4; + + // apply the InvHaar4 to all columns +#define COMPENSATE(x) (x) + src = in; + dst = tmp; + for (i = 0; i < 4; i++) { + if (flags[i]) { + // pre-scaling + shift = !(i & 2); + sp1 = src[0] << shift; + sp2 = src[4] << shift; + INV_HAAR4( sp1, sp2, src[8], src[12], + dst[0], dst[4], dst[8], dst[12], + t0, t1, t2, t3, t4); + } else + dst[0] = dst[4] = dst[8] = dst[12] = 0; + + src++; + dst++; + } +#undef COMPENSATE + + // apply the InvHaar8 to all rows +#define COMPENSATE(x) (x) + src = tmp; + for (i = 0; i < 4; i++) { + if (!src[0] && !src[1] && !src[2] && !src[3]) { + memset(out, 0, 4 * sizeof(out[0])); + } else { + INV_HAAR4(src[0], src[1], src[2], src[3], + out[0], out[1], out[2], out[3], + t0, t1, t2, t3, t4); + } + src += 4; + out += pitch; + } +#undef COMPENSATE +} + +void IndeoDSP::ff_ivi_row_haar4(const int32 *in, int16 *out, uint32 pitch, + const uint8 *flags) { + int i; + int t0, t1, t2, t3, t4; + + // apply the InvHaar4 to all rows +#define COMPENSATE(x) (x) + for (i = 0; i < 4; i++) { + if (!in[0] && !in[1] && !in[2] && !in[3]) { + memset(out, 0, 4 * sizeof(out[0])); + } else { + INV_HAAR4(in[0], in[1], in[2], in[3], + out[0], out[1], out[2], out[3], + t0, t1, t2, t3, t4); + } + in += 4; + out += pitch; + } +#undef COMPENSATE +} + +void IndeoDSP::ff_ivi_col_haar4(const int32 *in, int16 *out, uint32 pitch, + const uint8 *flags) { + int i; + int t0, t1, t2, t3, t4; + + // apply the InvHaar8 to all columns +#define COMPENSATE(x) (x) + for (i = 0; i < 4; i++) { + if (flags[i]) { + INV_HAAR4(in[0], in[4], in[8], in[12], + out[0 * pitch], out[1 * pitch], + out[2 * pitch], out[3 * pitch], + t0, t1, t2, t3, t4); + } else + out[0 * pitch] = out[1 * pitch] = + out[2 * pitch] = out[3 * pitch] = 0; + + in++; + out++; + } +#undef COMPENSATE +} + +void IndeoDSP::ff_ivi_dc_haar_2d(const int32 *in, int16 *out, uint32 pitch, + int blk_size) { + int x, y; + int16 dc_coeff; + + dc_coeff = (*in + 0) >> 3; + + for (y = 0; y < blk_size; out += pitch, y++) { + for (x = 0; x < blk_size; x++) + out[x] = dc_coeff; + } +} + +//* butterfly operation for the inverse slant transform +#define IVI_SLANT_BFLY(s1, s2, o1, o2, t) \ + t = (s1) - (s2);\ + o1 = (s1) + (s2);\ + o2 = (t);\ + +//* This is a reflection a,b = 1/2, 5/4 for the inverse slant transform +#define IVI_IREFLECT(s1, s2, o1, o2, t) \ + t = (((s1) + (s2)*2 + 2) >> 2) + (s1);\ + o2 = (((s1)*2 - (s2) + 2) >> 2) - (s2);\ + o1 = (t);\ + +//* This is a reflection a,b = 1/2, 7/8 for the inverse slant transform +#define IVI_SLANT_PART4(s1, s2, o1, o2, t) \ + t = (s2) + (((s1)*4 - (s2) + 4) >> 3);\ + o2 = (s1) + ((-(s1) - (s2)*4 + 4) >> 3);\ + o1 = (t);\ + +//* inverse slant8 transform +#define IVI_INV_SLANT8(s1, s4, s8, s5, s2, s6, s3, s7,\ + d1, d2, d3, d4, d5, d6, d7, d8,\ + t0, t1, t2, t3, t4, t5, t6, t7, t8) {\ + IVI_SLANT_PART4(s4, s5, t4, t5, t0);\ +\ + IVI_SLANT_BFLY(s1, t5, t1, t5, t0); IVI_SLANT_BFLY(s2, s6, t2, t6, t0);\ + IVI_SLANT_BFLY(s7, s3, t7, t3, t0); IVI_SLANT_BFLY(t4, s8, t4, t8, t0);\ +\ + IVI_SLANT_BFLY(t1, t2, t1, t2, t0); IVI_IREFLECT (t4, t3, t4, t3, t0);\ + IVI_SLANT_BFLY(t5, t6, t5, t6, t0); IVI_IREFLECT (t8, t7, t8, t7, t0);\ + IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\ + IVI_SLANT_BFLY(t5, t8, t5, t8, t0); IVI_SLANT_BFLY(t6, t7, t6, t7, t0);\ + d1 = COMPENSATE(t1);\ + d2 = COMPENSATE(t2);\ + d3 = COMPENSATE(t3);\ + d4 = COMPENSATE(t4);\ + d5 = COMPENSATE(t5);\ + d6 = COMPENSATE(t6);\ + d7 = COMPENSATE(t7);\ + d8 = COMPENSATE(t8);} + +//* inverse slant4 transform +#define IVI_INV_SLANT4(s1, s4, s2, s3, d1, d2, d3, d4, t0, t1, t2, t3, t4) {\ + IVI_SLANT_BFLY(s1, s2, t1, t2, t0); IVI_IREFLECT (s4, s3, t4, t3, t0);\ +\ + IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\ + d1 = COMPENSATE(t1);\ + d2 = COMPENSATE(t2);\ + d3 = COMPENSATE(t3);\ + d4 = COMPENSATE(t4);} + +void IndeoDSP::ff_ivi_inverse_slant_8x8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { + int i; + const int32 *src; + int32 *dst; + int tmp[64]; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; + +#define COMPENSATE(x) (x) + src = in; + dst = tmp; + for (i = 0; i < 8; i++) { + if (flags[i]) { + IVI_INV_SLANT8(src[0], src[8], src[16], src[24], src[32], src[40], src[48], src[56], + dst[0], dst[8], dst[16], dst[24], dst[32], dst[40], dst[48], dst[56], + t0, t1, t2, t3, t4, t5, t6, t7, t8); + } else + dst[0] = dst[8] = dst[16] = dst[24] = dst[32] = dst[40] = dst[48] = dst[56] = 0; + + src++; + dst++; + } +#undef COMPENSATE + +#define COMPENSATE(x) (((x) + 1)>>1) + src = tmp; + for (i = 0; i < 8; i++) { + if (!src[0] && !src[1] && !src[2] && !src[3] && !src[4] && !src[5] && !src[6] && !src[7]) { + memset(out, 0, 8*sizeof(out[0])); + } else { + IVI_INV_SLANT8(src[0], src[1], src[2], src[3], src[4], src[5], src[6], src[7], + out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], + t0, t1, t2, t3, t4, t5, t6, t7, t8); + } + src += 8; + out += pitch; + } +#undef COMPENSATE +} + +void IndeoDSP::ff_ivi_inverse_slant_4x4(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { + int i; + const int32 *src; + int32 *dst; + int tmp[16]; + int t0, t1, t2, t3, t4; + +#define COMPENSATE(x) (x) + src = in; + dst = tmp; + for (i = 0; i < 4; i++) { + if (flags[i]) { + IVI_INV_SLANT4(src[0], src[4], src[8], src[12], + dst[0], dst[4], dst[8], dst[12], + t0, t1, t2, t3, t4); + } else + dst[0] = dst[4] = dst[8] = dst[12] = 0; + + src++; + dst++; + } +#undef COMPENSATE + +#define COMPENSATE(x) (((x) + 1)>>1) + src = tmp; + for (i = 0; i < 4; i++) { + if (!src[0] && !src[1] && !src[2] && !src[3]) { + out[0] = out[1] = out[2] = out[3] = 0; + } else { + IVI_INV_SLANT4(src[0], src[1], src[2], src[3], + out[0], out[1], out[2], out[3], + t0, t1, t2, t3, t4); + } + src += 4; + out += pitch; + } +#undef COMPENSATE +} + +void IndeoDSP::ff_ivi_dc_slant_2d(const int32 *in, int16 *out, uint32 pitch, + int blk_size) { + int x, y; + int16 dc_coeff; + + dc_coeff = (*in + 1) >> 1; + + for (y = 0; y < blk_size; out += pitch, y++) { + for (x = 0; x < blk_size; x++) + out[x] = dc_coeff; + } +} + +void IndeoDSP::ff_ivi_row_slant8(const int32 *in, int16 *out, uint32 pitch, + const uint8 *flags) { + int i; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; + +#define COMPENSATE(x) (((x) + 1)>>1) + for (i = 0; i < 8; i++) { + if (!in[0] && !in[1] && !in[2] && !in[3] && !in[4] && !in[5] && !in[6] && !in[7]) { + memset(out, 0, 8*sizeof(out[0])); + } else { + IVI_INV_SLANT8( in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7], + out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], + t0, t1, t2, t3, t4, t5, t6, t7, t8); + } + in += 8; + out += pitch; + } +#undef COMPENSATE +} + +void IndeoDSP::ff_ivi_dc_row_slant(const int32 *in, int16 *out, uint32 pitch, int blk_size) { + int x, y; + int16 dc_coeff; + + dc_coeff = (*in + 1) >> 1; + + for (x = 0; x < blk_size; x++) + out[x] = dc_coeff; + + out += pitch; + + for (y = 1; y < blk_size; out += pitch, y++) { + for (x = 0; x < blk_size; x++) + out[x] = 0; + } +} + +void IndeoDSP::ff_ivi_col_slant8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { + int i, row2, row4, row8; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; + + row2 = pitch << 1; + row4 = pitch << 2; + row8 = pitch << 3; + +#define COMPENSATE(x) (((x) + 1)>>1) + for (i = 0; i < 8; i++) { + if (flags[i]) { + IVI_INV_SLANT8(in[0], in[8], in[16], in[24], in[32], in[40], in[48], in[56], + out[0], out[pitch], out[row2], out[row2 + pitch], out[row4], + out[row4 + pitch], out[row4 + row2], out[row8 - pitch], + t0, t1, t2, t3, t4, t5, t6, t7, t8); + } else { + out[0] = out[pitch] = out[row2] = out[row2 + pitch] = out[row4] = + out[row4 + pitch] = out[row4 + row2] = out[row8 - pitch] = 0; + } + + in++; + out++; + } +#undef COMPENSATE +} + +void IndeoDSP::ff_ivi_dc_col_slant(const int32 *in, int16 *out, uint32 pitch, int blk_size) { + int x, y; + int16 dc_coeff; + + dc_coeff = (*in + 1) >> 1; + + for (y = 0; y < blk_size; out += pitch, y++) { + out[0] = dc_coeff; + for (x = 1; x < blk_size; x++) + out[x] = 0; + } +} + +void IndeoDSP::ff_ivi_row_slant4(const int32 *in, int16 *out, + uint32 pitch, const uint8 *flags) { + int i; + int t0, t1, t2, t3, t4; + +#define COMPENSATE(x) (((x) + 1)>>1) + for (i = 0; i < 4; i++) { + if (!in[0] && !in[1] && !in[2] && !in[3]) { + memset(out, 0, 4*sizeof(out[0])); + } else { + IVI_INV_SLANT4( in[0], in[1], in[2], in[3], + out[0], out[1], out[2], out[3], + t0, t1, t2, t3, t4); + } + in += 4; + out += pitch; + } +#undef COMPENSATE +} + +void IndeoDSP::ff_ivi_col_slant4(const int32 *in, int16 *out, uint32 pitch, + const uint8 *flags) { + int i, row2; + int t0, t1, t2, t3, t4; + + row2 = pitch << 1; + +#define COMPENSATE(x) (((x) + 1)>>1) + for (i = 0; i < 4; i++) { + if (flags[i]) { + IVI_INV_SLANT4(in[0], in[4], in[8], in[12], + out[0], out[pitch], out[row2], out[row2 + pitch], + t0, t1, t2, t3, t4); + } else { + out[0] = out[pitch] = out[row2] = out[row2 + pitch] = 0; + } + + in++; + out++; + } +#undef COMPENSATE +} + +void IndeoDSP::ff_ivi_put_pixels_8x8(const int32 *in, int16 *out, uint32 pitch, + const uint8 *flags) { + int x, y; + + for (y = 0; y < 8; out += pitch, in += 8, y++) + for (x = 0; x < 8; x++) + out[x] = in[x]; +} + +void IndeoDSP::ff_ivi_put_dc_pixel_8x8(const int32 *in, int16 *out, uint32 pitch, + int blk_size) { + int y; + + out[0] = in[0]; + memset(out + 1, 0, 7*sizeof(out[0])); + out += pitch; + + for (y = 1; y < 8; out += pitch, y++) + memset(out, 0, 8*sizeof(out[0])); +} + +#define IVI_MC_TEMPLATE(size, suffix, OP) \ +static void ivi_mc_ ## size ##x## size ## suffix(int16 *buf, \ + uint32 dpitch, \ + const int16 *ref_buf, \ + uint32 pitch, int mc_type) \ +{ \ + int i, j; \ + const int16 *wptr; \ +\ + switch (mc_type) { \ + case 0: /* fullpel (no interpolation) */ \ + for (i = 0; i < size; i++, buf += dpitch, ref_buf += pitch) { \ + for (j = 0; j < size; j++) {\ + OP(buf[j], ref_buf[j]); \ + } \ + } \ + break; \ + case 1: /* horizontal halfpel interpolation */ \ + for (i = 0; i < size; i++, buf += dpitch, ref_buf += pitch) \ + for (j = 0; j < size; j++) \ + OP(buf[j], (ref_buf[j] + ref_buf[j+1]) >> 1); \ + break; \ + case 2: /* vertical halfpel interpolation */ \ + wptr = ref_buf + pitch; \ + for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, ref_buf += pitch) \ + for (j = 0; j < size; j++) \ + OP(buf[j], (ref_buf[j] + wptr[j]) >> 1); \ + break; \ + case 3: /* vertical and horizontal halfpel interpolation */ \ + wptr = ref_buf + pitch; \ + for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, ref_buf += pitch) \ + for (j = 0; j < size; j++) \ + OP(buf[j], (ref_buf[j] + ref_buf[j+1] + wptr[j] + wptr[j+1]) >> 2); \ + break; \ + } \ +} \ +\ +void IndeoDSP::ff_ivi_mc_ ## size ##x## size ## suffix(int16 *buf, const int16 *ref_buf, \ + uint32 pitch, int mc_type) \ +{ \ + ivi_mc_ ## size ##x## size ## suffix(buf, pitch, ref_buf, pitch, mc_type); \ +} + +#define IVI_MC_AVG_TEMPLATE(size, suffix, OP) \ +void IndeoDSP::ff_ivi_mc_avg_ ## size ##x## size ## suffix(int16 *buf, \ + const int16 *ref_buf, \ + const int16 *ref_buf2, \ + uint32 pitch, \ + int mc_type, int mc_type2) \ +{ \ + int16 tmp[size * size]; \ + int i, j; \ +\ + ivi_mc_ ## size ##x## size ## _no_delta(tmp, size, ref_buf, pitch, mc_type); \ + ivi_mc_ ## size ##x## size ## _delta(tmp, size, ref_buf2, pitch, mc_type2); \ + for (i = 0; i < size; i++, buf += pitch) { \ + for (j = 0; j < size; j++) {\ + OP(buf[j], tmp[i * size + j] >> 1); \ + } \ + } \ +} + +#define OP_PUT(a, b) (a) = (b) +#define OP_ADD(a, b) (a) += (b) + +IVI_MC_TEMPLATE(8, _no_delta, OP_PUT) +IVI_MC_TEMPLATE(8, _delta, OP_ADD) +IVI_MC_TEMPLATE(4, _no_delta, OP_PUT) +IVI_MC_TEMPLATE(4, _delta, OP_ADD) +IVI_MC_AVG_TEMPLATE(8, _no_delta, OP_PUT) +IVI_MC_AVG_TEMPLATE(8, _delta, OP_ADD) +IVI_MC_AVG_TEMPLATE(4, _no_delta, OP_PUT) +IVI_MC_AVG_TEMPLATE(4, _delta, OP_ADD) + +} // End of namespace Indeo +} // End of namespace Image -- cgit v1.2.3 From c60a03019cb00649e19fa2c9baf289688237b90f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 6 Sep 2016 22:33:40 -0400 Subject: IMAGE: Cleanup and warning fixes for Indeo decoder --- image/codecs/indeo/indeo_dsp.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'image/codecs/indeo/indeo_dsp.cpp') diff --git a/image/codecs/indeo/indeo_dsp.cpp b/image/codecs/indeo/indeo_dsp.cpp index 88e078d5f1..f13ce91502 100644 --- a/image/codecs/indeo/indeo_dsp.cpp +++ b/image/codecs/indeo/indeo_dsp.cpp @@ -96,9 +96,10 @@ void IndeoDSP::ff_ivi_inverse_haar_8x8(const int32 *in, int16 *out, uint32 pitch dst[ 0], dst[ 8], dst[16], dst[24], dst[32], dst[40], dst[48], dst[56], t0, t1, t2, t3, t4, t5, t6, t7, t8); - } else + } else { dst[ 0] = dst[ 8] = dst[16] = dst[24] = dst[32] = dst[40] = dst[48] = dst[56] = 0; + } src++; dst++; @@ -165,11 +166,12 @@ void IndeoDSP::ff_ivi_col_haar8(const int32 *in, int16 *out, uint32 pitch, out[4 * pitch], out[5 * pitch], out[6 * pitch], out[7 * pitch], t0, t1, t2, t3, t4, t5, t6, t7, t8); - } else + } else { out[0 * pitch] = out[1 * pitch] = out[2 * pitch] = out[3 * pitch] = out[4 * pitch] = out[5 * pitch] = out[6 * pitch] = out[7 * pitch] = 0; + } in++; out++; @@ -198,8 +200,9 @@ void IndeoDSP::ff_ivi_inverse_haar_4x4(const int32 *in, int16 *out, uint32 pitch INV_HAAR4( sp1, sp2, src[8], src[12], dst[0], dst[4], dst[8], dst[12], t0, t1, t2, t3, t4); - } else + } else { dst[0] = dst[4] = dst[8] = dst[12] = 0; + } src++; dst++; @@ -257,9 +260,10 @@ void IndeoDSP::ff_ivi_col_haar4(const int32 *in, int16 *out, uint32 pitch, out[0 * pitch], out[1 * pitch], out[2 * pitch], out[3 * pitch], t0, t1, t2, t3, t4); - } else + } else { out[0 * pitch] = out[1 * pitch] = out[2 * pitch] = out[3 * pitch] = 0; + } in++; out++; @@ -345,11 +349,12 @@ void IndeoDSP::ff_ivi_inverse_slant_8x8(const int32 *in, int16 *out, uint32 pitc IVI_INV_SLANT8(src[0], src[8], src[16], src[24], src[32], src[40], src[48], src[56], dst[0], dst[8], dst[16], dst[24], dst[32], dst[40], dst[48], dst[56], t0, t1, t2, t3, t4, t5, t6, t7, t8); - } else + } else { dst[0] = dst[8] = dst[16] = dst[24] = dst[32] = dst[40] = dst[48] = dst[56] = 0; + } - src++; - dst++; + src++; + dst++; } #undef COMPENSATE @@ -384,11 +389,11 @@ void IndeoDSP::ff_ivi_inverse_slant_4x4(const int32 *in, int16 *out, uint32 pitc IVI_INV_SLANT4(src[0], src[4], src[8], src[12], dst[0], dst[4], dst[8], dst[12], t0, t1, t2, t3, t4); - } else + } else { dst[0] = dst[4] = dst[8] = dst[12] = 0; - - src++; - dst++; + } + src++; + dst++; } #undef COMPENSATE -- cgit v1.2.3 From 9c6a55a2a660d2c59e9c0e22402e4d16e08ef987 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 10 Sep 2016 18:07:13 -0400 Subject: IMAGE: Cleanup of miscellaneous methods and arrays in Indeo decoders --- image/codecs/indeo/indeo_dsp.cpp | 224 +++++++++++++++++++-------------------- 1 file changed, 112 insertions(+), 112 deletions(-) (limited to 'image/codecs/indeo/indeo_dsp.cpp') diff --git a/image/codecs/indeo/indeo_dsp.cpp b/image/codecs/indeo/indeo_dsp.cpp index f13ce91502..d4803b8b93 100644 --- a/image/codecs/indeo/indeo_dsp.cpp +++ b/image/codecs/indeo/indeo_dsp.cpp @@ -71,13 +71,13 @@ namespace Indeo { d3 = COMPENSATE(t2);\ d4 = COMPENSATE(t3); } -void IndeoDSP::ff_ivi_inverse_haar_8x8(const int32 *in, int16 *out, uint32 pitch, +void IndeoDSP::ffIviInverseHaar8x8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i, shift, sp1, sp2, sp3, sp4; + int i, shift, sp1, sp2, sp3, sp4; const int32 *src; - int32 *dst; - int tmp[64]; - int t0, t1, t2, t3, t4, t5, t6, t7, t8; + int32 * dst; + int tmp[64]; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; // apply the InvHaar8 to all columns #define COMPENSATE(x) (x) @@ -126,10 +126,10 @@ void IndeoDSP::ff_ivi_inverse_haar_8x8(const int32 *in, int16 *out, uint32 pitch #undef COMPENSATE } -void IndeoDSP::ff_ivi_row_haar8(const int32 *in, int16 *out, uint32 pitch, +void IndeoDSP::ffIviRowHaar8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i; - int t0, t1, t2, t3, t4, t5, t6, t7, t8; + int i; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; // apply the InvHaar8 to all rows #define COMPENSATE(x) (x) @@ -150,10 +150,10 @@ void IndeoDSP::ff_ivi_row_haar8(const int32 *in, int16 *out, uint32 pitch, #undef COMPENSATE } -void IndeoDSP::ff_ivi_col_haar8(const int32 *in, int16 *out, uint32 pitch, +void IndeoDSP::ffIviColHaar8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i; - int t0, t1, t2, t3, t4, t5, t6, t7, t8; + int i; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; // apply the InvHaar8 to all columns #define COMPENSATE(x) (x) @@ -179,13 +179,13 @@ void IndeoDSP::ff_ivi_col_haar8(const int32 *in, int16 *out, uint32 pitch, #undef COMPENSATE } -void IndeoDSP::ff_ivi_inverse_haar_4x4(const int32 *in, int16 *out, uint32 pitch, +void IndeoDSP::ffIviInverseHaar4x4(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i, shift, sp1, sp2; + int i, shift, sp1, sp2; const int32 *src; - int32 *dst; - int tmp[16]; - int t0, t1, t2, t3, t4; + int32 * dst; + int tmp[16]; + int t0, t1, t2, t3, t4; // apply the InvHaar4 to all columns #define COMPENSATE(x) (x) @@ -226,10 +226,10 @@ void IndeoDSP::ff_ivi_inverse_haar_4x4(const int32 *in, int16 *out, uint32 pitch #undef COMPENSATE } -void IndeoDSP::ff_ivi_row_haar4(const int32 *in, int16 *out, uint32 pitch, +void IndeoDSP::ffIviRowHaar4(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i; - int t0, t1, t2, t3, t4; + int i; + int t0, t1, t2, t3, t4; // apply the InvHaar4 to all rows #define COMPENSATE(x) (x) @@ -247,10 +247,10 @@ void IndeoDSP::ff_ivi_row_haar4(const int32 *in, int16 *out, uint32 pitch, #undef COMPENSATE } -void IndeoDSP::ff_ivi_col_haar4(const int32 *in, int16 *out, uint32 pitch, +void IndeoDSP::ffIviColHaar4(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i; - int t0, t1, t2, t3, t4; + int i; + int t0, t1, t2, t3, t4; // apply the InvHaar8 to all columns #define COMPENSATE(x) (x) @@ -271,16 +271,16 @@ void IndeoDSP::ff_ivi_col_haar4(const int32 *in, int16 *out, uint32 pitch, #undef COMPENSATE } -void IndeoDSP::ff_ivi_dc_haar_2d(const int32 *in, int16 *out, uint32 pitch, - int blk_size) { - int x, y; - int16 dc_coeff; +void IndeoDSP::ffIviDcHaar2d(const int32 *in, int16 *out, uint32 pitch, + int blkSize) { + int x, y; + int16 dcCoeff; - dc_coeff = (*in + 0) >> 3; + dcCoeff = (*in + 0) >> 3; - for (y = 0; y < blk_size; out += pitch, y++) { - for (x = 0; x < blk_size; x++) - out[x] = dc_coeff; + for (y = 0; y < blkSize; out += pitch, y++) { + for (x = 0; x < blkSize; x++) + out[x] = dcCoeff; } } @@ -334,12 +334,12 @@ void IndeoDSP::ff_ivi_dc_haar_2d(const int32 *in, int16 *out, uint32 pitch, d3 = COMPENSATE(t3);\ d4 = COMPENSATE(t4);} -void IndeoDSP::ff_ivi_inverse_slant_8x8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i; +void IndeoDSP::ffIviInverseSlant8x8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { + int i; const int32 *src; - int32 *dst; - int tmp[64]; - int t0, t1, t2, t3, t4, t5, t6, t7, t8; + int32 * dst; + int tmp[64]; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; #define COMPENSATE(x) (x) src = in; @@ -374,12 +374,12 @@ void IndeoDSP::ff_ivi_inverse_slant_8x8(const int32 *in, int16 *out, uint32 pitc #undef COMPENSATE } -void IndeoDSP::ff_ivi_inverse_slant_4x4(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i; +void IndeoDSP::ffIviInverseSlant4x4(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { + int i; const int32 *src; - int32 *dst; - int tmp[16]; - int t0, t1, t2, t3, t4; + int32 * dst; + int tmp[16]; + int t0, t1, t2, t3, t4; #define COMPENSATE(x) (x) src = in; @@ -413,23 +413,23 @@ void IndeoDSP::ff_ivi_inverse_slant_4x4(const int32 *in, int16 *out, uint32 pitc #undef COMPENSATE } -void IndeoDSP::ff_ivi_dc_slant_2d(const int32 *in, int16 *out, uint32 pitch, - int blk_size) { - int x, y; - int16 dc_coeff; +void IndeoDSP::ffIviDcSlant2d(const int32 *in, int16 *out, uint32 pitch, + int blkSize) { + int x, y; + int16 dcCoeff; - dc_coeff = (*in + 1) >> 1; + dcCoeff = (*in + 1) >> 1; - for (y = 0; y < blk_size; out += pitch, y++) { - for (x = 0; x < blk_size; x++) - out[x] = dc_coeff; + for (y = 0; y < blkSize; out += pitch, y++) { + for (x = 0; x < blkSize; x++) + out[x] = dcCoeff; } } -void IndeoDSP::ff_ivi_row_slant8(const int32 *in, int16 *out, uint32 pitch, +void IndeoDSP::ffIviRowSlant8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i; - int t0, t1, t2, t3, t4, t5, t6, t7, t8; + int i; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; #define COMPENSATE(x) (((x) + 1)>>1) for (i = 0; i < 8; i++) { @@ -446,26 +446,26 @@ void IndeoDSP::ff_ivi_row_slant8(const int32 *in, int16 *out, uint32 pitch, #undef COMPENSATE } -void IndeoDSP::ff_ivi_dc_row_slant(const int32 *in, int16 *out, uint32 pitch, int blk_size) { - int x, y; - int16 dc_coeff; +void IndeoDSP::ffIviDcRowSlant(const int32 *in, int16 *out, uint32 pitch, int blkSize) { + int x, y; + int16 dcCoeff; - dc_coeff = (*in + 1) >> 1; + dcCoeff = (*in + 1) >> 1; - for (x = 0; x < blk_size; x++) - out[x] = dc_coeff; + for (x = 0; x < blkSize; x++) + out[x] = dcCoeff; out += pitch; - for (y = 1; y < blk_size; out += pitch, y++) { - for (x = 0; x < blk_size; x++) + for (y = 1; y < blkSize; out += pitch, y++) { + for (x = 0; x < blkSize; x++) out[x] = 0; } } -void IndeoDSP::ff_ivi_col_slant8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i, row2, row4, row8; - int t0, t1, t2, t3, t4, t5, t6, t7, t8; +void IndeoDSP::ffIviColSlant8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { + int i, row2, row4, row8; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; row2 = pitch << 1; row4 = pitch << 2; @@ -489,23 +489,23 @@ void IndeoDSP::ff_ivi_col_slant8(const int32 *in, int16 *out, uint32 pitch, cons #undef COMPENSATE } -void IndeoDSP::ff_ivi_dc_col_slant(const int32 *in, int16 *out, uint32 pitch, int blk_size) { - int x, y; - int16 dc_coeff; +void IndeoDSP::ffIviDcColSlant(const int32 *in, int16 *out, uint32 pitch, int blkSize) { + int x, y; + int16 dcCoeff; - dc_coeff = (*in + 1) >> 1; + dcCoeff = (*in + 1) >> 1; - for (y = 0; y < blk_size; out += pitch, y++) { - out[0] = dc_coeff; - for (x = 1; x < blk_size; x++) + for (y = 0; y < blkSize; out += pitch, y++) { + out[0] = dcCoeff; + for (x = 1; x < blkSize; x++) out[x] = 0; } } -void IndeoDSP::ff_ivi_row_slant4(const int32 *in, int16 *out, +void IndeoDSP::ffIviRowSlant4(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i; - int t0, t1, t2, t3, t4; + int i; + int t0, t1, t2, t3, t4; #define COMPENSATE(x) (((x) + 1)>>1) for (i = 0; i < 4; i++) { @@ -522,10 +522,10 @@ void IndeoDSP::ff_ivi_row_slant4(const int32 *in, int16 *out, #undef COMPENSATE } -void IndeoDSP::ff_ivi_col_slant4(const int32 *in, int16 *out, uint32 pitch, +void IndeoDSP::ffIviColSlant4(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i, row2; - int t0, t1, t2, t3, t4; + int i, row2; + int t0, t1, t2, t3, t4; row2 = pitch << 1; @@ -545,18 +545,18 @@ void IndeoDSP::ff_ivi_col_slant4(const int32 *in, int16 *out, uint32 pitch, #undef COMPENSATE } -void IndeoDSP::ff_ivi_put_pixels_8x8(const int32 *in, int16 *out, uint32 pitch, +void IndeoDSP::ffIviPutPixels8x8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int x, y; + int x, y; for (y = 0; y < 8; out += pitch, in += 8, y++) for (x = 0; x < 8; x++) out[x] = in[x]; } -void IndeoDSP::ff_ivi_put_dc_pixel_8x8(const int32 *in, int16 *out, uint32 pitch, - int blk_size) { - int y; +void IndeoDSP::ffIviPutDcPixel8x8(const int32 *in, int16 *out, uint32 pitch, + int blkSize) { + int y; out[0] = in[0]; memset(out + 1, 0, 7*sizeof(out[0])); @@ -567,60 +567,60 @@ void IndeoDSP::ff_ivi_put_dc_pixel_8x8(const int32 *in, int16 *out, uint32 pitch } #define IVI_MC_TEMPLATE(size, suffix, OP) \ -static void ivi_mc_ ## size ##x## size ## suffix(int16 *buf, \ +static void iviMc ## size ##x## size ## suffix(int16 *buf, \ uint32 dpitch, \ - const int16 *ref_buf, \ - uint32 pitch, int mc_type) \ + const int16 *refBuf, \ + uint32 pitch, int mcType) \ { \ - int i, j; \ + int i, j; \ const int16 *wptr; \ \ - switch (mc_type) { \ + switch (mcType) { \ case 0: /* fullpel (no interpolation) */ \ - for (i = 0; i < size; i++, buf += dpitch, ref_buf += pitch) { \ + for (i = 0; i < size; i++, buf += dpitch, refBuf += pitch) { \ for (j = 0; j < size; j++) {\ - OP(buf[j], ref_buf[j]); \ + OP(buf[j], refBuf[j]); \ } \ } \ break; \ case 1: /* horizontal halfpel interpolation */ \ - for (i = 0; i < size; i++, buf += dpitch, ref_buf += pitch) \ + for (i = 0; i < size; i++, buf += dpitch, refBuf += pitch) \ for (j = 0; j < size; j++) \ - OP(buf[j], (ref_buf[j] + ref_buf[j+1]) >> 1); \ + OP(buf[j], (refBuf[j] + refBuf[j+1]) >> 1); \ break; \ case 2: /* vertical halfpel interpolation */ \ - wptr = ref_buf + pitch; \ - for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, ref_buf += pitch) \ + wptr = refBuf + pitch; \ + for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, refBuf += pitch) \ for (j = 0; j < size; j++) \ - OP(buf[j], (ref_buf[j] + wptr[j]) >> 1); \ + OP(buf[j], (refBuf[j] + wptr[j]) >> 1); \ break; \ case 3: /* vertical and horizontal halfpel interpolation */ \ - wptr = ref_buf + pitch; \ - for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, ref_buf += pitch) \ + wptr = refBuf + pitch; \ + for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, refBuf += pitch) \ for (j = 0; j < size; j++) \ - OP(buf[j], (ref_buf[j] + ref_buf[j+1] + wptr[j] + wptr[j+1]) >> 2); \ + OP(buf[j], (refBuf[j] + refBuf[j+1] + wptr[j] + wptr[j+1]) >> 2); \ break; \ } \ } \ \ -void IndeoDSP::ff_ivi_mc_ ## size ##x## size ## suffix(int16 *buf, const int16 *ref_buf, \ - uint32 pitch, int mc_type) \ +void IndeoDSP::ffIviMc ## size ##x## size ## suffix(int16 *buf, const int16 *refBuf, \ + uint32 pitch, int mcType) \ { \ - ivi_mc_ ## size ##x## size ## suffix(buf, pitch, ref_buf, pitch, mc_type); \ + iviMc ## size ##x## size ## suffix(buf, pitch, refBuf, pitch, mcType); \ } #define IVI_MC_AVG_TEMPLATE(size, suffix, OP) \ -void IndeoDSP::ff_ivi_mc_avg_ ## size ##x## size ## suffix(int16 *buf, \ - const int16 *ref_buf, \ - const int16 *ref_buf2, \ +void IndeoDSP::ffIviMcAvg ## size ##x## size ## suffix(int16 *buf, \ + const int16 *refBuf, \ + const int16 *refBuf2, \ uint32 pitch, \ - int mc_type, int mc_type2) \ + int mcType, int mcType2) \ { \ int16 tmp[size * size]; \ int i, j; \ \ - ivi_mc_ ## size ##x## size ## _no_delta(tmp, size, ref_buf, pitch, mc_type); \ - ivi_mc_ ## size ##x## size ## _delta(tmp, size, ref_buf2, pitch, mc_type2); \ + iviMc ## size ##x## size ## NoDelta(tmp, size, refBuf, pitch, mcType); \ + iviMc ## size ##x## size ## Delta(tmp, size, refBuf2, pitch, mcType2); \ for (i = 0; i < size; i++, buf += pitch) { \ for (j = 0; j < size; j++) {\ OP(buf[j], tmp[i * size + j] >> 1); \ @@ -631,14 +631,14 @@ void IndeoDSP::ff_ivi_mc_avg_ ## size ##x## size ## suffix(int16 *buf, \ #define OP_PUT(a, b) (a) = (b) #define OP_ADD(a, b) (a) += (b) -IVI_MC_TEMPLATE(8, _no_delta, OP_PUT) -IVI_MC_TEMPLATE(8, _delta, OP_ADD) -IVI_MC_TEMPLATE(4, _no_delta, OP_PUT) -IVI_MC_TEMPLATE(4, _delta, OP_ADD) -IVI_MC_AVG_TEMPLATE(8, _no_delta, OP_PUT) -IVI_MC_AVG_TEMPLATE(8, _delta, OP_ADD) -IVI_MC_AVG_TEMPLATE(4, _no_delta, OP_PUT) -IVI_MC_AVG_TEMPLATE(4, _delta, OP_ADD) +IVI_MC_TEMPLATE(8, NoDelta, OP_PUT) +IVI_MC_TEMPLATE(8, Delta, OP_ADD) +IVI_MC_TEMPLATE(4, NoDelta, OP_PUT) +IVI_MC_TEMPLATE(4, Delta, OP_ADD) +IVI_MC_AVG_TEMPLATE(8, NoDelta, OP_PUT) +IVI_MC_AVG_TEMPLATE(8, Delta, OP_ADD) +IVI_MC_AVG_TEMPLATE(4, NoDelta, OP_PUT) +IVI_MC_AVG_TEMPLATE(4, Delta, OP_ADD) } // End of namespace Indeo } // End of namespace Image -- cgit v1.2.3 From a5f43663875e789baa8b7d9e79d5da4b3362f04a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 10 Sep 2016 22:18:05 -0400 Subject: IMAGE: Fix leading spaces into tabs in Indeo decoders --- image/codecs/indeo/indeo_dsp.cpp | 826 +++++++++++++++++++-------------------- 1 file changed, 413 insertions(+), 413 deletions(-) (limited to 'image/codecs/indeo/indeo_dsp.cpp') diff --git a/image/codecs/indeo/indeo_dsp.cpp b/image/codecs/indeo/indeo_dsp.cpp index d4803b8b93..15626e9473 100644 --- a/image/codecs/indeo/indeo_dsp.cpp +++ b/image/codecs/indeo/indeo_dsp.cpp @@ -35,597 +35,597 @@ namespace Indeo { * butterfly operation for the inverse Haar transform */ #define IVI_HAAR_BFLY(s1, s2, o1, o2, t) \ - t = ((s1) - (s2)) >> 1;\ - o1 = ((s1) + (s2)) >> 1;\ - o2 = (t);\ + t = ((s1) - (s2)) >> 1;\ + o1 = ((s1) + (s2)) >> 1;\ + o2 = (t);\ /** * inverse 8-point Haar transform */ #define INV_HAAR8(s1, s5, s3, s7, s2, s4, s6, s8,\ - d1, d2, d3, d4, d5, d6, d7, d8,\ - t0, t1, t2, t3, t4, t5, t6, t7, t8) {\ - t1 = (s1) << 1; t5 = (s5) << 1;\ - IVI_HAAR_BFLY(t1, t5, t1, t5, t0); IVI_HAAR_BFLY(t1, s3, t1, t3, t0);\ - IVI_HAAR_BFLY(t5, s7, t5, t7, t0); IVI_HAAR_BFLY(t1, s2, t1, t2, t0);\ - IVI_HAAR_BFLY(t3, s4, t3, t4, t0); IVI_HAAR_BFLY(t5, s6, t5, t6, t0);\ - IVI_HAAR_BFLY(t7, s8, t7, t8, t0);\ - d1 = COMPENSATE(t1);\ - d2 = COMPENSATE(t2);\ - d3 = COMPENSATE(t3);\ - d4 = COMPENSATE(t4);\ - d5 = COMPENSATE(t5);\ - d6 = COMPENSATE(t6);\ - d7 = COMPENSATE(t7);\ - d8 = COMPENSATE(t8); } + d1, d2, d3, d4, d5, d6, d7, d8,\ + t0, t1, t2, t3, t4, t5, t6, t7, t8) {\ + t1 = (s1) << 1; t5 = (s5) << 1;\ + IVI_HAAR_BFLY(t1, t5, t1, t5, t0); IVI_HAAR_BFLY(t1, s3, t1, t3, t0);\ + IVI_HAAR_BFLY(t5, s7, t5, t7, t0); IVI_HAAR_BFLY(t1, s2, t1, t2, t0);\ + IVI_HAAR_BFLY(t3, s4, t3, t4, t0); IVI_HAAR_BFLY(t5, s6, t5, t6, t0);\ + IVI_HAAR_BFLY(t7, s8, t7, t8, t0);\ + d1 = COMPENSATE(t1);\ + d2 = COMPENSATE(t2);\ + d3 = COMPENSATE(t3);\ + d4 = COMPENSATE(t4);\ + d5 = COMPENSATE(t5);\ + d6 = COMPENSATE(t6);\ + d7 = COMPENSATE(t7);\ + d8 = COMPENSATE(t8); } /** * inverse 4-point Haar transform */ #define INV_HAAR4(s1, s3, s5, s7, d1, d2, d3, d4, t0, t1, t2, t3, t4) {\ - IVI_HAAR_BFLY(s1, s3, t0, t1, t4);\ - IVI_HAAR_BFLY(t0, s5, t2, t3, t4);\ - d1 = COMPENSATE(t2);\ - d2 = COMPENSATE(t3);\ - IVI_HAAR_BFLY(t1, s7, t2, t3, t4);\ - d3 = COMPENSATE(t2);\ - d4 = COMPENSATE(t3); } + IVI_HAAR_BFLY(s1, s3, t0, t1, t4);\ + IVI_HAAR_BFLY(t0, s5, t2, t3, t4);\ + d1 = COMPENSATE(t2);\ + d2 = COMPENSATE(t3);\ + IVI_HAAR_BFLY(t1, s7, t2, t3, t4);\ + d3 = COMPENSATE(t2);\ + d4 = COMPENSATE(t3); } void IndeoDSP::ffIviInverseHaar8x8(const int32 *in, int16 *out, uint32 pitch, - const uint8 *flags) { - int i, shift, sp1, sp2, sp3, sp4; - const int32 *src; - int32 * dst; - int tmp[64]; - int t0, t1, t2, t3, t4, t5, t6, t7, t8; - - // apply the InvHaar8 to all columns + const uint8 *flags) { + int i, shift, sp1, sp2, sp3, sp4; + const int32 *src; + int32 * dst; + int tmp[64]; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; + + // apply the InvHaar8 to all columns #define COMPENSATE(x) (x) - src = in; - dst = tmp; - for (i = 0; i < 8; i++) { - if (flags[i]) { - // pre-scaling - shift = !(i & 4); - sp1 = src[ 0] << shift; - sp2 = src[ 8] << shift; - sp3 = src[16] << shift; - sp4 = src[24] << shift; - INV_HAAR8( sp1, sp2, sp3, sp4, - src[32], src[40], src[48], src[56], - dst[ 0], dst[ 8], dst[16], dst[24], - dst[32], dst[40], dst[48], dst[56], - t0, t1, t2, t3, t4, t5, t6, t7, t8); - } else { - dst[ 0] = dst[ 8] = dst[16] = dst[24] = - dst[32] = dst[40] = dst[48] = dst[56] = 0; + src = in; + dst = tmp; + for (i = 0; i < 8; i++) { + if (flags[i]) { + // pre-scaling + shift = !(i & 4); + sp1 = src[ 0] << shift; + sp2 = src[ 8] << shift; + sp3 = src[16] << shift; + sp4 = src[24] << shift; + INV_HAAR8( sp1, sp2, sp3, sp4, + src[32], src[40], src[48], src[56], + dst[ 0], dst[ 8], dst[16], dst[24], + dst[32], dst[40], dst[48], dst[56], + t0, t1, t2, t3, t4, t5, t6, t7, t8); + } else { + dst[ 0] = dst[ 8] = dst[16] = dst[24] = + dst[32] = dst[40] = dst[48] = dst[56] = 0; } - src++; - dst++; - } + src++; + dst++; + } #undef COMPENSATE - // apply the InvHaar8 to all rows + // apply the InvHaar8 to all rows #define COMPENSATE(x) (x) - src = tmp; - for (i = 0; i < 8; i++) { - if ( !src[0] && !src[1] && !src[2] && !src[3] - && !src[4] && !src[5] && !src[6] && !src[7]) { - memset(out, 0, 8 * sizeof(out[0])); - } else { - INV_HAAR8(src[0], src[1], src[2], src[3], - src[4], src[5], src[6], src[7], - out[0], out[1], out[2], out[3], - out[4], out[5], out[6], out[7], - t0, t1, t2, t3, t4, t5, t6, t7, t8); - } - src += 8; - out += pitch; - } + src = tmp; + for (i = 0; i < 8; i++) { + if ( !src[0] && !src[1] && !src[2] && !src[3] + && !src[4] && !src[5] && !src[6] && !src[7]) { + memset(out, 0, 8 * sizeof(out[0])); + } else { + INV_HAAR8(src[0], src[1], src[2], src[3], + src[4], src[5], src[6], src[7], + out[0], out[1], out[2], out[3], + out[4], out[5], out[6], out[7], + t0, t1, t2, t3, t4, t5, t6, t7, t8); + } + src += 8; + out += pitch; + } #undef COMPENSATE } void IndeoDSP::ffIviRowHaar8(const int32 *in, int16 *out, uint32 pitch, - const uint8 *flags) { - int i; - int t0, t1, t2, t3, t4, t5, t6, t7, t8; + const uint8 *flags) { + int i; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; - // apply the InvHaar8 to all rows + // apply the InvHaar8 to all rows #define COMPENSATE(x) (x) - for (i = 0; i < 8; i++) { - if ( !in[0] && !in[1] && !in[2] && !in[3] - && !in[4] && !in[5] && !in[6] && !in[7]) { - memset(out, 0, 8 * sizeof(out[0])); - } else { - INV_HAAR8(in[0], in[1], in[2], in[3], - in[4], in[5], in[6], in[7], - out[0], out[1], out[2], out[3], - out[4], out[5], out[6], out[7], - t0, t1, t2, t3, t4, t5, t6, t7, t8); - } - in += 8; - out += pitch; - } + for (i = 0; i < 8; i++) { + if ( !in[0] && !in[1] && !in[2] && !in[3] + && !in[4] && !in[5] && !in[6] && !in[7]) { + memset(out, 0, 8 * sizeof(out[0])); + } else { + INV_HAAR8(in[0], in[1], in[2], in[3], + in[4], in[5], in[6], in[7], + out[0], out[1], out[2], out[3], + out[4], out[5], out[6], out[7], + t0, t1, t2, t3, t4, t5, t6, t7, t8); + } + in += 8; + out += pitch; + } #undef COMPENSATE } void IndeoDSP::ffIviColHaar8(const int32 *in, int16 *out, uint32 pitch, - const uint8 *flags) { - int i; - int t0, t1, t2, t3, t4, t5, t6, t7, t8; + const uint8 *flags) { + int i; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; - // apply the InvHaar8 to all columns + // apply the InvHaar8 to all columns #define COMPENSATE(x) (x) - for (i = 0; i < 8; i++) { - if (flags[i]) { - INV_HAAR8(in[ 0], in[ 8], in[16], in[24], - in[32], in[40], in[48], in[56], - out[0 * pitch], out[1 * pitch], - out[2 * pitch], out[3 * pitch], - out[4 * pitch], out[5 * pitch], - out[6 * pitch], out[7 * pitch], - t0, t1, t2, t3, t4, t5, t6, t7, t8); - } else { - out[0 * pitch] = out[1 * pitch] = - out[2 * pitch] = out[3 * pitch] = - out[4 * pitch] = out[5 * pitch] = - out[6 * pitch] = out[7 * pitch] = 0; + for (i = 0; i < 8; i++) { + if (flags[i]) { + INV_HAAR8(in[ 0], in[ 8], in[16], in[24], + in[32], in[40], in[48], in[56], + out[0 * pitch], out[1 * pitch], + out[2 * pitch], out[3 * pitch], + out[4 * pitch], out[5 * pitch], + out[6 * pitch], out[7 * pitch], + t0, t1, t2, t3, t4, t5, t6, t7, t8); + } else { + out[0 * pitch] = out[1 * pitch] = + out[2 * pitch] = out[3 * pitch] = + out[4 * pitch] = out[5 * pitch] = + out[6 * pitch] = out[7 * pitch] = 0; } - in++; - out++; - } + in++; + out++; + } #undef COMPENSATE } void IndeoDSP::ffIviInverseHaar4x4(const int32 *in, int16 *out, uint32 pitch, - const uint8 *flags) { - int i, shift, sp1, sp2; - const int32 *src; - int32 * dst; - int tmp[16]; - int t0, t1, t2, t3, t4; - - // apply the InvHaar4 to all columns + const uint8 *flags) { + int i, shift, sp1, sp2; + const int32 *src; + int32 * dst; + int tmp[16]; + int t0, t1, t2, t3, t4; + + // apply the InvHaar4 to all columns #define COMPENSATE(x) (x) - src = in; - dst = tmp; - for (i = 0; i < 4; i++) { - if (flags[i]) { - // pre-scaling - shift = !(i & 2); - sp1 = src[0] << shift; - sp2 = src[4] << shift; - INV_HAAR4( sp1, sp2, src[8], src[12], - dst[0], dst[4], dst[8], dst[12], - t0, t1, t2, t3, t4); - } else { - dst[0] = dst[4] = dst[8] = dst[12] = 0; + src = in; + dst = tmp; + for (i = 0; i < 4; i++) { + if (flags[i]) { + // pre-scaling + shift = !(i & 2); + sp1 = src[0] << shift; + sp2 = src[4] << shift; + INV_HAAR4( sp1, sp2, src[8], src[12], + dst[0], dst[4], dst[8], dst[12], + t0, t1, t2, t3, t4); + } else { + dst[0] = dst[4] = dst[8] = dst[12] = 0; } - src++; - dst++; - } + src++; + dst++; + } #undef COMPENSATE - // apply the InvHaar8 to all rows + // apply the InvHaar8 to all rows #define COMPENSATE(x) (x) - src = tmp; - for (i = 0; i < 4; i++) { - if (!src[0] && !src[1] && !src[2] && !src[3]) { - memset(out, 0, 4 * sizeof(out[0])); - } else { - INV_HAAR4(src[0], src[1], src[2], src[3], - out[0], out[1], out[2], out[3], - t0, t1, t2, t3, t4); - } - src += 4; - out += pitch; - } + src = tmp; + for (i = 0; i < 4; i++) { + if (!src[0] && !src[1] && !src[2] && !src[3]) { + memset(out, 0, 4 * sizeof(out[0])); + } else { + INV_HAAR4(src[0], src[1], src[2], src[3], + out[0], out[1], out[2], out[3], + t0, t1, t2, t3, t4); + } + src += 4; + out += pitch; + } #undef COMPENSATE } void IndeoDSP::ffIviRowHaar4(const int32 *in, int16 *out, uint32 pitch, - const uint8 *flags) { - int i; - int t0, t1, t2, t3, t4; + const uint8 *flags) { + int i; + int t0, t1, t2, t3, t4; - // apply the InvHaar4 to all rows + // apply the InvHaar4 to all rows #define COMPENSATE(x) (x) - for (i = 0; i < 4; i++) { - if (!in[0] && !in[1] && !in[2] && !in[3]) { - memset(out, 0, 4 * sizeof(out[0])); - } else { - INV_HAAR4(in[0], in[1], in[2], in[3], - out[0], out[1], out[2], out[3], - t0, t1, t2, t3, t4); - } - in += 4; - out += pitch; - } + for (i = 0; i < 4; i++) { + if (!in[0] && !in[1] && !in[2] && !in[3]) { + memset(out, 0, 4 * sizeof(out[0])); + } else { + INV_HAAR4(in[0], in[1], in[2], in[3], + out[0], out[1], out[2], out[3], + t0, t1, t2, t3, t4); + } + in += 4; + out += pitch; + } #undef COMPENSATE } void IndeoDSP::ffIviColHaar4(const int32 *in, int16 *out, uint32 pitch, - const uint8 *flags) { - int i; - int t0, t1, t2, t3, t4; + const uint8 *flags) { + int i; + int t0, t1, t2, t3, t4; - // apply the InvHaar8 to all columns + // apply the InvHaar8 to all columns #define COMPENSATE(x) (x) - for (i = 0; i < 4; i++) { - if (flags[i]) { - INV_HAAR4(in[0], in[4], in[8], in[12], - out[0 * pitch], out[1 * pitch], - out[2 * pitch], out[3 * pitch], - t0, t1, t2, t3, t4); - } else { - out[0 * pitch] = out[1 * pitch] = - out[2 * pitch] = out[3 * pitch] = 0; + for (i = 0; i < 4; i++) { + if (flags[i]) { + INV_HAAR4(in[0], in[4], in[8], in[12], + out[0 * pitch], out[1 * pitch], + out[2 * pitch], out[3 * pitch], + t0, t1, t2, t3, t4); + } else { + out[0 * pitch] = out[1 * pitch] = + out[2 * pitch] = out[3 * pitch] = 0; } - in++; - out++; - } + in++; + out++; + } #undef COMPENSATE } void IndeoDSP::ffIviDcHaar2d(const int32 *in, int16 *out, uint32 pitch, - int blkSize) { - int x, y; - int16 dcCoeff; + int blkSize) { + int x, y; + int16 dcCoeff; - dcCoeff = (*in + 0) >> 3; + dcCoeff = (*in + 0) >> 3; - for (y = 0; y < blkSize; out += pitch, y++) { - for (x = 0; x < blkSize; x++) - out[x] = dcCoeff; - } + for (y = 0; y < blkSize; out += pitch, y++) { + for (x = 0; x < blkSize; x++) + out[x] = dcCoeff; + } } //* butterfly operation for the inverse slant transform #define IVI_SLANT_BFLY(s1, s2, o1, o2, t) \ - t = (s1) - (s2);\ - o1 = (s1) + (s2);\ - o2 = (t);\ + t = (s1) - (s2);\ + o1 = (s1) + (s2);\ + o2 = (t);\ //* This is a reflection a,b = 1/2, 5/4 for the inverse slant transform #define IVI_IREFLECT(s1, s2, o1, o2, t) \ - t = (((s1) + (s2)*2 + 2) >> 2) + (s1);\ - o2 = (((s1)*2 - (s2) + 2) >> 2) - (s2);\ - o1 = (t);\ + t = (((s1) + (s2)*2 + 2) >> 2) + (s1);\ + o2 = (((s1)*2 - (s2) + 2) >> 2) - (s2);\ + o1 = (t);\ //* This is a reflection a,b = 1/2, 7/8 for the inverse slant transform #define IVI_SLANT_PART4(s1, s2, o1, o2, t) \ - t = (s2) + (((s1)*4 - (s2) + 4) >> 3);\ - o2 = (s1) + ((-(s1) - (s2)*4 + 4) >> 3);\ - o1 = (t);\ + t = (s2) + (((s1)*4 - (s2) + 4) >> 3);\ + o2 = (s1) + ((-(s1) - (s2)*4 + 4) >> 3);\ + o1 = (t);\ //* inverse slant8 transform #define IVI_INV_SLANT8(s1, s4, s8, s5, s2, s6, s3, s7,\ - d1, d2, d3, d4, d5, d6, d7, d8,\ - t0, t1, t2, t3, t4, t5, t6, t7, t8) {\ - IVI_SLANT_PART4(s4, s5, t4, t5, t0);\ + d1, d2, d3, d4, d5, d6, d7, d8,\ + t0, t1, t2, t3, t4, t5, t6, t7, t8) {\ + IVI_SLANT_PART4(s4, s5, t4, t5, t0);\ \ - IVI_SLANT_BFLY(s1, t5, t1, t5, t0); IVI_SLANT_BFLY(s2, s6, t2, t6, t0);\ - IVI_SLANT_BFLY(s7, s3, t7, t3, t0); IVI_SLANT_BFLY(t4, s8, t4, t8, t0);\ + IVI_SLANT_BFLY(s1, t5, t1, t5, t0); IVI_SLANT_BFLY(s2, s6, t2, t6, t0);\ + IVI_SLANT_BFLY(s7, s3, t7, t3, t0); IVI_SLANT_BFLY(t4, s8, t4, t8, t0);\ \ - IVI_SLANT_BFLY(t1, t2, t1, t2, t0); IVI_IREFLECT (t4, t3, t4, t3, t0);\ - IVI_SLANT_BFLY(t5, t6, t5, t6, t0); IVI_IREFLECT (t8, t7, t8, t7, t0);\ - IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\ - IVI_SLANT_BFLY(t5, t8, t5, t8, t0); IVI_SLANT_BFLY(t6, t7, t6, t7, t0);\ - d1 = COMPENSATE(t1);\ - d2 = COMPENSATE(t2);\ - d3 = COMPENSATE(t3);\ - d4 = COMPENSATE(t4);\ - d5 = COMPENSATE(t5);\ - d6 = COMPENSATE(t6);\ - d7 = COMPENSATE(t7);\ - d8 = COMPENSATE(t8);} + IVI_SLANT_BFLY(t1, t2, t1, t2, t0); IVI_IREFLECT (t4, t3, t4, t3, t0);\ + IVI_SLANT_BFLY(t5, t6, t5, t6, t0); IVI_IREFLECT (t8, t7, t8, t7, t0);\ + IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\ + IVI_SLANT_BFLY(t5, t8, t5, t8, t0); IVI_SLANT_BFLY(t6, t7, t6, t7, t0);\ + d1 = COMPENSATE(t1);\ + d2 = COMPENSATE(t2);\ + d3 = COMPENSATE(t3);\ + d4 = COMPENSATE(t4);\ + d5 = COMPENSATE(t5);\ + d6 = COMPENSATE(t6);\ + d7 = COMPENSATE(t7);\ + d8 = COMPENSATE(t8);} //* inverse slant4 transform #define IVI_INV_SLANT4(s1, s4, s2, s3, d1, d2, d3, d4, t0, t1, t2, t3, t4) {\ - IVI_SLANT_BFLY(s1, s2, t1, t2, t0); IVI_IREFLECT (s4, s3, t4, t3, t0);\ + IVI_SLANT_BFLY(s1, s2, t1, t2, t0); IVI_IREFLECT (s4, s3, t4, t3, t0);\ \ - IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\ - d1 = COMPENSATE(t1);\ - d2 = COMPENSATE(t2);\ - d3 = COMPENSATE(t3);\ - d4 = COMPENSATE(t4);} + IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\ + d1 = COMPENSATE(t1);\ + d2 = COMPENSATE(t2);\ + d3 = COMPENSATE(t3);\ + d4 = COMPENSATE(t4);} void IndeoDSP::ffIviInverseSlant8x8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i; - const int32 *src; - int32 * dst; - int tmp[64]; - int t0, t1, t2, t3, t4, t5, t6, t7, t8; + int i; + const int32 *src; + int32 * dst; + int tmp[64]; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; #define COMPENSATE(x) (x) - src = in; - dst = tmp; - for (i = 0; i < 8; i++) { - if (flags[i]) { - IVI_INV_SLANT8(src[0], src[8], src[16], src[24], src[32], src[40], src[48], src[56], - dst[0], dst[8], dst[16], dst[24], dst[32], dst[40], dst[48], dst[56], - t0, t1, t2, t3, t4, t5, t6, t7, t8); - } else { - dst[0] = dst[8] = dst[16] = dst[24] = dst[32] = dst[40] = dst[48] = dst[56] = 0; + src = in; + dst = tmp; + for (i = 0; i < 8; i++) { + if (flags[i]) { + IVI_INV_SLANT8(src[0], src[8], src[16], src[24], src[32], src[40], src[48], src[56], + dst[0], dst[8], dst[16], dst[24], dst[32], dst[40], dst[48], dst[56], + t0, t1, t2, t3, t4, t5, t6, t7, t8); + } else { + dst[0] = dst[8] = dst[16] = dst[24] = dst[32] = dst[40] = dst[48] = dst[56] = 0; } src++; - dst++; - } + dst++; + } #undef COMPENSATE #define COMPENSATE(x) (((x) + 1)>>1) - src = tmp; - for (i = 0; i < 8; i++) { - if (!src[0] && !src[1] && !src[2] && !src[3] && !src[4] && !src[5] && !src[6] && !src[7]) { - memset(out, 0, 8*sizeof(out[0])); - } else { - IVI_INV_SLANT8(src[0], src[1], src[2], src[3], src[4], src[5], src[6], src[7], - out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], - t0, t1, t2, t3, t4, t5, t6, t7, t8); - } - src += 8; - out += pitch; - } + src = tmp; + for (i = 0; i < 8; i++) { + if (!src[0] && !src[1] && !src[2] && !src[3] && !src[4] && !src[5] && !src[6] && !src[7]) { + memset(out, 0, 8*sizeof(out[0])); + } else { + IVI_INV_SLANT8(src[0], src[1], src[2], src[3], src[4], src[5], src[6], src[7], + out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], + t0, t1, t2, t3, t4, t5, t6, t7, t8); + } + src += 8; + out += pitch; + } #undef COMPENSATE } void IndeoDSP::ffIviInverseSlant4x4(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i; - const int32 *src; - int32 * dst; - int tmp[16]; - int t0, t1, t2, t3, t4; + int i; + const int32 *src; + int32 * dst; + int tmp[16]; + int t0, t1, t2, t3, t4; #define COMPENSATE(x) (x) - src = in; - dst = tmp; - for (i = 0; i < 4; i++) { - if (flags[i]) { - IVI_INV_SLANT4(src[0], src[4], src[8], src[12], - dst[0], dst[4], dst[8], dst[12], - t0, t1, t2, t3, t4); - } else { - dst[0] = dst[4] = dst[8] = dst[12] = 0; + src = in; + dst = tmp; + for (i = 0; i < 4; i++) { + if (flags[i]) { + IVI_INV_SLANT4(src[0], src[4], src[8], src[12], + dst[0], dst[4], dst[8], dst[12], + t0, t1, t2, t3, t4); + } else { + dst[0] = dst[4] = dst[8] = dst[12] = 0; } src++; dst++; - } + } #undef COMPENSATE #define COMPENSATE(x) (((x) + 1)>>1) - src = tmp; - for (i = 0; i < 4; i++) { - if (!src[0] && !src[1] && !src[2] && !src[3]) { - out[0] = out[1] = out[2] = out[3] = 0; - } else { - IVI_INV_SLANT4(src[0], src[1], src[2], src[3], - out[0], out[1], out[2], out[3], - t0, t1, t2, t3, t4); - } - src += 4; - out += pitch; - } + src = tmp; + for (i = 0; i < 4; i++) { + if (!src[0] && !src[1] && !src[2] && !src[3]) { + out[0] = out[1] = out[2] = out[3] = 0; + } else { + IVI_INV_SLANT4(src[0], src[1], src[2], src[3], + out[0], out[1], out[2], out[3], + t0, t1, t2, t3, t4); + } + src += 4; + out += pitch; + } #undef COMPENSATE } void IndeoDSP::ffIviDcSlant2d(const int32 *in, int16 *out, uint32 pitch, int blkSize) { - int x, y; - int16 dcCoeff; + int x, y; + int16 dcCoeff; - dcCoeff = (*in + 1) >> 1; + dcCoeff = (*in + 1) >> 1; - for (y = 0; y < blkSize; out += pitch, y++) { - for (x = 0; x < blkSize; x++) - out[x] = dcCoeff; - } + for (y = 0; y < blkSize; out += pitch, y++) { + for (x = 0; x < blkSize; x++) + out[x] = dcCoeff; + } } void IndeoDSP::ffIviRowSlant8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i; - int t0, t1, t2, t3, t4, t5, t6, t7, t8; + int i; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; #define COMPENSATE(x) (((x) + 1)>>1) - for (i = 0; i < 8; i++) { - if (!in[0] && !in[1] && !in[2] && !in[3] && !in[4] && !in[5] && !in[6] && !in[7]) { - memset(out, 0, 8*sizeof(out[0])); - } else { - IVI_INV_SLANT8( in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7], - out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], - t0, t1, t2, t3, t4, t5, t6, t7, t8); - } - in += 8; - out += pitch; - } + for (i = 0; i < 8; i++) { + if (!in[0] && !in[1] && !in[2] && !in[3] && !in[4] && !in[5] && !in[6] && !in[7]) { + memset(out, 0, 8*sizeof(out[0])); + } else { + IVI_INV_SLANT8( in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7], + out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], + t0, t1, t2, t3, t4, t5, t6, t7, t8); + } + in += 8; + out += pitch; + } #undef COMPENSATE } void IndeoDSP::ffIviDcRowSlant(const int32 *in, int16 *out, uint32 pitch, int blkSize) { - int x, y; - int16 dcCoeff; + int x, y; + int16 dcCoeff; - dcCoeff = (*in + 1) >> 1; + dcCoeff = (*in + 1) >> 1; - for (x = 0; x < blkSize; x++) - out[x] = dcCoeff; + for (x = 0; x < blkSize; x++) + out[x] = dcCoeff; - out += pitch; + out += pitch; - for (y = 1; y < blkSize; out += pitch, y++) { - for (x = 0; x < blkSize; x++) - out[x] = 0; - } + for (y = 1; y < blkSize; out += pitch, y++) { + for (x = 0; x < blkSize; x++) + out[x] = 0; + } } void IndeoDSP::ffIviColSlant8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i, row2, row4, row8; - int t0, t1, t2, t3, t4, t5, t6, t7, t8; + int i, row2, row4, row8; + int t0, t1, t2, t3, t4, t5, t6, t7, t8; - row2 = pitch << 1; - row4 = pitch << 2; - row8 = pitch << 3; + row2 = pitch << 1; + row4 = pitch << 2; + row8 = pitch << 3; #define COMPENSATE(x) (((x) + 1)>>1) - for (i = 0; i < 8; i++) { - if (flags[i]) { - IVI_INV_SLANT8(in[0], in[8], in[16], in[24], in[32], in[40], in[48], in[56], - out[0], out[pitch], out[row2], out[row2 + pitch], out[row4], - out[row4 + pitch], out[row4 + row2], out[row8 - pitch], - t0, t1, t2, t3, t4, t5, t6, t7, t8); - } else { - out[0] = out[pitch] = out[row2] = out[row2 + pitch] = out[row4] = - out[row4 + pitch] = out[row4 + row2] = out[row8 - pitch] = 0; - } - - in++; - out++; - } + for (i = 0; i < 8; i++) { + if (flags[i]) { + IVI_INV_SLANT8(in[0], in[8], in[16], in[24], in[32], in[40], in[48], in[56], + out[0], out[pitch], out[row2], out[row2 + pitch], out[row4], + out[row4 + pitch], out[row4 + row2], out[row8 - pitch], + t0, t1, t2, t3, t4, t5, t6, t7, t8); + } else { + out[0] = out[pitch] = out[row2] = out[row2 + pitch] = out[row4] = + out[row4 + pitch] = out[row4 + row2] = out[row8 - pitch] = 0; + } + + in++; + out++; + } #undef COMPENSATE } void IndeoDSP::ffIviDcColSlant(const int32 *in, int16 *out, uint32 pitch, int blkSize) { - int x, y; - int16 dcCoeff; + int x, y; + int16 dcCoeff; - dcCoeff = (*in + 1) >> 1; + dcCoeff = (*in + 1) >> 1; - for (y = 0; y < blkSize; out += pitch, y++) { - out[0] = dcCoeff; - for (x = 1; x < blkSize; x++) - out[x] = 0; - } + for (y = 0; y < blkSize; out += pitch, y++) { + out[0] = dcCoeff; + for (x = 1; x < blkSize; x++) + out[x] = 0; + } } void IndeoDSP::ffIviRowSlant4(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i; - int t0, t1, t2, t3, t4; + int i; + int t0, t1, t2, t3, t4; #define COMPENSATE(x) (((x) + 1)>>1) - for (i = 0; i < 4; i++) { - if (!in[0] && !in[1] && !in[2] && !in[3]) { - memset(out, 0, 4*sizeof(out[0])); - } else { - IVI_INV_SLANT4( in[0], in[1], in[2], in[3], - out[0], out[1], out[2], out[3], - t0, t1, t2, t3, t4); - } - in += 4; - out += pitch; - } + for (i = 0; i < 4; i++) { + if (!in[0] && !in[1] && !in[2] && !in[3]) { + memset(out, 0, 4*sizeof(out[0])); + } else { + IVI_INV_SLANT4( in[0], in[1], in[2], in[3], + out[0], out[1], out[2], out[3], + t0, t1, t2, t3, t4); + } + in += 4; + out += pitch; + } #undef COMPENSATE } void IndeoDSP::ffIviColSlant4(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int i, row2; - int t0, t1, t2, t3, t4; + int i, row2; + int t0, t1, t2, t3, t4; - row2 = pitch << 1; + row2 = pitch << 1; #define COMPENSATE(x) (((x) + 1)>>1) - for (i = 0; i < 4; i++) { - if (flags[i]) { - IVI_INV_SLANT4(in[0], in[4], in[8], in[12], - out[0], out[pitch], out[row2], out[row2 + pitch], - t0, t1, t2, t3, t4); - } else { - out[0] = out[pitch] = out[row2] = out[row2 + pitch] = 0; - } - - in++; - out++; - } + for (i = 0; i < 4; i++) { + if (flags[i]) { + IVI_INV_SLANT4(in[0], in[4], in[8], in[12], + out[0], out[pitch], out[row2], out[row2 + pitch], + t0, t1, t2, t3, t4); + } else { + out[0] = out[pitch] = out[row2] = out[row2 + pitch] = 0; + } + + in++; + out++; + } #undef COMPENSATE } void IndeoDSP::ffIviPutPixels8x8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) { - int x, y; + int x, y; - for (y = 0; y < 8; out += pitch, in += 8, y++) - for (x = 0; x < 8; x++) - out[x] = in[x]; + for (y = 0; y < 8; out += pitch, in += 8, y++) + for (x = 0; x < 8; x++) + out[x] = in[x]; } void IndeoDSP::ffIviPutDcPixel8x8(const int32 *in, int16 *out, uint32 pitch, int blkSize) { - int y; + int y; - out[0] = in[0]; - memset(out + 1, 0, 7*sizeof(out[0])); - out += pitch; + out[0] = in[0]; + memset(out + 1, 0, 7*sizeof(out[0])); + out += pitch; - for (y = 1; y < 8; out += pitch, y++) - memset(out, 0, 8*sizeof(out[0])); + for (y = 1; y < 8; out += pitch, y++) + memset(out, 0, 8*sizeof(out[0])); } #define IVI_MC_TEMPLATE(size, suffix, OP) \ static void iviMc ## size ##x## size ## suffix(int16 *buf, \ - uint32 dpitch, \ - const int16 *refBuf, \ - uint32 pitch, int mcType) \ + uint32 dpitch, \ + const int16 *refBuf, \ + uint32 pitch, int mcType) \ { \ - int i, j; \ - const int16 *wptr; \ + int i, j; \ + const int16 *wptr; \ \ - switch (mcType) { \ - case 0: /* fullpel (no interpolation) */ \ - for (i = 0; i < size; i++, buf += dpitch, refBuf += pitch) { \ - for (j = 0; j < size; j++) {\ - OP(buf[j], refBuf[j]); \ - } \ - } \ - break; \ - case 1: /* horizontal halfpel interpolation */ \ - for (i = 0; i < size; i++, buf += dpitch, refBuf += pitch) \ - for (j = 0; j < size; j++) \ - OP(buf[j], (refBuf[j] + refBuf[j+1]) >> 1); \ - break; \ - case 2: /* vertical halfpel interpolation */ \ - wptr = refBuf + pitch; \ - for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, refBuf += pitch) \ - for (j = 0; j < size; j++) \ - OP(buf[j], (refBuf[j] + wptr[j]) >> 1); \ - break; \ - case 3: /* vertical and horizontal halfpel interpolation */ \ - wptr = refBuf + pitch; \ - for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, refBuf += pitch) \ - for (j = 0; j < size; j++) \ - OP(buf[j], (refBuf[j] + refBuf[j+1] + wptr[j] + wptr[j+1]) >> 2); \ - break; \ - } \ + switch (mcType) { \ + case 0: /* fullpel (no interpolation) */ \ + for (i = 0; i < size; i++, buf += dpitch, refBuf += pitch) { \ + for (j = 0; j < size; j++) {\ + OP(buf[j], refBuf[j]); \ + } \ + } \ + break; \ + case 1: /* horizontal halfpel interpolation */ \ + for (i = 0; i < size; i++, buf += dpitch, refBuf += pitch) \ + for (j = 0; j < size; j++) \ + OP(buf[j], (refBuf[j] + refBuf[j+1]) >> 1); \ + break; \ + case 2: /* vertical halfpel interpolation */ \ + wptr = refBuf + pitch; \ + for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, refBuf += pitch) \ + for (j = 0; j < size; j++) \ + OP(buf[j], (refBuf[j] + wptr[j]) >> 1); \ + break; \ + case 3: /* vertical and horizontal halfpel interpolation */ \ + wptr = refBuf + pitch; \ + for (i = 0; i < size; i++, buf += dpitch, wptr += pitch, refBuf += pitch) \ + for (j = 0; j < size; j++) \ + OP(buf[j], (refBuf[j] + refBuf[j+1] + wptr[j] + wptr[j+1]) >> 2); \ + break; \ + } \ } \ \ void IndeoDSP::ffIviMc ## size ##x## size ## suffix(int16 *buf, const int16 *refBuf, \ - uint32 pitch, int mcType) \ + uint32 pitch, int mcType) \ { \ - iviMc ## size ##x## size ## suffix(buf, pitch, refBuf, pitch, mcType); \ + iviMc ## size ##x## size ## suffix(buf, pitch, refBuf, pitch, mcType); \ } #define IVI_MC_AVG_TEMPLATE(size, suffix, OP) \ void IndeoDSP::ffIviMcAvg ## size ##x## size ## suffix(int16 *buf, \ - const int16 *refBuf, \ - const int16 *refBuf2, \ - uint32 pitch, \ - int mcType, int mcType2) \ + const int16 *refBuf, \ + const int16 *refBuf2, \ + uint32 pitch, \ + int mcType, int mcType2) \ { \ - int16 tmp[size * size]; \ - int i, j; \ + int16 tmp[size * size]; \ + int i, j; \ \ - iviMc ## size ##x## size ## NoDelta(tmp, size, refBuf, pitch, mcType); \ - iviMc ## size ##x## size ## Delta(tmp, size, refBuf2, pitch, mcType2); \ - for (i = 0; i < size; i++, buf += pitch) { \ - for (j = 0; j < size; j++) {\ - OP(buf[j], tmp[i * size + j] >> 1); \ - } \ - } \ + iviMc ## size ##x## size ## NoDelta(tmp, size, refBuf, pitch, mcType); \ + iviMc ## size ##x## size ## Delta(tmp, size, refBuf2, pitch, mcType2); \ + for (i = 0; i < size; i++, buf += pitch) { \ + for (j = 0; j < size; j++) {\ + OP(buf[j], tmp[i * size + j] >> 1); \ + } \ + } \ } #define OP_PUT(a, b) (a) = (b) -- cgit v1.2.3