summaryrefslogtreecommitdiff
path: root/libavformat/img2dec.c
diff options
context:
space:
mode:
authorLeo Izen <leo.izen@gmail.com>2022-04-17 09:22:36 -0400
committerLynne <dev@lynne.ee>2022-04-23 19:51:46 +0200
commit3ac23440ef4a5a203f53b33325fa38b2e8afa219 (patch)
tree0b02a0d6b1f5126d05391a7336163b515b25c21f /libavformat/img2dec.c
parent5f0b4e9c709761eafe0775c1c1791b09462a91e0 (diff)
avformat/image2: add Jpeg XL as image2 format
This commit adds support to libavformat for muxing and demuxing Jpeg XL images as image2 streams.
Diffstat (limited to 'libavformat/img2dec.c')
-rw-r--r--libavformat/img2dec.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 551b9d508e..5f9d1f094f 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -36,6 +36,7 @@
#include "avio_internal.h"
#include "internal.h"
#include "img2.h"
+#include "jpegxl_probe.h"
#include "libavcodec/mjpeg.h"
#include "libavcodec/vbn.h"
#include "libavcodec/xwd.h"
@@ -837,6 +838,24 @@ static int jpegls_probe(const AVProbeData *p)
return 0;
}
+static int jpegxl_probe(const AVProbeData *p)
+{
+ const uint8_t *b = p->buf;
+
+ /* ISOBMFF-based container */
+ /* 0x4a584c20 == "JXL " */
+ if (AV_RL64(b) == FF_JPEGXL_CONTAINER_SIGNATURE_LE)
+ return AVPROBE_SCORE_EXTENSION + 1;
+ /* Raw codestreams all start with 0xff0a */
+ if (AV_RL16(b) != FF_JPEGXL_CODESTREAM_SIGNATURE_LE)
+ return 0;
+#if CONFIG_IMAGE_JPEGXL_PIPE_DEMUXER
+ if (ff_jpegxl_verify_codestream_header(p->buf, p->buf_size) >= 0)
+ return AVPROBE_SCORE_MAX - 2;
+#endif
+ return 0;
+}
+
static int pcx_probe(const AVProbeData *p)
{
const uint8_t *b = p->buf;
@@ -1176,6 +1195,7 @@ IMAGEAUTO_DEMUXER(gif, GIF)
IMAGEAUTO_DEMUXER_EXT(j2k, JPEG2000, J2K)
IMAGEAUTO_DEMUXER_EXT(jpeg, MJPEG, JPEG)
IMAGEAUTO_DEMUXER(jpegls, JPEGLS)
+IMAGEAUTO_DEMUXER(jpegxl, JPEGXL)
IMAGEAUTO_DEMUXER(pam, PAM)
IMAGEAUTO_DEMUXER(pbm, PBM)
IMAGEAUTO_DEMUXER(pcx, PCX)