static int matroska_probe(AVProbeData *p)

{

    uint64_t total = 0;

    int len_mask = 0x80, size = 1, n = 1, i;



    /* EBML header? */

    if (AV_RB32(p->buf) != EBML_ID_HEADER)

        return 0;



    /* length of header */

    total = p->buf[4];

    while (size <= 8 && !(total & len_mask)) {

        size++;

        len_mask >>= 1;

    }

    if (size > 8)

      return 0;

    total &= (len_mask - 1);

    while (n < size)

        total = (total << 8) | p->buf[4 + n++];



    /* Does the probe data contain the whole header? */

    if (p->buf_size < 4 + size + total)

      return 0;



    /* The header should contain a known document type. For now,

     * we don't parse the whole header but simply check for the

     * availability of that array of characters inside the header.

     * Not fully fool-proof, but good enough. */

    for (i = 0; i < FF_ARRAY_ELEMS(matroska_doctypes); i++) {

        int probelen = strlen(matroska_doctypes[i]);



        for (n = 4+size; n <= 4+size+total-probelen; n++)

            if (!memcmp(p->buf+n, matroska_doctypes[i], probelen))

                return AVPROBE_SCORE_MAX;

    }



    // probably valid EBML header but no recognized doctype

    return AVPROBE_SCORE_MAX/2;

}
static int matroska_probe(AVProbeData *p)

{

    uint64_t total = 0;

    int len_mask = 0x80, size = 1, n = 1, i;



    

    if (AV_RB32(p->buf) != EBML_ID_HEADER)

        return 0;



    

    total = p->buf[4];

    while (size <= 8 && !(total & len_mask)) {

        size++;

        len_mask >>= 1;

    }

    if (size > 8)

      return 0;

    total &= (len_mask - 1);

    while (n < size)

        total = (total << 8) | p->buf[4 + n++];



    

    if (p->buf_size < 4 + size + total)

      return 0;



    







    for (i = 0; i < FF_ARRAY_ELEMS(matroska_doctypes); i++) {

        int probelen = strlen(matroska_doctypes[i]);



        for (n = 4+size; n <= 4+size+total-probelen; n++)

            if (!memcmp(p->buf+n, matroska_doctypes[i], probelen))

                return AVPROBE_SCORE_MAX;

    }



    

    return AVPROBE_SCORE_MAX/2;

}
static int FUNC_0(AVProbeData *VAR_0)

{

    uint64_t total = 0;

    int VAR_1 = 0x80, VAR_2 = 1, VAR_3 = 1, VAR_4;



    

    if (AV_RB32(VAR_0->buf) != EBML_ID_HEADER)

        return 0;



    

    total = VAR_0->buf[4];

    while (VAR_2 <= 8 && !(total & VAR_1)) {

        VAR_2++;

        VAR_1 >>= 1;

    }

    if (VAR_2 > 8)

      return 0;

    total &= (VAR_1 - 1);

    while (VAR_3 < VAR_2)

        total = (total << 8) | VAR_0->buf[4 + VAR_3++];



    

    if (VAR_0->buf_size < 4 + VAR_2 + total)

      return 0;



    







    for (VAR_4 = 0; VAR_4 < FF_ARRAY_ELEMS(matroska_doctypes); VAR_4++) {

        int probelen = strlen(matroska_doctypes[VAR_4]);



        for (VAR_3 = 4+VAR_2; VAR_3 <= 4+VAR_2+total-probelen; VAR_3++)

            if (!memcmp(VAR_0->buf+VAR_3, matroska_doctypes[VAR_4], probelen))

                return AVPROBE_SCORE_MAX;

    }



    

    return AVPROBE_SCORE_MAX/2;

}
static int FUNC_0(AVProbeData *VAR_0)
{ uint64_t total = 0; int VAR_1 = 0x80, VAR_2 = 1, VAR_3 = 1, VAR_4; if (AV_RB32(VAR_0->buf) != EBML_ID_HEADER)
return 0; total = VAR_0->buf[4]; while (VAR_2 <= 8 && !(total & VAR_1)) { VAR_2++; VAR_1 >>= 1; } if (VAR_2 > 8)
return 0; total &= (VAR_1 - 1); while (VAR_3 < VAR_2)
total = (total << 8) | VAR_0->buf[4 + VAR_3++]; if (VAR_0->buf_size < 4 + VAR_2 + total)
return 0; for (VAR_4 = 0; VAR_4 < FF_ARRAY_ELEMS(matroska_doctypes); VAR_4++) { int probelen = strlen(matroska_doctypes[VAR_4]); for (VAR_3 = 4+VAR_2; VAR_3 <= 4+VAR_2+total-probelen; VAR_3++) if (!memcmp(VAR_0->buf+VAR_3, matroska_doctypes[VAR_4], probelen))
return AVPROBE_SCORE_MAX; } return AVPROBE_SCORE_MAX/2; }