#include "libavutil/parseutils.h"
#include "libavutil/intreadwrite.h"
#include "avformat.h"
+#include "avio_internal.h"
#include "internal.h"
#include "img2.h"
s->split_planes = str && !av_strcasecmp(str + 1, "y");
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
if (s1->pb) {
- uint8_t probe_buffer[AVPROBE_PADDING_SIZE] = {0};
+ int probe_buffer_size = 2048;
+ uint8_t *probe_buffer = av_realloc(NULL, probe_buffer_size + AVPROBE_PADDING_SIZE);
AVInputFormat *fmt = NULL;
AVProbeData pd;
- int ret = avio_read(s1->pb, probe_buffer, 8);
- if (ret < 8)
- return AVERROR(EINVAL);
- avio_seek(s1->pb, -8, SEEK_CUR);
+
+ if (!probe_buffer)
+ return AVERROR(ENOMEM);
+
+ probe_buffer_size = avio_read(s1->pb, probe_buffer, probe_buffer_size);
+ if (probe_buffer_size < 0) {
+ av_free(probe_buffer);
+ return probe_buffer_size;
+ }
+ memset(probe_buffer + probe_buffer_size, 0, AVPROBE_PADDING_SIZE);
pd.buf = probe_buffer;
- pd.buf_size = 8;
+ pd.buf_size = probe_buffer_size;
pd.filename = s1->filename;
while ((fmt = av_iformat_next(fmt))) {
break;
}
}
+ ffio_rewind_with_probe_data(s1->pb, &probe_buffer, probe_buffer_size);
}
if (st->codec->codec_id == AV_CODEC_ID_NONE)
st->codec->codec_id = ff_guess_image2_codec(s->path);
static int bmp_probe(AVProbeData *p)
{
const uint8_t *b = p->buf;
+ int ihsize;
- if (AV_RB16(b) == 0x424d)
- if (!AV_RN32(b + 6)) {
- return AVPROBE_SCORE_EXTENSION + 1;
- } else {
- return AVPROBE_SCORE_EXTENSION / 4;
- }
+ if (AV_RB16(b) != 0x424d)
+ return 0;
+
+ ihsize = AV_RL32(b+14);
+ if (ihsize < 12 || ihsize > 255)
+ return 0;
+
+ if (!AV_RN32(b + 6)) {
+ return AVPROBE_SCORE_EXTENSION + 1;
+ } else {
+ return AVPROBE_SCORE_EXTENSION / 4;
+ }
return 0;
}
return 0;
}
+static int j2k_probe(AVProbeData *p)
+{
+ const uint8_t *b = p->buf;
+
+ if (AV_RB64(b) == 0x0000000c6a502020 ||
+ AV_RB32(b) == 0xff4fff51)
+ return AVPROBE_SCORE_EXTENSION + 1;
+ return 0;
+}
+
static int pictor_probe(AVProbeData *p)
{
const uint8_t *b = p->buf;
{
const uint8_t *b = p->buf;
- if (AV_RB32(b) == 0x49492a00)
+ if (AV_RB32(b) == 0x49492a00 ||
+ AV_RB32(b) == 0x4D4D002a)
return AVPROBE_SCORE_EXTENSION + 1;
return 0;
}
};\
AVInputFormat ff_image_ ## imgname ## _pipe_demuxer = {\
.name = AV_STRINGIFY(imgname) "_pipe",\
+ .long_name = NULL_IF_CONFIG_SMALL("piped " AV_STRINGIFY(imgname) " sequence"),\
.priv_data_size = sizeof(VideoDemuxData),\
.read_probe = imgname ## _probe,\
.read_header = ff_img_read_header,\
.read_packet = ff_img_read_packet,\
- .read_close = img_read_close,\
- .read_seek = img_read_seek,\
.priv_class = & imgname ## _class,\
.raw_codec_id = codecid,\
};
IMAGEAUTO_DEMUXER(bmp, AV_CODEC_ID_BMP)
IMAGEAUTO_DEMUXER(dpx, AV_CODEC_ID_DPX)
IMAGEAUTO_DEMUXER(exr, AV_CODEC_ID_EXR)
+IMAGEAUTO_DEMUXER(j2k, AV_CODEC_ID_JPEG2000)
IMAGEAUTO_DEMUXER(pictor, AV_CODEC_ID_PICTOR)
IMAGEAUTO_DEMUXER(png, AV_CODEC_ID_PNG)
IMAGEAUTO_DEMUXER(sgi, AV_CODEC_ID_SGI)