Revision 919e7497 libavcodec/motion_est.c

View differences:

libavcodec/motion_est.c
107 107
/*! \brief compares a block (either a full macroblock or a partition thereof)
108 108
    against a proposed motion-compensated prediction of that block
109 109
 */
110
static av_always_inline int cmp(MpegEncContext *s, const int x, const int y, const int subx, const int suby,
110
static av_always_inline int cmp_direct_inline(MpegEncContext *s, const int x, const int y, const int subx, const int suby,
111 111
                      const int size, const int h, int ref_index, int src_index,
112
                      me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags){
112
                      me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, int qpel){
113 113
    MotionEstContext * const c= &s->me;
114 114
    const int stride= c->stride;
115
    const int uvstride= c->uvstride;
116
    const int qpel= flags&FLAG_QPEL;
117
    const int chroma= flags&FLAG_CHROMA;
118
    const int dxy= subx + (suby<<(1+qpel)); //FIXME log2_subpel?
119 115
    const int hx= subx + (x<<(1+qpel));
120 116
    const int hy= suby + (y<<(1+qpel));
121 117
    uint8_t * const * const ref= c->ref[ref_index];
122 118
    uint8_t * const * const src= c->src[src_index];
123 119
    int d;
124 120
    //FIXME check chroma 4mv, (no crashes ...)
125
    if(flags&FLAG_DIRECT){
126 121
        assert(x >= c->xmin && hx <= c->xmax<<(qpel+1) && y >= c->ymin && hy <= c->ymax<<(qpel+1));
127 122
        if(x >= c->xmin && hx <= c->xmax<<(qpel+1) && y >= c->ymin && hy <= c->ymax<<(qpel+1)){
128 123
            const int time_pp= s->pp_time;
......
181 176
            d = cmp_func(s, c->temp, src[0], stride, 16);
182 177
        }else
183 178
            d= 256*256*256*32;
184
    }else{
179
    return d;
180
}
181

  
182
static av_always_inline int cmp_inline(MpegEncContext *s, const int x, const int y, const int subx, const int suby,
183
                      const int size, const int h, int ref_index, int src_index,
184
                      me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, int qpel, int chroma){
185
    MotionEstContext * const c= &s->me;
186
    const int stride= c->stride;
187
    const int uvstride= c->uvstride;
188
    const int dxy= subx + (suby<<(1+qpel)); //FIXME log2_subpel?
189
    const int hx= subx + (x<<(1+qpel));
190
    const int hy= suby + (y<<(1+qpel));
191
    uint8_t * const * const ref= c->ref[ref_index];
192
    uint8_t * const * const src= c->src[src_index];
193
    int d;
194
    //FIXME check chroma 4mv, (no crashes ...)
185 195
        int uvdxy;              /* no, it might not be used uninitialized */
186 196
        if(dxy){
187 197
            if(qpel){
......
212 222
            d += chroma_cmp_func(s, uvtemp  , src[1], uvstride, h>>1);
213 223
            d += chroma_cmp_func(s, uvtemp+8, src[2], uvstride, h>>1);
214 224
        }
225
    return d;
226
}
227

  
228
static int cmp_simple(MpegEncContext *s, const int x, const int y,
229
                      int ref_index, int src_index,
230
                      me_cmp_func cmp_func, me_cmp_func chroma_cmp_func){
231
    return cmp_inline(s,x,y,0,0,0,16,ref_index,src_index, cmp_func, chroma_cmp_func, 0, 0);
232
}
233

  
234
static int cmp_fpel_internal(MpegEncContext *s, const int x, const int y,
235
                      const int size, const int h, int ref_index, int src_index,
236
                      me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags){
237
    if(flags&FLAG_DIRECT){
238
        return cmp_direct_inline(s,x,y,0,0,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, flags&FLAG_QPEL);
239
    }else{
240
        return cmp_inline(s,x,y,0,0,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, 0, flags&FLAG_CHROMA);
215 241
    }
216
#if 0
217
    if(full_pel){
218
        const int index= (((y)<<ME_MAP_SHIFT) + (x))&(ME_MAP_SIZE-1);
219
        score_map[index]= d;
242
}
243

  
244
static int cmp_internal(MpegEncContext *s, const int x, const int y, const int subx, const int suby,
245
                      const int size, const int h, int ref_index, int src_index,
246
                      me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags){
247
    if(flags&FLAG_DIRECT){
248
        return cmp_direct_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, flags&FLAG_QPEL);
249
    }else{
250
        return cmp_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, flags&FLAG_QPEL, flags&FLAG_CHROMA);
220 251
    }
252
}
221 253

  
222
    d += (c->mv_penalty[hx - c->pred_x] + c->mv_penalty[hy - c->pred_y])*c->penalty_factor;
223
#endif
224
    return d;
254
static av_always_inline int cmp(MpegEncContext *s, const int x, const int y, const int subx, const int suby,
255
                      const int size, const int h, int ref_index, int src_index,
256
                      me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags){
257
    if(av_builtin_constant_p(flags) && av_builtin_constant_p(h) && av_builtin_constant_p(size)
258
       && av_builtin_constant_p(subx) && av_builtin_constant_p(suby)
259
       && flags==0 && h==16 && size==0 && subx==0 && suby==0){
260
        return cmp_simple(s,x,y,ref_index,src_index, cmp_func, chroma_cmp_func);
261
    }else if(av_builtin_constant_p(subx) && av_builtin_constant_p(suby)
262
       && subx==0 && suby==0){
263
        return cmp_fpel_internal(s,x,y,size,h,ref_index,src_index, cmp_func, chroma_cmp_func,flags);
264
    }else{
265
        return cmp_internal(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, flags);
266
    }
267
}
268

  
269
static int cmp_hpel(MpegEncContext *s, const int x, const int y, const int subx, const int suby,
270
                      const int size, const int h, int ref_index, int src_index,
271
                      me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags){
272
    if(flags&FLAG_DIRECT){
273
        return cmp_direct_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, 0);
274
    }else{
275
        return cmp_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, 0, flags&FLAG_CHROMA);
276
    }
277
}
278

  
279
static int cmp_qpel(MpegEncContext *s, const int x, const int y, const int subx, const int suby,
280
                      const int size, const int h, int ref_index, int src_index,
281
                      me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags){
282
    if(flags&FLAG_DIRECT){
283
        return cmp_direct_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, 1);
284
    }else{
285
        return cmp_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, 1, flags&FLAG_CHROMA);
286
    }
225 287
}
226 288

  
227 289
#include "motion_est_template.c"

Also available in: Unified diff