~siretart/x264/trunk

« back to all changes in this revision

Viewing changes to encoder/me.c

  • Committer: Loren Merritt
  • Date: 2005-04-19 08:45:36 UTC
  • Revision ID: git-v1:7d35ba6bf080610d8f144f4270e961c69ba14f1c
Allow manual selection of fullpel ME method. New method: Exhaustive search.
based on a patch by Tuukka Toivonen.


git-svn-id: svn://svn.videolan.org/x264/trunk@211 df754926-b1dd-0310-bc7b-ec298dee348c

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
void x264_me_search_ref( x264_t *h, x264_me_t *m, int (*mvc)[2], int i_mvc, int *p_fullpel_thresh )
61
61
{
62
62
    const int i_pixel = m->i_pixel;
 
63
    const unsigned int i_me_range = h->param.analyse.i_me_range;
63
64
    const int b_chroma_me = h->mb.b_chroma_me && i_pixel <= PIXEL_8x8;
64
65
    int bmx, bmy, bcost;
65
66
    int omx, omy;
99
100
    
100
101
    COST_MV( 0, 0 );
101
102
 
102
 
    if( h->mb.i_subpel_refine >= 2 )
103
 
    {
 
103
    switch( h->param.analyse.i_me_method ) {
 
104
    case X264_ME_DIA:
 
105
        /* diamond search */
 
106
        for( i_iter = 0; i_iter < i_me_range; i_iter++ )
 
107
        {
 
108
            omx = bmx;
 
109
            omy = bmy;
 
110
            COST_MV( omx  , omy-1 );
 
111
            COST_MV( omx  , omy+1 );
 
112
            COST_MV( omx-1, omy   );
 
113
            COST_MV( omx+1, omy   );
 
114
            if( bmx == omx && bmy == omy )
 
115
                break;
 
116
        }
 
117
        break;
 
118
    case X264_ME_HEX:
104
119
        /* hexagon search */
105
120
        /* Don't need to test mv_range each time, we won't go outside picture+padding */
106
121
        omx = bmx;
107
122
        omy = bmy;
108
 
        for( i_iter = 0; i_iter < 8; i_iter++ )
 
123
        for( i_iter = 0; i_iter < i_me_range/2; i_iter++ )
109
124
        {
110
125
            COST_MV( omx-2, omy   );
111
126
            COST_MV( omx-1, omy+2 );
129
144
        COST_MV( omx+1, omy-1 );
130
145
        COST_MV( omx+1, omy   );
131
146
        COST_MV( omx+1, omy+1 );
132
 
    }
133
 
    else
134
 
    {
135
 
        /* diamond search */
136
 
        for( i_iter = 0; i_iter < 16; i_iter++ )
 
147
        break;
 
148
    case X264_ME_ESA:
137
149
        {
138
 
            omx = bmx;
139
 
            omy = bmy;
140
 
            COST_MV( omx  , omy-1 );
141
 
            COST_MV( omx  , omy+1 );
142
 
            COST_MV( omx-1, omy   );
143
 
            COST_MV( omx+1, omy   );
144
 
            if( bmx == omx && bmy == omy )
145
 
                break;
 
150
            const int min_x = X264_MAX( bmx - i_me_range, mv_x_min-8);
 
151
            const int min_y = X264_MAX( bmy - i_me_range, mv_y_min-8);
 
152
            const int max_x = X264_MIN( bmx + i_me_range, mv_x_max+8);
 
153
            const int max_y = X264_MIN( bmy + i_me_range, mv_y_max+8);
 
154
            for( omy = min_y; omy <= max_y; omy++ )
 
155
                for( omx = min_x; omx <= max_x; omx++ )
 
156
                {
 
157
                    COST_MV( omx, omy );
 
158
                }
146
159
        }
 
160
        break;
147
161
    }
148
162
 
149
163
    /* -> qpel mv */