X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=encoder%2Fme.h;h=ce041aa66a50af9bb1b701be385067103fd8efea;hb=d23d18655249944c1ca894b451e2c82c7a584c62;hp=e0be0e9a04d216bad3a92959db0ba420a9ebc53a;hpb=2ed861c86065fd556a6f7b18718725c1fc04452b;p=x264 diff --git a/encoder/me.h b/encoder/me.h index e0be0e9a..ce041aa6 100644 --- a/encoder/me.h +++ b/encoder/me.h @@ -1,10 +1,10 @@ /***************************************************************************** - * me.h: h264 encoder library (Motion Estimation) + * me.h: motion estimation ***************************************************************************** - * Copyright (C) 2003 Laurent Aimar - * $Id: me.h,v 1.1 2004/06/03 19:27:08 fenrir Exp $ + * Copyright (C) 2003-2016 x264 project * - * Authors: Laurent Aimar + * Authors: Loren Merritt + * Laurent Aimar * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,45 +18,61 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. + * + * This program is also available under a commercial proprietary license. + * For more information, contact us at licensing@x264.com. *****************************************************************************/ -#ifndef _ME_H -#define _ME_H 1 +#ifndef X264_ME_H +#define X264_ME_H #define COST_MAX (1<<28) +#define COST_MAX64 (1ULL<<60) typedef struct { + /* aligning the first member is a gcc hack to force the struct to be + * 16 byte aligned, as well as force sizeof(struct) to be a multiple of 16 */ /* input */ - int i_pixel; /* PIXEL_WxH */ - int16_t *p_cost_mv; /* lambda * nbits for each possible mv */ + ALIGNED_16( int i_pixel ); /* PIXEL_WxH */ + uint16_t *p_cost_mv; /* lambda * nbits for each possible mv */ int i_ref_cost; int i_ref; + const x264_weight_t *weight; - uint8_t *p_fref[6]; - uint8_t *p_fenc[3]; + pixel *p_fref[12]; + pixel *p_fref_w; + pixel *p_fenc[3]; uint16_t *integral; - int i_stride[2]; + int i_stride[3]; - int mvp[2]; + ALIGNED_4( int16_t mvp[2] ); /* output */ int cost_mv; /* lambda * nbits for the chosen mv */ int cost; /* satd + lambda * nbits */ - int mv[2]; -} x264_me_t; + ALIGNED_4( int16_t mv[2] ); +} ALIGNED_16( x264_me_t ); -void x264_me_search_ref( x264_t *h, x264_me_t *m, int (*mvc)[2], int i_mvc, int *p_fullpel_thresh ); -static inline void x264_me_search( x264_t *h, x264_me_t *m, int (*mvc)[2], int i_mvc ) - { x264_me_search_ref( h, m, mvc, i_mvc, NULL ); } +typedef struct +{ + int sad; + int16_t mv[2]; +} mvsad_t; + +void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, int *p_fullpel_thresh ); +#define x264_me_search( h, m, mvc, i_mvc )\ + x264_me_search_ref( h, m, mvc, i_mvc, NULL ) void x264_me_refine_qpel( x264_t *h, x264_me_t *m ); -void x264_me_refine_qpel_rd( x264_t *h, x264_me_t *m, int i_lambda2, int i8 ); -int x264_me_refine_bidir( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight ); -int x264_rd_cost_part( x264_t *h, int i_lambda2, int i8, int i_pixel ); +void x264_me_refine_qpel_refdupe( x264_t *h, x264_me_t *m, int *p_halfpel_thresh ); +void x264_me_refine_qpel_rd( x264_t *h, x264_me_t *m, int i_lambda2, int i4, int i_list ); +void x264_me_refine_bidir_rd( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight, int i8, int i_lambda2 ); +void x264_me_refine_bidir_satd( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight ); +uint64_t x264_rd_cost_part( x264_t *h, int i_lambda2, int i8, int i_pixel ); -extern uint16_t *x264_cost_mv_fpel[52][4]; +extern uint16_t *x264_cost_mv_fpel[QP_MAX+1][4]; #define COPY1_IF_LT(x,y)\ if((y)<(x))\ @@ -77,13 +93,20 @@ if((y)<(x))\ (c)=(d);\ } -#define COPY4_IF_LT(x,y,a,b,c,d,f,e)\ +#define COPY4_IF_LT(x,y,a,b,c,d,e,f)\ if((y)<(x))\ {\ (x)=(y);\ (a)=(b);\ (c)=(d);\ - (f)=(e);\ + (e)=(f);\ +} + +#define COPY2_IF_GT(x,y,a,b)\ +if((y)>(x))\ +{\ + (x)=(y);\ + (a)=(b);\ } #endif