static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt)

{

    ConcatContext *cat = avf->priv_data;

    int ret;

    int64_t delta;

    ConcatStream *cs;



    while (1) {

        ret = av_read_frame(cat->avf, pkt);

        if (ret == AVERROR_EOF) {

            if ((ret = open_next_file(avf)) < 0)

                return ret;

            continue;

        }

        if (ret < 0)

            return ret;

        if (cat->match_streams) {

            match_streams(avf);

            cs = &cat->cur_file->streams[pkt->stream_index];

            if (cs->out_stream_index < 0) {

                av_packet_unref(pkt);

                continue;

            }

            pkt->stream_index = cs->out_stream_index;

        }

        break;

    }



    delta = av_rescale_q(cat->cur_file->start_time - cat->avf->start_time,

                         AV_TIME_BASE_Q,

                         cat->avf->streams[pkt->stream_index]->time_base);

    if (pkt->pts != AV_NOPTS_VALUE)

        pkt->pts += delta;

    if (pkt->dts != AV_NOPTS_VALUE)

        pkt->dts += delta;

    return ret;

}

static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt)

{

    ConcatContext *cat = avf->priv_data;

    int ret;

    int64_t delta;

    ConcatStream *cs;



    while (1) {

        ret = av_read_frame(cat->avf, pkt);

        if (ret == AVERROR_EOF) {

            if ((ret = open_next_file(avf)) < 0)

                return ret;

            continue;

        }

        if (ret < 0)

            return ret;

        if (cat->match_streams) {

            match_streams(avf);

            cs = &cat->cur_file->streams[pkt->stream_index];

            if (cs->out_stream_index < 0) {

                av_packet_unref(pkt);

                continue;

            }

            pkt->stream_index = cs->out_stream_index;

        }

        break;

    }



    delta = av_rescale_q(cat->cur_file->start_time - cat->avf->start_time,

                         AV_TIME_BASE_Q,

                         cat->avf->streams[pkt->stream_index]->time_base);

    if (pkt->pts != AV_NOPTS_VALUE)

        pkt->pts += delta;

    if (pkt->dts != AV_NOPTS_VALUE)

        pkt->dts += delta;

    return ret;

}

static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)

{

    ConcatContext *cat = VAR_0->priv_data;

    int VAR_2;

    int64_t delta;

    ConcatStream *cs;



    while (1) {

        VAR_2 = av_read_frame(cat->VAR_0, VAR_1);

        if (VAR_2 == AVERROR_EOF) {

            if ((VAR_2 = open_next_file(VAR_0)) < 0)

                return VAR_2;

            continue;

        }

        if (VAR_2 < 0)

            return VAR_2;

        if (cat->match_streams) {

            match_streams(VAR_0);

            cs = &cat->cur_file->streams[VAR_1->stream_index];

            if (cs->out_stream_index < 0) {

                av_packet_unref(VAR_1);

                continue;

            }

            VAR_1->stream_index = cs->out_stream_index;

        }

        break;

    }



    delta = av_rescale_q(cat->cur_file->start_time - cat->VAR_0->start_time,

                         AV_TIME_BASE_Q,

                         cat->VAR_0->streams[VAR_1->stream_index]->time_base);

    if (VAR_1->pts != AV_NOPTS_VALUE)

        VAR_1->pts += delta;

    if (VAR_1->dts != AV_NOPTS_VALUE)

        VAR_1->dts += delta;

    return VAR_2;

}

static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{ ConcatContext *cat = VAR_0->priv_data; int VAR_2; int64_t delta; ConcatStream *cs; while (1) { VAR_2 = av_read_frame(cat->VAR_0, VAR_1); if (VAR_2 == AVERROR_EOF) { if ((VAR_2 = open_next_file(VAR_0)) < 0)
return VAR_2; continue; } if (VAR_2 < 0)
return VAR_2; if (cat->match_streams) { match_streams(VAR_0); cs = &cat->cur_file->streams[VAR_1->stream_index]; if (cs->out_stream_index < 0) { av_packet_unref(VAR_1); continue; } VAR_1->stream_index = cs->out_stream_index; } break; } delta = av_rescale_q(cat->cur_file->start_time - cat->VAR_0->start_time,
AV_TIME_BASE_Q,
cat->VAR_0->streams[VAR_1->stream_index]->time_base); if (VAR_1->pts != AV_NOPTS_VALUE)
VAR_1->pts += delta; if (VAR_1->dts != AV_NOPTS_VALUE)
VAR_1->dts += delta; return VAR_2; }