summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2022-05-31 12:33:54 +0200
committerPaul B Mahol <onemda@gmail.com>2022-06-05 13:06:54 +0200
commit973fab565378cbdd0712977152a66f5b17938d51 (patch)
tree720f0b9c6e8f3cf64c4134d0ae78a5e30d97a577 /libavformat
parentc6364b711bad1fe2fbd90e5b2798f87080ddf5ea (diff)
avcodec: add QOI decoder and demuxer and parser and encoder and muxer
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/Makefile1
-rw-r--r--libavformat/allformats.c1
-rw-r--r--libavformat/img2.c1
-rw-r--r--libavformat/img2dec.c18
-rw-r--r--libavformat/img2enc.c2
5 files changed, 22 insertions, 1 deletions
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 8e612b6cc7..1416bf31bd 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -289,6 +289,7 @@ OBJS-$(CONFIG_IMAGE_PNG_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_PPM_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_PSD_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_QDRAW_PIPE_DEMUXER) += img2dec.o img2.o
+OBJS-$(CONFIG_IMAGE_QOI_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_SGI_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_SVG_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 1802536633..8b84b52c64 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -524,6 +524,7 @@ extern const AVInputFormat ff_image_png_pipe_demuxer;
extern const AVInputFormat ff_image_ppm_pipe_demuxer;
extern const AVInputFormat ff_image_psd_pipe_demuxer;
extern const AVInputFormat ff_image_qdraw_pipe_demuxer;
+extern const AVInputFormat ff_image_qoi_pipe_demuxer;
extern const AVInputFormat ff_image_sgi_pipe_demuxer;
extern const AVInputFormat ff_image_svg_pipe_demuxer;
extern const AVInputFormat ff_image_sunrast_pipe_demuxer;
diff --git a/libavformat/img2.c b/libavformat/img2.c
index 566ef873ca..68cb7de2c1 100644
--- a/libavformat/img2.c
+++ b/libavformat/img2.c
@@ -89,6 +89,7 @@ const IdStrMap ff_img_tags[] = {
{ AV_CODEC_ID_GEM, "timg" },
{ AV_CODEC_ID_VBN, "vbn" },
{ AV_CODEC_ID_JPEGXL, "jxl" },
+ { AV_CODEC_ID_QOI, "qoi" },
{ AV_CODEC_ID_NONE, NULL }
};
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 5f9d1f094f..e4912cb487 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -1131,6 +1131,23 @@ static int photocd_probe(const AVProbeData *p)
return AVPROBE_SCORE_MAX - 1;
}
+static int qoi_probe(const AVProbeData *p)
+{
+ if (memcmp(p->buf, "qoif", 4))
+ return 0;
+
+ if (AV_RB32(p->buf + 4) == 0 || AV_RB32(p->buf + 8) == 0)
+ return 0;
+
+ if (p->buf[12] != 3 && p->buf[12] != 4)
+ return 0;
+
+ if (p->buf[13] > 1)
+ return 0;
+
+ return AVPROBE_SCORE_MAX - 1;
+}
+
static int gem_probe(const AVProbeData *p)
{
const uint8_t *b = p->buf;
@@ -1208,6 +1225,7 @@ IMAGEAUTO_DEMUXER(png, PNG)
IMAGEAUTO_DEMUXER(ppm, PPM)
IMAGEAUTO_DEMUXER(psd, PSD)
IMAGEAUTO_DEMUXER(qdraw, QDRAW)
+IMAGEAUTO_DEMUXER(qoi, QOI)
IMAGEAUTO_DEMUXER(sgi, SGI)
IMAGEAUTO_DEMUXER(sunrast, SUNRAST)
IMAGEAUTO_DEMUXER(svg, SVG)
diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index 0015297ec2..b3a0801ec9 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -267,7 +267,7 @@ const AVOutputFormat ff_image2_muxer = {
.long_name = NULL_IF_CONFIG_SMALL("image2 sequence"),
.extensions = "bmp,dpx,exr,jls,jpeg,jpg,jxl,ljpg,pam,pbm,pcx,pfm,pgm,pgmyuv,"
"png,ppm,sgi,tga,tif,tiff,jp2,j2c,j2k,xwd,sun,ras,rs,im1,im8,"
- "im24,sunras,vbn,xbm,xface,pix,y,avif",
+ "im24,sunras,vbn,xbm,xface,pix,y,avif,qoi",
.priv_data_size = sizeof(VideoMuxData),
.video_codec = AV_CODEC_ID_MJPEG,
.write_header = write_header,