me.h 2.54 KB
Newer Older
Laurent Aimar's avatar
Laurent Aimar committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*****************************************************************************
 * me.h: h264 encoder library (Motion Estimation)
 *****************************************************************************
 * Copyright (C) 2003 Laurent Aimar
 * $Id: me.h,v 1.1 2004/06/03 19:27:08 fenrir Exp $
 *
 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
 *
 * 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
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * 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.
 *****************************************************************************/

24 25
#ifndef X264_ME_H
#define X264_ME_H
Laurent Aimar's avatar
Laurent Aimar committed
26

27 28
#define COST_MAX (1<<28)

Laurent Aimar's avatar
Laurent Aimar committed
29 30 31 32
typedef struct
{
    /* input */
    int      i_pixel;   /* PIXEL_WxH */
33
    int16_t *p_cost_mv; /* lambda * nbits for each possible mv */
Loren Merritt's avatar
Loren Merritt committed
34 35
    int      i_ref_cost;
    int      i_ref;
Laurent Aimar's avatar
Laurent Aimar committed
36

Loren Merritt's avatar
Loren Merritt committed
37 38
    uint8_t *p_fref[6];
    uint8_t *p_fenc[3];
39
    uint16_t *integral;
Loren Merritt's avatar
Loren Merritt committed
40
    int      i_stride[2];
Laurent Aimar's avatar
Laurent Aimar committed
41 42 43 44

    int mvp[2];

    /* output */
45 46
    int cost_mv;        /* lambda * nbits for the chosen mv */
    int cost;           /* satd + lambda * nbits */
Loren Merritt's avatar
Loren Merritt committed
47
    DECLARE_ALIGNED_8( int mv[2] );
Laurent Aimar's avatar
Laurent Aimar committed
48 49
} x264_me_t;

50 51 52 53
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 ); }

Laurent Aimar's avatar
Laurent Aimar committed
54
void x264_me_refine_qpel( x264_t *h, x264_me_t *m );
55
void x264_me_refine_qpel_rd( x264_t *h, x264_me_t *m, int i_lambda2, int i8 );
56
int x264_me_refine_bidir( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight );
57
int x264_rd_cost_part( x264_t *h, int i_lambda2, int i8, int i_pixel );
Laurent Aimar's avatar
Laurent Aimar committed
58

59 60
extern uint16_t *x264_cost_mv_fpel[52][4];

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
#define COPY1_IF_LT(x,y)\
if((y)<(x))\
    (x)=(y);

#define COPY2_IF_LT(x,y,a,b)\
if((y)<(x))\
{\
    (x)=(y);\
    (a)=(b);\
}

#define COPY3_IF_LT(x,y,a,b,c,d)\
if((y)<(x))\
{\
    (x)=(y);\
    (a)=(b);\
    (c)=(d);\
}

80 81 82 83 84 85 86 87 88
#define COPY4_IF_LT(x,y,a,b,c,d,f,e)\
if((y)<(x))\
{\
    (x)=(y);\
    (a)=(b);\
    (c)=(d);\
    (f)=(e);\
}

Laurent Aimar's avatar
Laurent Aimar committed
89
#endif