static int encode_frame(AVCodecContext *avctx, unsigned char *buf,

                        int buf_size, void *data)

{

    const AVFrame *pic = data;

    int aligned_width = ((avctx->width + 47) / 48) * 48;

    int stride = aligned_width * 8 / 3;

    int h, w;

    const uint16_t *y = (const uint16_t*)pic->data[0];

    const uint16_t *u = (const uint16_t*)pic->data[1];

    const uint16_t *v = (const uint16_t*)pic->data[2];

    uint8_t *p = buf;

    uint8_t *pdst = buf;



    if (buf_size < aligned_width * avctx->height * 8 / 3) {

        av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");

        return -1;

    }



#define CLIP(v) av_clip(v, 4, 1019)



#define WRITE_PIXELS(a, b, c)           \

    do {                                \

        val =   CLIP(*a++);             \

        val |= (CLIP(*b++) << 10) |     \

               (CLIP(*c++) << 20);      \

        bytestream_put_le32(&p, val);   \

    } while (0)



    for (h = 0; h < avctx->height; h++) {

        uint32_t val;

        for (w = 0; w < avctx->width - 5; w += 6) {

            WRITE_PIXELS(u, y, v);

            WRITE_PIXELS(y, u, y);

            WRITE_PIXELS(v, y, u);

            WRITE_PIXELS(y, v, y);

        }

        if (w < avctx->width - 1) {

            WRITE_PIXELS(u, y, v);



            val = CLIP(*y++);

            if (w == avctx->width - 2)

                bytestream_put_le32(&p, val);

        }

        if (w < avctx->width - 3) {

            val |= (CLIP(*u++) << 10) | (CLIP(*y++) << 20);

            bytestream_put_le32(&p, val);



            val = CLIP(*v++) | (CLIP(*y++) << 10);

            bytestream_put_le32(&p, val);

        }



        pdst += stride;

        memset(p, 0, pdst - p);

        p = pdst;

        y += pic->linesize[0] / 2 - avctx->width;

        u += pic->linesize[1] / 2 - avctx->width / 2;

        v += pic->linesize[2] / 2 - avctx->width / 2;

    }



    return p - buf;

}

static int encode_frame(AVCodecContext *avctx, unsigned char *buf,

                        int buf_size, void *data)

