encode_block(s, &plane[left_edge], stride, 5, 256, (s->picture.quality*s->picture.quality) >> (2*FF_LAMBDA_SHIFT));
if(x*16 + 16 > width || y*16 + 16 > height){ ff_emulated_edge_mc(buf, src, stride, 16, 16, 16*x, 16*y, width, height); src= buf; } s->rd_total += encode_block(s, src, stride, 5, 256, (s->picture.quality*s->picture.quality) >> (2*FF_LAMBDA_SHIFT));
static void svq1_encode_plane(SVQ1Context *s, unsigned char *plane,    int width, int height, int stride){    unsigned char buffer0[256];    unsigned char buffer1[256];    int current_buffer;    unsigned char *vector;    unsigned char *subvectors;    int vector_count;    int subvector_count;    int x, y;    int i, j;    int block_width, block_height;    int left_edge;    int level;    int threshold[6];static int frame = 0;#ifdef DEBUG_SVQ1av_log(s->avctx, AV_LOG_INFO, "********* frame #%d\n", frame++);#endif    /* figure out the acceptable level thresholds in advance */    threshold[5] = QUALITY_THRESHOLD;    for (level = 4; level >= 0; level--)        threshold[level] = threshold[level + 1] * THRESHOLD_MULTIPLIER;    block_width = (width + 15) / 16;    block_height = (height + 15) / 16;    for (y = 0; y < block_height; y++) {        for (x = 0; x < block_width; x++) {            uint8_t reorder_buffer[6][7*32];#ifdef DEBUG_SVQ1av_log(s->avctx, AV_LOG_INFO, "* level 5 vector @ %d, %d:\n", x * 16, y * 16);#endif            /* copy the block into the current work buffer */            left_edge = (y * 16 * stride) + (x * 16);                        for(i=0; i<6; i++){                init_put_bits(&s->reorder_pb[i], reorder_buffer[i], 7*32);            }            encode_block(s, &plane[left_edge], stride, 5, 256, (s->picture.quality*s->picture.quality) >> (2*FF_LAMBDA_SHIFT));            for(i=5; i>=0; i--){                int count= put_bits_count(&s->reorder_pb[i]);                                flush_put_bits(&s->reorder_pb[i]);                ff_copy_bits(&s->pb, s->reorder_pb[i].buf, count);            }            #if 0            for (i = 0; i < 256; i += 16) {                memcpy(&buffer0[i], &plane[left_edge], 16);                left_edge += stride;            }            current_buffer = 1;  /* this will toggle to 0 immediately */            /* perform a breadth-first tree encoding for each vector level */            subvector_count = 1;  /* one subvector at level 5 */            for (level = 5; level >= 0; level--) {                vector_count = subvector_count;                subvector_count = 0;                if (current_buffer == 0) {                    current_buffer = 1;                    vector = buffer1;                    subvectors = buffer0;                } else {                    current_buffer = 0;                    vector = buffer0;                    subvectors = buffer1;                }                /* iterate through each vector in the list */                for (i = 0; i < vector_count; i++) {                    if (encode_vector(s, vector, level, threshold[level])) {#ifdef DEBUG_SVQ1av_log(s->avctx, AV_LOG_INFO, "  split to level %d\n", level - 1);#endif                        /* subdivide into 2 subvectors for later processing */                        subvector_count += 2;                        if (level - 1 == 3) {                            /* subdivide 16x8 -> 2 8x8 */                            for (j = 0; j < 8; j++) {                                /* left half */                                memcpy(subvectors + j * 8, vector + j * 16, 8);                                /* right half */                                memcpy(subvectors + 64 + j * 8,                                    vector + 8 + j * 16, 8);                            }                            subvectors += 128;                        } else if (level - 1 == 1) {                            /* subdivide 8x4 -> 2 4x4 */                            for (j = 0; j < 4; j++) {                                /* left half */                                memcpy(subvectors + j * 4, vector + j * 8, 4);                                /* right half */                                memcpy(subvectors + 16 + j * 4,                                    vector + 4 + j * 8, 4);                            }                            subvectors += 32;                        } else {                            /* first half */                            memcpy(subvectors, vector, level_sizes[level - 1]);                            subvectors += level_sizes[level - 1];                            /* second half */                            memcpy(subvectors, vector + level_sizes[level - 1],                                 level_sizes[level - 1]);                            subvectors += level_sizes[level - 1];                        }                    }                     vector += level_sizes[level];                }                /* if there are no more subvectors, break early */                if (!subvector_count)                    break;            }#endif        }    }}