int ff_mpv_lowest_referenced_row(MpegEncContext *s, int dir)

{

    int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !s->quarter_sample;

    int my, off, i, mvs;



    if (s->picture_structure != PICT_FRAME || s->mcsel)

        goto unhandled;



    switch (s->mv_type) {

        case MV_TYPE_16X16:

            mvs = 1;

            break;

        case MV_TYPE_16X8:

            mvs = 2;

            break;

        case MV_TYPE_8X8:

            mvs = 4;

            break;

        default:

            goto unhandled;

    }



    for (i = 0; i < mvs; i++) {

        my = s->mv[dir][i][1]<<qpel_shift;

        my_max = FFMAX(my_max, my);

        my_min = FFMIN(my_min, my);

    }



    off = (FFMAX(-my_min, my_max) + 63) >> 6;



    return FFMIN(FFMAX(s->mb_y + off, 0), s->mb_height-1);

unhandled:

    return s->mb_height-1;

}

int ff_mpv_lowest_referenced_row(MpegEncContext *s, int dir)

{

    int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !s->quarter_sample;

    int my, off, i, mvs;



    if (s->picture_structure != PICT_FRAME || s->mcsel)

        goto unhandled;



    switch (s->mv_type) {

        case MV_TYPE_16X16:

            mvs = 1;

            break;

        case MV_TYPE_16X8:

            mvs = 2;

            break;

        case MV_TYPE_8X8:

            mvs = 4;

            break;

        default:

            goto unhandled;

    }



    for (i = 0; i < mvs; i++) {

        my = s->mv[dir][i][1]<<qpel_shift;

        my_max = FFMAX(my_max, my);

        my_min = FFMIN(my_min, my);

    }



    off = (FFMAX(-my_min, my_max) + 63) >> 6;



    return FFMIN(FFMAX(s->mb_y + off, 0), s->mb_height-1);

unhandled:

    return s->mb_height-1;

}

int FUNC_0(MpegEncContext *VAR_0, int VAR_1)

{

    int VAR_2 = INT_MIN, VAR_3 = INT_MAX, VAR_4 = !VAR_0->quarter_sample;

    int VAR_5, VAR_6, VAR_7, VAR_8;



    if (VAR_0->picture_structure != PICT_FRAME || VAR_0->mcsel)

        goto unhandled;



    switch (VAR_0->mv_type) {

        case MV_TYPE_16X16:

            VAR_8 = 1;

            break;

        case MV_TYPE_16X8:

            VAR_8 = 2;

            break;

        case MV_TYPE_8X8:

            VAR_8 = 4;

            break;

        default:

            goto unhandled;

    }



    for (VAR_7 = 0; VAR_7 < VAR_8; VAR_7++) {

        VAR_5 = VAR_0->mv[VAR_1][VAR_7][1]<<VAR_4;

        VAR_2 = FFMAX(VAR_2, VAR_5);

        VAR_3 = FFMIN(VAR_3, VAR_5);

    }



    VAR_6 = (FFMAX(-VAR_3, VAR_2) + 63) >> 6;



    return FFMIN(FFMAX(VAR_0->mb_y + VAR_6, 0), VAR_0->mb_height-1);

unhandled:

    return VAR_0->mb_height-1;

}

int FUNC_0(MpegEncContext *VAR_0, int VAR_1)
{ int VAR_2 = INT_MIN, VAR_3 = INT_MAX, VAR_4 = !VAR_0->quarter_sample; int VAR_5, VAR_6, VAR_7, VAR_8; if (VAR_0->picture_structure != PICT_FRAME || VAR_0->mcsel)
goto unhandled; switch (VAR_0->mv_type) { case MV_TYPE_16X16:
VAR_8 = 1; break; case MV_TYPE_16X8:
VAR_8 = 2; break; case MV_TYPE_8X8:
VAR_8 = 4; break; default:
goto unhandled; } for (VAR_7 = 0; VAR_7 < VAR_8; VAR_7++) { VAR_5 = VAR_0->mv[VAR_1][VAR_7][1]<<VAR_4; VAR_2 = FFMAX(VAR_2, VAR_5); VAR_3 = FFMIN(VAR_3, VAR_5); } VAR_6 = (FFMAX(-VAR_3, VAR_2) + 63) >> 6; return FFMIN(FFMAX(VAR_0->mb_y + VAR_6, 0), VAR_0->mb_height-1); unhandled:
return VAR_0->mb_height-1; }