static int v410_encode_frame(AVCodecContext *avctx, uint8_t *buf,

                             int buf_size, void *data)

{

    AVFrame *pic = data;

    uint8_t *dst = buf;

    uint16_t *y, *u, *v;

    uint32_t val;

    int i, j;

    int output_size = 0;



    if (buf_size < avctx->width * avctx->height * 3) {

        av_log(avctx, AV_LOG_ERROR, "Out buffer is too small.\n");

        return AVERROR(ENOMEM);

    }



    avctx->coded_frame->reference = 0;

    avctx->coded_frame->key_frame = 1;

    avctx->coded_frame->pict_type = FF_I_TYPE;



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

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

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



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

        for (j = 0; j < avctx->width; j++) {

            val  = u[j] << 2;

            val |= y[j] << 12;

            val |= v[j] << 22;

            AV_WL32(dst, val);

            dst += 4;

            output_size += 4;

        }

        y += pic->linesize[0] >> 1;

        u += pic->linesize[1] >> 1;

        v += pic->linesize[2] >> 1;

    }



    return output_size;

}

static int v410_encode_frame(AVCodecContext *avctx, uint8_t *buf,

                             int buf_size, void *data)

{

    AVFrame *pic = data;

    uint8_t *dst = buf;

    uint16_t *y, *u, *v;

    uint32_t val;

    int i, j;

    int output_size = 0;



    if (buf_size < avctx->width * avctx->height * 3) {

        av_log(avctx, AV_LOG_ERROR, "Out buffer is too small.\n");

        return AVERROR(ENOMEM);

    }



    avctx->coded_frame->reference = 0;

    avctx->coded_frame->key_frame = 1;

    avctx->coded_frame->pict_type = FF_I_TYPE;



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

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

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



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

        for (j = 0; j < avctx->width; j++) {

            val  = u[j] << 2;

            val |= y[j] << 12;

            val |= v[j] << 22;

            AV_WL32(dst, val);

            dst += 4;

            output_size += 4;

        }

        y += pic->linesize[0] >> 1;

        u += pic->linesize[1] >> 1;

        v += pic->linesize[2] >> 1;

    }



    return output_size;

}

static int FUNC_0(AVCodecContext *VAR_0, uint8_t *VAR_1,

                             int VAR_2, void *VAR_3)

{

    AVFrame *pic = VAR_3;

    uint8_t *dst = VAR_1;

    uint16_t *y, *u, *v;

    uint32_t val;

    int VAR_4, VAR_5;

    int VAR_6 = 0;



    if (VAR_2 < VAR_0->width * VAR_0->height * 3) {

        av_log(VAR_0, AV_LOG_ERROR, "Out buffer is too small.\n");

        return AVERROR(ENOMEM);

    }



    VAR_0->coded_frame->reference = 0;

    VAR_0->coded_frame->key_frame = 1;

    VAR_0->coded_frame->pict_type = FF_I_TYPE;



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

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

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



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

        for (VAR_5 = 0; VAR_5 < VAR_0->width; VAR_5++) {

            val  = u[VAR_5] << 2;

            val |= y[VAR_5] << 12;

            val |= v[VAR_5] << 22;

            AV_WL32(dst, val);

            dst += 4;

            VAR_6 += 4;

        }

        y += pic->linesize[0] >> 1;

        u += pic->linesize[1] >> 1;

        v += pic->linesize[2] >> 1;

    }



    return VAR_6;

}

static int FUNC_0(AVCodecContext *VAR_0, uint8_t *VAR_1,
int VAR_2, void *VAR_3)
{ AVFrame *pic = VAR_3; uint8_t *dst = VAR_1; uint16_t *y, *u, *v; uint32_t val; int VAR_4, VAR_5; int VAR_6 = 0; if (VAR_2 < VAR_0->width * VAR_0->height * 3) { av_log(VAR_0, AV_LOG_ERROR, "Out buffer is too small.\n"); return AVERROR(ENOMEM); } VAR_0->coded_frame->reference = 0; VAR_0->coded_frame->key_frame = 1; VAR_0->coded_frame->pict_type = FF_I_TYPE; y = (uint16_t *)pic->VAR_3[0]; u = (uint16_t *)pic->VAR_3[1]; v = (uint16_t *)pic->VAR_3[2]; for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4++) { for (VAR_5 = 0; VAR_5 < VAR_0->width; VAR_5++) { val  = u[VAR_5] << 2; val |= y[VAR_5] << 12; val |= v[VAR_5] << 22; AV_WL32(dst, val); dst += 4; VAR_6 += 4; } y += pic->linesize[0] >> 1; u += pic->linesize[1] >> 1; v += pic->linesize[2] >> 1; } return VAR_6; }