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/pnmdec.c | |
parent | 9c0b3eddf4262f9dcea479091f1307444e614e88 (diff) |
lavc/pnm: Allow decoding gray float pfm images.
Diffstat (limited to 'libavcodec/pnmdec.c')
-rw-r--r-- | libavcodec/pnmdec.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c index 9add5cfc84..4d5ce0bcb5 100644 --- a/libavcodec/pnmdec.c +++ b/libavcodec/pnmdec.c @@ -297,6 +297,30 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data, } } break; + case AV_PIX_FMT_GRAYF32: + if (avctx->width * avctx->height * 4 > 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(AV_RL32(s->bytestream)) * scale; + s->bytestream += 4; + } + 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(AV_RB32(s->bytestream)) * scale; + s->bytestream += 4; + } + g += p->linesize[0] / 4; + } + } + break; } *got_frame = 1; |