diff options
author | Carl Eugen Hoyos <ceffmpeg@gmail.com> | 2021-02-11 23:37:06 +0100 |
---|---|---|
committer | Carl Eugen Hoyos <ceffmpeg@gmail.com> | 2021-02-15 00:01:07 +0100 |
commit | ca781761d61de20f28b5c6486c64dbf2c2c4c944 (patch) | |
tree | 250fbc6e3640f3f2f8d7bee87d4f82f2b4832d7a /libavcodec/pnm.c | |
parent | 9c0b3eddf4262f9dcea479091f1307444e614e88 (diff) |
lavc/pnm: Allow decoding gray float pfm images.
Diffstat (limited to 'libavcodec/pnm.c')
-rw-r--r-- | libavcodec/pnm.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c index 94ae74e13a..958f2a342e 100644 --- a/libavcodec/pnm.c +++ b/libavcodec/pnm.c @@ -72,6 +72,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s) s->bytestream[0] != 'P' || (s->bytestream[1] < '1' || s->bytestream[1] > '7' && + s->bytestream[1] != 'f' && s->bytestream[1] != 'F')) { s->bytestream += s->bytestream_end > s->bytestream; s->bytestream += s->bytestream_end > s->bytestream; @@ -82,6 +83,8 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s) 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 (s->type==1 || s->type==4) { avctx->pix_fmt = AV_PIX_FMT_MONOWHITE; } else if (s->type==2 || s->type==5) { @@ -177,7 +180,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s) if (ret < 0) return ret; - if (avctx->pix_fmt == AV_PIX_FMT_GBRPF32) { + if (avctx->pix_fmt == AV_PIX_FMT_GBRPF32 || avctx->pix_fmt == AV_PIX_FMT_GRAYF32) { pnm_get(s, buf1, sizeof(buf1)); if (av_sscanf(buf1, "%f", &s->scale) != 1 || s->scale == 0.0 || !isfinite(s->scale)) { av_log(avctx, AV_LOG_ERROR, "Invalid scale.\n"); |