libavcodec/motion_est.c:1219: error: Null Dereference
  pointer `null` is dereferenced by call to `init_ref()` at line 1219, column 5.

libavcodec/motion_est.c:1211:1: start of procedure ff_pre_estimate_p_frame_motion()
1209. }
1210. 
1211. int ff_pre_estimate_p_frame_motion(MpegEncContext * s,
      ^
1212.                                     int mb_x, int mb_y)
1213. {

libavcodec/motion_est.c:1214:5: 
1212.                                     int mb_x, int mb_y)
1213. {
1214.     MotionEstContext * const c= &s->me;
          ^
1215.     int mx, my, dmin;
1216.     int P[10][2];

libavcodec/motion_est.c:1217:5: 
1215.     int mx, my, dmin;
1216.     int P[10][2];
1217.     const int shift= 1+s->quarter_sample;
          ^
1218.     const int xy= mb_x + mb_y*s->mb_stride;
1219.     init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0);

libavcodec/motion_est.c:1218:5: 
1216.     int P[10][2];
1217.     const int shift= 1+s->quarter_sample;
1218.     const int xy= mb_x + mb_y*s->mb_stride;
          ^
1219.     init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0);
1220. 

libavcodec/motion_est.c:1219:5: 
1217.     const int shift= 1+s->quarter_sample;
1218.     const int xy= mb_x + mb_y*s->mb_stride;
1219.     init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0);
          ^
1220. 
1221.     assert(s->quarter_sample==0 || s->quarter_sample==1);

