static int probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt)
{
    if(st->codec->codec_id == AV_CODEC_ID_PROBE){
        AVProbeData *pd = &st->probe_data;
        av_log(s, AV_LOG_DEBUG, "probing stream %d\n", st->index);
        --st->probe_packets;
        if (pkt) {
            int err;
            if ((err = av_reallocp(&pd->buf, pd->buf_size + pkt->size +
                                   AVPROBE_PADDING_SIZE)) < 0)
                return err;
            memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size);
            pd->buf_size += pkt->size;
            memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE);
        } else {
            st->probe_packets = 0;
            if (!pd->buf_size) {
                av_log(s, AV_LOG_ERROR, "nothing to probe for stream %d\n",
                       st->index);
                return 0;
            }
        }
        if (!st->probe_packets ||
            av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)) {
            set_codec_from_probe_data(s, st, pd, st->probe_packets > 0 ? AVPROBE_SCORE_MAX/4 : 0);
            if(st->codec->codec_id != AV_CODEC_ID_PROBE){
                pd->buf_size=0;
                av_freep(&pd->buf);
                av_log(s, AV_LOG_DEBUG, "probed stream %d\n", st->index);
            }
        }
    }
    return 0;
}
['static int probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt)\n{\n    if(st->codec->codec_id == AV_CODEC_ID_PROBE){\n        AVProbeData *pd = &st->probe_data;\n        av_log(s, AV_LOG_DEBUG, "probing stream %d\\n", st->index);\n        --st->probe_packets;\n        if (pkt) {\n            int err;\n            if ((err = av_reallocp(&pd->buf, pd->buf_size + pkt->size +\n                                   AVPROBE_PADDING_SIZE)) < 0)\n                return err;\n            memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size);\n            pd->buf_size += pkt->size;\n            memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE);\n        } else {\n            st->probe_packets = 0;\n            if (!pd->buf_size) {\n                av_log(s, AV_LOG_ERROR, "nothing to probe for stream %d\\n",\n                       st->index);\n                return 0;\n            }\n        }\n        if (!st->probe_packets ||\n            av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)) {\n            set_codec_from_probe_data(s, st, pd, st->probe_packets > 0 ? AVPROBE_SCORE_MAX/4 : 0);\n            if(st->codec->codec_id != AV_CODEC_ID_PROBE){\n                pd->buf_size=0;\n                av_freep(&pd->buf);\n                av_log(s, AV_LOG_DEBUG, "probed stream %d\\n", st->index);\n            }\n        }\n    }\n    return 0;\n}', 'int av_reallocp(void *ptr, size_t size)\n{\n    void **ptrptr = ptr;\n    void *ret;\n    ret = av_realloc(*ptrptr, size);\n    if (!ret) {\n        av_freep(ptr);\n        return AVERROR(ENOMEM);\n    }\n    *ptrptr = ret;\n    return 0;\n}', 'void *av_realloc(void *ptr, size_t size)\n{\n#if CONFIG_MEMALIGN_HACK\n    int diff;\n#endif\n    if (size > (INT_MAX - 16))\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    if (!ptr)\n        return av_malloc(size);\n    diff = ((char *)ptr)[-1];\n    return (char *)realloc((char *)ptr - diff, size + diff) + diff;\n#elif HAVE_ALIGNED_MALLOC\n    return _aligned_realloc(ptr, size, 32);\n#else\n    return realloc(ptr, size);\n#endif\n}']