static void process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof)

{

    int i;

    int repeating = 0;

    AVPacket avpkt;



    if (ist->next_dts == AV_NOPTS_VALUE)

        ist->next_dts = ist->last_dts;



    if (!pkt) {

        /* EOF handling */

        av_init_packet(&avpkt);

        avpkt.data = NULL;

        avpkt.size = 0;

    } else {

        avpkt = *pkt;

    }



    if (pkt && pkt->dts != AV_NOPTS_VALUE)

        ist->next_dts = ist->last_dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);



    // while we have more to decode or while the decoder did output something on EOF

    while (ist->decoding_needed && (!pkt || avpkt.size > 0)) {

        int ret = 0;

        int got_output = 0;



        if (!repeating)

            ist->last_dts = ist->next_dts;



        switch (ist->dec_ctx->codec_type) {

        case AVMEDIA_TYPE_AUDIO:

            ret = decode_audio    (ist, repeating ? NULL : &avpkt, &got_output);

            break;

        case AVMEDIA_TYPE_VIDEO:

            ret = decode_video    (ist, repeating ? NULL : &avpkt, &got_output);

            if (repeating && !got_output)

                ;

            else if (pkt && pkt->duration)

                ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);

            else if (ist->st->avg_frame_rate.num)

                ist->next_dts += av_rescale_q(1, av_inv_q(ist->st->avg_frame_rate),

                                              AV_TIME_BASE_Q);

            else if (ist->dec_ctx->framerate.num != 0) {

                int ticks      = ist->st->parser ? ist->st->parser->repeat_pict + 1 :

                                                   ist->dec_ctx->ticks_per_frame;

                ist->next_dts += av_rescale_q(ticks, ist->dec_ctx->framerate, AV_TIME_BASE_Q);

            }

            break;

        case AVMEDIA_TYPE_SUBTITLE:

            if (repeating)

                break;

            ret = transcode_subtitles(ist, &avpkt, &got_output);

            break;

        default:

            return;

        }



        if (ret < 0) {

            av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",

                   ist->file_index, ist->st->index);

            if (exit_on_error)

                exit_program(1);

            break;

        }



        if (!got_output)

            break;



        repeating = 1;

    }



    /* after flushing, send an EOF on all the filter inputs attached to the stream */

    /* except when looping we need to flush but not to send an EOF */

    if (!pkt && ist->decoding_needed && !no_eof) {

        int ret = send_filter_eof(ist);

        if (ret < 0) {

            av_log(NULL, AV_LOG_FATAL, "Error marking filters as finished\n");

            exit_program(1);

        }

    }



    /* handle stream copy */

    if (!ist->decoding_needed) {

        ist->last_dts = ist->next_dts;

        switch (ist->dec_ctx->codec_type) {

        case AVMEDIA_TYPE_AUDIO:

            ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->frame_size) /

                             ist->dec_ctx->sample_rate;

            break;

        case AVMEDIA_TYPE_VIDEO:

            if (ist->dec_ctx->framerate.num != 0) {

                int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 : ist->dec_ctx->ticks_per_frame;

                ist->next_dts += ((int64_t)AV_TIME_BASE *

                                  ist->dec_ctx->framerate.den * ticks) /

                                  ist->dec_ctx->framerate.num;

            }

            break;

        }

    }

    for (i = 0; pkt && i < nb_output_streams; i++) {

        OutputStream *ost = output_streams[i];



        if (!check_output_constraints(ist, ost) || ost->encoding_needed)

            continue;



        do_streamcopy(ist, ost, pkt);

    }



    return;

}

static void process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof)

