aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2022-07-01 10:06:15 +0200
committerPaul B Mahol <onemda@gmail.com>2022-07-03 15:16:31 +0200
commitff1450e449f848ad4b37b3cf448315ba4581364e (patch)
tree4c6e245afa51c3ec58bb0865ed27f2940acf4f4a
parent33fe3b73c2d4dec674509de5dc48698895f0806b (diff)
downloadffmpeg-ff1450e449f848ad4b37b3cf448315ba4581364e.tar.gz
avcodec: add PHM decoder and encoder
-rw-r--r--Changelog1
-rw-r--r--doc/general_contents.texi2
-rw-r--r--libavcodec/Makefile2
-rw-r--r--libavcodec/allcodecs.c2
-rw-r--r--libavcodec/codec_desc.c7
-rw-r--r--libavcodec/codec_id.h1
-rw-r--r--libavcodec/pnm.c11
-rw-r--r--libavcodec/pnm.h5
-rw-r--r--libavcodec/pnm_parser.c5
-rw-r--r--libavcodec/pnmdec.c114
-rw-r--r--libavcodec/pnmenc.c75
-rw-r--r--libavcodec/version.h2
-rw-r--r--libavformat/Makefile2
-rw-r--r--libavformat/allformats.c2
-rw-r--r--libavformat/img2.c1
-rw-r--r--libavformat/img2dec.c16
-rw-r--r--libavformat/img2enc.c2
-rw-r--r--libavformat/version.h2
18 files changed, 244 insertions, 8 deletions
diff --git a/Changelog b/Changelog
index c39cc5087e..ba679aa64e 100644
--- a/Changelog
+++ b/Changelog
@@ -22,6 +22,7 @@ version 5.1:
- ffprobe -o option
- virtualbass audio filter
- VDPAU AV1 hwaccel
+- PHM image format support
version 5.0:
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 987a2f82fb..b1d3e3aa05 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -775,6 +775,8 @@ following image formats are supported:
@tab PGM with U and V components in YUV 4:2:0
@item PGX @tab @tab X
@tab PGX file decoder
+@item PHM @tab X @tab X
+ @tab Portable HalfFloatMap image
@item PIC @tab @tab X
@tab Pictor/PC Paint
@item PNG @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 050934101c..457ec58377 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -571,6 +571,8 @@ OBJS-$(CONFIG_PGMYUV_DECODER) += pnmdec.o pnm.o
OBJS-$(CONFIG_PGMYUV_ENCODER) += pnmenc.o
OBJS-$(CONFIG_PGSSUB_DECODER) += pgssubdec.o
OBJS-$(CONFIG_PGX_DECODER) += pgxdec.o
+OBJS-$(CONFIG_PHM_DECODER) += pnmdec.o pnm.o
+OBJS-$(CONFIG_PHM_ENCODER) += pnmenc.o
OBJS-$(CONFIG_PHOTOCD_DECODER) += photocd.o
OBJS-$(CONFIG_PICTOR_DECODER) += pictordec.o cga_data.o
OBJS-$(CONFIG_PIXLET_DECODER) += pixlet.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index f0b01051b0..bdfc2f6f45 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -254,6 +254,8 @@ extern const FFCodec ff_pgm_decoder;
extern const FFCodec ff_pgmyuv_encoder;
extern const FFCodec ff_pgmyuv_decoder;
extern const FFCodec ff_pgx_decoder;
+extern const FFCodec ff_phm_encoder;
+extern const FFCodec ff_phm_decoder;
extern const FFCodec ff_photocd_decoder;
extern const FFCodec ff_pictor_decoder;
extern const FFCodec ff_pixlet_decoder;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index e2c1c67f5e..44ad2d1fe8 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1886,6 +1886,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("QOI (Quite OK Image)"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
},
+ {
+ .id = AV_CODEC_ID_PHM,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "phm",
+ .long_name = NULL_IF_CONFIG_SMALL("PHM (Portable HalfFloatMap) image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ },
/* various PCM "codecs" */
{
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 93856a16f2..81fb316cff 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -311,6 +311,7 @@ enum AVCodecID {
AV_CODEC_ID_VBN,
AV_CODEC_ID_JPEGXL,
AV_CODEC_ID_QOI,
+ AV_CODEC_ID_PHM,
/* various PCM "codecs" */
AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index 958f2a342e..605a529622 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -73,18 +73,27 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
(s->bytestream[1] < '1' ||
s->bytestream[1] > '7' &&
s->bytestream[1] != 'f' &&
- s->bytestream[1] != 'F')) {
+ s->bytestream[1] != 'F' &&
+ s->bytestream[1] != 'H' &&
+ s->bytestream[1] != 'h')) {
s->bytestream += s->bytestream_end > s->bytestream;
s->bytestream += s->bytestream_end > s->bytestream;
return AVERROR_INVALIDDATA;
}
pnm_get(s, buf1, sizeof(buf1));
s->type= buf1[1]-'0';
+ s->half = 0;
if (buf1[1] == 'F') {
avctx->pix_fmt = AV_PIX_FMT_GBRPF32;
} else if (buf1[1] == 'f') {
avctx->pix_fmt = AV_PIX_FMT_GRAYF32;
+ } else if (buf1[1] == 'H') {
+ avctx->pix_fmt = AV_PIX_FMT_GBRPF32;
+ s->half = 1;
+ } else if (buf1[1] == 'h') {
+ avctx->pix_fmt = AV_PIX_FMT_GRAYF32;
+ s->half = 1;
} else if (s->type==1 || s->type==4) {
avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
} else if (s->type==2 || s->type==5) {
diff --git a/libavcodec/pnm.h b/libavcodec/pnm.h
index 89c3b5a2da..f109d16239 100644
--- a/libavcodec/pnm.h
+++ b/libavcodec/pnm.h
@@ -31,7 +31,12 @@ typedef struct PNMContext {
int maxval; ///< maximum value of a pixel
int type;
int endian;
+ int half;
float scale;
+
+ uint32_t mantissatable[2048];
+ uint32_t exponenttable[64];
+ uint16_t offsettable[64];
} PNMContext;
int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s);
diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c
index 309bc76a24..6607ac7e7f 100644
--- a/libavcodec/pnm_parser.c
+++ b/libavcodec/pnm_parser.c
@@ -111,6 +111,8 @@ retry:
} else {
int ret = av_image_get_buffer_size(avctx->pix_fmt, avctx->width, avctx->height, 1);
next = pnmctx.bytestream - pnmctx.bytestream_start + skip;
+ if (ret > 0 && pnmctx.half)
+ ret >>= 1;
if (ret >= 0 && next + (uint64_t)ret <= INT_MAX)
next += ret;
}
@@ -133,7 +135,8 @@ end:
const AVCodecParser ff_pnm_parser = {
.codec_ids = { AV_CODEC_ID_PGM, AV_CODEC_ID_PGMYUV, AV_CODEC_ID_PPM,
- AV_CODEC_ID_PBM, AV_CODEC_ID_PAM, AV_CODEC_ID_PFM },
+ AV_CODEC_ID_PBM, AV_CODEC_ID_PAM, AV_CODEC_ID_PFM,
+ AV_CODEC_ID_PHM },
.priv_data_size = sizeof(PNMParseContext),
.parser_parse = pnm_parse,
.parser_close = ff_parse_close,
diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c
index f2d9b7e4b6..bb2ce53496 100644
--- a/libavcodec/pnmdec.c
+++ b/libavcodec/pnmdec.c
@@ -26,6 +26,7 @@
#include "internal.h"
#include "put_bits.h"
#include "pnm.h"
+#include "half2float.h"
static void samplecpy(uint8_t *dst, const uint8_t *src, int n, int maxval)
{
@@ -258,6 +259,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p,
}
break;
case AV_PIX_FMT_GBRPF32:
+ if (!s->half) {
if (avctx->width * avctx->height * 12 > s->bytestream_end - s->bytestream)
return AVERROR_INVALIDDATA;
scale = 1.f / s->scale;
@@ -298,8 +300,68 @@ static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p,
b += p->linesize[1] / 4;
}
}
+ } else {
+ if (avctx->width * avctx->height * 6 > s->bytestream_end - s->bytestream)
+ return AVERROR_INVALIDDATA;
+ scale = 1.f / s->scale;
+ if (s->endian) {
+ float *r, *g, *b;
+
+ r = (float *)p->data[2];
+ g = (float *)p->data[0];
+ b = (float *)p->data[1];
+ for (int i = 0; i < avctx->height; i++) {
+ for (int j = 0; j < avctx->width; j++) {
+ r[j] = av_int2float(half2float(AV_RL16(s->bytestream+0),
+ s->mantissatable,
+ s->exponenttable,
+ s->offsettable)) * scale;
+ g[j] = av_int2float(half2float(AV_RL16(s->bytestream+2),
+ s->mantissatable,
+ s->exponenttable,
+ s->offsettable)) * scale;
+ b[j] = av_int2float(half2float(AV_RL16(s->bytestream+4),
+ s->mantissatable,
+ s->exponenttable,
+ s->offsettable)) * scale;
+ s->bytestream += 6;
+ }
+
+ r += p->linesize[2] / 4;
+ g += p->linesize[0] / 4;
+ b += p->linesize[1] / 4;
+ }
+ } else {
+ float *r, *g, *b;
+
+ r = (float *)p->data[2];
+ g = (float *)p->data[0];
+ b = (float *)p->data[1];
+ for (int i = 0; i < avctx->height; i++) {
+ for (int j = 0; j < avctx->width; j++) {
+ r[j] = av_int2float(half2float(AV_RB16(s->bytestream+0),
+ s->mantissatable,
+ s->exponenttable,
+ s->offsettable)) * scale;
+ g[j] = av_int2float(half2float(AV_RB16(s->bytestream+2),
+ s->mantissatable,
+ s->exponenttable,
+ s->offsettable)) * scale;
+ b[j] = av_int2float(half2float(AV_RB16(s->bytestream+4),
+ s->mantissatable,
+ s->exponenttable,
+ s->offsettable)) * scale;
+ s->bytestream += 6;
+ }
+
+ r += p->linesize[2] / 4;
+ g += p->linesize[0] / 4;
+ b += p->linesize[1] / 4;
+ }
+ } }
break;
case AV_PIX_FMT_GRAYF32:
+ if (!s->half) {
if (avctx->width * avctx->height * 4 > s->bytestream_end - s->bytestream)
return AVERROR_INVALIDDATA;
scale = 1.f / s->scale;
@@ -322,6 +384,36 @@ static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p,
g += p->linesize[0] / 4;
}
}
+ } else {
+ if (avctx->width * avctx->height * 2 > s->bytestream_end - s->bytestream)
+ return AVERROR_INVALIDDATA;
+ scale = 1.f / s->scale;
+ if (s->endian) {
+ float *g = (float *)p->data[0];
+ for (int i = 0; i < avctx->height; i++) {
+ for (int j = 0; j < avctx->width; j++) {
+ g[j] = av_int2float(half2float(AV_RL16(s->bytestream),
+ s->mantissatable,
+ s->exponenttable,
+ s->offsettable)) * scale;
+ s->bytestream += 2;
+ }
+ g += p->linesize[0] / 4;
+ }
+ } else {
+ float *g = (float *)p->data[0];
+ for (int i = 0; i < avctx->height; i++) {
+ for (int j = 0; j < avctx->width; j++) {
+ g[j] = av_int2float(half2float(AV_RB16(s->bytestream),
+ s->mantissatable,
+ s->exponenttable,
+ s->offsettable)) * scale;
+ s->bytestream += 2;
+ }
+ g += p->linesize[0] / 4;
+ }
+ }
+ }
break;
}
*got_frame = 1;
@@ -401,3 +493,25 @@ const FFCodec ff_pfm_decoder = {
FF_CODEC_DECODE_CB(pnm_decode_frame),
};
#endif
+
+#if CONFIG_PHM_DECODER
+static av_cold int phm_dec_init(AVCodecContext *avctx)
+{
+ PNMContext *s = avctx->priv_data;
+
+ half2float_table(s->mantissatable, s->exponenttable, s->offsettable);
+
+ return 0;
+}
+
+const FFCodec ff_phm_decoder = {
+ .p.name = "phm",
+ .p.long_name = NULL_IF_CONFIG_SMALL("PHM (Portable HalfFloatMap) image"),
+ .p.type = AVMEDIA_TYPE_VIDEO,
+ .p.id = AV_CODEC_ID_PHM,
+ .p.capabilities = AV_CODEC_CAP_DR1,
+ .priv_data_size = sizeof(PNMContext),
+ .init = phm_dec_init,
+ FF_CODEC_DECODE_CB(pnm_decode_frame),
+};
+#endif
diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c
index c1820ac79e..258d919d32 100644
--- a/libavcodec/pnmenc.c
+++ b/libavcodec/pnmenc.c
@@ -27,10 +27,17 @@
#include "avcodec.h"
#include "codec_internal.h"
#include "encode.h"
+#include "float2half.h"
+
+typedef struct PHMEncContext {
+ uint16_t basetable[512];
+ uint8_t shifttable[512];
+} PHMEncContext;
static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *p, int *got_packet)
{
+ PHMEncContext *s = avctx->priv_data;
uint8_t *bytestream, *bytestream_start, *bytestream_end;
int i, h, h1, c, n, linesize, ret;
uint8_t *ptr, *ptr1, *ptr2;
@@ -82,12 +89,22 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
h1 = (h * 3) / 2;
break;
case AV_PIX_FMT_GBRPF32:
+ if (avctx->codec_id == AV_CODEC_ID_PFM) {
c = 'F';
n = avctx->width * 4;
+ } else {
+ c = 'H';
+ n = avctx->width * 2;
+ }
break;
case AV_PIX_FMT_GRAYF32:
+ if (avctx->codec_id == AV_CODEC_ID_PFM) {
c = 'f';
n = avctx->width * 4;
+ } else {
+ c = 'h';
+ n = avctx->width * 2;
+ }
break;
default:
return -1;
@@ -110,7 +127,7 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
bytestream += strlen(bytestream);
}
- if (avctx->pix_fmt == AV_PIX_FMT_GBRPF32) {
+ if (avctx->pix_fmt == AV_PIX_FMT_GBRPF32 && c == 'F') {
float *r = (float *)p->data[2];
float *g = (float *)p->data[0];
float *b = (float *)p->data[1];
@@ -127,7 +144,7 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
g += p->linesize[0] / 4;
b += p->linesize[1] / 4;
}
- } else if (avctx->pix_fmt == AV_PIX_FMT_GRAYF32) {
+ } else if (avctx->pix_fmt == AV_PIX_FMT_GRAYF32 && c == 'f') {
const float *g = (const float *)p->data[0];
for (int i = 0; i < avctx->height; i++) {
@@ -138,6 +155,34 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
g += p->linesize[0] / 4;
}
+ } else if (avctx->pix_fmt == AV_PIX_FMT_GBRPF32 && c == 'H') {
+ float *r = (float *)p->data[2];
+ float *g = (float *)p->data[0];
+ float *b = (float *)p->data[1];
+
+ for (int i = 0; i < avctx->height; i++) {
+ for (int j = 0; j < avctx->width; j++) {
+ AV_WN16(bytestream + 0, float2half(av_float2int(r[j]), s->basetable, s->shifttable));
+ AV_WN16(bytestream + 2, float2half(av_float2int(g[j]), s->basetable, s->shifttable));
+ AV_WN16(bytestream + 4, float2half(av_float2int(b[j]), s->basetable, s->shifttable));
+ bytestream += 6;
+ }
+
+ r += p->linesize[2] / 4;
+ g += p->linesize[0] / 4;
+ b += p->linesize[1] / 4;
+ }
+ } else if (avctx->pix_fmt == AV_PIX_FMT_GRAYF32 && c == 'h') {
+ const float *g = (const float *)p->data[0];
+
+ for (int i = 0; i < avctx->height; i++) {
+ for (int j = 0; j < avctx->width; j++) {
+ AV_WN16(bytestream, float2half(av_float2int(g[j]), s->basetable, s->shifttable));
+ bytestream += 2;
+ }
+
+ g += p->linesize[0] / 4;
+ }
} else {
ptr = p->data[0];
linesize = p->linesize[0];
@@ -241,3 +286,29 @@ const FFCodec ff_pfm_encoder = {
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
};
#endif
+
+#if CONFIG_PHM_ENCODER
+static av_cold int phm_enc_init(AVCodecContext *avctx)
+{
+ PHMEncContext *s = avctx->priv_data;
+
+ float2half_tables(s->basetable, s->shifttable);
+
+ return 0;
+}
+
+const FFCodec ff_phm_encoder = {
+ .p.name = "phm",
+ .p.long_name = NULL_IF_CONFIG_SMALL("PHM (Portable HalfFloatMap) image"),
+ .p.type = AVMEDIA_TYPE_VIDEO,
+ .p.id = AV_CODEC_ID_PHM,
+ .p.capabilities = AV_CODEC_CAP_DR1,
+ .priv_data_size = sizeof(PHMEncContext),
+ .init = phm_enc_init,
+ FF_CODEC_ENCODE_CB(pnm_encode_frame),
+ .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_GBRPF32,
+ AV_PIX_FMT_GRAYF32,
+ AV_PIX_FMT_NONE },
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
+};
+#endif
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 1008fead27..34b059a8a9 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#include "version_major.h"
-#define LIBAVCODEC_VERSION_MINOR 35
+#define LIBAVCODEC_VERSION_MINOR 36
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 1416bf31bd..6c6b779080 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -280,9 +280,11 @@ OBJS-$(CONFIG_IMAGE_JPEGXL_PIPE_DEMUXER) += img2dec.o img2.o jpegxl_probe.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_PFM_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_PGX_PIPE_DEMUXER) += img2dec.o img2.o
+OBJS-$(CONFIG_IMAGE_PHM_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_PHOTOCD_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
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 8b84b52c64..32698b857f 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -515,9 +515,11 @@ extern const AVInputFormat ff_image_jpegxl_pipe_demuxer;
extern const AVInputFormat ff_image_pam_pipe_demuxer;
extern const AVInputFormat ff_image_pbm_pipe_demuxer;
extern const AVInputFormat ff_image_pcx_pipe_demuxer;
+extern const AVInputFormat ff_image_pfm_pipe_demuxer;
extern const AVInputFormat ff_image_pgmyuv_pipe_demuxer;
extern const AVInputFormat ff_image_pgm_pipe_demuxer;
extern const AVInputFormat ff_image_pgx_pipe_demuxer;
+extern const AVInputFormat ff_image_phm_pipe_demuxer;
extern const AVInputFormat ff_image_photocd_pipe_demuxer;
extern const AVInputFormat ff_image_pictor_pipe_demuxer;
extern const AVInputFormat ff_image_png_pipe_demuxer;
diff --git a/libavformat/img2.c b/libavformat/img2.c
index 68cb7de2c1..870d2ebbc5 100644
--- a/libavformat/img2.c
+++ b/libavformat/img2.c
@@ -41,6 +41,7 @@ const IdStrMap ff_img_tags[] = {
{ AV_CODEC_ID_PBM, "pbm" },
{ AV_CODEC_ID_PAM, "pam" },
{ AV_CODEC_ID_PFM, "pfm" },
+ { AV_CODEC_ID_PHM, "phm" },
{ AV_CODEC_ID_CRI, "cri" },
{ AV_CODEC_ID_ALIAS_PIX, "pix" },
{ AV_CODEC_ID_DDS, "dds" },
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index e4912cb487..e7ff26e5dd 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -1020,7 +1020,19 @@ static inline int pnm_probe(const AVProbeData *p)
static int pbm_probe(const AVProbeData *p)
{
- return pnm_magic_check(p, 1) || pnm_magic_check(p, 4) || pnm_magic_check(p, 22) || pnm_magic_check(p, 54) ? pnm_probe(p) : 0;
+ return pnm_magic_check(p, 1) || pnm_magic_check(p, 4) ? pnm_probe(p) : 0;
+}
+
+static int pfm_probe(const AVProbeData *p)
+{
+ return pnm_magic_check(p, 'F' - '0') ||
+ pnm_magic_check(p, 'f' - '0') ? pnm_probe(p) : 0;
+}
+
+static int phm_probe(const AVProbeData *p)
+{
+ return pnm_magic_check(p, 'H' - '0') ||
+ pnm_magic_check(p, 'h' - '0') ? pnm_probe(p) : 0;
}
static inline int pgmx_probe(const AVProbeData *p)
@@ -1216,9 +1228,11 @@ IMAGEAUTO_DEMUXER(jpegxl, JPEGXL)
IMAGEAUTO_DEMUXER(pam, PAM)
IMAGEAUTO_DEMUXER(pbm, PBM)
IMAGEAUTO_DEMUXER(pcx, PCX)
+IMAGEAUTO_DEMUXER(pfm, PFM)
IMAGEAUTO_DEMUXER(pgm, PGM)
IMAGEAUTO_DEMUXER(pgmyuv, PGMYUV)
IMAGEAUTO_DEMUXER(pgx, PGX)
+IMAGEAUTO_DEMUXER(phm, PHM)
IMAGEAUTO_DEMUXER(photocd, PHOTOCD)
IMAGEAUTO_DEMUXER(pictor, PICTOR)
IMAGEAUTO_DEMUXER(png, PNG)
diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index b3a0801ec9..0a11fae34e 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -265,7 +265,7 @@ static const AVClass img2mux_class = {
const AVOutputFormat ff_image2_muxer = {
.name = "image2",
.long_name = NULL_IF_CONFIG_SMALL("image2 sequence"),
- .extensions = "bmp,dpx,exr,jls,jpeg,jpg,jxl,ljpg,pam,pbm,pcx,pfm,pgm,pgmyuv,"
+ .extensions = "bmp,dpx,exr,jls,jpeg,jpg,jxl,ljpg,pam,pbm,pcx,pfm,pgm,pgmyuv,phm,"
"png,ppm,sgi,tga,tif,tiff,jp2,j2c,j2k,xwd,sun,ras,rs,im1,im8,"
"im24,sunras,vbn,xbm,xface,pix,y,avif,qoi",
.priv_data_size = sizeof(VideoMuxData),
diff --git a/libavformat/version.h b/libavformat/version.h
index 966ebb7ed3..0708d619c0 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
#include "version_major.h"
-#define LIBAVFORMAT_VERSION_MINOR 25
+#define LIBAVFORMAT_VERSION_MINOR 26
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \