[Ffmpeg-cvslog] CVS: ffmpeg/libavformat utils.c,1.175,1.176
Michael Niedermayer CVS
michael
Thu Feb 2 12:27:37 CET 2006
Update of /cvsroot/ffmpeg/ffmpeg/libavformat
In directory mail:/var2/tmp/cvs-serv19851
Modified Files:
utils.c
Log Message:
dynamically increase probe buffer until format is detected
Index: utils.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/utils.c,v
retrieving revision 1.175
retrieving revision 1.176
diff -u -d -r1.175 -r1.176
--- utils.c 25 Jan 2006 22:10:13 -0000 1.175
+++ utils.c 2 Feb 2006 11:27:35 -0000 1.176
@@ -508,7 +508,8 @@
}
/** Size of probe buffer, for guessing file type from file contents. */
-#define PROBE_BUF_SIZE 2048
+#define PROBE_BUF_MIN 2048
+#define PROBE_BUF_MAX 131072
/**
* Open a media file as input. The codec are not opened. Only the file
@@ -526,8 +527,7 @@
int buf_size,
AVFormatParameters *ap)
{
- int err, must_open_file, file_opened;
- uint8_t buf[PROBE_BUF_SIZE];
+ int err, must_open_file, file_opened, probe_size;
AVProbeData probe_data, *pd = &probe_data;
ByteIOContext pb1, *pb = &pb1;
@@ -535,7 +535,7 @@
pd->filename = "";
if (filename)
pd->filename = filename;
- pd->buf = buf;
+ pd->buf = NULL;
pd->buf_size = 0;
if (!fmt) {
@@ -561,9 +561,11 @@
if (buf_size > 0) {
url_setbufsize(pb, buf_size);
}
- if (!fmt) {
+
+ for(probe_size= PROBE_BUF_MIN; probe_size<=PROBE_BUF_MAX && !fmt; probe_size<<=1){
/* read probe data */
- pd->buf_size = get_buffer(pb, buf, PROBE_BUF_SIZE);
+ pd->buf= av_realloc(pd->buf, probe_size);
+ pd->buf_size = get_buffer(pb, pd->buf, probe_size);
if (url_fseek(pb, 0, SEEK_SET) == (offset_t)-EPIPE) {
url_fclose(pb);
if (url_fopen(pb, filename, URL_RDONLY) < 0) {
@@ -571,12 +573,10 @@
goto fail;
}
}
+ /* guess file format */
+ fmt = av_probe_input_format(pd, 1);
}
- }
-
- /* guess file format */
- if (!fmt) {
- fmt = av_probe_input_format(pd, 1);
+ av_freep(&pd->buf);
}
/* if still no format found, error */
@@ -606,6 +606,7 @@
goto fail;
return 0;
fail:
+ av_freep(&pd->buf);
if (file_opened)
url_fclose(pb);
*ic_ptr = NULL;
@@ -3223,7 +3224,7 @@
AVImageFormat *fmt,
int (*alloc_cb)(void *, AVImageInfo *info), void *opaque)
{
- uint8_t buf[PROBE_BUF_SIZE];
+ uint8_t buf[PROBE_BUF_MIN];
AVProbeData probe_data, *pd = &probe_data;
offset_t pos;
int ret;
@@ -3232,7 +3233,7 @@
pd->filename = filename;
pd->buf = buf;
pos = url_ftell(pb);
- pd->buf_size = get_buffer(pb, buf, PROBE_BUF_SIZE);
+ pd->buf_size = get_buffer(pb, buf, PROBE_BUF_MIN);
url_fseek(pb, pos, SEEK_SET);
fmt = av_probe_image_format(pd);
}
More information about the ffmpeg-cvslog
mailing list