static int temporal_luma_motion_vector(HEVCContext *s, int x0, int y0,

                                       int nPbW, int nPbH, int refIdxLx,

                                       Mv *mvLXCol, int X)

{

    MvField *tab_mvf;

    MvField temp_col;

    int x, y, x_pu, y_pu;

    int min_pu_width = s->sps->min_pu_width;

    int availableFlagLXCol = 0;

    int colPic;



    HEVCFrame *ref = s->ref->collocated_ref;



    if (!ref)

        return 0;



    tab_mvf = ref->tab_mvf;

    colPic  = ref->poc;



    //bottom right collocated motion vector

    x = x0 + nPbW;

    y = y0 + nPbH;



    if (tab_mvf &&

        (y0 >> s->sps->log2_ctb_size) == (y >> s->sps->log2_ctb_size) &&

        y < s->sps->height &&

        x < s->sps->width) {

        x                 &= ~15;

        y                 &= ~15;

        ff_thread_await_progress(&ref->tf, y, 0);

        x_pu               = x >> s->sps->log2_min_pu_size;

        y_pu               = y >> s->sps->log2_min_pu_size;

        temp_col           = TAB_MVF(x_pu, y_pu);

        availableFlagLXCol = DERIVE_TEMPORAL_COLOCATED_MVS;

    }



    // derive center collocated motion vector

    if (tab_mvf && !availableFlagLXCol) {

        x                  = x0 + (nPbW >> 1);

        y                  = y0 + (nPbH >> 1);

        x                 &= ~15;

        y                 &= ~15;

        ff_thread_await_progress(&ref->tf, y, 0);

        x_pu               = x >> s->sps->log2_min_pu_size;

        y_pu               = y >> s->sps->log2_min_pu_size;

        temp_col           = TAB_MVF(x_pu, y_pu);

        availableFlagLXCol = DERIVE_TEMPORAL_COLOCATED_MVS;

    }

    return availableFlagLXCol;

}

static int temporal_luma_motion_vector(HEVCContext *s, int x0, int y0,

                                       int nPbW, int nPbH, int refIdxLx,

                                       Mv *mvLXCol, int X)

{

    MvField *tab_mvf;

    MvField temp_col;

    int x, y, x_pu, y_pu;

    int min_pu_width = s->sps->min_pu_width;

    int availableFlagLXCol = 0;

    int colPic;



    HEVCFrame *ref = s->ref->collocated_ref;



    if (!ref)

        return 0;



    tab_mvf = ref->tab_mvf;

    colPic  = ref->poc;



    

    x = x0 + nPbW;

    y = y0 + nPbH;



    if (tab_mvf &&

        (y0 >> s->sps->log2_ctb_size) == (y >> s->sps->log2_ctb_size) &&

        y < s->sps->height &&

        x < s->sps->width) {

        x                 &= ~15;

        y                 &= ~15;

        ff_thread_await_progress(&ref->tf, y, 0);

        x_pu               = x >> s->sps->log2_min_pu_size;

        y_pu               = y >> s->sps->log2_min_pu_size;

        temp_col           = TAB_MVF(x_pu, y_pu);

        availableFlagLXCol = DERIVE_TEMPORAL_COLOCATED_MVS;

    }



    

    if (tab_mvf && !availableFlagLXCol) {

        x                  = x0 + (nPbW >> 1);

        y                  = y0 + (nPbH >> 1);

        x                 &= ~15;

        y                 &= ~15;

        ff_thread_await_progress(&ref->tf, y, 0);

        x_pu               = x >> s->sps->log2_min_pu_size;

        y_pu               = y >> s->sps->log2_min_pu_size;

        temp_col           = TAB_MVF(x_pu, y_pu);

        availableFlagLXCol = DERIVE_TEMPORAL_COLOCATED_MVS;

    }

    return availableFlagLXCol;

}

static int FUNC_0(HEVCContext *VAR_0, int VAR_1, int VAR_2,

                                       int VAR_3, int VAR_4, int VAR_5,

                                       Mv *VAR_6, int VAR_7)

