static int avui_encode_frame(AVCodecContext *avctx, AVPacket *pkt,

                             const AVFrame *pic, int *got_packet)

{

    uint8_t *dst, *src = pic->data[0];

    int i, j, skip, ret, size, interlaced;



    interlaced = avctx->field_order > AV_FIELD_PROGRESSIVE;



    if (avctx->height == 486) {

        skip = 10;

    } else {

        skip = 16;

    }

    size = 2 * avctx->width * (avctx->height + skip) + 8 * interlaced;

    if ((ret = ff_alloc_packet2(avctx, pkt, size)) < 0)

        return ret;

    dst = pkt->data;

    if (!(avctx->extradata = av_mallocz(24 + FF_INPUT_BUFFER_PADDING_SIZE)))

        return AVERROR(ENOMEM);

    avctx->extradata_size = 24;

    memcpy(avctx->extradata, "\0\0\0\x18""APRGAPRG0001", 16);

    if (interlaced) {

        avctx->extradata[19] = 2;

    } else {

        avctx->extradata[19] = 1;

        dst += avctx->width * skip;

    }



    avctx->coded_frame->reference = 0;

    avctx->coded_frame->key_frame = 1;

    avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;



    for (i = 0; i <= interlaced; i++) {

        if (interlaced && avctx->height == 486) {

            src = pic->data[0] + (1 - i) * pic->linesize[0];

        } else {

            src = pic->data[0] + i * pic->linesize[0];

        }

        dst += avctx->width * skip + 4 * i;

        for (j = 0; j < avctx->height; j += interlaced + 1) {

            memcpy(dst, src, avctx->width * 2);

            src += (interlaced + 1) * pic->linesize[0];

            dst += avctx->width * 2;

        }

    }



    pkt->flags |= AV_PKT_FLAG_KEY;

    *got_packet = 1;

    return 0;

}

static int avui_encode_frame(AVCodecContext *avctx, AVPacket *pkt,

                             const AVFrame *pic, int *got_packet)

{

    uint8_t *dst, *src = pic->data[0];

    int i, j, skip, ret, size, interlaced;



    interlaced = avctx->field_order > AV_FIELD_PROGRESSIVE;



    if (avctx->height == 486) {

        skip = 10;

    } else {

        skip = 16;

    }

    size = 2 * avctx->width * (avctx->height + skip) + 8 * interlaced;

    if ((ret = ff_alloc_packet2(avctx, pkt, size)) < 0)

        return ret;

    dst = pkt->data;

    if (!(avctx->extradata = av_mallocz(24 + FF_INPUT_BUFFER_PADDING_SIZE)))

        return AVERROR(ENOMEM);

    avctx->extradata_size = 24;

    memcpy(avctx->extradata, "\0\0\0\x18""APRGAPRG0001", 16);

    if (interlaced) {

        avctx->extradata[19] = 2;

    } else {

        avctx->extradata[19] = 1;

        dst += avctx->width * skip;

    }



    avctx->coded_frame->reference = 0;

    avctx->coded_frame->key_frame = 1;

    avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;



    for (i = 0; i <= interlaced; i++) {

        if (interlaced && avctx->height == 486) {

            src = pic->data[0] + (1 - i) * pic->linesize[0];

        } else {

            src = pic->data[0] + i * pic->linesize[0];

        }

        dst += avctx->width * skip + 4 * i;

        for (j = 0; j < avctx->height; j += interlaced + 1) {

            memcpy(dst, src, avctx->width * 2);

            src += (interlaced + 1) * pic->linesize[0];

            dst += avctx->width * 2;

        }

    }



    pkt->flags |= AV_PKT_FLAG_KEY;

    *got_packet = 1;

    return 0;

}

    if (!(avctx->extradata = av_mallocz(24 + FF_INPUT_BUFFER_PADDING_SIZE)))         return AVERROR(ENOMEM);     avctx->extradata_size = 24;     memcpy(avctx->extradata, "\0\0\0\x18""APRGAPRG0001", 16);     if (interlaced) {         avctx->extradata[19] = 2;     } else {         avctx->extradata[19] = 1;
static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,

                             const AVFrame *VAR_2, int *VAR_3)

