static int read_gab2_sub(AVFormatContext *s, AVStream *st, AVPacket *pkt)

{

    if (pkt->size >= 7 &&

        pkt->size < INT_MAX - AVPROBE_PADDING_SIZE &&

        !strcmp(pkt->data, "GAB2") && AV_RL16(pkt->data + 5) == 2) {

        uint8_t desc[256];

        int score      = AVPROBE_SCORE_EXTENSION, ret;

        AVIStream *ast = st->priv_data;

        AVInputFormat *sub_demuxer;

        AVRational time_base;

        int size;

        AVIOContext *pb = avio_alloc_context(pkt->data + 7,

                                             pkt->size - 7,

                                             0, NULL, NULL, NULL, NULL);

        AVProbeData pd;

        unsigned int desc_len = avio_rl32(pb);



        if (desc_len > pb->buf_end - pb->buf_ptr)

            goto error;



        ret = avio_get_str16le(pb, desc_len, desc, sizeof(desc));

        avio_skip(pb, desc_len - ret);

        if (*desc)

            av_dict_set(&st->metadata, "title", desc, 0);



        avio_rl16(pb);   /* flags? */

        avio_rl32(pb);   /* data size */



        size = pb->buf_end - pb->buf_ptr;

        pd = (AVProbeData) { .buf      = av_mallocz(size + AVPROBE_PADDING_SIZE),

                             .buf_size = size };

        if (!pd.buf)

            goto error;

        memcpy(pd.buf, pb->buf_ptr, size);

        sub_demuxer = av_probe_input_format2(&pd, 1, &score);

        av_freep(&pd.buf);

        if (!sub_demuxer)

            goto error;



        if (!(ast->sub_ctx = avformat_alloc_context()))

            goto error;



        ast->sub_ctx->pb = pb;



        av_assert0(!ast->sub_ctx->codec_whitelist && !ast->sub_ctx->format_whitelist);

        ast->sub_ctx-> codec_whitelist = av_strdup(s->codec_whitelist);

        ast->sub_ctx->format_whitelist = av_strdup(s->format_whitelist);



        if (!avformat_open_input(&ast->sub_ctx, "", sub_demuxer, NULL)) {

            ff_read_packet(ast->sub_ctx, &ast->sub_pkt);

            *st->codec = *ast->sub_ctx->streams[0]->codec;

            ast->sub_ctx->streams[0]->codec->extradata = NULL;

            time_base = ast->sub_ctx->streams[0]->time_base;

            avpriv_set_pts_info(st, 64, time_base.num, time_base.den);

        }

        ast->sub_buffer = pkt->data;

        memset(pkt, 0, sizeof(*pkt));

        return 1;



error:

        av_freep(&pb);

    }

    return 0;

}

static int read_gab2_sub(AVFormatContext *s, AVStream *st, AVPacket *pkt)

{

    if (pkt->size >= 7 &&

        pkt->size < INT_MAX - AVPROBE_PADDING_SIZE &&

        !strcmp(pkt->data, "GAB2") && AV_RL16(pkt->data + 5) == 2) {

        uint8_t desc[256];

        int score      = AVPROBE_SCORE_EXTENSION, ret;

        AVIStream *ast = st->priv_data;

        AVInputFormat *sub_demuxer;

        AVRational time_base;

        int size;

        AVIOContext *pb = avio_alloc_context(pkt->data + 7,

                                             pkt->size - 7,

                                             0, NULL, NULL, NULL, NULL);

        AVProbeData pd;

        unsigned int desc_len = avio_rl32(pb);



        if (desc_len > pb->buf_end - pb->buf_ptr)

            goto error;



        ret = avio_get_str16le(pb, desc_len, desc, sizeof(desc));

        avio_skip(pb, desc_len - ret);

        if (*desc)

            av_dict_set(&st->metadata, "title", desc, 0);



        avio_rl16(pb);   

        avio_rl32(pb);   



        size = pb->buf_end - pb->buf_ptr;

        pd = (AVProbeData) { .buf      = av_mallocz(size + AVPROBE_PADDING_SIZE),

                             .buf_size = size };

        if (!pd.buf)

            goto error;

        memcpy(pd.buf, pb->buf_ptr, size);

        sub_demuxer = av_probe_input_format2(&pd, 1, &score);

        av_freep(&pd.buf);

        if (!sub_demuxer)

            goto error;



        if (!(ast->sub_ctx = avformat_alloc_context()))

            goto error;



        ast->sub_ctx->pb = pb;



        av_assert0(!ast->sub_ctx->codec_whitelist && !ast->sub_ctx->format_whitelist);

        ast->sub_ctx-> codec_whitelist = av_strdup(s->codec_whitelist);

        ast->sub_ctx->format_whitelist = av_strdup(s->format_whitelist);



        if (!avformat_open_input(&ast->sub_ctx, "", sub_demuxer, NULL)) {

            ff_read_packet(ast->sub_ctx, &ast->sub_pkt);

            *st->codec = *ast->sub_ctx->streams[0]->codec;

            ast->sub_ctx->streams[0]->codec->extradata = NULL;

            time_base = ast->sub_ctx->streams[0]->time_base;

            avpriv_set_pts_info(st, 64, time_base.num, time_base.den);

        }

        ast->sub_buffer = pkt->data;

        memset(pkt, 0, sizeof(*pkt));

        return 1;



error:

        av_freep(&pb);

    }

    return 0;

}

        av_assert0(!ast->sub_ctx->codec_whitelist && !ast->sub_ctx->format_whitelist);         ast->sub_ctx-> codec_whitelist = av_strdup(s->codec_whitelist);         ast->sub_ctx->format_whitelist = av_strdup(s->format_whitelist);