libavcodec/motion_est.c:83:1: start of procedure init_ref()
  81. #define FLAG_DIRECT 4
  82. 
  83. static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index){
      ^
  84.     const int offset[3]= {
  85.           y*c->  stride + x,

libavcodec/motion_est.c:84:5: 
  82. 
  83. static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index){
  84.     const int offset[3]= {
          ^
  85.           y*c->  stride + x,
  86.         ((y*c->uvstride + x)>>1),

libavcodec/motion_est.c:90:9: 
  88.     };
  89.     int i;
  90.     for(i=0; i<3; i++){
              ^
  91.         c->src[0][i]= src [i] + offset[i];
  92.         c->ref[0][i]= ref [i] + offset[i];

libavcodec/motion_est.c:90:14: Loop condition is true. Entering loop body
  88.     };
  89.     int i;
  90.     for(i=0; i<3; i++){
                   ^
  91.         c->src[0][i]= src [i] + offset[i];
  92.         c->ref[0][i]= ref [i] + offset[i];

libavcodec/motion_est.c:91:9: 
  89.     int i;
  90.     for(i=0; i<3; i++){
  91.         c->src[0][i]= src [i] + offset[i];
              ^
  92.         c->ref[0][i]= ref [i] + offset[i];
  93.     }

libavcodec/motion_est.c:92:9: 
  90.     for(i=0; i<3; i++){
  91.         c->src[0][i]= src [i] + offset[i];
  92.         c->ref[0][i]= ref [i] + offset[i];
              ^
  93.     }
  94.     if(ref_index){

libavcodec/motion_est.c:90:19: 
  88.     };
  89.     int i;
  90.     for(i=0; i<3; i++){
                        ^
  91.         c->src[0][i]= src [i] + offset[i];
  92.         c->ref[0][i]= ref [i] + offset[i];

libavcodec/motion_est.c:90:14: Loop condition is true. Entering loop body
  88.     };
  89.     int i;
  90.     for(i=0; i<3; i++){
                   ^
  91.         c->src[0][i]= src [i] + offset[i];
  92.         c->ref[0][i]= ref [i] + offset[i];

libavcodec/motion_est.c:91:9: 
  89.     int i;
  90.     for(i=0; i<3; i++){
  91.         c->src[0][i]= src [i] + offset[i];
              ^
  92.         c->ref[0][i]= ref [i] + offset[i];
  93.     }

libavcodec/motion_est.c:92:9: 
  90.     for(i=0; i<3; i++){
  91.         c->src[0][i]= src [i] + offset[i];
  92.         c->ref[0][i]= ref [i] + offset[i];
              ^
  93.     }
  94.     if(ref_index){

libavcodec/motion_est.c:90:19: 
  88.     };
  89.     int i;
  90.     for(i=0; i<3; i++){
                        ^
  91.         c->src[0][i]= src [i] + offset[i];
  92.         c->ref[0][i]= ref [i] + offset[i];

libavcodec/motion_est.c:90:14: Loop condition is false. Leaving loop
  88.     };
  89.     int i;
  90.     for(i=0; i<3; i++){
                   ^
  91.         c->src[0][i]= src [i] + offset[i];
  92.         c->ref[0][i]= ref [i] + offset[i];

libavcodec/motion_est.c:94:8: Taking true branch
  92.         c->ref[0][i]= ref [i] + offset[i];
  93.     }
  94.     if(ref_index){
             ^
  95.         for(i=0; i<3; i++){
  96.             c->ref[ref_index][i]= ref2[i] + offset[i];

libavcodec/motion_est.c:95:13: 
  93.     }
  94.     if(ref_index){
  95.         for(i=0; i<3; i++){
                  ^
  96.             c->ref[ref_index][i]= ref2[i] + offset[i];
  97.         }

libavcodec/motion_est.c:95:18: Loop condition is true. Entering loop body
  93.     }
  94.     if(ref_index){
  95.         for(i=0; i<3; i++){
                       ^
  96.             c->ref[ref_index][i]= ref2[i] + offset[i];
  97.         }

libavcodec/motion_est.c:96:13: 
  94.     if(ref_index){
  95.         for(i=0; i<3; i++){
  96.             c->ref[ref_index][i]= ref2[i] + offset[i];
                  ^
  97.         }
  98.     }

int ff_pre_estimate_p_frame_motion(MpegEncContext * s,
                                    int mb_x, int mb_y)
{
    MotionEstContext * const c= &s->me;
    int mx, my, dmin;
    int P[10][2];
    const int shift= 1+s->quarter_sample;
    const int xy= mb_x + mb_y*s->mb_stride;
    init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0);
    assert(s->quarter_sample==0 || s->quarter_sample==1);
    c->pre_penalty_factor    = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_pre_cmp);
    c->current_mv_penalty= c->mv_penalty[s->f_code] + MAX_MV;
    get_limits(s, 16*mb_x, 16*mb_y);
    c->skip=0;
    P_LEFT[0]       = s->p_mv_table[xy + 1][0];
    P_LEFT[1]       = s->p_mv_table[xy + 1][1];
    if(P_LEFT[0]       < (c->xmin<<shift)) P_LEFT[0]       = (c->xmin<<shift);
    if (s->first_slice_line) {
        c->pred_x= P_LEFT[0];
        c->pred_y= P_LEFT[1];
        P_TOP[0]= P_TOPRIGHT[0]= P_MEDIAN[0]=
        P_TOP[1]= P_TOPRIGHT[1]= P_MEDIAN[1]= 0;
    } else {
        P_TOP[0]      = s->p_mv_table[xy + s->mb_stride    ][0];
        P_TOP[1]      = s->p_mv_table[xy + s->mb_stride    ][1];
        P_TOPRIGHT[0] = s->p_mv_table[xy + s->mb_stride - 1][0];
        P_TOPRIGHT[1] = s->p_mv_table[xy + s->mb_stride - 1][1];
        if(P_TOP[1]      < (c->ymin<<shift)) P_TOP[1]     = (c->ymin<<shift);
        if(P_TOPRIGHT[0] > (c->xmax<<shift)) P_TOPRIGHT[0]= (c->xmax<<shift);
        if(P_TOPRIGHT[1] < (c->ymin<<shift)) P_TOPRIGHT[1]= (c->ymin<<shift);
        P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
        P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
        c->pred_x = P_MEDIAN[0];
        c->pred_y = P_MEDIAN[1];
    }
    dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, 0, s->p_mv_table, (1<<16)>>shift, 0, 16);
    s->p_mv_table[xy][0] = mx<<shift;
    s->p_mv_table[xy][1] = my<<shift;
    return dmin;
}
['int ff_pre_estimate_p_frame_motion(MpegEncContext * s,\n                                    int mb_x, int mb_y)\n{\n    MotionEstContext * const c= &s->me;\n    int mx, my, dmin;\n    int P[10][2];\n    const int shift= 1+s->quarter_sample;\n    const int xy= mb_x + mb_y*s->mb_stride;\n    init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0);\n    assert(s->quarter_sample==0 || s->quarter_sample==1);\n    c->pre_penalty_factor    = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_pre_cmp);\n    c->current_mv_penalty= c->mv_penalty[s->f_code] + MAX_MV;\n    get_limits(s, 16*mb_x, 16*mb_y);\n    c->skip=0;\n    P_LEFT[0]       = s->p_mv_table[xy + 1][0];\n    P_LEFT[1]       = s->p_mv_table[xy + 1][1];\n    if(P_LEFT[0]       < (c->xmin<<shift)) P_LEFT[0]       = (c->xmin<<shift);\n    if (s->first_slice_line) {\n        c->pred_x= P_LEFT[0];\n        c->pred_y= P_LEFT[1];\n        P_TOP[0]= P_TOPRIGHT[0]= P_MEDIAN[0]=\n        P_TOP[1]= P_TOPRIGHT[1]= P_MEDIAN[1]= 0;\n    } else {\n        P_TOP[0]      = s->p_mv_table[xy + s->mb_stride    ][0];\n        P_TOP[1]      = s->p_mv_table[xy + s->mb_stride    ][1];\n        P_TOPRIGHT[0] = s->p_mv_table[xy + s->mb_stride - 1][0];\n        P_TOPRIGHT[1] = s->p_mv_table[xy + s->mb_stride - 1][1];\n        if(P_TOP[1]      < (c->ymin<<shift)) P_TOP[1]     = (c->ymin<<shift);\n        if(P_TOPRIGHT[0] > (c->xmax<<shift)) P_TOPRIGHT[0]= (c->xmax<<shift);\n        if(P_TOPRIGHT[1] < (c->ymin<<shift)) P_TOPRIGHT[1]= (c->ymin<<shift);\n        P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);\n        P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);\n        c->pred_x = P_MEDIAN[0];\n        c->pred_y = P_MEDIAN[1];\n    }\n    dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, 0, s->p_mv_table, (1<<16)>>shift, 0, 16);\n    s->p_mv_table[xy][0] = mx<<shift;\n    s->p_mv_table[xy][1] = my<<shift;\n    return dmin;\n}', 'static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index){\n    const int offset[3]= {\n          y*c->  stride + x,\n        ((y*c->uvstride + x)>>1),\n        ((y*c->uvstride + x)>>1),\n    };\n    int i;\n    for(i=0; i<3; i++){\n        c->src[0][i]= src [i] + offset[i];\n        c->ref[0][i]= ref [i] + offset[i];\n    }\n    if(ref_index){\n        for(i=0; i<3; i++){\n            c->ref[ref_index][i]= ref2[i] + offset[i];\n        }\n    }\n}']