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
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
42 * Invariant: blk points to top-left sub-sampled pel for macroblock
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.
52 int SIMD_SUFFIX(mblock_sub44_dists
)( uint8_t *blk
, uint8_t *ref
,
60 uint8_t *currowblk
= blk
;
62 mc_result_s
*cres
= resvec
;
63 int gridrowstride
= (rowstride
);
65 for( y
=jlow
; y
<= jhigh
; y
+=4)
68 for( x
= ilow
; x
<= ihigh
; x
+= 4)
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
84 cres
->weight
= (uint16_t)weight
+((intabs(x
)+intabs(y
))>>3);
92 currowblk
+= gridrowstride
;