{

    const AVFrame *pic = data;

    int aligned_width = ((avctx->width + 47) / 48) * 48;

    int stride = aligned_width * 8 / 3;

    int h, w;

    const uint16_t *y = (const uint16_t*)pic->data[0];

    const uint16_t *u = (const uint16_t*)pic->data[1];

    const uint16_t *v = (const uint16_t*)pic->data[2];

    uint8_t *p = buf;

    uint8_t *pdst = buf;



    if (buf_size < aligned_width * avctx->height * 8 / 3) {

        av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");

        return -1;

    }



#define CLIP(v) av_clip(v, 4, 1019)



#define WRITE_PIXELS(a, b, c)           \

    do {                                \

        val =   CLIP(*a++);             \

        val |= (CLIP(*b++) << 10) |     \

               (CLIP(*c++) << 20);      \

        bytestream_put_le32(&p, val);   \

    } while (0)



    for (h = 0; h < avctx->height; h++) {

        uint32_t val;

        for (w = 0; w < avctx->width - 5; w += 6) {

            WRITE_PIXELS(u, y, v);

            WRITE_PIXELS(y, u, y);

            WRITE_PIXELS(v, y, u);

            WRITE_PIXELS(y, v, y);

        }

        if (w < avctx->width - 1) {

            WRITE_PIXELS(u, y, v);



            val = CLIP(*y++);

            if (w == avctx->width - 2)

                bytestream_put_le32(&p, val);

        }

        if (w < avctx->width - 3) {

            val |= (CLIP(*u++) << 10) | (CLIP(*y++) << 20);

            bytestream_put_le32(&p, val);



            val = CLIP(*v++) | (CLIP(*y++) << 10);

            bytestream_put_le32(&p, val);

        }



        pdst += stride;

        memset(p, 0, pdst - p);

        p = pdst;

        y += pic->linesize[0] / 2 - avctx->width;

        u += pic->linesize[1] / 2 - avctx->width / 2;

        v += pic->linesize[2] / 2 - avctx->width / 2;

    }



    return p - buf;

}

        if (w < avctx->width - 3) {             val |= (CLIP(*u++) << 10) | (CLIP(*y++) << 20);             bytestream_put_le32(&p, val);             val = CLIP(*v++) | (CLIP(*y++) << 10);             bytestream_put_le32(&p, val);
static int FUNC_0(AVCodecContext *VAR_0, unsigned char *VAR_1,

                        int VAR_2, void *VAR_3)

{

    const AVFrame *VAR_4 = VAR_3;

    int VAR_5 = ((VAR_0->width + 47) / 48) * 48;

    int VAR_6 = VAR_5 * 8 / 3;

    int VAR_7, VAR_8;

    const uint16_t *VAR_9 = (const uint16_t*)VAR_4->VAR_3[0];

    const uint16_t *VAR_10 = (const uint16_t*)VAR_4->VAR_3[1];

    const uint16_t *VAR_11 = (const uint16_t*)VAR_4->VAR_3[2];

    uint8_t *p = VAR_1;

    uint8_t *pdst = VAR_1;



    if (VAR_2 < VAR_5 * VAR_0->height * 8 / 3) {

        av_log(VAR_0, AV_LOG_ERROR, "output buffer too small\n");

        return -1;

    }



#define CLIP(VAR_11) av_clip(VAR_11, 4, 1019)



#define WRITE_PIXELS(a, b, c)           \

    do {                                \

        val =   CLIP(*a++);             \

        val |= (CLIP(*b++) << 10) |     \

               (CLIP(*c++) << 20);      \

        bytestream_put_le32(&p, val);   \

    } while (0)



    for (VAR_7 = 0; VAR_7 < VAR_0->height; VAR_7++) {

        uint32_t val;

        for (VAR_8 = 0; VAR_8 < VAR_0->width - 5; VAR_8 += 6) {

            WRITE_PIXELS(VAR_10, VAR_9, VAR_11);

            WRITE_PIXELS(VAR_9, VAR_10, VAR_9);

            WRITE_PIXELS(VAR_11, VAR_9, VAR_10);

            WRITE_PIXELS(VAR_9, VAR_11, VAR_9);

        }

        if (VAR_8 < VAR_0->width - 1) {

            WRITE_PIXELS(VAR_10, VAR_9, VAR_11);



            val = CLIP(*VAR_9++);

            if (VAR_8 == VAR_0->width - 2)

                bytestream_put_le32(&p, val);

        }

        if (VAR_8 < VAR_0->width - 3) {

            val |= (CLIP(*VAR_10++) << 10) | (CLIP(*VAR_9++) << 20);

            bytestream_put_le32(&p, val);



            val = CLIP(*VAR_11++) | (CLIP(*VAR_9++) << 10);

            bytestream_put_le32(&p, val);

        }



        pdst += VAR_6;

        memset(p, 0, pdst - p);

        p = pdst;

        VAR_9 += VAR_4->linesize[0] / 2 - VAR_0->width;

        VAR_10 += VAR_4->linesize[1] / 2 - VAR_0->width / 2;

        VAR_11 += VAR_4->linesize[2] / 2 - VAR_0->width / 2;

    }



    return p - VAR_1;

}

static int FUNC_0(AVCodecContext *VAR_0, unsigned char *VAR_1,
int VAR_2, void *VAR_3)
{ const AVFrame *VAR_4 = VAR_3; int VAR_5 = ((VAR_0->width + 47) / 48) * 48; int VAR_6 = VAR_5 * 8 / 3; int VAR_7, VAR_8; const uint16_t *VAR_9 = (const uint16_t*)VAR_4->VAR_3[0]; const uint16_t *VAR_10 = (const uint16_t*)VAR_4->VAR_3[1]; const uint16_t *VAR_11 = (const uint16_t*)VAR_4->VAR_3[2]; uint8_t *p = VAR_1; uint8_t *pdst = VAR_1; if (VAR_2 < VAR_5 * VAR_0->height * 8 / 3) { av_log(VAR_0, AV_LOG_ERROR, "output buffer too small\n"); return -1; } #define CLIP(VAR_11) av_clip(VAR_11, 4, 1019)
#define WRITE_PIXELS(a, b, c)           \
do {                                \ val =   CLIP(*a++);             \ val |= (CLIP(*b++) << 10) |     \
(CLIP(*c++) << 20);      \ bytestream_put_le32(&p, val);   \ } while (0) for (VAR_7 = 0; VAR_7 < VAR_0->height; VAR_7++) { uint32_t val; for (VAR_8 = 0; VAR_8 < VAR_0->width - 5; VAR_8 += 6) { WRITE_PIXELS(VAR_10, VAR_9, VAR_11); WRITE_PIXELS(VAR_9, VAR_10, VAR_9); WRITE_PIXELS(VAR_11, VAR_9, VAR_10); WRITE_PIXELS(VAR_9, VAR_11, VAR_9); } if (VAR_8 < VAR_0->width - 1) { WRITE_PIXELS(VAR_10, VAR_9, VAR_11); val = CLIP(*VAR_9++); if (VAR_8 == VAR_0->width - 2)
bytestream_put_le32(&p, val); } if (VAR_8 < VAR_0->width - 3) { val |= (CLIP(*VAR_10++) << 10) | (CLIP(*VAR_9++) << 20); bytestream_put_le32(&p, val); val = CLIP(*VAR_11++) | (CLIP(*VAR_9++) << 10); bytestream_put_le32(&p, val); } pdst += VAR_6; memset(p, 0, pdst - p); p = pdst; VAR_9 += VAR_4->linesize[0] / 2 - VAR_0->width; VAR_10 += VAR_4->linesize[1] / 2 - VAR_0->width / 2; VAR_11 += VAR_4->linesize[2] / 2 - VAR_0->width / 2; } return p - VAR_1; }