1 /*****************************************************************************
2 * rectangle.h: rectangle filling
3 *****************************************************************************
4 * Copyright (C) 2003-2011 x264 project
6 * Authors: Fiona Glaser <fiona@x264.com>
7 * Loren Merritt <lorenm@u.washington.edu>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
23 * This program is also available under a commercial proprietary license.
24 * For more information, contact us at licensing@x264.com.
25 *****************************************************************************/
27 /* This function should only be called with constant w / h / s arguments! */
28 static ALWAYS_INLINE void x264_macroblock_cache_rect( void *dst, int w, int h, int s, uint32_t v )
31 uint16_t v2 = s == 2 ? v : v * 0x101;
32 uint32_t v4 = s == 4 ? v : s == 2 ? v * 0x10001 : v * 0x1010101;
33 uint64_t v8 = v4 + ((uint64_t)v4 << 32);
81 /* height 1, width 16 doesn't occur */
83 #if HAVE_VECTOREXT && defined(__SSE__)
86 M128( d+s*0+0 ) = (__m128)v16;
87 M128( d+s*1+0 ) = (__m128)v16;
89 M128( d+s*2+0 ) = (__m128)v16;
90 M128( d+s*3+0 ) = (__m128)v16;
121 extern void (*x264_cache_mv_func_table[10])(void *, uint32_t);\
122 extern void (*x264_cache_mvd_func_table[10])(void *, uint32_t);\
123 extern void (*x264_cache_ref_func_table[10])(void *, uint32_t);\
125 #define x264_macroblock_cache_mv_ptr( a, x, y, w, h, l, mv ) x264_macroblock_cache_mv( a, x, y, w, h, l, M32( mv ) )
126 static ALWAYS_INLINE void x264_macroblock_cache_mv( x264_t *h, int x, int y, int width, int height, int i_list, uint32_t mv )
128 void *mv_cache = &h->mb.cache.mv[i_list][X264_SCAN8_0+x+8*y];
129 if( x264_nonconstant_p( width ) || x264_nonconstant_p( height ) )
130 x264_cache_mv_func_table[width + (height<<1)-3]( mv_cache, mv );
132 x264_macroblock_cache_rect( mv_cache, width*4, height, 4, mv );
134 static ALWAYS_INLINE void x264_macroblock_cache_mvd( x264_t *h, int x, int y, int width, int height, int i_list, uint16_t mvd )
136 void *mvd_cache = &h->mb.cache.mvd[i_list][X264_SCAN8_0+x+8*y];
137 if( x264_nonconstant_p( width ) || x264_nonconstant_p( height ) )
138 x264_cache_mvd_func_table[width + (height<<1)-3]( mvd_cache, mvd );
140 x264_macroblock_cache_rect( mvd_cache, width*2, height, 2, mvd );
142 static ALWAYS_INLINE void x264_macroblock_cache_ref( x264_t *h, int x, int y, int width, int height, int i_list, uint8_t ref )
144 void *ref_cache = &h->mb.cache.ref[i_list][X264_SCAN8_0+x+8*y];
145 if( x264_nonconstant_p( width ) || x264_nonconstant_p( height ) )
146 x264_cache_ref_func_table[width + (height<<1)-3]( ref_cache, ref );
148 x264_macroblock_cache_rect( ref_cache, width, height, 1, ref );
150 static ALWAYS_INLINE void x264_macroblock_cache_skip( x264_t *h, int x, int y, int width, int height, int b_skip )
152 x264_macroblock_cache_rect( &h->mb.cache.skip[X264_SCAN8_0+x+8*y], width, height, 1, b_skip );
154 static ALWAYS_INLINE void x264_macroblock_cache_intra8x8_pred( x264_t *h, int x, int y, int i_mode )
156 x264_macroblock_cache_rect( &h->mb.cache.intra4x4_pred_mode[X264_SCAN8_0+x+8*y], 2, 2, 1, i_mode );