static int qdm2_parse_packet(AVFormatContext *s, PayloadContext *qdm,

                             AVStream *st, AVPacket *pkt,

                             uint32_t *timestamp,

                             const uint8_t *buf, int len, int flags)

{

    int res = AVERROR_INVALIDDATA, n;

    const uint8_t *end = buf + len, *p = buf;



    if (len > 0) {

        if (len < 2)

            return AVERROR_INVALIDDATA;



        /* configuration block */

        if (*p == 0xff) {

            if (qdm->n_pkts > 0) {

                av_log(s, AV_LOG_WARNING,

                       "Out of sequence config - dropping queue\n");

                qdm->n_pkts = 0;

                memset(qdm->len, 0, sizeof(qdm->len));

            }



            if ((res = qdm2_parse_config(qdm, st, ++p, end)) < 0)

                return res;

            p += res;



            /* We set codec_id to CODEC_ID_NONE initially to

             * delay decoder initialization since extradata is

             * carried within the RTP stream, not SDP. Here,

             * by setting codec_id to CODEC_ID_QDM2, we are signalling

             * to the decoder that it is OK to initialize. */

            st->codec->codec_id = CODEC_ID_QDM2;

        }





        /* subpackets */

        while (end - p >= 4) {

            if ((res = qdm2_parse_subpacket(qdm, st, p, end)) < 0)

                return res;

            p += res;

        }



        qdm->timestamp = *timestamp;

        if (++qdm->n_pkts < qdm->subpkts_per_block)


        qdm->cache = 0;

        for (n = 0; n < 0x80; n++)

            if (qdm->len[n] > 0)

                qdm->cache++;

    }



    /* output the subpackets into freshly created superblock structures */

    if (!qdm->cache || (res = qdm2_restore_block(qdm, st, pkt)) < 0)

        return res;

    if (--qdm->cache == 0)

        qdm->n_pkts = 0;



    *timestamp = qdm->timestamp;

    qdm->timestamp = RTP_NOTS_VALUE;



    return (qdm->cache > 0) ? 1 : 0;

}
static int qdm2_parse_packet(AVFormatContext *s, PayloadContext *qdm,

                             AVStream *st, AVPacket *pkt,

                             uint32_t *timestamp,

                             const uint8_t *buf, int len, int flags)

{

    int res = AVERROR_INVALIDDATA, n;

    const uint8_t *end = buf + len, *p = buf;



    if (len > 0) {

        if (len < 2)

            return AVERROR_INVALIDDATA;



        

        if (*p == 0xff) {

            if (qdm->n_pkts > 0) {

                av_log(s, AV_LOG_WARNING,

                       "Out of sequence config - dropping queue\n");

                qdm->n_pkts = 0;

                memset(qdm->len, 0, sizeof(qdm->len));

            }



            if ((res = qdm2_parse_config(qdm, st, ++p, end)) < 0)

                return res;

            p += res;



            









            st->codec->codec_id = CODEC_ID_QDM2;

        }





        

        while (end - p >= 4) {

            if ((res = qdm2_parse_subpacket(qdm, st, p, end)) < 0)

                return res;

            p += res;

        }



        qdm->timestamp = *timestamp;

        if (++qdm->n_pkts < qdm->subpkts_per_block)


        qdm->cache = 0;

        for (n = 0; n < 0x80; n++)

            if (qdm->len[n] > 0)

                qdm->cache++;

    }



    

    if (!qdm->cache || (res = qdm2_restore_block(qdm, st, pkt)) < 0)

        return res;

    if (--qdm->cache == 0)

        qdm->n_pkts = 0;



    *timestamp = qdm->timestamp;

    qdm->timestamp = RTP_NOTS_VALUE;



    return (qdm->cache > 0) ? 1 : 0;

}
static int FUNC_0(AVFormatContext *VAR_0, PayloadContext *VAR_1,

                             AVStream *VAR_2, AVPacket *VAR_3,

                             uint32_t *VAR_4,

                             const uint8_t *VAR_5, int VAR_6, int VAR_7)

