diff mbox

[FFmpeg-devel] lavf/img2dec: Autodetect Photo CD images

Message ID CAB0OVGotzoCtGaPMHJ4Bi+MS=Bv29jOXxD0SasNzj6BKW=B14g@mail.gmail.com
State New
Headers show

Commit Message

Carl Eugen Hoyos Dec. 20, 2018, midnight UTC
Hi!

Attached patch depends on Paul's PhotoCD decoder.

Please comment, Carl Eugen
diff mbox

Patch

From b7247956162c8104ba8bef90ea85e2fc3578b643 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Thu, 20 Dec 2018 00:58:47 +0100
Subject: [PATCH] lavf/img2dec: Auto-detect Kodak Photo CD image files.

---
 libavformat/Makefile     |    1 +
 libavformat/allformats.c |    1 +
 libavformat/img2dec.c    |   12 ++++++++++++
 3 files changed, 14 insertions(+)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 0e43a12..1f0fb45 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -251,6 +251,7 @@  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_PHOTOCD_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
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index df83b04..b965bc2 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -472,6 +472,7 @@  extern AVInputFormat  ff_image_pbm_pipe_demuxer;
 extern AVInputFormat  ff_image_pcx_pipe_demuxer;
 extern AVInputFormat  ff_image_pgmyuv_pipe_demuxer;
 extern AVInputFormat  ff_image_pgm_pipe_demuxer;
+extern AVInputFormat  ff_image_photocd_pipe_demuxer;
 extern AVInputFormat  ff_image_pictor_pipe_demuxer;
 extern AVInputFormat  ff_image_png_pipe_demuxer;
 extern AVInputFormat  ff_image_ppm_pipe_demuxer;
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index e82b1df..09de5a9 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -1019,6 +1019,17 @@  static int gif_probe(AVProbeData *p)
     return AVPROBE_SCORE_MAX - 1;
 }
 
+static int photocd_probe(AVProbeData *p)
+{
+    if (!memcmp(p->buf, "PCD_OPA", 7))
+        return AVPROBE_SCORE_MAX - 1;
+
+    if (p->buf_size < 0x804 || memcmp(p->buf + 0x800, "PCD_", 4))
+        return 0;
+
+    return AVPROBE_SCORE_MAX / 2 + 1;
+}
+
 #define IMAGEAUTO_DEMUXER(imgname, codecid)\
 static const AVClass imgname ## _class = {\
     .class_name = AV_STRINGIFY(imgname) " demuxer",\
@@ -1051,6 +1062,7 @@  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(photocd, AV_CODEC_ID_PHOTOCD)
 IMAGEAUTO_DEMUXER(pictor,  AV_CODEC_ID_PICTOR)
 IMAGEAUTO_DEMUXER(png,     AV_CODEC_ID_PNG)
 IMAGEAUTO_DEMUXER(ppm,     AV_CODEC_ID_PPM)
-- 
1.7.10.4