static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)

{

    AVSubtitle subtitle;

    int i, ret = avcodec_decode_subtitle2(ist->dec_ctx,

                                          &subtitle, got_output, pkt);



    check_decode_result(got_output, ret);



    if (ret < 0 || !*got_output) {

        if (!pkt->size)

            sub2video_flush(ist);

        return ret;

    }



    if (ist->fix_sub_duration) {

        int end = 1;

        if (ist->prev_sub.got_output) {

            end = av_rescale(subtitle.pts - ist->prev_sub.subtitle.pts,

                             1000, AV_TIME_BASE);

            if (end < ist->prev_sub.subtitle.end_display_time) {

                av_log(ist->dec_ctx, AV_LOG_DEBUG,

                       "Subtitle duration reduced from %d to %d%s\n",

                       ist->prev_sub.subtitle.end_display_time, end,

                       end <= 0 ? ", dropping it" : "");

                ist->prev_sub.subtitle.end_display_time = end;

            }

        }

        FFSWAP(int,        *got_output, ist->prev_sub.got_output);

        FFSWAP(int,        ret,         ist->prev_sub.ret);

        FFSWAP(AVSubtitle, subtitle,    ist->prev_sub.subtitle);

        if (end <= 0)

            goto out;

    }



    if (!*got_output)

        return ret;



    sub2video_update(ist, &subtitle);



    if (!subtitle.num_rects)

        goto out;



    ist->frames_decoded++;



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

        OutputStream *ost = output_streams[i];



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

            || ost->enc->type != AVMEDIA_TYPE_SUBTITLE)

            continue;



        do_subtitle_out(output_files[ost->file_index]->ctx, ost, ist, &subtitle);

    }



out:

    avsubtitle_free(&subtitle);

    return ret;

}

static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)

{

    AVSubtitle subtitle;

    int i, ret = avcodec_decode_subtitle2(ist->dec_ctx,

                                          &subtitle, got_output, pkt);



    check_decode_result(got_output, ret);



    if (ret < 0 || !*got_output) {

        if (!pkt->size)

            sub2video_flush(ist);

        return ret;

    }



    if (ist->fix_sub_duration) {

        int end = 1;

        if (ist->prev_sub.got_output) {

            end = av_rescale(subtitle.pts - ist->prev_sub.subtitle.pts,

                             1000, AV_TIME_BASE);

            if (end < ist->prev_sub.subtitle.end_display_time) {

                av_log(ist->dec_ctx, AV_LOG_DEBUG,

                       "Subtitle duration reduced from %d to %d%s\n",

                       ist->prev_sub.subtitle.end_display_time, end,

                       end <= 0 ? ", dropping it" : "");

                ist->prev_sub.subtitle.end_display_time = end;

            }

        }

        FFSWAP(int,        *got_output, ist->prev_sub.got_output);

        FFSWAP(int,        ret,         ist->prev_sub.ret);

        FFSWAP(AVSubtitle, subtitle,    ist->prev_sub.subtitle);

        if (end <= 0)

            goto out;

    }



    if (!*got_output)

        return ret;



    sub2video_update(ist, &subtitle);



    if (!subtitle.num_rects)

        goto out;



    ist->frames_decoded++;



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

        OutputStream *ost = output_streams[i];



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

            || ost->enc->type != AVMEDIA_TYPE_SUBTITLE)

            continue;



        do_subtitle_out(output_files[ost->file_index]->ctx, ost, ist, &subtitle);

    }



out:

    avsubtitle_free(&subtitle);

    return ret;

}

    check_decode_result(got_output, ret);     check_decode_result(got_output, ret);     check_decode_result(got_output, ret);
static int FUNC_0(InputStream *VAR_0, AVPacket *VAR_1, int *VAR_2)