{

    int i;

    int repeating = 0;

    AVPacket avpkt;



    if (ist->next_dts == AV_NOPTS_VALUE)

        ist->next_dts = ist->last_dts;



    if (!pkt) {

        

        av_init_packet(&avpkt);

        avpkt.data = NULL;

        avpkt.size = 0;

    } else {

        avpkt = *pkt;

    }



    if (pkt && pkt->dts != AV_NOPTS_VALUE)

        ist->next_dts = ist->last_dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);



    

    while (ist->decoding_needed && (!pkt || avpkt.size > 0)) {

        int ret = 0;

        int got_output = 0;



        if (!repeating)

            ist->last_dts = ist->next_dts;



        switch (ist->dec_ctx->codec_type) {

        case AVMEDIA_TYPE_AUDIO:

            ret = decode_audio    (ist, repeating ? NULL : &avpkt, &got_output);

            break;

        case AVMEDIA_TYPE_VIDEO:

            ret = decode_video    (ist, repeating ? NULL : &avpkt, &got_output);

            if (repeating && !got_output)

                ;

            else if (pkt && pkt->duration)

                ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);

            else if (ist->st->avg_frame_rate.num)

                ist->next_dts += av_rescale_q(1, av_inv_q(ist->st->avg_frame_rate),

                                              AV_TIME_BASE_Q);

            else if (ist->dec_ctx->framerate.num != 0) {

                int ticks      = ist->st->parser ? ist->st->parser->repeat_pict + 1 :

                                                   ist->dec_ctx->ticks_per_frame;

                ist->next_dts += av_rescale_q(ticks, ist->dec_ctx->framerate, AV_TIME_BASE_Q);

            }

            break;

        case AVMEDIA_TYPE_SUBTITLE:

            if (repeating)

                break;

            ret = transcode_subtitles(ist, &avpkt, &got_output);

            break;

        default:

            return;

        }



        if (ret < 0) {

            av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",

                   ist->file_index, ist->st->index);

            if (exit_on_error)

                exit_program(1);

            break;

        }



        if (!got_output)

            break;



        repeating = 1;

    }



    

    

    if (!pkt && ist->decoding_needed && !no_eof) {

        int ret = send_filter_eof(ist);

        if (ret < 0) {

            av_log(NULL, AV_LOG_FATAL, "Error marking filters as finished\n");

            exit_program(1);

        }

    }



    

    if (!ist->decoding_needed) {

        ist->last_dts = ist->next_dts;

        switch (ist->dec_ctx->codec_type) {

        case AVMEDIA_TYPE_AUDIO:

            ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->frame_size) /

                             ist->dec_ctx->sample_rate;

            break;

        case AVMEDIA_TYPE_VIDEO:

            if (ist->dec_ctx->framerate.num != 0) {

                int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 : ist->dec_ctx->ticks_per_frame;

                ist->next_dts += ((int64_t)AV_TIME_BASE *

                                  ist->dec_ctx->framerate.den * ticks) /

                                  ist->dec_ctx->framerate.num;

            }

            break;

        }

    }

    for (i = 0; pkt && i < nb_output_streams; i++) {

        OutputStream *ost = output_streams[i];



        if (!check_output_constraints(ist, ost) || ost->encoding_needed)

            continue;



        do_streamcopy(ist, ost, pkt);

    }



    return;

}

            ret = decode_audio    (ist, repeating ? NULL : &avpkt, &got_output);             ret = decode_video    (ist, repeating ? NULL : &avpkt, &got_output);             ret = transcode_subtitles(ist, &avpkt, &got_output);             av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",                    ist->file_index, ist->st->index);             if (exit_on_error)
static void FUNC_0(InputStream *VAR_0, const AVPacket *VAR_1, int VAR_2)