{

    MvField *tab_mvf;

    MvField temp_col;

    int VAR_8, VAR_9, VAR_10, VAR_11;

    int VAR_12 = VAR_0->sps->VAR_12;

    int VAR_13 = 0;

    int VAR_14;



    HEVCFrame *ref = VAR_0->ref->collocated_ref;



    if (!ref)

        return 0;



    tab_mvf = ref->tab_mvf;

    VAR_14  = ref->poc;



    

    VAR_8 = VAR_1 + VAR_3;

    VAR_9 = VAR_2 + VAR_4;



    if (tab_mvf &&

        (VAR_2 >> VAR_0->sps->log2_ctb_size) == (VAR_9 >> VAR_0->sps->log2_ctb_size) &&

        VAR_9 < VAR_0->sps->height &&

        VAR_8 < VAR_0->sps->width) {

        VAR_8                 &= ~15;

        VAR_9                 &= ~15;

        ff_thread_await_progress(&ref->tf, VAR_9, 0);

        VAR_10               = VAR_8 >> VAR_0->sps->log2_min_pu_size;

        VAR_11               = VAR_9 >> VAR_0->sps->log2_min_pu_size;

        temp_col           = TAB_MVF(VAR_10, VAR_11);

        VAR_13 = DERIVE_TEMPORAL_COLOCATED_MVS;

    }



    

    if (tab_mvf && !VAR_13) {

        VAR_8                  = VAR_1 + (VAR_3 >> 1);

        VAR_9                  = VAR_2 + (VAR_4 >> 1);

        VAR_8                 &= ~15;

        VAR_9                 &= ~15;

        ff_thread_await_progress(&ref->tf, VAR_9, 0);

        VAR_10               = VAR_8 >> VAR_0->sps->log2_min_pu_size;

        VAR_11               = VAR_9 >> VAR_0->sps->log2_min_pu_size;

        temp_col           = TAB_MVF(VAR_10, VAR_11);

        VAR_13 = DERIVE_TEMPORAL_COLOCATED_MVS;

    }

    return VAR_13;

}

static int FUNC_0(HEVCContext *VAR_0, int VAR_1, int VAR_2,
int VAR_3, int VAR_4, int VAR_5,
Mv *VAR_6, int VAR_7)
{ MvField *tab_mvf; MvField temp_col; int VAR_8, VAR_9, VAR_10, VAR_11; int VAR_12 = VAR_0->sps->VAR_12; int VAR_13 = 0; int VAR_14; HEVCFrame *ref = VAR_0->ref->collocated_ref; if (!ref)
return 0; tab_mvf = ref->tab_mvf; VAR_14  = ref->poc; VAR_8 = VAR_1 + VAR_3; VAR_9 = VAR_2 + VAR_4; if (tab_mvf &&
(VAR_2 >> VAR_0->sps->log2_ctb_size) == (VAR_9 >> VAR_0->sps->log2_ctb_size) &&
VAR_9 < VAR_0->sps->height &&
VAR_8 < VAR_0->sps->width) { VAR_8                 &= ~15; VAR_9                 &= ~15; ff_thread_await_progress(&ref->tf, VAR_9, 0); VAR_10               = VAR_8 >> VAR_0->sps->log2_min_pu_size; VAR_11               = VAR_9 >> VAR_0->sps->log2_min_pu_size; temp_col           = TAB_MVF(VAR_10, VAR_11); VAR_13 = DERIVE_TEMPORAL_COLOCATED_MVS; } if (tab_mvf && !VAR_13) { VAR_8                  = VAR_1 + (VAR_3 >> 1); VAR_9                  = VAR_2 + (VAR_4 >> 1); VAR_8                 &= ~15; VAR_9                 &= ~15; ff_thread_await_progress(&ref->tf, VAR_9, 0); VAR_10               = VAR_8 >> VAR_0->sps->log2_min_pu_size; VAR_11               = VAR_9 >> VAR_0->sps->log2_min_pu_size; temp_col           = TAB_MVF(VAR_10, VAR_11); VAR_13 = DERIVE_TEMPORAL_COLOCATED_MVS; } return VAR_13; }