{

    AVSubtitle subtitle;

    int VAR_3, VAR_4 = avcodec_decode_subtitle2(VAR_0->dec_ctx,

                                          &subtitle, VAR_2, VAR_1);



    check_decode_result(VAR_2, VAR_4);



    if (VAR_4 < 0 || !*VAR_2) {

        if (!VAR_1->size)

            sub2video_flush(VAR_0);

        return VAR_4;

    }



    if (VAR_0->fix_sub_duration) {

        int VAR_5 = 1;

        if (VAR_0->prev_sub.VAR_2) {

            VAR_5 = av_rescale(subtitle.pts - VAR_0->prev_sub.subtitle.pts,

                             1000, AV_TIME_BASE);

            if (VAR_5 < VAR_0->prev_sub.subtitle.end_display_time) {

                av_log(VAR_0->dec_ctx, AV_LOG_DEBUG,

                       "Subtitle duration reduced from %d to %d%s\n",

                       VAR_0->prev_sub.subtitle.end_display_time, VAR_5,

                       VAR_5 <= 0 ? ", dropping it" : "");

                VAR_0->prev_sub.subtitle.end_display_time = VAR_5;

            }

        }

        FFSWAP(int,        *VAR_2, VAR_0->prev_sub.VAR_2);

        FFSWAP(int,        VAR_4,         VAR_0->prev_sub.VAR_4);

        FFSWAP(AVSubtitle, subtitle,    VAR_0->prev_sub.subtitle);

        if (VAR_5 <= 0)

            goto out;

    }



    if (!*VAR_2)

        return VAR_4;



    sub2video_update(VAR_0, &subtitle);



    if (!subtitle.num_rects)

        goto out;



    VAR_0->frames_decoded++;



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

        OutputStream *ost = output_streams[VAR_3];



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

            || ost->enc->type != AVMEDIA_TYPE_SUBTITLE)

            continue;



        do_subtitle_out(output_files[ost->file_index]->ctx, ost, VAR_0, &subtitle);

    }



out:

    avsubtitle_free(&subtitle);

    return VAR_4;

}

static int FUNC_0(InputStream *VAR_0, AVPacket *VAR_1, int *VAR_2)
{ AVSubtitle subtitle; int VAR_3, VAR_4 = avcodec_decode_subtitle2(VAR_0->dec_ctx,
&subtitle, VAR_2, VAR_1); check_decode_result(VAR_2, VAR_4); if (VAR_4 < 0 || !*VAR_2) { if (!VAR_1->size)
sub2video_flush(VAR_0); return VAR_4; } if (VAR_0->fix_sub_duration) { int VAR_5 = 1; if (VAR_0->prev_sub.VAR_2) { VAR_5 = av_rescale(subtitle.pts - VAR_0->prev_sub.subtitle.pts,
1000, AV_TIME_BASE); if (VAR_5 < VAR_0->prev_sub.subtitle.end_display_time) { av_log(VAR_0->dec_ctx, AV_LOG_DEBUG,
"Subtitle duration reduced from %d to %d%s\n",
VAR_0->prev_sub.subtitle.end_display_time, VAR_5,
VAR_5 <= 0 ? ", dropping it" : ""); VAR_0->prev_sub.subtitle.end_display_time = VAR_5; } } FFSWAP(int,        *VAR_2, VAR_0->prev_sub.VAR_2); FFSWAP(int,        VAR_4,         VAR_0->prev_sub.VAR_4); FFSWAP(AVSubtitle, subtitle,    VAR_0->prev_sub.subtitle); if (VAR_5 <= 0)
goto out; } if (!*VAR_2)
return VAR_4; sub2video_update(VAR_0, &subtitle); if (!subtitle.num_rects)
goto out; VAR_0->frames_decoded++; for (VAR_3 = 0; VAR_3 < nb_output_streams; VAR_3++) { OutputStream *ost = output_streams[VAR_3]; if (!check_output_constraints(VAR_0, ost) || !ost->encoding_needed
|| ost->enc->type != AVMEDIA_TYPE_SUBTITLE)
continue; do_subtitle_out(output_files[ost->file_index]->ctx, ost, VAR_0, &subtitle); } out:
avsubtitle_free(&subtitle); return VAR_4; }