int ff_probe_input_buffer(ByteIOContext **pb, AVInputFormat **fmt,

                          const char *filename, void *logctx,

                          unsigned int offset, unsigned int max_probe_size)

{

    AVProbeData pd = { filename ? filename : "", NULL, -offset };

    unsigned char *buf = NULL;

    int probe_size;



    if (!max_probe_size) {

        max_probe_size = PROBE_BUF_MAX;

    } else if (max_probe_size > PROBE_BUF_MAX) {

        max_probe_size = PROBE_BUF_MAX;

    } else if (max_probe_size < PROBE_BUF_MIN) {

        return AVERROR(EINVAL);

    }



    if (offset >= max_probe_size) {

        return AVERROR(EINVAL);

    }



    for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt; probe_size<<=1){

        int ret, score = probe_size < max_probe_size ? AVPROBE_SCORE_MAX/4 : 0;

        int buf_offset = (probe_size == PROBE_BUF_MIN) ? 0 : probe_size>>1;



        if (probe_size < offset) {

            continue;

        }



        /* read probe data */

        buf = av_realloc(buf, probe_size + AVPROBE_PADDING_SIZE);

        if ((ret = get_buffer(*pb, buf + buf_offset, probe_size - buf_offset)) < 0) {

            av_free(buf);

            return ret;

        }

        pd.buf_size += ret;

        pd.buf = &buf[offset];



        memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);



        /* guess file format */

        *fmt = av_probe_input_format2(&pd, 1, &score);

        if(*fmt){

            if(score <= AVPROBE_SCORE_MAX/4){ //this can only be true in the last iteration

                av_log(logctx, AV_LOG_WARNING, "Format detected only with low score of %d, misdetection possible!\n", score);

            }else

                av_log(logctx, AV_LOG_DEBUG, "Probed with size=%d and score=%d\n", probe_size, score);

        }

    }



    av_free(buf);

    if (url_fseek(*pb, 0, SEEK_SET) < 0) {

        url_fclose(*pb);

        if (url_fopen(pb, filename, URL_RDONLY) < 0)

            return AVERROR(EIO);

    }



    return 0;

}

int ff_probe_input_buffer(ByteIOContext **pb, AVInputFormat **fmt,

                          const char *filename, void *logctx,

                          unsigned int offset, unsigned int max_probe_size)

{

    AVProbeData pd = { filename ? filename : "", NULL, -offset };

    unsigned char *buf = NULL;

    int probe_size;



    if (!max_probe_size) {

        max_probe_size = PROBE_BUF_MAX;

    } else if (max_probe_size > PROBE_BUF_MAX) {

        max_probe_size = PROBE_BUF_MAX;

    } else if (max_probe_size < PROBE_BUF_MIN) {

        return AVERROR(EINVAL);

    }



    if (offset >= max_probe_size) {

        return AVERROR(EINVAL);

    }



    for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt; probe_size<<=1){

        int ret, score = probe_size < max_probe_size ? AVPROBE_SCORE_MAX/4 : 0;

        int buf_offset = (probe_size == PROBE_BUF_MIN) ? 0 : probe_size>>1;



        if (probe_size < offset) {

            continue;

        }



        

        buf = av_realloc(buf, probe_size + AVPROBE_PADDING_SIZE);

        if ((ret = get_buffer(*pb, buf + buf_offset, probe_size - buf_offset)) < 0) {

            av_free(buf);

            return ret;

        }

        pd.buf_size += ret;

        pd.buf = &buf[offset];



        memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);



        

        *fmt = av_probe_input_format2(&pd, 1, &score);

        if(*fmt){

            if(score <= AVPROBE_SCORE_MAX/4){ 

                av_log(logctx, AV_LOG_WARNING, "Format detected only with low score of %d, misdetection possible!\n", score);

            }else

                av_log(logctx, AV_LOG_DEBUG, "Probed with size=%d and score=%d\n", probe_size, score);

        }

    }



    av_free(buf);

    if (url_fseek(*pb, 0, SEEK_SET) < 0) {

        url_fclose(*pb);

        if (url_fopen(pb, filename, URL_RDONLY) < 0)

            return AVERROR(EIO);

    }



    return 0;

}

