1 /*****************************************************************************
2 * mc.h: h264 encoder library (Motion Compensation)
3 *****************************************************************************
4 * Copyright (C) 2004-2008 Loren Merritt <lorenm@u.washington.edu>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
19 *****************************************************************************/
25 typedef void (* weight_fn_t)( pixel *, int, pixel *,int, const struct x264_weight_t *, int );
26 typedef struct x264_weight_t
28 /* aligning the first member is a gcc hack to force the struct to be
29 * 16 byte aligned, as well as force sizeof(struct) to be a multiple of 16 */
30 ALIGNED_16( int16_t cachea[8] );
35 weight_fn_t *weightfn;
36 } ALIGNED_16( x264_weight_t );
38 extern const x264_weight_t weight_none[3];
40 #define SET_WEIGHT( w, b, s, d, o )\
46 h->mc.weight_cache( h, &w );\
52 * XXX: Only width = 4, 8 or 16 are valid
53 * width == 4 -> height == 4 or 8
54 * width == 8 -> height == 4 or 8 or 16
55 * width == 16-> height == 8 or 16
60 void (*mc_luma)(pixel *dst, int i_dst, pixel **src, int i_src,
62 int i_width, int i_height, const x264_weight_t *weight );
64 /* may round up the dimensions if they're not a power of 2 */
65 pixel* (*get_ref)(pixel *dst, int *i_dst, pixel **src, int i_src,
67 int i_width, int i_height, const x264_weight_t *weight );
69 /* mc_chroma may write up to 2 bytes of garbage to the right of dst,
70 * so it must be run from left to right. */
71 void (*mc_chroma)(pixel *dst, int i_dst, pixel *src, int i_src,
73 int i_width, int i_height );
75 void (*avg[10])( pixel *dst, int, pixel *src1, int, pixel *src2, int, int i_weight );
77 /* only 16x16, 8x8, and 4x4 defined */
78 void (*copy[7])( pixel *dst, int, pixel *src, int, int i_height );
79 void (*copy_16x16_unaligned)( pixel *dst, int, pixel *src, int, int i_height );
81 void (*plane_copy)( pixel *dst, int i_dst,
82 uint8_t *src, int i_src, int w, int h);
84 void (*hpel_filter)( pixel *dsth, pixel *dstv, pixel *dstc, pixel *src,
85 int i_stride, int i_width, int i_height, dctcoef *buf );
87 /* prefetch the next few macroblocks of fenc or fdec */
88 void (*prefetch_fenc)( pixel *pix_y, int stride_y,
89 pixel *pix_uv, int stride_uv, int mb_x );
90 /* prefetch the next few macroblocks of a hpel reference frame */
91 void (*prefetch_ref)( pixel *pix, int stride, int parity );
93 void *(*memcpy_aligned)( void *dst, const void *src, size_t n );
94 void (*memzero_aligned)( void *dst, int n );
96 /* successive elimination prefilter */
97 void (*integral_init4h)( uint16_t *sum, pixel *pix, int stride );
98 void (*integral_init8h)( uint16_t *sum, pixel *pix, int stride );
99 void (*integral_init4v)( uint16_t *sum8, uint16_t *sum4, int stride );
100 void (*integral_init8v)( uint16_t *sum8, int stride );
102 void (*frame_init_lowres_core)( pixel *src0, pixel *dst0, pixel *dsth, pixel *dstv, pixel *dstc,
103 int src_stride, int dst_stride, int width, int height );
105 weight_fn_t *offsetadd;
106 weight_fn_t *offsetsub;
107 void (*weight_cache)( x264_t *, x264_weight_t * );
109 void (*mbtree_propagate_cost)( int *dst, uint16_t *propagate_in, uint16_t *intra_costs,
110 uint16_t *inter_costs, uint16_t *inv_qscales, int len );
111 } x264_mc_functions_t;
113 void x264_mc_init( int cpu, x264_mc_functions_t *pf );