X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Futils.c;h=c53051155d3c891fc981c6414f9f3fd113ec71c5;hb=357a733f91ac96d5806856b83081f3f7dace01fe;hp=fc1ab6d146a77e51ea1d835463b64ee28ecd70c2;hpb=c47fc0339a7fae6a39508dd3f7fbcac5cf27fda8;p=ffmpeg diff --git a/libavformat/utils.c b/libavformat/utils.c index fc1ab6d146a..c53051155d3 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -342,8 +342,8 @@ int av_probe_input_buffer2(AVIOContext *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; + AVProbeData pd = { filename ? filename : "" }; + uint8_t *buf = NULL; uint8_t *mime_type; int ret = 0, probe_size, buf_offset = 0; int score = 0; @@ -371,10 +371,6 @@ int av_probe_input_buffer2(AVIOContext *pb, AVInputFormat **fmt, for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt; probe_size = FFMIN(probe_size<<1, FFMAX(max_probe_size, probe_size+1))) { - - if (probe_size < offset) { - continue; - } score = probe_size < max_probe_size ? AVPROBE_SCORE_RETRY : 0; /* read probe data */ @@ -389,7 +385,10 @@ int av_probe_input_buffer2(AVIOContext *pb, AVInputFormat **fmt, score = 0; ret = 0; /* error was end of file, nothing read */ } - pd.buf_size = buf_offset += ret; + buf_offset += ret; + if (buf_offset < offset) + continue; + pd.buf_size = buf_offset - offset; pd.buf = &buf[offset]; memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE); @@ -415,7 +414,7 @@ int av_probe_input_buffer2(AVIOContext *pb, AVInputFormat **fmt, } /* rewind. reuse probe buffer to avoid seeking */ - ret = ffio_rewind_with_probe_data(pb, &buf, pd.buf_size); + ret = ffio_rewind_with_probe_data(pb, &buf, buf_offset); return ret < 0 ? ret : score; } @@ -3264,6 +3263,8 @@ int av_find_best_stream(AVFormatContext *ic, continue; if (st->disposition & (AV_DISPOSITION_HEARING_IMPAIRED|AV_DISPOSITION_VISUAL_IMPAIRED)) continue; + if (type == AVMEDIA_TYPE_AUDIO && !avctx->channels) + continue; if (decoder_ret) { decoder = find_decoder(ic, st, st->codec->codec_id); if (!decoder) {