/*****************************************************************************1* me.h: motion estimation2*****************************************************************************3* Copyright (C) 2003-2016 x264 project4*5* Authors: Loren Merritt <[email protected]>6* Laurent Aimar <[email protected]>7*8* This program is free software; you can redistribute it and/or modify9* it under the terms of the GNU General Public License as published by10* the Free Software Foundation; either version 2 of the License, or11* (at your option) any later version.12*13* This program is distributed in the hope that it will be useful,14* but WITHOUT ANY WARRANTY; without even the implied warranty of15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16* GNU General Public License for more details.17*18* You should have received a copy of the GNU General Public License19* along with this program; if not, write to the Free Software20* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.21*22* This program is also available under a commercial proprietary license.23* For more information, contact us at [email protected].24*****************************************************************************/2526#ifndef X264_ME_H27#define X264_ME_H2829#define COST_MAX (1<<28)30#define COST_MAX64 (1ULL<<60)3132typedef struct33{34/* aligning the first member is a gcc hack to force the struct to be35* 16 byte aligned, as well as force sizeof(struct) to be a multiple of 16 */36/* input */37ALIGNED_16( int i_pixel ); /* PIXEL_WxH */38uint16_t *p_cost_mv; /* lambda * nbits for each possible mv */39int i_ref_cost;40int i_ref;41const x264_weight_t *weight;4243pixel *p_fref[12];44pixel *p_fref_w;45pixel *p_fenc[3];46uint16_t *integral;47int i_stride[3];4849ALIGNED_4( int16_t mvp[2] );5051/* output */52int cost_mv; /* lambda * nbits for the chosen mv */53int cost; /* satd + lambda * nbits */54ALIGNED_4( int16_t mv[2] );55} ALIGNED_16( x264_me_t );5657typedef struct58{59int sad;60int16_t mv[2];61} mvsad_t;6263void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, int *p_fullpel_thresh );64#define x264_me_search( h, m, mvc, i_mvc )\65x264_me_search_ref( h, m, mvc, i_mvc, NULL )6667void x264_me_refine_qpel( x264_t *h, x264_me_t *m );68void x264_me_refine_qpel_refdupe( x264_t *h, x264_me_t *m, int *p_halfpel_thresh );69void x264_me_refine_qpel_rd( x264_t *h, x264_me_t *m, int i_lambda2, int i4, int i_list );70void x264_me_refine_bidir_rd( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight, int i8, int i_lambda2 );71void x264_me_refine_bidir_satd( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight );72uint64_t x264_rd_cost_part( x264_t *h, int i_lambda2, int i8, int i_pixel );7374extern uint16_t *x264_cost_mv_fpel[QP_MAX+1][4];7576#define COPY1_IF_LT(x,y)\77if((y)<(x))\78(x)=(y);7980#define COPY2_IF_LT(x,y,a,b)\81if((y)<(x))\82{\83(x)=(y);\84(a)=(b);\85}8687#define COPY3_IF_LT(x,y,a,b,c,d)\88if((y)<(x))\89{\90(x)=(y);\91(a)=(b);\92(c)=(d);\93}9495#define COPY4_IF_LT(x,y,a,b,c,d,e,f)\96if((y)<(x))\97{\98(x)=(y);\99(a)=(b);\100(c)=(d);\101(e)=(f);\102}103104#define COPY2_IF_GT(x,y,a,b)\105if((y)>(x))\106{\107(x)=(y);\108(a)=(b);\109}110111#endif112113114