static inline void xchg_mb_border(H264Context *h, uint8_t *src_y,

                                  uint8_t *src_cb, uint8_t *src_cr,

                                  int linesize, int uvlinesize,

                                  int xchg, int simple, int pixel_shift){

    MpegEncContext * const s = &h->s;

    int deblock_left;

    int deblock_top;

    int top_idx = 1;

    uint8_t *top_border_m1;

    uint8_t *top_border;



    if(!simple && FRAME_MBAFF){

        if(s->mb_y&1){

            if(!MB_MBAFF)

                return;

        }else{

            top_idx = MB_MBAFF ? 0 : 1;

        }

    }



    if(h->deblocking_filter == 2) {

        deblock_left = h->left_type[0];

        deblock_top  = h->top_type;

    } else {

        deblock_left = (s->mb_x > 0);

        deblock_top =  (s->mb_y > !!MB_FIELD);

    }



    src_y  -=   linesize + 1 + pixel_shift;

    src_cb -= uvlinesize + 1 + pixel_shift;

    src_cr -= uvlinesize + 1 + pixel_shift;



    top_border_m1 = h->top_borders[top_idx][s->mb_x-1];

    top_border    = h->top_borders[top_idx][s->mb_x];



#define XCHG(a,b,xchg)\

    if (pixel_shift) {\

        if (xchg) {\

            AV_SWAP64(b+0,a+0);\

            AV_SWAP64(b+8,a+8);\

        } else {\

            AV_COPY128(b,a); \

        }\

    } else \

if (xchg) AV_SWAP64(b,a);\

else      AV_COPY64(b,a);



    if(deblock_top){

        if(deblock_left){

            XCHG(top_border_m1 + (8 << pixel_shift), src_y - (7 << pixel_shift), 1);

        }

        XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg);

        XCHG(top_border + (8 << pixel_shift), src_y + (9 << pixel_shift), 1);

        if(s->mb_x+1 < s->mb_width){

            XCHG(h->top_borders[top_idx][s->mb_x+1], src_y + (17 << pixel_shift), 1);

        }

    }

    if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){

        if(deblock_top){

            if(deblock_left){

                XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1);

                XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);

            }

            XCHG(top_border + (16 << pixel_shift), src_cb+1+pixel_shift, 1);

            XCHG(top_border + (24 << pixel_shift), src_cr+1+pixel_shift, 1);

        }

    }

}

static inline void xchg_mb_border(H264Context *h, uint8_t *src_y,

                                  uint8_t *src_cb, uint8_t *src_cr,

                                  int linesize, int uvlinesize,

                                  int xchg, int simple, int pixel_shift){

    MpegEncContext * const s = &h->s;

    int deblock_left;

    int deblock_top;

    int top_idx = 1;

    uint8_t *top_border_m1;

    uint8_t *top_border;



    if(!simple && FRAME_MBAFF){

        if(s->mb_y&1){

            if(!MB_MBAFF)

                return;

        }else{

            top_idx = MB_MBAFF ? 0 : 1;

        }

    }



    if(h->deblocking_filter == 2) {

        deblock_left = h->left_type[0];

        deblock_top  = h->top_type;

    } else {

        deblock_left = (s->mb_x > 0);

        deblock_top =  (s->mb_y > !!MB_FIELD);

    }



    src_y  -=   linesize + 1 + pixel_shift;

    src_cb -= uvlinesize + 1 + pixel_shift;

    src_cr -= uvlinesize + 1 + pixel_shift;



    top_border_m1 = h->top_borders[top_idx][s->mb_x-1];

    top_border    = h->top_borders[top_idx][s->mb_x];



#define XCHG(a,b,xchg)\

    if (pixel_shift) {\

        if (xchg) {\

            AV_SWAP64(b+0,a+0);\

            AV_SWAP64(b+8,a+8);\

        } else {\

            AV_COPY128(b,a); \

        }\

    } else \

if (xchg) AV_SWAP64(b,a);\

else      AV_COPY64(b,a);



    if(deblock_top){

        if(deblock_left){

            XCHG(top_border_m1 + (8 << pixel_shift), src_y - (7 << pixel_shift), 1);

        }

        XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg);

        XCHG(top_border + (8 << pixel_shift), src_y + (9 << pixel_shift), 1);

        if(s->mb_x+1 < s->mb_width){

            XCHG(h->top_borders[top_idx][s->mb_x+1], src_y + (17 << pixel_shift), 1);

        }

    }

    if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){

        if(deblock_top){

            if(deblock_left){

                XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1);

                XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);

            }

            XCHG(top_border + (16 << pixel_shift), src_cb+1+pixel_shift, 1);

            XCHG(top_border + (24 << pixel_shift), src_cr+1+pixel_shift, 1);

        }

    }

}

