ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

indeo_dsp.cpp

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 /* VLC code
00024  *
00025  * Original copyright note: * Intel Indeo 4 (IV41, IV42, etc.) video decoder for ffmpeg
00026  * written, produced, and directed by Alan Smithee
00027  */
00028 
00029 #include "image/codecs/indeo/indeo_dsp.h"
00030 
00031 namespace Image {
00032 namespace Indeo {
00033 
00037 #define IVI_HAAR_BFLY(s1, s2, o1, o2, t) \
00038     t  = ((s1) - (s2)) >> 1;\
00039     o1 = ((s1) + (s2)) >> 1;\
00040     o2 = (t);\
00041 
00042 
00045 #define INV_HAAR8(s1, s5, s3, s7, s2, s4, s6, s8,\
00046                   d1, d2, d3, d4, d5, d6, d7, d8,\
00047                   t0, t1, t2, t3, t4, t5, t6, t7, t8) {\
00048     t1 = (s1) << 1; t5 = (s5) << 1;\
00049     IVI_HAAR_BFLY(t1, t5, t1, t5, t0); IVI_HAAR_BFLY(t1, s3, t1, t3, t0);\
00050     IVI_HAAR_BFLY(t5, s7, t5, t7, t0); IVI_HAAR_BFLY(t1, s2, t1, t2, t0);\
00051     IVI_HAAR_BFLY(t3, s4, t3, t4, t0); IVI_HAAR_BFLY(t5, s6, t5, t6, t0);\
00052     IVI_HAAR_BFLY(t7, s8, t7, t8, t0);\
00053     d1 = COMPENSATE(t1);\
00054     d2 = COMPENSATE(t2);\
00055     d3 = COMPENSATE(t3);\
00056     d4 = COMPENSATE(t4);\
00057     d5 = COMPENSATE(t5);\
00058     d6 = COMPENSATE(t6);\
00059     d7 = COMPENSATE(t7);\
00060     d8 = COMPENSATE(t8); }
00061 
00065 #define INV_HAAR4(s1, s3, s5, s7, d1, d2, d3, d4, t0, t1, t2, t3, t4) {\
00066     IVI_HAAR_BFLY(s1, s3, t0, t1, t4);\
00067     IVI_HAAR_BFLY(t0, s5, t2, t3, t4);\
00068     d1 = COMPENSATE(t2);\
00069     d2 = COMPENSATE(t3);\
00070     IVI_HAAR_BFLY(t1, s7, t2, t3, t4);\
00071     d3 = COMPENSATE(t2);\
00072     d4 = COMPENSATE(t3); }
00073 
00074 void IndeoDSP::ffIviInverseHaar8x8(const int32 *in, int16 *out, uint32 pitch,
00075                              const uint8 *flags) {
00076     int32 tmp[64];
00077     int t0, t1, t2, t3, t4, t5, t6, t7, t8;
00078 
00079     // apply the InvHaar8 to all columns
00080 #define COMPENSATE(x) (x)
00081     const int32 *src = in;
00082     int32 *dst = tmp;
00083     for (int i = 0; i < 8; i++) {
00084         if (flags[i]) {
00085             // pre-scaling
00086             int shift = !(i & 4);
00087             int sp1 = src[ 0] << shift;
00088             int sp2 = src[ 8] << shift;
00089             int sp3 = src[16] << shift;
00090             int sp4 = src[24] << shift;
00091             INV_HAAR8(    sp1,     sp2,     sp3,     sp4,
00092                       src[32], src[40], src[48], src[56],
00093                       dst[ 0], dst[ 8], dst[16], dst[24],
00094                       dst[32], dst[40], dst[48], dst[56],
00095                       t0, t1, t2, t3, t4, t5, t6, t7, t8);
00096         } else {
00097             dst[ 0] = dst[ 8] = dst[16] = dst[24] =
00098             dst[32] = dst[40] = dst[48] = dst[56] = 0;
00099         }
00100 
00101         src++;
00102         dst++;
00103     }
00104 #undef  COMPENSATE
00105 
00106     // apply the InvHaar8 to all rows
00107 #define COMPENSATE(x) (x)
00108     src = tmp;
00109     for (int i = 0; i < 8; i++) {
00110         if (!src[0] && !src[1] && !src[2] && !src[3] &&
00111                 !src[4] && !src[5] && !src[6] && !src[7]) {
00112             memset(out, 0, 8 * sizeof(out[0]));
00113         } else {
00114             INV_HAAR8(src[0], src[1], src[2], src[3],
00115                       src[4], src[5], src[6], src[7],
00116                       out[0], out[1], out[2], out[3],
00117                       out[4], out[5], out[6], out[7],
00118                       t0, t1, t2, t3, t4, t5, t6, t7, t8);
00119         }
00120         src += 8;
00121         out += pitch;
00122     }
00123 #undef  COMPENSATE
00124 }
00125 
00126 void IndeoDSP::ffIviRowHaar8(const int32 *in, int16 *out, uint32 pitch,
00127                       const uint8 *flags) {
00128     int t0, t1, t2, t3, t4, t5, t6, t7, t8;
00129 
00130     // apply the InvHaar8 to all rows
00131 #define COMPENSATE(x) (x)
00132     for (int i = 0; i < 8; i++) {
00133         if (   !in[0] && !in[1] && !in[2] && !in[3]
00134             && !in[4] && !in[5] && !in[6] && !in[7]) {
00135             memset(out, 0, 8 * sizeof(out[0]));
00136         } else {
00137             INV_HAAR8(in[0],  in[1],  in[2],  in[3],
00138                       in[4],  in[5],  in[6],  in[7],
00139                       out[0], out[1], out[2], out[3],
00140                       out[4], out[5], out[6], out[7],
00141                       t0, t1, t2, t3, t4, t5, t6, t7, t8);
00142         }
00143         in  += 8;
00144         out += pitch;
00145     }
00146 #undef  COMPENSATE
00147 }
00148 
00149 void IndeoDSP::ffIviColHaar8(const int32 *in, int16 *out, uint32 pitch,
00150                       const uint8 *flags) {
00151     int t0, t1, t2, t3, t4, t5, t6, t7, t8;
00152 
00153     // apply the InvHaar8 to all columns
00154 #define COMPENSATE(x) (x)
00155     for (int i = 0; i < 8; i++) {
00156         if (flags[i]) {
00157             INV_HAAR8(in[ 0], in[ 8], in[16], in[24],
00158                       in[32], in[40], in[48], in[56],
00159                       out[0 * pitch], out[1 * pitch],
00160                       out[2 * pitch], out[3 * pitch],
00161                       out[4 * pitch], out[5 * pitch],
00162                       out[6 * pitch], out[7 * pitch],
00163                       t0, t1, t2, t3, t4, t5, t6, t7, t8);
00164         } else {
00165             out[0 * pitch] = out[1 * pitch] =
00166             out[2 * pitch] = out[3 * pitch] =
00167             out[4 * pitch] = out[5 * pitch] =
00168             out[6 * pitch] = out[7 * pitch] = 0;
00169         }
00170 
00171         in++;
00172         out++;
00173     }
00174 #undef  COMPENSATE
00175 }
00176 
00177 void IndeoDSP::ffIviInverseHaar4x4(const int32 *in, int16 *out, uint32 pitch,
00178                              const uint8 *flags) {
00179     int32 tmp[16];
00180     int t0, t1, t2, t3, t4;
00181 
00182     // apply the InvHaar4 to all columns
00183 #define COMPENSATE(x) (x)
00184     const int32 *src = in;
00185     int32 *dst = tmp;
00186     for (int i = 0; i < 4; i++) {
00187         if (flags[i]) {
00188             // pre-scaling
00189             int shift = !(i & 2);
00190             int sp1 = src[0] << shift;
00191             int sp2 = src[4] << shift;
00192             INV_HAAR4(   sp1,    sp2, src[8], src[12],
00193                       dst[0], dst[4], dst[8], dst[12],
00194                       t0, t1, t2, t3, t4);
00195         } else {
00196             dst[0] = dst[4] = dst[8] = dst[12] = 0;
00197         }
00198 
00199         src++;
00200         dst++;
00201     }
00202 #undef  COMPENSATE
00203 
00204     // apply the InvHaar8 to all rows
00205 #define COMPENSATE(x) (x)
00206     src = tmp;
00207     for (int i = 0; i < 4; i++) {
00208         if (!src[0] && !src[1] && !src[2] && !src[3]) {
00209             memset(out, 0, 4 * sizeof(out[0]));
00210         } else {
00211             INV_HAAR4(src[0], src[1], src[2], src[3],
00212                       out[0], out[1], out[2], out[3],
00213                       t0, t1, t2, t3, t4);
00214         }
00215         src += 4;
00216         out += pitch;
00217     }
00218 #undef  COMPENSATE
00219 }
00220 
00221 void IndeoDSP::ffIviRowHaar4(const int32 *in, int16 *out, uint32 pitch,
00222                       const uint8 *flags) {
00223     int t0, t1, t2, t3, t4;
00224 
00225     // apply the InvHaar4 to all rows
00226 #define COMPENSATE(x) (x)
00227     for (int i = 0; i < 4; i++) {
00228         if (!in[0] && !in[1] && !in[2] && !in[3]) {
00229             memset(out, 0, 4 * sizeof(out[0]));
00230         } else {
00231             INV_HAAR4(in[0], in[1], in[2], in[3],
00232                       out[0], out[1], out[2], out[3],
00233                       t0, t1, t2, t3, t4);
00234         }
00235         in  += 4;
00236         out += pitch;
00237     }
00238 #undef  COMPENSATE
00239 }
00240 
00241 void IndeoDSP::ffIviColHaar4(const int32 *in, int16 *out, uint32 pitch,
00242                       const uint8 *flags) {
00243     int t0, t1, t2, t3, t4;
00244 
00245     // apply the InvHaar8 to all columns
00246 #define COMPENSATE(x) (x)
00247     for (int i = 0; i < 4; i++) {
00248         if (flags[i]) {
00249             INV_HAAR4(in[0], in[4], in[8], in[12],
00250                       out[0 * pitch], out[1 * pitch],
00251                       out[2 * pitch], out[3 * pitch],
00252                       t0, t1, t2, t3, t4);
00253         } else {
00254             out[0 * pitch] = out[1 * pitch] =
00255             out[2 * pitch] = out[3 * pitch] = 0;
00256         }
00257 
00258         in++;
00259         out++;
00260     }
00261 #undef  COMPENSATE
00262 }
00263 
00264 void IndeoDSP::ffIviDcHaar2d(const int32 *in, int16 *out, uint32 pitch,
00265                        int blkSize) {
00266     int16 dcCoeff = (*in + 0) >> 3;
00267 
00268     for (int y = 0; y < blkSize; out += pitch, y++) {
00269         for (int x = 0; x < blkSize; x++)
00270             out[x] = dcCoeff;
00271     }
00272 }
00273 
00274 //* butterfly operation for the inverse slant transform
00275 #define IVI_SLANT_BFLY(s1, s2, o1, o2, t) \
00276     t  = (s1) - (s2);\
00277     o1 = (s1) + (s2);\
00278     o2 = (t);\
00279 
00280 //* This is a reflection a,b = 1/2, 5/4 for the inverse slant transform
00281 #define IVI_IREFLECT(s1, s2, o1, o2, t) \
00282     t  = (((s1) + (s2)*2 + 2) >> 2) + (s1);\
00283     o2 = (((s1)*2 - (s2) + 2) >> 2) - (s2);\
00284     o1 = (t);\
00285 
00286 //* This is a reflection a,b = 1/2, 7/8 for the inverse slant transform
00287 #define IVI_SLANT_PART4(s1, s2, o1, o2, t) \
00288     t  = (s2) + (((s1)*4  - (s2) + 4) >> 3);\
00289     o2 = (s1) + ((-(s1) - (s2)*4 + 4) >> 3);\
00290     o1 = (t);\
00291 
00292 //* inverse slant8 transform
00293 #define IVI_INV_SLANT8(s1, s4, s8, s5, s2, s6, s3, s7,\
00294                        d1, d2, d3, d4, d5, d6, d7, d8,\
00295                        t0, t1, t2, t3, t4, t5, t6, t7, t8) {\
00296     IVI_SLANT_PART4(s4, s5, t4, t5, t0);\
00297 \
00298     IVI_SLANT_BFLY(s1, t5, t1, t5, t0); IVI_SLANT_BFLY(s2, s6, t2, t6, t0);\
00299     IVI_SLANT_BFLY(s7, s3, t7, t3, t0); IVI_SLANT_BFLY(t4, s8, t4, t8, t0);\
00300 \
00301     IVI_SLANT_BFLY(t1, t2, t1, t2, t0); IVI_IREFLECT  (t4, t3, t4, t3, t0);\
00302     IVI_SLANT_BFLY(t5, t6, t5, t6, t0); IVI_IREFLECT  (t8, t7, t8, t7, t0);\
00303     IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\
00304     IVI_SLANT_BFLY(t5, t8, t5, t8, t0); IVI_SLANT_BFLY(t6, t7, t6, t7, t0);\
00305     d1 = COMPENSATE(t1);\
00306     d2 = COMPENSATE(t2);\
00307     d3 = COMPENSATE(t3);\
00308     d4 = COMPENSATE(t4);\
00309     d5 = COMPENSATE(t5);\
00310     d6 = COMPENSATE(t6);\
00311     d7 = COMPENSATE(t7);\
00312     d8 = COMPENSATE(t8);}
00313 
00314 //* inverse slant4 transform
00315 #define IVI_INV_SLANT4(s1, s4, s2, s3, d1, d2, d3, d4, t0, t1, t2, t3, t4) {\
00316     IVI_SLANT_BFLY(s1, s2, t1, t2, t0); IVI_IREFLECT  (s4, s3, t4, t3, t0);\
00317 \
00318     IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\
00319     d1 = COMPENSATE(t1);\
00320     d2 = COMPENSATE(t2);\
00321     d3 = COMPENSATE(t3);\
00322     d4 = COMPENSATE(t4);}
00323 
00324 void IndeoDSP::ffIviInverseSlant8x8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) {
00325     int32 tmp[64];
00326     int t0, t1, t2, t3, t4, t5, t6, t7, t8;
00327 
00328 #define COMPENSATE(x) (x)
00329     const int32 *src = in;
00330     int32 *dst = tmp;
00331     for (int i = 0; i < 8; i++) {
00332         if (flags[i]) {
00333             IVI_INV_SLANT8(src[0], src[8], src[16], src[24], src[32], src[40], src[48], src[56],
00334                            dst[0], dst[8], dst[16], dst[24], dst[32], dst[40], dst[48], dst[56],
00335                            t0, t1, t2, t3, t4, t5, t6, t7, t8);
00336         } else {
00337             dst[0] = dst[8] = dst[16] = dst[24] = dst[32] = dst[40] = dst[48] = dst[56] = 0;
00338         }
00339 
00340         src++;
00341         dst++;
00342     }
00343 #undef COMPENSATE
00344 
00345 #define COMPENSATE(x) (((x) + 1)>>1)
00346     src = tmp;
00347     for (int i = 0; i < 8; i++) {
00348         if (!src[0] && !src[1] && !src[2] && !src[3] && !src[4] && !src[5] && !src[6] && !src[7]) {
00349             memset(out, 0, 8*sizeof(out[0]));
00350         } else {
00351             IVI_INV_SLANT8(src[0], src[1], src[2], src[3], src[4], src[5], src[6], src[7],
00352                            out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7],
00353                            t0, t1, t2, t3, t4, t5, t6, t7, t8);
00354         }
00355         src += 8;
00356         out += pitch;
00357     }
00358 #undef COMPENSATE
00359 }
00360 
00361 void IndeoDSP::ffIviInverseSlant4x4(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) {
00362     int32 tmp[16];
00363     int t0, t1, t2, t3, t4;
00364 
00365 #define COMPENSATE(x) (x)
00366     const int32 *src = in;
00367     int32 *dst = tmp;
00368     for (int i = 0; i < 4; i++) {
00369         if (flags[i]) {
00370             IVI_INV_SLANT4(src[0], src[4], src[8], src[12],
00371                            dst[0], dst[4], dst[8], dst[12],
00372                            t0, t1, t2, t3, t4);
00373         } else {
00374             dst[0] = dst[4] = dst[8] = dst[12] = 0;
00375         }
00376         src++;
00377         dst++;
00378     }
00379 #undef COMPENSATE
00380 
00381 #define COMPENSATE(x) (((x) + 1)>>1)
00382     src = tmp;
00383     for (int i = 0; i < 4; i++) {
00384         if (!src[0] && !src[1] && !src[2] && !src[3]) {
00385             out[0] = out[1] = out[2] = out[3] = 0;
00386         } else {
00387             IVI_INV_SLANT4(src[0], src[1], src[2], src[3],
00388                            out[0], out[1], out[2], out[3],
00389                            t0, t1, t2, t3, t4);
00390         }
00391         src += 4;
00392         out += pitch;
00393     }
00394 #undef COMPENSATE
00395 }
00396 
00397 void IndeoDSP::ffIviDcSlant2d(const int32 *in, int16 *out, uint32 pitch,
00398         int blkSize) {
00399     int16 dcCoeff = (*in + 1) >> 1;
00400 
00401     for (int y = 0; y < blkSize; out += pitch, y++) {
00402         for (int x = 0; x < blkSize; x++)
00403             out[x] = dcCoeff;
00404     }
00405 }
00406 
00407 void IndeoDSP::ffIviRowSlant8(const int32 *in, int16 *out, uint32 pitch,
00408         const uint8 *flags) {
00409     int t0, t1, t2, t3, t4, t5, t6, t7, t8;
00410 
00411 #define COMPENSATE(x) (((x) + 1)>>1)
00412     for (int i = 0; i < 8; i++) {
00413         if (!in[0] && !in[1] && !in[2] && !in[3] && !in[4] && !in[5] && !in[6] && !in[7]) {
00414             memset(out, 0, 8*sizeof(out[0]));
00415         } else {
00416             IVI_INV_SLANT8( in[0],  in[1],  in[2],  in[3],  in[4],  in[5],  in[6],  in[7],
00417                            out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7],
00418                            t0, t1, t2, t3, t4, t5, t6, t7, t8);
00419         }
00420         in += 8;
00421         out += pitch;
00422     }
00423 #undef COMPENSATE
00424 }
00425 
00426 void IndeoDSP::ffIviDcRowSlant(const int32 *in, int16 *out, uint32 pitch, int blkSize) {
00427     int16 dcCoeff = (*in + 1) >> 1;
00428 
00429     for (int x = 0; x < blkSize; x++)
00430         out[x] = dcCoeff;
00431 
00432     out += pitch;
00433 
00434     for (int y = 1; y < blkSize; out += pitch, y++) {
00435         for (int x = 0; x < blkSize; x++)
00436             out[x] = 0;
00437     }
00438 }
00439 
00440 void IndeoDSP::ffIviColSlant8(const int32 *in, int16 *out, uint32 pitch, const uint8 *flags) {
00441     int t0, t1, t2, t3, t4, t5, t6, t7, t8;
00442 
00443     int row2 = pitch << 1;
00444     int row4 = pitch << 2;
00445     int row8 = pitch << 3;
00446 
00447 #define COMPENSATE(x) (((x) + 1)>>1)
00448     for (int i = 0; i < 8; i++) {
00449         if (flags[i]) {
00450             IVI_INV_SLANT8(in[0], in[8], in[16], in[24], in[32], in[40], in[48], in[56],
00451                            out[0], out[pitch], out[row2], out[row2 + pitch], out[row4],
00452                            out[row4 + pitch],  out[row4 + row2], out[row8 - pitch],
00453                            t0, t1, t2, t3, t4, t5, t6, t7, t8);
00454         } else {
00455             out[0] = out[pitch] = out[row2] = out[row2 + pitch] = out[row4] =
00456             out[row4 + pitch] =  out[row4 + row2] = out[row8 - pitch] = 0;
00457         }
00458 
00459         in++;
00460         out++;
00461     }
00462 #undef COMPENSATE
00463 }
00464 
00465 void IndeoDSP::ffIviDcColSlant(const int32 *in, int16 *out, uint32 pitch, int blkSize) {
00466     int16 dcCoeff = (*in + 1) >> 1;
00467 
00468     for (int y = 0; y < blkSize; out += pitch, y++) {
00469         out[0] = dcCoeff;
00470         for (int x = 1; x < blkSize; x++)
00471             out[x] = 0;
00472     }
00473 }
00474 
00475 void IndeoDSP::ffIviRowSlant4(const int32 *in, int16 *out,
00476         uint32 pitch, const uint8 *flags) {
00477     int t0, t1, t2, t3, t4;
00478 
00479 #define COMPENSATE(x) (((x) + 1)>>1)
00480     for (int i = 0; i < 4; i++) {
00481         if (!in[0] && !in[1] && !in[2] && !in[3]) {
00482             memset(out, 0, 4*sizeof(out[0]));
00483         } else {
00484             IVI_INV_SLANT4( in[0],  in[1],  in[2],  in[3],
00485                            out[0], out[1], out[2], out[3],
00486                            t0, t1, t2, t3, t4);
00487         }
00488         in  += 4;
00489         out += pitch;
00490     }
00491 #undef COMPENSATE
00492 }
00493 
00494 void IndeoDSP::ffIviColSlant4(const int32 *in, int16 *out, uint32 pitch,
00495         const uint8 *flags) {
00496     int t0, t1, t2, t3, t4;
00497 
00498     int row2 = pitch << 1;
00499 
00500 #define COMPENSATE(x) (((x) + 1)>>1)
00501     for (int i = 0; i < 4; i++) {
00502         if (flags[i]) {
00503             IVI_INV_SLANT4(in[0], in[4], in[8], in[12],
00504                            out[0], out[pitch], out[row2], out[row2 + pitch],
00505                            t0, t1, t2, t3, t4);
00506         } else {
00507             out[0] = out[pitch] = out[row2] = out[row2 + pitch] = 0;
00508         }
00509 
00510         in++;
00511         out++;
00512     }
00513 #undef COMPENSATE
00514 }
00515 
00516 void IndeoDSP::ffIviPutPixels8x8(const int32 *in, int16 *out, uint32 pitch,
00517         const uint8 *flags) {
00518     for (int y = 0; y < 8; out += pitch, in += 8, y++)
00519         for (int x = 0; x < 8; x++)
00520             out[x] = in[x];
00521 }
00522 
00523 void IndeoDSP::ffIviPutDcPixel8x8(const int32 *in, int16 *out, uint32 pitch,
00524         int blkSize) {
00525     out[0] = in[0];
00526     memset(out + 1, 0, 7 * sizeof(out[0]));
00527     out += pitch;
00528 
00529     for (int y = 1; y < 8; out += pitch, y++)
00530         memset(out, 0, 8 * sizeof(out[0]));
00531 }
00532 
00533 #define IVI_MC_TEMPLATE(size, suffix, OP) \
00534 static void iviMc ## size ##x## size ## suffix(int16 *buf, \
00535                                                  uint32 dpitch, \
00536                                                  const int16 *refBuf, \
00537                                                  uint32 pitch, int mcType) \
00538 { \
00539     const int16 *wptr; \
00540 \
00541     switch (mcType) { \
00542     case 0: /* fullpel (no interpolation) */ \
00543         for (int i = 0; i < size; i++, buf += dpitch, refBuf += pitch) { \
00544             for (int j = 0; j < size; j++) {\
00545                 OP(buf[j], refBuf[j]); \
00546             } \
00547         } \
00548         break; \
00549     case 1: /* horizontal halfpel interpolation */ \
00550         for (int i = 0; i < size; i++, buf += dpitch, refBuf += pitch) \
00551             for (int j = 0; j < size; j++) \
00552                 OP(buf[j], (refBuf[j] + refBuf[j+1]) >> 1); \
00553         break; \
00554     case 2: /* vertical halfpel interpolation */ \
00555         wptr = refBuf + pitch; \
00556         for (int i = 0; i < size; i++, buf += dpitch, wptr += pitch, refBuf += pitch) \
00557             for (int j = 0; j < size; j++) \
00558                 OP(buf[j], (refBuf[j] + wptr[j]) >> 1); \
00559         break; \
00560     case 3: /* vertical and horizontal halfpel interpolation */ \
00561         wptr = refBuf + pitch; \
00562         for (int i = 0; i < size; i++, buf += dpitch, wptr += pitch, refBuf += pitch) \
00563             for (int j = 0; j < size; j++) \
00564                 OP(buf[j], (refBuf[j] + refBuf[j+1] + wptr[j] + wptr[j+1]) >> 2); \
00565         break; \
00566     } \
00567 } \
00568 \
00569 void IndeoDSP::ffIviMc ## size ##x## size ## suffix(int16 *buf, const int16 *refBuf, \
00570                                              uint32 pitch, int mcType) \
00571 { \
00572     iviMc ## size ##x## size ## suffix(buf, pitch, refBuf, pitch, mcType); \
00573 }
00574 
00575 #define IVI_MC_AVG_TEMPLATE(size, suffix, OP) \
00576 void IndeoDSP::ffIviMcAvg ## size ##x## size ## suffix(int16 *buf, \
00577                                                  const int16 *refBuf, \
00578                                                  const int16 *refBuf2, \
00579                                                  uint32 pitch, \
00580                                                int mcType, int mcType2) \
00581 { \
00582     int16 tmp[size * size]; \
00583 \
00584     iviMc ## size ##x## size ## NoDelta(tmp, size, refBuf, pitch, mcType); \
00585     iviMc ## size ##x## size ## Delta(tmp, size, refBuf2, pitch, mcType2); \
00586     for (int i = 0; i < size; i++, buf += pitch) { \
00587         for (int j = 0; j < size; j++) {\
00588             OP(buf[j], tmp[i * size + j] >> 1); \
00589         } \
00590     } \
00591 }
00592 
00593 #define OP_PUT(a, b)  (a) = (b)
00594 #define OP_ADD(a, b)  (a) += (b)
00595 
00596 IVI_MC_TEMPLATE(8, NoDelta, OP_PUT)
00597 IVI_MC_TEMPLATE(8, Delta,   OP_ADD)
00598 IVI_MC_TEMPLATE(4, NoDelta, OP_PUT)
00599 IVI_MC_TEMPLATE(4, Delta,   OP_ADD)
00600 IVI_MC_AVG_TEMPLATE(8, NoDelta, OP_PUT)
00601 IVI_MC_AVG_TEMPLATE(8, Delta,   OP_ADD)
00602 IVI_MC_AVG_TEMPLATE(4, NoDelta, OP_PUT)
00603 IVI_MC_AVG_TEMPLATE(4, Delta,   OP_ADD)
00604 
00605 } // End of namespace Indeo
00606 } // End of namespace Image


Generated on Sat Mar 23 2019 05:01:43 for ResidualVM by doxygen 1.7.1
curved edge   curved edge