Mercurial > libavformat.hg
comparison utils.c @ 5895:d8031a05ceec libavformat
Fix updating condition for the probe_size variable in the internal
loop of ff_probe_input_buffer(), making sure that probe_size is always
set to probe_max_size in the last iteration.
Also make the function return an error if we get to the max probe
length and still cannot figure out what the format is.
Patch by Micah Galizia micahgalizia A gmail D com.
author | stefano |
---|---|
date | Fri, 26 Mar 2010 01:12:14 +0000 |
parents | 416041cfd600 |
children | 536e5527c1e0 |
comparison
equal
deleted
inserted
replaced
5894:51c410f2251b | 5895:d8031a05ceec |
---|---|
476 | 476 |
477 if (offset >= max_probe_size) { | 477 if (offset >= max_probe_size) { |
478 return AVERROR(EINVAL); | 478 return AVERROR(EINVAL); |
479 } | 479 } |
480 | 480 |
481 for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt && ret >= 0; probe_size<<=1){ | 481 for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt && ret >= 0; |
482 probe_size = FFMIN(probe_size<<1, FFMAX(max_probe_size, probe_size+1))) { | |
482 int ret, score = probe_size < max_probe_size ? AVPROBE_SCORE_MAX/4 : 0; | 483 int ret, score = probe_size < max_probe_size ? AVPROBE_SCORE_MAX/4 : 0; |
483 int buf_offset = (probe_size == PROBE_BUF_MIN) ? 0 : probe_size>>1; | 484 int buf_offset = (probe_size == PROBE_BUF_MIN) ? 0 : probe_size>>1; |
484 | 485 |
485 if (probe_size < offset) { | 486 if (probe_size < offset) { |
486 continue; | 487 continue; |
511 av_log(logctx, AV_LOG_DEBUG, "Probed with size=%d and score=%d\n", probe_size, score); | 512 av_log(logctx, AV_LOG_DEBUG, "Probed with size=%d and score=%d\n", probe_size, score); |
512 } | 513 } |
513 } | 514 } |
514 | 515 |
515 av_free(buf); | 516 av_free(buf); |
517 | |
518 if (!*fmt) { | |
519 return AVERROR_INVALIDDATA; | |
520 } | |
521 | |
516 if (url_fseek(*pb, 0, SEEK_SET) < 0) { | 522 if (url_fseek(*pb, 0, SEEK_SET) < 0) { |
517 url_fclose(*pb); | 523 url_fclose(*pb); |
518 if (url_fopen(pb, filename, URL_RDONLY) < 0) | 524 if (url_fopen(pb, filename, URL_RDONLY) < 0) |
519 return AVERROR(EIO); | 525 return AVERROR(EIO); |
520 } | 526 } |