int ff_probe_input_buffer(ByteIOContext **pb, AVInputFormat **fmt,                           const char *filename, void *logctx, int ff_probe_input_buffer(ByteIOContext **pb, AVInputFormat **fmt,                           const char *filename, void *logctx,                           unsigned int offset, unsigned int max_probe_size)     AVProbeData pd = { filename ? filename : "", NULL, -offset };     unsigned char *buf = NULL;     int probe_size;     if (!max_probe_size) {         max_probe_size = PROBE_BUF_MAX;     } else if (max_probe_size > PROBE_BUF_MAX) {         max_probe_size = PROBE_BUF_MAX;     } else if (max_probe_size < PROBE_BUF_MIN) {         return AVERROR(EINVAL);     if (offset >= max_probe_size) {         return AVERROR(EINVAL);     for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt; probe_size<<=1){         int ret, score = probe_size < max_probe_size ? AVPROBE_SCORE_MAX/4 : 0;         int buf_offset = (probe_size == PROBE_BUF_MIN) ? 0 : probe_size>>1;         if (probe_size < offset) {             continue;         buf = av_realloc(buf, probe_size + AVPROBE_PADDING_SIZE);         if ((ret = get_buffer(*pb, buf + buf_offset, probe_size - buf_offset)) < 0) {             av_free(buf);             return ret;         pd.buf_size += ret;         pd.buf = &buf[offset];         memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);         *fmt = av_probe_input_format2(&pd, 1, &score);         if(*fmt){                 av_log(logctx, AV_LOG_WARNING, "Format detected only with low score of %d, misdetection possible!\n", score);             }else                 av_log(logctx, AV_LOG_DEBUG, "Probed with size=%d and score=%d\n", probe_size, score);     av_free(buf);     if (url_fseek(*pb, 0, SEEK_SET) < 0) {         url_fclose(*pb);         if (url_fopen(pb, filename, URL_RDONLY) < 0)             return AVERROR(EIO);     return 0;
int FUNC_0(ByteIOContext **VAR_0, AVInputFormat **VAR_1,

                          const char *VAR_2, void *VAR_3,

                          unsigned int VAR_4, unsigned int VAR_5)

{

    AVProbeData pd = { VAR_2 ? VAR_2 : "", NULL, -VAR_4 };

    unsigned char *VAR_6 = NULL;

    int VAR_7;



    if (!VAR_5) {

        VAR_5 = PROBE_BUF_MAX;

    } else if (VAR_5 > PROBE_BUF_MAX) {

        VAR_5 = PROBE_BUF_MAX;

    } else if (VAR_5 < PROBE_BUF_MIN) {

        return AVERROR(EINVAL);

    }



    if (VAR_4 >= VAR_5) {

        return AVERROR(EINVAL);

    }



    for(VAR_7= PROBE_BUF_MIN; VAR_7<=VAR_5 && !*VAR_1; VAR_7<<=1){

        int ret, score = VAR_7 < VAR_5 ? AVPROBE_SCORE_MAX/4 : 0;

        int buf_offset = (VAR_7 == PROBE_BUF_MIN) ? 0 : VAR_7>>1;



        if (VAR_7 < VAR_4) {

            continue;

        }



        

        VAR_6 = av_realloc(VAR_6, VAR_7 + AVPROBE_PADDING_SIZE);

        if ((ret = get_buffer(*VAR_0, VAR_6 + buf_offset, VAR_7 - buf_offset)) < 0) {

            av_free(VAR_6);

            return ret;

        }

        pd.buf_size += ret;

        pd.VAR_6 = &VAR_6[VAR_4];



        memset(pd.VAR_6 + pd.buf_size, 0, AVPROBE_PADDING_SIZE);



        

        *VAR_1 = av_probe_input_format2(&pd, 1, &score);

        if(*VAR_1){

            if(score <= AVPROBE_SCORE_MAX/4){ 

                av_log(VAR_3, AV_LOG_WARNING, "Format detected only with low score of %d, misdetection possible!\n", score);

            }else

                av_log(VAR_3, AV_LOG_DEBUG, "Probed with size=%d and score=%d\n", VAR_7, score);

        }

    }



    av_free(VAR_6);

    if (url_fseek(*VAR_0, 0, SEEK_SET) < 0) {

        url_fclose(*VAR_0);

        if (url_fopen(VAR_0, VAR_2, URL_RDONLY) < 0)

            return AVERROR(EIO);

    }



    return 0;

}

int FUNC_0(ByteIOContext **VAR_0, AVInputFormat **VAR_1,
const char *VAR_2, void *VAR_3,
unsigned int VAR_4, unsigned int VAR_5)
{ AVProbeData pd = { VAR_2 ? VAR_2 : "", NULL, -VAR_4 }; unsigned char *VAR_6 = NULL; int VAR_7; if (!VAR_5) { VAR_5 = PROBE_BUF_MAX; } else if (VAR_5 > PROBE_BUF_MAX) { VAR_5 = PROBE_BUF_MAX; } else if (VAR_5 < PROBE_BUF_MIN) { return AVERROR(EINVAL); } if (VAR_4 >= VAR_5) { return AVERROR(EINVAL); } for(VAR_7= PROBE_BUF_MIN; VAR_7<=VAR_5 && !*VAR_1; VAR_7<<=1){ int ret, score = VAR_7 < VAR_5 ? AVPROBE_SCORE_MAX/4 : 0; int buf_offset = (VAR_7 == PROBE_BUF_MIN) ? 0 : VAR_7>>1; if (VAR_7 < VAR_4) { continue; } VAR_6 = av_realloc(VAR_6, VAR_7 + AVPROBE_PADDING_SIZE); if ((ret = get_buffer(*VAR_0, VAR_6 + buf_offset, VAR_7 - buf_offset)) < 0) { av_free(VAR_6); return ret; } pd.buf_size += ret; pd.VAR_6 = &VAR_6[VAR_4]; memset(pd.VAR_6 + pd.buf_size, 0, AVPROBE_PADDING_SIZE); *VAR_1 = av_probe_input_format2(&pd, 1, &score); if(*VAR_1){ if(score <= AVPROBE_SCORE_MAX/4){ av_log(VAR_3, AV_LOG_WARNING, "Format detected only with low score of %d, misdetection possible!\n", score); }else av_log(VAR_3, AV_LOG_DEBUG, "Probed with size=%d and score=%d\n", VAR_7, score); } } av_free(VAR_6); if (url_fseek(*VAR_0, 0, SEEK_SET) < 0) { url_fclose(*VAR_0); if (url_fopen(VAR_0, VAR_2, URL_RDONLY) < 0)
return AVERROR(EIO); } return 0; }