static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h ) {
    const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
    const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
    const int alpha = alpha_table[index_a];
    const int beta  = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
    if (alpha ==0 || beta == 0) return;
    if( bS[0] < 4 ) {
        int8_t tc[4];
        tc[0] = tc0_table[index_a][bS[0]];
        tc[1] = tc0_table[index_a][bS[1]];
        tc[2] = tc0_table[index_a][bS[2]];
        tc[3] = tc0_table[index_a][bS[3]];
        h->h264dsp.h264_v_loop_filter_luma(pix, stride, alpha, beta, tc);
    } else {
        h->h264dsp.h264_v_loop_filter_luma_intra(pix, stride, alpha, beta);
    }
}
['void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) {\n    MpegEncContext * const s = &h->s;\n    int mb_xy;\n    int mb_type, left_type, top_type;\n    int qp, qp0, qp1, qpc, qpc0, qpc1, qp_thresh;\n    int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY));\n    int chroma444 = CHROMA444;\n    mb_xy = h->mb_xy;\n    if(!h->h264dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff) {\n        ff_h264_filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize);\n        return;\n    }\n    assert(!FRAME_MBAFF);\n    left_type= h->left_type[LTOP];\n    top_type= h->top_type;\n    mb_type = s->current_picture.mb_type[mb_xy];\n    qp = s->current_picture.qscale_table[mb_xy];\n    qp0 = s->current_picture.qscale_table[mb_xy-1];\n    qp1 = s->current_picture.qscale_table[h->top_mb_xy];\n    qpc = get_chroma_qp( h, 0, qp );\n    qpc0 = get_chroma_qp( h, 0, qp0 );\n    qpc1 = get_chroma_qp( h, 0, qp1 );\n    qp0 = (qp + qp0 + 1) >> 1;\n    qp1 = (qp + qp1 + 1) >> 1;\n    qpc0 = (qpc + qpc0 + 1) >> 1;\n    qpc1 = (qpc + qpc1 + 1) >> 1;\n    qp_thresh = 15+52 - h->slice_alpha_c0_offset;\n    if(qp <= qp_thresh && qp0 <= qp_thresh && qp1 <= qp_thresh &&\n       qpc <= qp_thresh && qpc0 <= qp_thresh && qpc1 <= qp_thresh)\n        return;\n    if( IS_INTRA(mb_type) ) {\n        static const int16_t bS4[4] = {4,4,4,4};\n        static const int16_t bS3[4] = {3,3,3,3};\n        const int16_t *bSH = FIELD_PICTURE ? bS3 : bS4;\n        if(left_type)\n            filter_mb_edgev( &img_y[4*0], linesize, bS4, qp0, h);\n        if( IS_8x8DCT(mb_type) ) {\n            filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, h);\n            if(top_type){\n                filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h);\n            }\n            filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, h);\n        } else {\n            filter_mb_edgev( &img_y[4*1], linesize, bS3, qp, h);\n            filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, h);\n            filter_mb_edgev( &img_y[4*3], linesize, bS3, qp, h);\n            if(top_type){\n                filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h);\n            }\n            filter_mb_edgeh( &img_y[4*1*linesize], linesize, bS3, qp, h);\n            filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, h);\n            filter_mb_edgeh( &img_y[4*3*linesize], linesize, bS3, qp, h);\n        }\n        if(chroma){\n            if(chroma444){\n                if(left_type){\n                    filter_mb_edgev( &img_cb[4*0], linesize, bS4, qpc0, h);\n                    filter_mb_edgev( &img_cr[4*0], linesize, bS4, qpc0, h);\n                }\n                if( IS_8x8DCT(mb_type) ) {\n                    filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, h);\n                    filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, h);\n                    if(top_type){\n                        filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h);\n                        filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h);\n                    }\n                    filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, h);\n                    filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, h);\n                } else {\n                    filter_mb_edgev( &img_cb[4*1], linesize, bS3, qpc, h);\n                    filter_mb_edgev( &img_cr[4*1], linesize, bS3, qpc, h);\n                    filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, h);\n                    filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, h);\n                    filter_mb_edgev( &img_cb[4*3], linesize, bS3, qpc, h);\n                    filter_mb_edgev( &img_cr[4*3], linesize, bS3, qpc, h);\n                    if(top_type){\n                        filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h);\n                        filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h);\n                    }\n                    filter_mb_edgeh( &img_cb[4*1*linesize], linesize, bS3, qpc, h);\n                    filter_mb_edgeh( &img_cr[4*1*linesize], linesize, bS3, qpc, h);\n                    filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, h);\n                    filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, h);\n                    filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, qpc, h);\n                    filter_mb_edgeh( &img_cr[4*3*linesize], linesize, bS3, qpc, h);\n                }\n            }else{\n                if(left_type){\n                    filter_mb_edgecv( &img_cb[2*0], uvlinesize, bS4, qpc0, h);\n                    filter_mb_edgecv( &img_cr[2*0], uvlinesize, bS4, qpc0, h);\n                }\n                filter_mb_edgecv( &img_cb[2*2], uvlinesize, bS3, qpc, h);\n                filter_mb_edgecv( &img_cr[2*2], uvlinesize, bS3, qpc, h);\n                if(top_type){\n                    filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, h);\n                    filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, h);\n                }\n                filter_mb_edgech( &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc, h);\n                filter_mb_edgech( &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc, h);\n            }\n        }\n        return;\n    } else {\n        LOCAL_ALIGNED_8(int16_t, bS, [2], [4][4]);\n        int edges;\n        if( IS_8x8DCT(mb_type) && (h->cbp&7) == 7 ) {\n            edges = 4;\n            AV_WN64A(bS[0][0], 0x0002000200020002ULL);\n            AV_WN64A(bS[0][2], 0x0002000200020002ULL);\n            AV_WN64A(bS[1][0], 0x0002000200020002ULL);\n            AV_WN64A(bS[1][2], 0x0002000200020002ULL);\n        } else {\n            int mask_edge1 = (3*(((5*mb_type)>>5)&1)) | (mb_type>>4);\n            int mask_edge0 = 3*((mask_edge1>>1) & ((5*left_type)>>5)&1);\n            int step =  1+(mb_type>>24);\n            edges = 4 - 3*((mb_type>>3) & !(h->cbp & 15));\n            h->h264dsp.h264_loop_filter_strength( bS, h->non_zero_count_cache, h->ref_cache, h->mv_cache,\n                                              h->list_count==2, edges, step, mask_edge0, mask_edge1, FIELD_PICTURE);\n        }\n        if( IS_INTRA(left_type) )\n            AV_WN64A(bS[0][0], 0x0004000400040004ULL);\n        if( IS_INTRA(top_type) )\n            AV_WN64A(bS[1][0], FIELD_PICTURE ? 0x0003000300030003ULL : 0x0004000400040004ULL);\n#define FILTER(hv,dir,edge)\\\n        if(AV_RN64A(bS[dir][edge])) {                                   \\\n            filter_mb_edge##hv( &img_y[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qp : qp##dir, h );\\\n            if(chroma){\\\n                if(chroma444){\\\n                    filter_mb_edge##hv( &img_cb[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\\\n                    filter_mb_edge##hv( &img_cr[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\\\n                } else if(!(edge&1)) {\\\n                    filter_mb_edgec##hv( &img_cb[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\\\n                    filter_mb_edgec##hv( &img_cr[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\\\n                }\\\n            }\\\n        }\n        if(left_type)\n            FILTER(v,0,0);\n        if( edges == 1 ) {\n            if(top_type)\n                FILTER(h,1,0);\n        } else if( IS_8x8DCT(mb_type) ) {\n            FILTER(v,0,2);\n            if(top_type)\n                FILTER(h,1,0);\n            FILTER(h,1,2);\n        } else {\n            FILTER(v,0,1);\n            FILTER(v,0,2);\n            FILTER(v,0,3);\n            if(top_type)\n                FILTER(h,1,0);\n            FILTER(h,1,1);\n            FILTER(h,1,2);\n            FILTER(h,1,3);\n        }\n#undef FILTER\n    }\n}', 'static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h ) {\n    const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);\n    const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;\n    const int alpha = alpha_table[index_a];\n    const int beta  = beta_table[qp - qp_bd_offset + h->slice_beta_offset];\n    if (alpha ==0 || beta == 0) return;\n    if( bS[0] < 4 ) {\n        int8_t tc[4];\n        tc[0] = tc0_table[index_a][bS[0]];\n        tc[1] = tc0_table[index_a][bS[1]];\n        tc[2] = tc0_table[index_a][bS[2]];\n        tc[3] = tc0_table[index_a][bS[3]];\n        h->h264dsp.h264_v_loop_filter_luma(pix, stride, alpha, beta, tc);\n    } else {\n        h->h264dsp.h264_v_loop_filter_luma_intra(pix, stride, alpha, beta);\n    }\n}']