static inline void FUNC_0(H264Context *VAR_0, uint8_t *VAR_1,

                                  uint8_t *VAR_2, uint8_t *VAR_3,

                                  int VAR_4, int VAR_5,

                                  int VAR_6, int VAR_7, int VAR_8){

    MpegEncContext * const s = &VAR_0->s;

    int VAR_9;

    int VAR_10;

    int VAR_11 = 1;

    uint8_t *top_border_m1;

    uint8_t *top_border;



    if(!VAR_7 && FRAME_MBAFF){

        if(s->mb_y&1){

            if(!MB_MBAFF)

                return;

        }else{

            VAR_11 = MB_MBAFF ? 0 : 1;

        }

    }



    if(VAR_0->deblocking_filter == 2) {

        VAR_9 = VAR_0->left_type[0];

        VAR_10  = VAR_0->top_type;

    } else {

        VAR_9 = (s->mb_x > 0);

        VAR_10 =  (s->mb_y > !!MB_FIELD);

    }



    VAR_1  -=   VAR_4 + 1 + VAR_8;

    VAR_2 -= VAR_5 + 1 + VAR_8;

    VAR_3 -= VAR_5 + 1 + VAR_8;



    top_border_m1 = VAR_0->top_borders[VAR_11][s->mb_x-1];

    top_border    = VAR_0->top_borders[VAR_11][s->mb_x];



#define XCHG(a,b,VAR_6)\

    if (VAR_8) {\

        if (VAR_6) {\

            AV_SWAP64(b+0,a+0);\

            AV_SWAP64(b+8,a+8);\

        } else {\

            AV_COPY128(b,a); \

        }\

    } else \

if (VAR_6) AV_SWAP64(b,a);\

else      AV_COPY64(b,a);



    if(VAR_10){

        if(VAR_9){

            XCHG(top_border_m1 + (8 << VAR_8), VAR_1 - (7 << VAR_8), 1);

        }

        XCHG(top_border + (0 << VAR_8), VAR_1 + (1 << VAR_8), VAR_6);

        XCHG(top_border + (8 << VAR_8), VAR_1 + (9 << VAR_8), 1);

        if(s->mb_x+1 < s->mb_width){

            XCHG(VAR_0->top_borders[VAR_11][s->mb_x+1], VAR_1 + (17 << VAR_8), 1);

        }

    }

    if(VAR_7 || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){

        if(VAR_10){

            if(VAR_9){

                XCHG(top_border_m1 + (16 << VAR_8), VAR_2 - (7 << VAR_8), 1);

                XCHG(top_border_m1 + (24 << VAR_8), VAR_3 - (7 << VAR_8), 1);

            }

            XCHG(top_border + (16 << VAR_8), VAR_2+1+VAR_8, 1);

            XCHG(top_border + (24 << VAR_8), VAR_3+1+VAR_8, 1);

        }

    }

}

static inline void FUNC_0(H264Context *VAR_0, uint8_t *VAR_1,
uint8_t *VAR_2, uint8_t *VAR_3,
int VAR_4, int VAR_5,
int VAR_6, int VAR_7, int VAR_8){ MpegEncContext * const s = &VAR_0->s; int VAR_9; int VAR_10; int VAR_11 = 1; uint8_t *top_border_m1; uint8_t *top_border; if(!VAR_7 && FRAME_MBAFF){ if(s->mb_y&1){ if(!MB_MBAFF)
return; }else{ VAR_11 = MB_MBAFF ? 0 : 1; } } if(VAR_0->deblocking_filter == 2) { VAR_9 = VAR_0->left_type[0]; VAR_10  = VAR_0->top_type; } else { VAR_9 = (s->mb_x > 0); VAR_10 =  (s->mb_y > !!MB_FIELD); } VAR_1  -=   VAR_4 + 1 + VAR_8; VAR_2 -= VAR_5 + 1 + VAR_8; VAR_3 -= VAR_5 + 1 + VAR_8; top_border_m1 = VAR_0->top_borders[VAR_11][s->mb_x-1]; top_border    = VAR_0->top_borders[VAR_11][s->mb_x]; #define XCHG(a,b,VAR_6)\
if (VAR_8) {\ if (VAR_6) {\ AV_SWAP64(b+0,a+0);\ AV_SWAP64(b+8,a+8);\ } else {\ AV_COPY128(b,a); \ }\ } else \ if (VAR_6) AV_SWAP64(b,a);\ else      AV_COPY64(b,a); if(VAR_10){ if(VAR_9){ XCHG(top_border_m1 + (8 << VAR_8), VAR_1 - (7 << VAR_8), 1); } XCHG(top_border + (0 << VAR_8), VAR_1 + (1 << VAR_8), VAR_6); XCHG(top_border + (8 << VAR_8), VAR_1 + (9 << VAR_8), 1); if(s->mb_x+1 < s->mb_width){ XCHG(VAR_0->top_borders[VAR_11][s->mb_x+1], VAR_1 + (17 << VAR_8), 1); } } if(VAR_7 || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){ if(VAR_10){ if(VAR_9){ XCHG(top_border_m1 + (16 << VAR_8), VAR_2 - (7 << VAR_8), 1); XCHG(top_border_m1 + (24 << VAR_8), VAR_3 - (7 << VAR_8), 1); } XCHG(top_border + (16 << VAR_8), VAR_2+1+VAR_8, 1); XCHG(top_border + (24 << VAR_8), VAR_3+1+VAR_8, 1); } } }