r105: This commit was manufactured by cvs2svn to create tag
[cinelerra_cv/mob.git] / hvirtual / mpeg2enc / mblock_sub44_sads_x86_h.c
blobf3cd0b1e4f20f26f5f9c8bc9dc3225fbecf1f23e
1 /*
3 * mblock_sub44_sads_x86_h.c
4 * Copyright (C) 2000 Andrew Stevens <as@comlab.ox.ac.uk>
6 * Fast block sum-absolute difference computation for a rectangular area 4*x
7 * by y where y > h against a 4 by h block.
9 * Used for 4*4 sub-sampled motion compensation calculations.
12 * This file is part of mpeg2enc, a free MPEG-2 video stream encoder
13 * based on the original MSSG reference design
15 * mpeg2enc is free software; you can redistribute new parts
16 * and/or modify under the terms of the GNU General Public License
17 * as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * mpeg2enc is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * See the files for those sections (c) MSSG
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 * Generates a vector sad's for 4*4 sub-sampled pel (qpel) data (with
36 * co-ordinates and top-left qpel address) from specified rectangle
37 * against a specified 16*h pel (4*4 qpel) reference block. The
38 * generated vector contains results only for those sad's that fall
39 * below twice the running best sad and are aligned on 8-pel
40 * boundaries
42 * Invariant: blk points to top-left sub-sampled pel for macroblock
43 * at (ilow,ihigh)
44 * i{low,high) j(low,high) must be multiples of 4.
46 * sad = Sum Absolute Differences
48 * NOTES: for best efficiency i{low,high) should be multiples of 16.
50 * */
52 int SIMD_SUFFIX(mblock_sub44_dists)( uint8_t *blk, uint8_t *ref,
53 int ilow,int jlow,
54 int ihigh, int jhigh,
55 int h, int rowstride,
56 int threshold,
57 mc_result_s *resvec)
59 int32_t x,y;
60 uint8_t *currowblk = blk;
61 uint8_t *curblk;
62 mc_result_s *cres = resvec;
63 int gridrowstride = (rowstride);
65 for( y=jlow; y <= jhigh ; y+=4)
67 curblk = currowblk;
68 for( x = ilow; x <= ihigh; x += 4)
70 int weight;
71 if( (x & 15) == (ilow & 15) )
73 load_blk( curblk, rowstride, h );
75 weight = SIMD_SUFFIX(qblock_sad)(ref, h, rowstride);
76 if( weight <= threshold )
78 threshold = intmin(weight<<2,threshold);
79 /* Rough and-ready absolute distance penalty */
80 /* NOTE: This penalty is *vital* to correct operation
81 as otherwise the sub-mean filtering won't work on very
82 uniform images.
84 cres->weight = (uint16_t)weight+((intabs(x)+intabs(y))>>3);
85 cres->x = (uint8_t)x;
86 cres->y = (uint8_t)y;
87 ++cres;
89 curblk += 1;
90 shift_blk(8);
92 currowblk += gridrowstride;
94 emms();
95 return cres - resvec;
98 #undef concat