static void decode(AVCodecContext *dec_ctx, AVFrame *frame, AVPacket *pkt,

                   const char *filename)

{

    char buf[1024];

    int ret;



    ret = avcodec_send_packet(dec_ctx, pkt);

    if (ret < 0) {

        fprintf(stderr, "Error sending a packet for decoding\n");

        exit(1);

    }



    while (ret >= 0) {

        ret = avcodec_receive_frame(dec_ctx, frame);

        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)

            return;

        else if (ret < 0) {

            fprintf(stderr, "Error during decoding\n");

            exit(1);

        }



        printf("saving frame %3d\n", dec_ctx->frame_number);

        fflush(stdout);



        /* the picture is allocated by the decoder. no need to

           free it */

        snprintf(buf, sizeof(buf), filename, dec_ctx->frame_number);

        pgm_save(frame->data[0], frame->linesize[0],

                 frame->width, frame->height, buf);

    }

}

static void decode(AVCodecContext *dec_ctx, AVFrame *frame, AVPacket *pkt,

                   const char *filename)

{

    char buf[1024];

    int ret;



    ret = avcodec_send_packet(dec_ctx, pkt);

    if (ret < 0) {

        fprintf(stderr, "Error sending a packet for decoding\n");

        exit(1);

    }



    while (ret >= 0) {

        ret = avcodec_receive_frame(dec_ctx, frame);

        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)

            return;

        else if (ret < 0) {

            fprintf(stderr, "Error during decoding\n");

            exit(1);

        }



        printf("saving frame %3d\n", dec_ctx->frame_number);

        fflush(stdout);



        



        snprintf(buf, sizeof(buf), filename, dec_ctx->frame_number);

        pgm_save(frame->data[0], frame->linesize[0],

                 frame->width, frame->height, buf);

    }

}

        snprintf(buf, sizeof(buf), filename, dec_ctx->frame_number);
static void FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1, AVPacket *VAR_2,

                   const char *VAR_3)

{

    char VAR_4[1024];

    int VAR_5;



    VAR_5 = avcodec_send_packet(VAR_0, VAR_2);

    if (VAR_5 < 0) {

        fprintf(stderr, "Error sending a packet for decoding\n");

        exit(1);

    }



    while (VAR_5 >= 0) {

        VAR_5 = avcodec_receive_frame(VAR_0, VAR_1);

        if (VAR_5 == AVERROR(EAGAIN) || VAR_5 == AVERROR_EOF)

            return;

        else if (VAR_5 < 0) {

            fprintf(stderr, "Error during decoding\n");

            exit(1);

        }



        printf("saving VAR_1 %3d\n", VAR_0->frame_number);

        fflush(stdout);



        



        snprintf(VAR_4, sizeof(VAR_4), VAR_3, VAR_0->frame_number);

        pgm_save(VAR_1->data[0], VAR_1->linesize[0],

                 VAR_1->width, VAR_1->height, VAR_4);

    }

}

static void FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1, AVPacket *VAR_2,
const char *VAR_3)
{ char VAR_4[1024]; int VAR_5; VAR_5 = avcodec_send_packet(VAR_0, VAR_2); if (VAR_5 < 0) { fprintf(stderr, "Error sending a packet for decoding\n"); exit(1); } while (VAR_5 >= 0) { VAR_5 = avcodec_receive_frame(VAR_0, VAR_1); if (VAR_5 == AVERROR(EAGAIN) || VAR_5 == AVERROR_EOF)
return; else if (VAR_5 < 0) { fprintf(stderr, "Error during decoding\n"); exit(1); } printf("saving VAR_1 %3d\n", VAR_0->frame_number); fflush(stdout); snprintf(VAR_4, sizeof(VAR_4), VAR_3, VAR_0->frame_number); pgm_save(VAR_1->data[0], VAR_1->linesize[0],
VAR_1->width, VAR_1->height, VAR_4); } }