static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, AVPacket *VAR_2)

{

    if (VAR_2->VAR_5 >= 7 &&

        VAR_2->VAR_5 < INT_MAX - AVPROBE_PADDING_SIZE &&

        !strcmp(VAR_2->data, "GAB2") && AV_RL16(VAR_2->data + 5) == 2) {

        uint8_t desc[256];

        int VAR_3      = AVPROBE_SCORE_EXTENSION, VAR_4;

        AVIStream *ast = VAR_1->priv_data;

        AVInputFormat *sub_demuxer;

        AVRational time_base;

        int VAR_5;

        AVIOContext *pb = avio_alloc_context(VAR_2->data + 7,

                                             VAR_2->VAR_5 - 7,

                                             0, NULL, NULL, NULL, NULL);

        AVProbeData pd;

        unsigned int VAR_6 = avio_rl32(pb);



        if (VAR_6 > pb->buf_end - pb->buf_ptr)

            goto error;



        VAR_4 = avio_get_str16le(pb, VAR_6, desc, sizeof(desc));

        avio_skip(pb, VAR_6 - VAR_4);

        if (*desc)

            av_dict_set(&VAR_1->metadata, "title", desc, 0);



        avio_rl16(pb);   

        avio_rl32(pb);   



        VAR_5 = pb->buf_end - pb->buf_ptr;

        pd = (AVProbeData) { .buf      = av_mallocz(VAR_5 + AVPROBE_PADDING_SIZE),

                             .buf_size = VAR_5 };

        if (!pd.buf)

            goto error;

        memcpy(pd.buf, pb->buf_ptr, VAR_5);

        sub_demuxer = av_probe_input_format2(&pd, 1, &VAR_3);

        av_freep(&pd.buf);

        if (!sub_demuxer)

            goto error;



        if (!(ast->sub_ctx = avformat_alloc_context()))

            goto error;



        ast->sub_ctx->pb = pb;



        av_assert0(!ast->sub_ctx->codec_whitelist && !ast->sub_ctx->format_whitelist);

        ast->sub_ctx-> codec_whitelist = av_strdup(VAR_0->codec_whitelist);

        ast->sub_ctx->format_whitelist = av_strdup(VAR_0->format_whitelist);



        if (!avformat_open_input(&ast->sub_ctx, "", sub_demuxer, NULL)) {

            ff_read_packet(ast->sub_ctx, &ast->sub_pkt);

            *VAR_1->codec = *ast->sub_ctx->streams[0]->codec;

            ast->sub_ctx->streams[0]->codec->extradata = NULL;

            time_base = ast->sub_ctx->streams[0]->time_base;

            avpriv_set_pts_info(VAR_1, 64, time_base.num, time_base.den);

        }

        ast->sub_buffer = VAR_2->data;

        memset(VAR_2, 0, sizeof(*VAR_2));

        return 1;



error:

        av_freep(&pb);

    }

    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, AVPacket *VAR_2)
{ if (VAR_2->VAR_5 >= 7 &&
VAR_2->VAR_5 < INT_MAX - AVPROBE_PADDING_SIZE &&
!strcmp(VAR_2->data, "GAB2") && AV_RL16(VAR_2->data + 5) == 2) { uint8_t desc[256]; int VAR_3      = AVPROBE_SCORE_EXTENSION, VAR_4; AVIStream *ast = VAR_1->priv_data; AVInputFormat *sub_demuxer; AVRational time_base; int VAR_5; AVIOContext *pb = avio_alloc_context(VAR_2->data + 7,
VAR_2->VAR_5 - 7,
0, NULL, NULL, NULL, NULL); AVProbeData pd; unsigned int VAR_6 = avio_rl32(pb); if (VAR_6 > pb->buf_end - pb->buf_ptr)
goto error; VAR_4 = avio_get_str16le(pb, VAR_6, desc, sizeof(desc)); avio_skip(pb, VAR_6 - VAR_4); if (*desc)
av_dict_set(&VAR_1->metadata, "title", desc, 0); avio_rl16(pb); avio_rl32(pb); VAR_5 = pb->buf_end - pb->buf_ptr; pd = (AVProbeData) { .buf      = av_mallocz(VAR_5 + AVPROBE_PADDING_SIZE), .buf_size = VAR_5 }; if (!pd.buf)
goto error; memcpy(pd.buf, pb->buf_ptr, VAR_5); sub_demuxer = av_probe_input_format2(&pd, 1, &VAR_3); av_freep(&pd.buf); if (!sub_demuxer)
goto error; if (!(ast->sub_ctx = avformat_alloc_context()))
goto error; ast->sub_ctx->pb = pb; av_assert0(!ast->sub_ctx->codec_whitelist && !ast->sub_ctx->format_whitelist); ast->sub_ctx-> codec_whitelist = av_strdup(VAR_0->codec_whitelist); ast->sub_ctx->format_whitelist = av_strdup(VAR_0->format_whitelist); if (!avformat_open_input(&ast->sub_ctx, "", sub_demuxer, NULL)) { ff_read_packet(ast->sub_ctx, &ast->sub_pkt); *VAR_1->codec = *ast->sub_ctx->streams[0]->codec; ast->sub_ctx->streams[0]->codec->extradata = NULL; time_base = ast->sub_ctx->streams[0]->time_base; avpriv_set_pts_info(VAR_1, 64, time_base.num, time_base.den); } ast->sub_buffer = VAR_2->data; memset(VAR_2, 0, sizeof(*VAR_2)); return 1; error:
av_freep(&pb); } return 0; }