{

    uint8_t *dst, *src = VAR_2->data[0];

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



    VAR_9 = VAR_0->field_order > AV_FIELD_PROGRESSIVE;



    if (VAR_0->height == 486) {

        VAR_6 = 10;

    } else {

        VAR_6 = 16;

    }

    VAR_8 = 2 * VAR_0->width * (VAR_0->height + VAR_6) + 8 * VAR_9;

    if ((VAR_7 = ff_alloc_packet2(VAR_0, VAR_1, VAR_8)) < 0)

        return VAR_7;

    dst = VAR_1->data;

    if (!(VAR_0->extradata = av_mallocz(24 + FF_INPUT_BUFFER_PADDING_SIZE)))

        return AVERROR(ENOMEM);

    VAR_0->extradata_size = 24;

    memcpy(VAR_0->extradata, "\0\0\0\x18""APRGAPRG0001", 16);

    if (VAR_9) {

        VAR_0->extradata[19] = 2;

    } else {

        VAR_0->extradata[19] = 1;

        dst += VAR_0->width * VAR_6;

    }



    VAR_0->coded_frame->reference = 0;

    VAR_0->coded_frame->key_frame = 1;

    VAR_0->coded_frame->pict_type = AV_PICTURE_TYPE_I;



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

        if (VAR_9 && VAR_0->height == 486) {

            src = VAR_2->data[0] + (1 - VAR_4) * VAR_2->linesize[0];

        } else {

            src = VAR_2->data[0] + VAR_4 * VAR_2->linesize[0];

        }

        dst += VAR_0->width * VAR_6 + 4 * VAR_4;

        for (VAR_5 = 0; VAR_5 < VAR_0->height; VAR_5 += VAR_9 + 1) {

            memcpy(dst, src, VAR_0->width * 2);

            src += (VAR_9 + 1) * VAR_2->linesize[0];

            dst += VAR_0->width * 2;

        }

    }



    VAR_1->flags |= AV_PKT_FLAG_KEY;

    *VAR_3 = 1;

    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{ uint8_t *dst, *src = VAR_2->data[0]; int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9; VAR_9 = VAR_0->field_order > AV_FIELD_PROGRESSIVE; if (VAR_0->height == 486) { VAR_6 = 10; } else { VAR_6 = 16; } VAR_8 = 2 * VAR_0->width * (VAR_0->height + VAR_6) + 8 * VAR_9; if ((VAR_7 = ff_alloc_packet2(VAR_0, VAR_1, VAR_8)) < 0)
return VAR_7; dst = VAR_1->data; if (!(VAR_0->extradata = av_mallocz(24 + FF_INPUT_BUFFER_PADDING_SIZE)))
return AVERROR(ENOMEM); VAR_0->extradata_size = 24; memcpy(VAR_0->extradata, "\0\0\0\x18""APRGAPRG0001", 16); if (VAR_9) { VAR_0->extradata[19] = 2; } else { VAR_0->extradata[19] = 1; dst += VAR_0->width * VAR_6; } VAR_0->coded_frame->reference = 0; VAR_0->coded_frame->key_frame = 1; VAR_0->coded_frame->pict_type = AV_PICTURE_TYPE_I; for (VAR_4 = 0; VAR_4 <= VAR_9; VAR_4++) { if (VAR_9 && VAR_0->height == 486) { src = VAR_2->data[0] + (1 - VAR_4) * VAR_2->linesize[0]; } else { src = VAR_2->data[0] + VAR_4 * VAR_2->linesize[0]; } dst += VAR_0->width * VAR_6 + 4 * VAR_4; for (VAR_5 = 0; VAR_5 < VAR_0->height; VAR_5 += VAR_9 + 1) { memcpy(dst, src, VAR_0->width * 2); src += (VAR_9 + 1) * VAR_2->linesize[0]; dst += VAR_0->width * 2; } } VAR_1->flags |= AV_PKT_FLAG_KEY; *VAR_3 = 1; return 0; }