[FFmpeg-devel] [PATCH] lavf/img2dec: add pnm pipe demuxers
Clément Bœsch
u at pkh.me
Thu Jun 16 11:26:02 CEST 2016
From: Clément Bœsch <clement at stupeflix.com>
---
Still unsure about the FATE changes.
Also couldn't test pgm vs pgmyuv due to a crash
---
libavformat/Makefile | 5 +++++
libavformat/allformats.c | 5 +++++
libavformat/img2dec.c | 55 +++++++++++++++++++++++++++++++++++++++++++++
tests/ref/seek/lavf-pbmpipe | 50 ++++++++++++++++++++++-------------------
tests/ref/seek/lavf-pgmpipe | 50 ++++++++++++++++++++++-------------------
tests/ref/seek/lavf-ppmpipe | 50 ++++++++++++++++++++++-------------------
6 files changed, 146 insertions(+), 69 deletions(-)
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 481f3b1..12d8f6b 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -226,9 +226,14 @@ OBJS-$(CONFIG_IMAGE_EXR_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_J2K_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_JPEG_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_JPEGLS_PIPE_DEMUXER) += img2dec.o img2.o
+OBJS-$(CONFIG_IMAGE_PAM_PIPE_DEMUXER) += img2dec.o img2.o
+OBJS-$(CONFIG_IMAGE_PBM_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_PCX_PIPE_DEMUXER) += img2dec.o img2.o
+OBJS-$(CONFIG_IMAGE_PGMYUV_PIPE_DEMUXER) += img2dec.o img2.o
+OBJS-$(CONFIG_IMAGE_PGM_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_PICTOR_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_PNG_PIPE_DEMUXER) += img2dec.o img2.o
+OBJS-$(CONFIG_IMAGE_PPM_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_QDRAW_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_SGI_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER) += img2dec.o img2.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index ddf540c..d490cc4 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -356,9 +356,14 @@ void av_register_all(void)
REGISTER_DEMUXER (IMAGE_J2K_PIPE, image_j2k_pipe);
REGISTER_DEMUXER (IMAGE_JPEG_PIPE, image_jpeg_pipe);
REGISTER_DEMUXER (IMAGE_JPEGLS_PIPE, image_jpegls_pipe);
+ REGISTER_DEMUXER (IMAGE_PAM_PIPE, image_pam_pipe);
+ REGISTER_DEMUXER (IMAGE_PBM_PIPE, image_pbm_pipe);
REGISTER_DEMUXER (IMAGE_PCX_PIPE, image_pcx_pipe);
+ REGISTER_DEMUXER (IMAGE_PGMYUV_PIPE, image_pgmyuv_pipe);
+ REGISTER_DEMUXER (IMAGE_PGM_PIPE, image_pgm_pipe);
REGISTER_DEMUXER (IMAGE_PICTOR_PIPE, image_pictor_pipe);
REGISTER_DEMUXER (IMAGE_PNG_PIPE, image_png_pipe);
+ REGISTER_DEMUXER (IMAGE_PPM_PIPE, image_ppm_pipe);
REGISTER_DEMUXER (IMAGE_QDRAW_PIPE, image_qdraw_pipe);
REGISTER_DEMUXER (IMAGE_SGI_PIPE, image_sgi_pipe);
REGISTER_DEMUXER (IMAGE_SUNRAST_PIPE, image_sunrast_pipe);
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 1b0e608..9cbc9dc 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -862,6 +862,56 @@ static int webp_probe(AVProbeData *p)
return 0;
}
+static int pnm_magic_check(const AVProbeData *p, int magic)
+{
+ const uint8_t *b = p->buf;
+
+ return b[0] == 'P' && b[1] == magic + '0';
+}
+
+static inline int pnm_probe(const AVProbeData *p)
+{
+ const uint8_t *b = p->buf;
+
+ while (b[2] == '\r')
+ b++;
+ if (b[2] == '\n' && (b[3] == '#' || (b[3] >= '0' && b[3] <= '9')))
+ return AVPROBE_SCORE_EXTENSION + 2;
+ return 0;
+}
+
+static int pbm_probe(AVProbeData *p)
+{
+ return pnm_magic_check(p, 1) || pnm_magic_check(p, 4) ? pnm_probe(p) : 0;
+}
+
+static inline int pgmx_probe(AVProbeData *p)
+{
+ return pnm_magic_check(p, 2) || pnm_magic_check(p, 5) ? pnm_probe(p) : 0;
+}
+
+static int pgm_probe(AVProbeData *p)
+{
+ int ret = pgmx_probe(p);
+ return ret && !av_match_ext(p->filename, "pgmyuv") ? ret : 0;
+}
+
+static int pgmyuv_probe(AVProbeData *p)
+{
+ int ret = pgmx_probe(p);
+ return ret && av_match_ext(p->filename, "pgmyuv") ? ret : 0;
+}
+
+static int ppm_probe(AVProbeData *p)
+{
+ return pnm_magic_check(p, 3) || pnm_magic_check(p, 6) ? pnm_probe(p) : 0;
+}
+
+static int pam_probe(AVProbeData *p)
+{
+ return pnm_magic_check(p, 7) ? pnm_probe(p) : 0;
+}
+
#define IMAGEAUTO_DEMUXER(imgname, codecid)\
static const AVClass imgname ## _class = {\
.class_name = AV_STRINGIFY(imgname) " demuxer",\
@@ -888,9 +938,14 @@ IMAGEAUTO_DEMUXER(exr, AV_CODEC_ID_EXR)
IMAGEAUTO_DEMUXER(j2k, AV_CODEC_ID_JPEG2000)
IMAGEAUTO_DEMUXER(jpeg, AV_CODEC_ID_MJPEG)
IMAGEAUTO_DEMUXER(jpegls, AV_CODEC_ID_JPEGLS)
+IMAGEAUTO_DEMUXER(pam, AV_CODEC_ID_PAM)
+IMAGEAUTO_DEMUXER(pbm, AV_CODEC_ID_PBM)
IMAGEAUTO_DEMUXER(pcx, AV_CODEC_ID_PCX)
+IMAGEAUTO_DEMUXER(pgm, AV_CODEC_ID_PGM)
+IMAGEAUTO_DEMUXER(pgmyuv, AV_CODEC_ID_PGMYUV)
IMAGEAUTO_DEMUXER(pictor, AV_CODEC_ID_PICTOR)
IMAGEAUTO_DEMUXER(png, AV_CODEC_ID_PNG)
+IMAGEAUTO_DEMUXER(ppm, AV_CODEC_ID_PPM)
IMAGEAUTO_DEMUXER(qdraw, AV_CODEC_ID_QDRAW)
IMAGEAUTO_DEMUXER(sgi, AV_CODEC_ID_SGI)
IMAGEAUTO_DEMUXER(sunrast, AV_CODEC_ID_SUNRAST)
diff --git a/tests/ref/seek/lavf-pbmpipe b/tests/ref/seek/lavf-pbmpipe
index 25bb68f..2782a9f 100644
--- a/tests/ref/seek/lavf-pbmpipe
+++ b/tests/ref/seek/lavf-pbmpipe
@@ -1,27 +1,31 @@
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: -1 size:317075
-ret:-1 st:-1 flags:0 ts:-1.000000
-ret:-1 st:-1 flags:1 ts: 1.894167
-ret:-1 st: 0 flags:0 ts: 0.800000
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 12683
+ret: 0 st:-1 flags:0 ts:-1.000000
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 12683
+ret:-EINVAL st:-1 flags:1 ts: 1.894167
+ret:-EINVAL st: 0 flags:0 ts: 0.800000
ret:-1 st: 0 flags:1 ts:-0.320000
-ret:-1 st:-1 flags:0 ts: 2.576668
-ret:-1 st:-1 flags:1 ts: 1.470835
-ret:-1 st: 0 flags:0 ts: 0.360000
+ret:-EINVAL st:-1 flags:0 ts: 2.576668
+ret:-EINVAL st:-1 flags:1 ts: 1.470835
+ret:-EINVAL st: 0 flags:0 ts: 0.360000
ret:-1 st: 0 flags:1 ts:-0.760000
-ret:-1 st:-1 flags:0 ts: 2.153336
-ret:-1 st:-1 flags:1 ts: 1.047503
-ret:-1 st: 0 flags:0 ts:-0.040000
-ret:-1 st: 0 flags:1 ts: 2.840000
-ret:-1 st:-1 flags:0 ts: 1.730004
-ret:-1 st:-1 flags:1 ts: 0.624171
-ret:-1 st: 0 flags:0 ts:-0.480000
-ret:-1 st: 0 flags:1 ts: 2.400000
-ret:-1 st:-1 flags:0 ts: 1.306672
-ret:-1 st:-1 flags:1 ts: 0.200839
-ret:-1 st: 0 flags:0 ts:-0.920000
-ret:-1 st: 0 flags:1 ts: 2.000000
-ret:-1 st:-1 flags:0 ts: 0.883340
+ret:-EINVAL st:-1 flags:0 ts: 2.153336
+ret:-EINVAL st:-1 flags:1 ts: 1.047503
+ret: 0 st: 0 flags:0 ts:-0.040000
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 12683
+ret:-EINVAL st: 0 flags:1 ts: 2.840000
+ret:-EINVAL st:-1 flags:0 ts: 1.730004
+ret:-EINVAL st:-1 flags:1 ts: 0.624171
+ret: 0 st: 0 flags:0 ts:-0.480000
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 12683
+ret:-EINVAL st: 0 flags:1 ts: 2.400000
+ret:-EINVAL st:-1 flags:0 ts: 1.306672
+ret:-EINVAL st:-1 flags:1 ts: 0.200839
+ret: 0 st: 0 flags:0 ts:-0.920000
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 12683
+ret:-EINVAL st: 0 flags:1 ts: 2.000000
+ret:-EINVAL st:-1 flags:0 ts: 0.883340
ret:-1 st:-1 flags:1 ts:-0.222493
-ret:-1 st: 0 flags:0 ts: 2.680000
-ret:-1 st: 0 flags:1 ts: 1.560000
-ret:-1 st:-1 flags:0 ts: 0.460008
+ret:-EINVAL st: 0 flags:0 ts: 2.680000
+ret:-EINVAL st: 0 flags:1 ts: 1.560000
+ret:-EINVAL st:-1 flags:0 ts: 0.460008
ret:-1 st:-1 flags:1 ts:-0.645825
diff --git a/tests/ref/seek/lavf-pgmpipe b/tests/ref/seek/lavf-pgmpipe
index 57b4e4a..66415c4 100644
--- a/tests/ref/seek/lavf-pgmpipe
+++ b/tests/ref/seek/lavf-pgmpipe
@@ -1,27 +1,31 @@
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: -1 size:2534775
-ret:-1 st:-1 flags:0 ts:-1.000000
-ret:-1 st:-1 flags:1 ts: 1.894167
-ret:-1 st: 0 flags:0 ts: 0.800000
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size:101391
+ret: 0 st:-1 flags:0 ts:-1.000000
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size:101391
+ret:-EINVAL st:-1 flags:1 ts: 1.894167
+ret:-EINVAL st: 0 flags:0 ts: 0.800000
ret:-1 st: 0 flags:1 ts:-0.320000
-ret:-1 st:-1 flags:0 ts: 2.576668
-ret:-1 st:-1 flags:1 ts: 1.470835
-ret:-1 st: 0 flags:0 ts: 0.360000
+ret:-EINVAL st:-1 flags:0 ts: 2.576668
+ret:-EINVAL st:-1 flags:1 ts: 1.470835
+ret:-EINVAL st: 0 flags:0 ts: 0.360000
ret:-1 st: 0 flags:1 ts:-0.760000
-ret:-1 st:-1 flags:0 ts: 2.153336
-ret:-1 st:-1 flags:1 ts: 1.047503
-ret:-1 st: 0 flags:0 ts:-0.040000
-ret:-1 st: 0 flags:1 ts: 2.840000
-ret:-1 st:-1 flags:0 ts: 1.730004
-ret:-1 st:-1 flags:1 ts: 0.624171
-ret:-1 st: 0 flags:0 ts:-0.480000
-ret:-1 st: 0 flags:1 ts: 2.400000
-ret:-1 st:-1 flags:0 ts: 1.306672
-ret:-1 st:-1 flags:1 ts: 0.200839
-ret:-1 st: 0 flags:0 ts:-0.920000
-ret:-1 st: 0 flags:1 ts: 2.000000
-ret:-1 st:-1 flags:0 ts: 0.883340
+ret:-EINVAL st:-1 flags:0 ts: 2.153336
+ret:-EINVAL st:-1 flags:1 ts: 1.047503
+ret: 0 st: 0 flags:0 ts:-0.040000
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size:101391
+ret:-EINVAL st: 0 flags:1 ts: 2.840000
+ret:-EINVAL st:-1 flags:0 ts: 1.730004
+ret:-EINVAL st:-1 flags:1 ts: 0.624171
+ret: 0 st: 0 flags:0 ts:-0.480000
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size:101391
+ret:-EINVAL st: 0 flags:1 ts: 2.400000
+ret:-EINVAL st:-1 flags:0 ts: 1.306672
+ret:-EINVAL st:-1 flags:1 ts: 0.200839
+ret: 0 st: 0 flags:0 ts:-0.920000
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size:101391
+ret:-EINVAL st: 0 flags:1 ts: 2.000000
+ret:-EINVAL st:-1 flags:0 ts: 0.883340
ret:-1 st:-1 flags:1 ts:-0.222493
-ret:-1 st: 0 flags:0 ts: 2.680000
-ret:-1 st: 0 flags:1 ts: 1.560000
-ret:-1 st:-1 flags:0 ts: 0.460008
+ret:-EINVAL st: 0 flags:0 ts: 2.680000
+ret:-EINVAL st: 0 flags:1 ts: 1.560000
+ret:-EINVAL st:-1 flags:0 ts: 0.460008
ret:-1 st:-1 flags:1 ts:-0.645825
diff --git a/tests/ref/seek/lavf-ppmpipe b/tests/ref/seek/lavf-ppmpipe
index 7087494..29a9425 100644
--- a/tests/ref/seek/lavf-ppmpipe
+++ b/tests/ref/seek/lavf-ppmpipe
@@ -1,27 +1,31 @@
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: -1 size:7603575
-ret:-1 st:-1 flags:0 ts:-1.000000
-ret:-1 st:-1 flags:1 ts: 1.894167
-ret:-1 st: 0 flags:0 ts: 0.800000
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size:304143
+ret: 0 st:-1 flags:0 ts:-1.000000
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size:304143
+ret:-EINVAL st:-1 flags:1 ts: 1.894167
+ret:-EINVAL st: 0 flags:0 ts: 0.800000
ret:-1 st: 0 flags:1 ts:-0.320000
-ret:-1 st:-1 flags:0 ts: 2.576668
-ret:-1 st:-1 flags:1 ts: 1.470835
-ret:-1 st: 0 flags:0 ts: 0.360000
+ret:-EINVAL st:-1 flags:0 ts: 2.576668
+ret:-EINVAL st:-1 flags:1 ts: 1.470835
+ret:-EINVAL st: 0 flags:0 ts: 0.360000
ret:-1 st: 0 flags:1 ts:-0.760000
-ret:-1 st:-1 flags:0 ts: 2.153336
-ret:-1 st:-1 flags:1 ts: 1.047503
-ret:-1 st: 0 flags:0 ts:-0.040000
-ret:-1 st: 0 flags:1 ts: 2.840000
-ret:-1 st:-1 flags:0 ts: 1.730004
-ret:-1 st:-1 flags:1 ts: 0.624171
-ret:-1 st: 0 flags:0 ts:-0.480000
-ret:-1 st: 0 flags:1 ts: 2.400000
-ret:-1 st:-1 flags:0 ts: 1.306672
-ret:-1 st:-1 flags:1 ts: 0.200839
-ret:-1 st: 0 flags:0 ts:-0.920000
-ret:-1 st: 0 flags:1 ts: 2.000000
-ret:-1 st:-1 flags:0 ts: 0.883340
+ret:-EINVAL st:-1 flags:0 ts: 2.153336
+ret:-EINVAL st:-1 flags:1 ts: 1.047503
+ret: 0 st: 0 flags:0 ts:-0.040000
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size:304143
+ret:-EINVAL st: 0 flags:1 ts: 2.840000
+ret:-EINVAL st:-1 flags:0 ts: 1.730004
+ret:-EINVAL st:-1 flags:1 ts: 0.624171
+ret: 0 st: 0 flags:0 ts:-0.480000
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size:304143
+ret:-EINVAL st: 0 flags:1 ts: 2.400000
+ret:-EINVAL st:-1 flags:0 ts: 1.306672
+ret:-EINVAL st:-1 flags:1 ts: 0.200839
+ret: 0 st: 0 flags:0 ts:-0.920000
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size:304143
+ret:-EINVAL st: 0 flags:1 ts: 2.000000
+ret:-EINVAL st:-1 flags:0 ts: 0.883340
ret:-1 st:-1 flags:1 ts:-0.222493
-ret:-1 st: 0 flags:0 ts: 2.680000
-ret:-1 st: 0 flags:1 ts: 1.560000
-ret:-1 st:-1 flags:0 ts: 0.460008
+ret:-EINVAL st: 0 flags:0 ts: 2.680000
+ret:-EINVAL st: 0 flags:1 ts: 1.560000
+ret:-EINVAL st:-1 flags:0 ts: 0.460008
ret:-1 st:-1 flags:1 ts:-0.645825
--
2.8.3
More information about the ffmpeg-devel
mailing list