static int rd_frame(CinepakEncContext *s, AVFrame *frame, unsigned char *buf, int buf_size)

{

    int num_strips, strip, h, i, y, size, temp_size, best_size;

    AVPicture last_pict, pict, scratch_pict;

    int64_t best_score = 0, score, score_temp;



    //TODO: support encoding zero strips (meaning skip the whole frame)

    for(num_strips = MIN_STRIPS; num_strips <= MAX_STRIPS && num_strips <= s->h / MB_SIZE; num_strips++) {

        score = 0;

        size = 0;

        h = s->h / num_strips;

        //make h into next multiple of 4

        h += 4 - (h & 3);



        for(strip = 0; strip < num_strips; strip++) {

            y = strip*h;



            get_sub_picture(s, 0, y, (AVPicture*)frame,            &pict);

            get_sub_picture(s, 0, y, (AVPicture*)&s->last_frame,    &last_pict);

            get_sub_picture(s, 0, y, (AVPicture*)&s->scratch_frame, &scratch_pict);



            if((temp_size = rd_strip(s, y, FFMIN(h, s->h - y), frame->key_frame, &last_pict, &pict, &scratch_pict, s->frame_buf + CVID_HEADER_SIZE, &score_temp)) < 0)

                return temp_size;



            score += score_temp;

            size += temp_size;

        }



        if(best_score == 0 || score < best_score) {

            best_score = score;

            best_size = size + write_cvid_header(s, s->frame_buf, num_strips, size);

            av_log(s->avctx, AV_LOG_INFO, "best number of strips so far: %2i, %12li, %i B\n", num_strips, score, best_size);



            FFSWAP(AVFrame, s->best_frame, s->scratch_frame);

        }

    }



    memcpy(buf, s->frame_buf, best_size);



    return best_size;

}

static int rd_frame(CinepakEncContext *s, AVFrame *frame, unsigned char *buf, int buf_size)

{

    int num_strips, strip, h, i, y, size, temp_size, best_size;

    AVPicture last_pict, pict, scratch_pict;

    int64_t best_score = 0, score, score_temp;



    

    for(num_strips = MIN_STRIPS; num_strips <= MAX_STRIPS && num_strips <= s->h / MB_SIZE; num_strips++) {

        score = 0;

        size = 0;

        h = s->h / num_strips;

        

        h += 4 - (h & 3);



        for(strip = 0; strip < num_strips; strip++) {

            y = strip*h;



            get_sub_picture(s, 0, y, (AVPicture*)frame,            &pict);

            get_sub_picture(s, 0, y, (AVPicture*)&s->last_frame,    &last_pict);

            get_sub_picture(s, 0, y, (AVPicture*)&s->scratch_frame, &scratch_pict);



            if((temp_size = rd_strip(s, y, FFMIN(h, s->h - y), frame->key_frame, &last_pict, &pict, &scratch_pict, s->frame_buf + CVID_HEADER_SIZE, &score_temp)) < 0)

                return temp_size;



            score += score_temp;

            size += temp_size;

        }



        if(best_score == 0 || score < best_score) {

            best_score = score;

            best_size = size + write_cvid_header(s, s->frame_buf, num_strips, size);

            av_log(s->avctx, AV_LOG_INFO, "best number of strips so far: %2i, %12li, %i B\n", num_strips, score, best_size);



            FFSWAP(AVFrame, s->best_frame, s->scratch_frame);

        }

    }



    memcpy(buf, s->frame_buf, best_size);



    return best_size;

}