{

    int VAR_3;

    int VAR_4 = 0;

    AVPacket avpkt;



    if (VAR_0->next_dts == AV_NOPTS_VALUE)

        VAR_0->next_dts = VAR_0->last_dts;



    if (!VAR_1) {

        

        av_init_packet(&avpkt);

        avpkt.data = NULL;

        avpkt.size = 0;

    } else {

        avpkt = *VAR_1;

    }



    if (VAR_1 && VAR_1->dts != AV_NOPTS_VALUE)

        VAR_0->next_dts = VAR_0->last_dts = av_rescale_q(VAR_1->dts, VAR_0->st->time_base, AV_TIME_BASE_Q);



    

    while (VAR_0->decoding_needed && (!VAR_1 || avpkt.size > 0)) {

        int VAR_8 = 0;

        int VAR_6 = 0;



        if (!VAR_4)

            VAR_0->last_dts = VAR_0->next_dts;



        switch (VAR_0->dec_ctx->codec_type) {

        case AVMEDIA_TYPE_AUDIO:

            VAR_8 = decode_audio    (VAR_0, VAR_4 ? NULL : &avpkt, &VAR_6);

            break;

        case AVMEDIA_TYPE_VIDEO:

            VAR_8 = decode_video    (VAR_0, VAR_4 ? NULL : &avpkt, &VAR_6);

            if (VAR_4 && !VAR_6)

                ;

            else if (VAR_1 && VAR_1->duration)

                VAR_0->next_dts += av_rescale_q(VAR_1->duration, VAR_0->st->time_base, AV_TIME_BASE_Q);

            else if (VAR_0->st->avg_frame_rate.num)

                VAR_0->next_dts += av_rescale_q(1, av_inv_q(VAR_0->st->avg_frame_rate),

                                              AV_TIME_BASE_Q);

            else if (VAR_0->dec_ctx->framerate.num != 0) {

                int VAR_8      = VAR_0->st->parser ? VAR_0->st->parser->repeat_pict + 1 :

                                                   VAR_0->dec_ctx->ticks_per_frame;

                VAR_0->next_dts += av_rescale_q(VAR_8, VAR_0->dec_ctx->framerate, AV_TIME_BASE_Q);

            }

            break;

        case AVMEDIA_TYPE_SUBTITLE:

            if (VAR_4)

                break;

            VAR_8 = transcode_subtitles(VAR_0, &avpkt, &VAR_6);

            break;

        default:

            return;

        }



        if (VAR_8 < 0) {

            av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",

                   VAR_0->file_index, VAR_0->st->index);

            if (exit_on_error)

                exit_program(1);

            break;

        }



        if (!VAR_6)

            break;



        VAR_4 = 1;

    }



    

    

    if (!VAR_1 && VAR_0->decoding_needed && !VAR_2) {

        int VAR_8 = send_filter_eof(VAR_0);

        if (VAR_8 < 0) {

            av_log(NULL, AV_LOG_FATAL, "Error marking filters as finished\n");

            exit_program(1);

        }

    }



    

    if (!VAR_0->decoding_needed) {

        VAR_0->last_dts = VAR_0->next_dts;

        switch (VAR_0->dec_ctx->codec_type) {

        case AVMEDIA_TYPE_AUDIO:

            VAR_0->next_dts += ((int64_t)AV_TIME_BASE * VAR_0->dec_ctx->frame_size) /

                             VAR_0->dec_ctx->sample_rate;

            break;

        case AVMEDIA_TYPE_VIDEO:

            if (VAR_0->dec_ctx->framerate.num != 0) {

                int VAR_8 = VAR_0->st->parser ? VAR_0->st->parser->repeat_pict + 1 : VAR_0->dec_ctx->ticks_per_frame;

                VAR_0->next_dts += ((int64_t)AV_TIME_BASE *

                                  VAR_0->dec_ctx->framerate.den * VAR_8) /

                                  VAR_0->dec_ctx->framerate.num;

            }

            break;

        }

    }

    for (VAR_3 = 0; VAR_1 && VAR_3 < nb_output_streams; VAR_3++) {

        OutputStream *ost = output_streams[VAR_3];



        if (!check_output_constraints(VAR_0, ost) || ost->encoding_needed)

            continue;



        do_streamcopy(VAR_0, ost, VAR_1);

    }



    return;

}