{

    int VAR_8 = AVERROR_INVALIDDATA, VAR_9;

    const uint8_t *VAR_10 = VAR_5 + VAR_6, *p = VAR_5;



    if (VAR_6 > 0) {

        if (VAR_6 < 2)

            return AVERROR_INVALIDDATA;



        

        if (*p == 0xff) {

            if (VAR_1->n_pkts > 0) {

                av_log(VAR_0, AV_LOG_WARNING,

                       "Out of sequence config - dropping queue\VAR_9");

                VAR_1->n_pkts = 0;

                memset(VAR_1->VAR_6, 0, sizeof(VAR_1->VAR_6));

            }



            if ((VAR_8 = qdm2_parse_config(VAR_1, VAR_2, ++p, VAR_10)) < 0)

                return VAR_8;

            p += VAR_8;



            









            VAR_2->codec->codec_id = CODEC_ID_QDM2;

        }





        

        while (VAR_10 - p >= 4) {

            if ((VAR_8 = qdm2_parse_subpacket(VAR_1, VAR_2, p, VAR_10)) < 0)

                return VAR_8;

            p += VAR_8;

        }



        VAR_1->VAR_4 = *VAR_4;

        if (++VAR_1->n_pkts < VAR_1->subpkts_per_block)


        VAR_1->cache = 0;

        for (VAR_9 = 0; VAR_9 < 0x80; VAR_9++)

            if (VAR_1->VAR_6[VAR_9] > 0)

                VAR_1->cache++;

    }



    

    if (!VAR_1->cache || (VAR_8 = qdm2_restore_block(VAR_1, VAR_2, VAR_3)) < 0)

        return VAR_8;

    if (--VAR_1->cache == 0)

        VAR_1->n_pkts = 0;



    *VAR_4 = VAR_1->VAR_4;

    VAR_1->VAR_4 = RTP_NOTS_VALUE;



    return (VAR_1->cache > 0) ? 1 : 0;

}
static int FUNC_0(AVFormatContext *VAR_0, PayloadContext *VAR_1,
AVStream *VAR_2, AVPacket *VAR_3,
uint32_t *VAR_4,
const uint8_t *VAR_5, int VAR_6, int VAR_7)
{ int VAR_8 = AVERROR_INVALIDDATA, VAR_9; const uint8_t *VAR_10 = VAR_5 + VAR_6, *p = VAR_5; if (VAR_6 > 0) { if (VAR_6 < 2)
return AVERROR_INVALIDDATA; if (*p == 0xff) { if (VAR_1->n_pkts > 0) { av_log(VAR_0, AV_LOG_WARNING,
"Out of sequence config - dropping queue\VAR_9"); VAR_1->n_pkts = 0; memset(VAR_1->VAR_6, 0, sizeof(VAR_1->VAR_6)); } if ((VAR_8 = qdm2_parse_config(VAR_1, VAR_2, ++p, VAR_10)) < 0)
return VAR_8; p += VAR_8; VAR_2->codec->codec_id = CODEC_ID_QDM2; } while (VAR_10 - p >= 4) { if ((VAR_8 = qdm2_parse_subpacket(VAR_1, VAR_2, p, VAR_10)) < 0)
return VAR_8; p += VAR_8; } VAR_1->VAR_4 = *VAR_4; if (++VAR_1->n_pkts < VAR_1->subpkts_per_block)
VAR_1->cache = 0; for (VAR_9 = 0; VAR_9 < 0x80; VAR_9++) if (VAR_1->VAR_6[VAR_9] > 0)
VAR_1->cache++; } if (!VAR_1->cache || (VAR_8 = qdm2_restore_block(VAR_1, VAR_2, VAR_3)) < 0)
return VAR_8; if (--VAR_1->cache == 0)
VAR_1->n_pkts = 0; *VAR_4 = VAR_1->VAR_4; VAR_1->VAR_4 = RTP_NOTS_VALUE; return (VAR_1->cache > 0) ? 1 : 0; }