static inline void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, MpegEncContext *best, int type,
                           PutBitContext pb[2], PutBitContext pb2[2], PutBitContext tex_pb[2],
                           int *dmin, int *next_block, int motion_x, int motion_y)
{
    int score;
    uint8_t *dest_backup[3];
    copy_context_before_encode(s, backup, type);
    s->block= s->blocks[*next_block];
    s->pb= pb[*next_block];
    if(s->data_partitioning){
        s->pb2   = pb2   [*next_block];
        s->tex_pb= tex_pb[*next_block];
    }
    if(*next_block){
        memcpy(dest_backup, s->dest, sizeof(s->dest));
        s->dest[0] = s->rd_scratchpad;
        s->dest[1] = s->rd_scratchpad + 16*s->linesize;
        s->dest[2] = s->rd_scratchpad + 16*s->linesize + 8;
        assert(s->linesize >= 32);
    }
    encode_mb(s, motion_x, motion_y);
    score= put_bits_count(&s->pb);
    if(s->data_partitioning){
        score+= put_bits_count(&s->pb2);
        score+= put_bits_count(&s->tex_pb);
    }
    if(s->avctx->mb_decision == FF_MB_DECISION_RD){
        MPV_decode_mb(s, s->block);
        score *= s->lambda2;
        score += sse_mb(s) << FF_LAMBDA_SHIFT;
    }
    if(*next_block){
        memcpy(s->dest, dest_backup, sizeof(s->dest));
    }
    if(score<*dmin){
        *dmin= score;
        *next_block^=1;
        copy_context_after_encode(best, s, type);
    }
}
['static inline void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, MpegEncContext *best, int type,\n                           PutBitContext pb[2], PutBitContext pb2[2], PutBitContext tex_pb[2],\n                           int *dmin, int *next_block, int motion_x, int motion_y)\n{\n    int score;\n    uint8_t *dest_backup[3];\n    copy_context_before_encode(s, backup, type);\n    s->block= s->blocks[*next_block];\n    s->pb= pb[*next_block];\n    if(s->data_partitioning){\n        s->pb2   = pb2   [*next_block];\n        s->tex_pb= tex_pb[*next_block];\n    }\n    if(*next_block){\n        memcpy(dest_backup, s->dest, sizeof(s->dest));\n        s->dest[0] = s->rd_scratchpad;\n        s->dest[1] = s->rd_scratchpad + 16*s->linesize;\n        s->dest[2] = s->rd_scratchpad + 16*s->linesize + 8;\n        assert(s->linesize >= 32);\n    }\n    encode_mb(s, motion_x, motion_y);\n    score= put_bits_count(&s->pb);\n    if(s->data_partitioning){\n        score+= put_bits_count(&s->pb2);\n        score+= put_bits_count(&s->tex_pb);\n    }\n    if(s->avctx->mb_decision == FF_MB_DECISION_RD){\n        MPV_decode_mb(s, s->block);\n        score *= s->lambda2;\n        score += sse_mb(s) << FF_LAMBDA_SHIFT;\n    }\n    if(*next_block){\n        memcpy(s->dest, dest_backup, sizeof(s->dest));\n    }\n    if(score<*dmin){\n        *dmin= score;\n        *next_block^=1;\n        copy_context_after_encode(best, s, type);\n    }\n}']