static void FUNC_0(InputStream *VAR_0, const AVPacket *VAR_1, int VAR_2)
{ int VAR_3; int VAR_4 = 0; AVPacket avpkt; if (VAR_0->next_dts == AV_NOPTS_VALUE)
VAR_0->next_dts = VAR_0->last_dts; if (!VAR_1) { av_init_packet(&avpkt); avpkt.data = NULL; avpkt.size = 0; } else { avpkt = *VAR_1; } if (VAR_1 && VAR_1->dts != AV_NOPTS_VALUE)
VAR_0->next_dts = VAR_0->last_dts = av_rescale_q(VAR_1->dts, VAR_0->st->time_base, AV_TIME_BASE_Q); while (VAR_0->decoding_needed && (!VAR_1 || avpkt.size > 0)) { int VAR_8 = 0; int VAR_6 = 0; if (!VAR_4)
VAR_0->last_dts = VAR_0->next_dts; switch (VAR_0->dec_ctx->codec_type) { case AVMEDIA_TYPE_AUDIO:
VAR_8 = decode_audio    (VAR_0, VAR_4 ? NULL : &avpkt, &VAR_6); break; case AVMEDIA_TYPE_VIDEO:
VAR_8 = decode_video    (VAR_0, VAR_4 ? NULL : &avpkt, &VAR_6); if (VAR_4 && !VAR_6)
; else if (VAR_1 && VAR_1->duration)
VAR_0->next_dts += av_rescale_q(VAR_1->duration, VAR_0->st->time_base, AV_TIME_BASE_Q); else if (VAR_0->st->avg_frame_rate.num)
VAR_0->next_dts += av_rescale_q(1, av_inv_q(VAR_0->st->avg_frame_rate),
AV_TIME_BASE_Q); else if (VAR_0->dec_ctx->framerate.num != 0) { int VAR_8      = VAR_0->st->parser ? VAR_0->st->parser->repeat_pict + 1 :
VAR_0->dec_ctx->ticks_per_frame; VAR_0->next_dts += av_rescale_q(VAR_8, VAR_0->dec_ctx->framerate, AV_TIME_BASE_Q); } break; case AVMEDIA_TYPE_SUBTITLE:
if (VAR_4)
break; VAR_8 = transcode_subtitles(VAR_0, &avpkt, &VAR_6); break; default:
return; } if (VAR_8 < 0) { av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",
VAR_0->file_index, VAR_0->st->index); if (exit_on_error)
exit_program(1); break; } if (!VAR_6)
break; VAR_4 = 1; } if (!VAR_1 && VAR_0->decoding_needed && !VAR_2) { int VAR_8 = send_filter_eof(VAR_0); if (VAR_8 < 0) { av_log(NULL, AV_LOG_FATAL, "Error marking filters as finished\n"); exit_program(1); } } if (!VAR_0->decoding_needed) { VAR_0->last_dts = VAR_0->next_dts; switch (VAR_0->dec_ctx->codec_type) { case AVMEDIA_TYPE_AUDIO:
VAR_0->next_dts += ((int64_t)AV_TIME_BASE * VAR_0->dec_ctx->frame_size) /
VAR_0->dec_ctx->sample_rate; break; case AVMEDIA_TYPE_VIDEO:
if (VAR_0->dec_ctx->framerate.num != 0) { int VAR_8 = VAR_0->st->parser ? VAR_0->st->parser->repeat_pict + 1 : VAR_0->dec_ctx->ticks_per_frame; VAR_0->next_dts += ((int64_t)AV_TIME_BASE *
VAR_0->dec_ctx->framerate.den * VAR_8) /
VAR_0->dec_ctx->framerate.num; } break; } } for (VAR_3 = 0; VAR_1 && VAR_3 < nb_output_streams; VAR_3++) { OutputStream *ost = output_streams[VAR_3]; if (!check_output_constraints(VAR_0, ost) || ost->encoding_needed)
continue; do_streamcopy(VAR_0, ost, VAR_1); } return; }