static int encode_codebook(CinepakEncContext *s, int *codebook, int size, int chunk_type_yuv, int chunk_type_gray, unsigned char *buf)

{

    int x, y, ret, entry_size = s->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4;



    ret = write_chunk_header(buf, s->pix_fmt == AV_PIX_FMT_YUV420P ? chunk_type_yuv : chunk_type_gray, entry_size * size);



    for(x = 0; x < size; x++)

        for(y = 0; y < entry_size; y++)

            buf[ret++] = codebook[y + x*entry_size] ^ (y >= 4 ? 0x80 : 0);



    return ret;

}

static int encode_codebook(CinepakEncContext *s, int *codebook, int size, int chunk_type_yuv, int chunk_type_gray, unsigned char *buf)

{

    int x, y, ret, entry_size = s->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4;



    ret = write_chunk_header(buf, s->pix_fmt == AV_PIX_FMT_YUV420P ? chunk_type_yuv : chunk_type_gray, entry_size * size);



    for(x = 0; x < size; x++)

        for(y = 0; y < entry_size; y++)

            buf[ret++] = codebook[y + x*entry_size] ^ (y >= 4 ? 0x80 : 0);



    return ret;

}

    int x, y, ret, entry_size = s->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4;     ret = write_chunk_header(buf, s->pix_fmt == AV_PIX_FMT_YUV420P ? chunk_type_yuv : chunk_type_gray, entry_size * size);     for(x = 0; x < size; x++)         for(y = 0; y < entry_size; y++)             buf[ret++] = codebook[y + x*entry_size] ^ (y >= 4 ? 0x80 : 0);     return ret;
static int FUNC_0(CinepakEncContext *VAR_0, int *VAR_1, int VAR_2, int VAR_3, int VAR_4, unsigned char *VAR_5)

{

    int VAR_6, VAR_7, VAR_8, VAR_9 = VAR_0->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4;



    VAR_8 = write_chunk_header(VAR_5, VAR_0->pix_fmt == AV_PIX_FMT_YUV420P ? VAR_3 : VAR_4, VAR_9 * VAR_2);



    for(VAR_6 = 0; VAR_6 < VAR_2; VAR_6++)

        for(VAR_7 = 0; VAR_7 < VAR_9; VAR_7++)

            VAR_5[VAR_8++] = VAR_1[VAR_7 + VAR_6*VAR_9] ^ (VAR_7 >= 4 ? 0x80 : 0);



    return VAR_8;

}

static int FUNC_0(CinepakEncContext *VAR_0, int *VAR_1, int VAR_2, int VAR_3, int VAR_4, unsigned char *VAR_5)
{ int VAR_6, VAR_7, VAR_8, VAR_9 = VAR_0->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4; VAR_8 = write_chunk_header(VAR_5, VAR_0->pix_fmt == AV_PIX_FMT_YUV420P ? VAR_3 : VAR_4, VAR_9 * VAR_2); for(VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) for(VAR_7 = 0; VAR_7 < VAR_9; VAR_7++) VAR_5[VAR_8++] = VAR_1[VAR_7 + VAR_6*VAR_9] ^ (VAR_7 >= 4 ? 0x80 : 0); return VAR_8; }