static int gif_write_header(AVFormatContext *s)

{

    GIFContext *gif = s->priv_data;

    AVIOContext *pb = s->pb;

    AVCodecContext *enc, *video_enc;

    int i, width, height, loop_count /*, rate*/;



/* XXX: do we reject audio streams or just ignore them ?

    if(s->nb_streams > 1)

        return -1;

*/

    gif->time = 0;

    gif->file_time = 0;



    video_enc = NULL;

    for(i=0;i<s->nb_streams;i++) {

        enc = s->streams[i]->codec;

        if (enc->codec_type != AVMEDIA_TYPE_AUDIO)

            video_enc = enc;

    }



    if (!video_enc) {

        av_free(gif);

        return -1;

    } else {

        width = video_enc->width;

        height = video_enc->height;

        loop_count = s->loop_output;

//        rate = video_enc->time_base.den;

    }



    if (video_enc->pix_fmt != PIX_FMT_RGB24) {

        av_log(s, AV_LOG_ERROR, "ERROR: gif only handles the rgb24 pixel format. Use -pix_fmt rgb24.\n");

        return AVERROR(EIO);

    }



    gif_image_write_header(pb, width, height, loop_count, NULL);



    avio_flush(s->pb);

    return 0;

}

static int gif_write_header(AVFormatContext *s)

{

    GIFContext *gif = s->priv_data;

    AVIOContext *pb = s->pb;

    AVCodecContext *enc, *video_enc;

    int i, width, height, loop_count ;











    gif->time = 0;

    gif->file_time = 0;



    video_enc = NULL;

    for(i=0;i<s->nb_streams;i++) {

        enc = s->streams[i]->codec;

        if (enc->codec_type != AVMEDIA_TYPE_AUDIO)

            video_enc = enc;

    }



    if (!video_enc) {

        av_free(gif);

        return -1;

    } else {

        width = video_enc->width;

        height = video_enc->height;

        loop_count = s->loop_output;



    }



    if (video_enc->pix_fmt != PIX_FMT_RGB24) {

        av_log(s, AV_LOG_ERROR, "ERROR: gif only handles the rgb24 pixel format. Use -pix_fmt rgb24.\n");

        return AVERROR(EIO);

    }



    gif_image_write_header(pb, width, height, loop_count, NULL);



    avio_flush(s->pb);

    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0)

{

    GIFContext *gif = VAR_0->priv_data;

    AVIOContext *pb = VAR_0->pb;

    AVCodecContext *enc, *video_enc;

    int VAR_1, VAR_2, VAR_3, VAR_4 ;











    gif->time = 0;

    gif->file_time = 0;



    video_enc = NULL;

    for(VAR_1=0;VAR_1<VAR_0->nb_streams;VAR_1++) {

        enc = VAR_0->streams[VAR_1]->codec;

        if (enc->codec_type != AVMEDIA_TYPE_AUDIO)

            video_enc = enc;

    }



    if (!video_enc) {

        av_free(gif);

        return -1;

    } else {

        VAR_2 = video_enc->VAR_2;

        VAR_3 = video_enc->VAR_3;

        VAR_4 = VAR_0->loop_output;



    }



    if (video_enc->pix_fmt != PIX_FMT_RGB24) {

        av_log(VAR_0, AV_LOG_ERROR, "ERROR: gif only handles the rgb24 pixel format. Use -pix_fmt rgb24.\n");

        return AVERROR(EIO);

    }



    gif_image_write_header(pb, VAR_2, VAR_3, VAR_4, NULL);



    avio_flush(VAR_0->pb);

    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0)
{ GIFContext *gif = VAR_0->priv_data; AVIOContext *pb = VAR_0->pb; AVCodecContext *enc, *video_enc; int VAR_1, VAR_2, VAR_3, VAR_4 ; gif->time = 0; gif->file_time = 0; video_enc = NULL; for(VAR_1=0;VAR_1<VAR_0->nb_streams;VAR_1++) { enc = VAR_0->streams[VAR_1]->codec; if (enc->codec_type != AVMEDIA_TYPE_AUDIO)
video_enc = enc; } if (!video_enc) { av_free(gif); return -1; } else { VAR_2 = video_enc->VAR_2; VAR_3 = video_enc->VAR_3; VAR_4 = VAR_0->loop_output; } if (video_enc->pix_fmt != PIX_FMT_RGB24) { av_log(VAR_0, AV_LOG_ERROR, "ERROR: gif only handles the rgb24 pixel format. Use -pix_fmt rgb24.\n"); return AVERROR(EIO); } gif_image_write_header(pb, VAR_2, VAR_3, VAR_4, NULL); avio_flush(VAR_0->pb); return 0; }