static int rd_frame(CinepakEncContext *s, AVFrame *frame, unsigned char *buf, int buf_size)     int num_strips, strip, h, i, y, size, temp_size, best_size;     for(num_strips = MIN_STRIPS; num_strips <= MAX_STRIPS && num_strips <= s->h / MB_SIZE; num_strips++) {         h = s->h / num_strips;         h += 4 - (h & 3);         for(strip = 0; strip < num_strips; strip++) {             y = strip*h;             get_sub_picture(s, 0, y, (AVPicture*)frame,            &pict);             get_sub_picture(s, 0, y, (AVPicture*)&s->last_frame,    &last_pict);             get_sub_picture(s, 0, y, (AVPicture*)&s->scratch_frame, &scratch_pict);             if((temp_size = rd_strip(s, y, FFMIN(h, s->h - y), frame->key_frame, &last_pict, &pict, &scratch_pict, s->frame_buf + CVID_HEADER_SIZE, &score_temp)) < 0)             best_size = size + write_cvid_header(s, s->frame_buf, num_strips, size);             av_log(s->avctx, AV_LOG_INFO, "best number of strips so far: %2i, %12li, %i B\n", num_strips, score, best_size);             FFSWAP(AVFrame, s->best_frame, s->scratch_frame);     memcpy(buf, s->frame_buf, best_size);
static int FUNC_0(CinepakEncContext *VAR_0, AVFrame *VAR_1, unsigned char *VAR_2, int VAR_3)

{

    int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;

    AVPicture last_pict, pict, scratch_pict;

    int64_t best_score = 0, score, score_temp;



    

    for(VAR_4 = MIN_STRIPS; VAR_4 <= MAX_STRIPS && VAR_4 <= VAR_0->VAR_6 / MB_SIZE; VAR_4++) {

        score = 0;

        VAR_9 = 0;

        VAR_6 = VAR_0->VAR_6 / VAR_4;

        

        VAR_6 += 4 - (VAR_6 & 3);



        for(VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {

            VAR_8 = VAR_5*VAR_6;



            get_sub_picture(VAR_0, 0, VAR_8, (AVPicture*)VAR_1,            &pict);

            get_sub_picture(VAR_0, 0, VAR_8, (AVPicture*)&VAR_0->last_frame,    &last_pict);

            get_sub_picture(VAR_0, 0, VAR_8, (AVPicture*)&VAR_0->scratch_frame, &scratch_pict);



            if((VAR_10 = rd_strip(VAR_0, VAR_8, FFMIN(VAR_6, VAR_0->VAR_6 - VAR_8), VAR_1->key_frame, &last_pict, &pict, &scratch_pict, VAR_0->frame_buf + CVID_HEADER_SIZE, &score_temp)) < 0)

                return VAR_10;



            score += score_temp;

            VAR_9 += VAR_10;

        }



        if(best_score == 0 || score < best_score) {

            best_score = score;

            VAR_11 = VAR_9 + write_cvid_header(VAR_0, VAR_0->frame_buf, VAR_4, VAR_9);

            av_log(VAR_0->avctx, AV_LOG_INFO, "best number of strips so far: %2i, %12li, %VAR_7 B\n", VAR_4, score, VAR_11);



            FFSWAP(AVFrame, VAR_0->best_frame, VAR_0->scratch_frame);

        }

    }



    memcpy(VAR_2, VAR_0->frame_buf, VAR_11);



    return VAR_11;

}

static int FUNC_0(CinepakEncContext *VAR_0, AVFrame *VAR_1, unsigned char *VAR_2, int VAR_3)
{ int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11; AVPicture last_pict, pict, scratch_pict; int64_t best_score = 0, score, score_temp; for(VAR_4 = MIN_STRIPS; VAR_4 <= MAX_STRIPS && VAR_4 <= VAR_0->VAR_6 / MB_SIZE; VAR_4++) { score = 0; VAR_9 = 0; VAR_6 = VAR_0->VAR_6 / VAR_4; VAR_6 += 4 - (VAR_6 & 3); for(VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) { VAR_8 = VAR_5*VAR_6; get_sub_picture(VAR_0, 0, VAR_8, (AVPicture*)VAR_1,            &pict); get_sub_picture(VAR_0, 0, VAR_8, (AVPicture*)&VAR_0->last_frame,    &last_pict); get_sub_picture(VAR_0, 0, VAR_8, (AVPicture*)&VAR_0->scratch_frame, &scratch_pict); if((VAR_10 = rd_strip(VAR_0, VAR_8, FFMIN(VAR_6, VAR_0->VAR_6 - VAR_8), VAR_1->key_frame, &last_pict, &pict, &scratch_pict, VAR_0->frame_buf + CVID_HEADER_SIZE, &score_temp)) < 0)
return VAR_10; score += score_temp; VAR_9 += VAR_10; } if(best_score == 0 || score < best_score) { best_score = score; VAR_11 = VAR_9 + write_cvid_header(VAR_0, VAR_0->frame_buf, VAR_4, VAR_9); av_log(VAR_0->avctx, AV_LOG_INFO, "best number of strips so far: %2i, %12li, %VAR_7 B\n", VAR_4, score, VAR_11); FFSWAP(AVFrame, VAR_0->best_frame, VAR_0->scratch_frame); } } memcpy(VAR_2, VAR_0->frame_buf, VAR_11); return VAR_11; }