[FFmpeg-devel] lavc/pnm: Support signed pgm files from jasper

Carl Eugen Hoyos ceffmpeg at gmail.com
Sat Apr 25 18:41:01 EEST 2020


Am Sa., 25. Apr. 2020 um 17:13 Uhr schrieb Nicolas George <george at nsup.org>:
>
> Carl Eugen Hoyos (12020-04-25):
> > Hi!
> >
> > Attached patch allows reading the pgm file that jasper creates
> > using the jpeg 2000 reference file p0_03.j2k as input.
> >
> > Please comment, Carl Eugen
>
> > From 5da97c417d66b1e840b1feae31f0852cf3755c39 Mon Sep 17 00:00:00 2001
> > From: Carl Eugen Hoyos <ceffmpeg at gmail.com>
> > Date: Sat, 25 Apr 2020 17:05:40 +0200
> > Subject: [PATCH] lavc/pnm: Allow reading signed pgm values as written by
> >  jasper.
> >
> > ---
> >  libavcodec/pnm.c    | 4 ++++
> >  libavcodec/pnm.h    | 1 +
> >  libavcodec/pnmdec.c | 2 +-
> >  3 files changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
> > index b5c2881948..c9b9eb9ccd 100644
> > --- a/libavcodec/pnm.c
> > +++ b/libavcodec/pnm.c
> > @@ -176,6 +176,10 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
> >      if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE && avctx->pix_fmt != AV_PIX_FMT_MONOBLACK) {
> >          pnm_get(s, buf1, sizeof(buf1));
> >          s->maxval = atoi(buf1);
>
> > +        if (s->maxval < 0) {
> > +            s->maxval *= -1;
> > +            s->jasper_signed = 1;
> > +        }
> >          if (s->maxval <= 0 || s->maxval > UINT16_MAX) {
>
> The s->maxval <= 0 test here has become redundant.

I did not consider it redundant...

Carl Eugen


More information about the ffmpeg-devel mailing list