[FFmpeg-devel] [RFC PATCH v4 4/5] libavcodec/j2kenc: Support for multiple layers

Gautam Ramakrishnan gautamramk at gmail.com
Tue Aug 25 12:50:53 EEST 2020


On Tue, Aug 25, 2020 at 2:09 PM Michael Niedermayer
<michael at niedermayer.cc> wrote:
>
> On Tue, Aug 25, 2020 at 09:50:06AM +0530, gautamramk at gmail.com wrote:
> > From: Gautam Ramakrishnan <gautamramk at gmail.com>
> >
> > This patch allows setting a compression ratio and to
> > set multiple layers. The user has to input a compression
> > ratio for each layer.
> > The per layer compression ration can be set as follows:
> > -layer_rates "r1,r2,...rn"
> > for to create 'n' layers.
>
> [...]
> > diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
> > index 70c25a0ca2..1c294ad9e6 100644
> > --- a/libavcodec/jpeg2000.c
> > +++ b/libavcodec/jpeg2000.c
> > @@ -261,9 +261,11 @@ static void init_band_stepsize(AVCodecContext *avctx,
> >          band->f_stepsize *= 0.5;
> >  }
> >
> > -static int init_prec(Jpeg2000Band *band,
> > +static int init_prec(AVCodecContext *avctx,
> > +                     Jpeg2000Band *band,
> >                       Jpeg2000ResLevel *reslevel,
> >                       Jpeg2000Component *comp,
> > +                     Jpeg2000CodingStyle *codsty,
> >                       int precno, int bandno, int reslevelno,
> >                       int log2_band_prec_width,
> >                       int log2_band_prec_height)
> > @@ -366,6 +368,11 @@ static int init_prec(Jpeg2000Band *band,
> >          cblk->lblock    = 3;
> >          cblk->length    = 0;
> >          cblk->npasses   = 0;
> > +        if (av_codec_is_encoder(avctx->codec)) {
> > +            cblk->layers = av_mallocz_array(codsty->nlayers, sizeof(*cblk->layers));
> > +            if (!cblk->layers)
> > +                return AVERROR(ENOMEM);
> > +        }
> >      }
> >
> >      return 0;
> > @@ -439,7 +446,7 @@ static int init_band(AVCodecContext *avctx,
> >          return AVERROR(ENOMEM);
> >
> >      for (precno = 0; precno < nb_precincts; precno++) {
> > -        ret = init_prec(band, reslevel, comp,
> > +        ret = init_prec(avctx, band, reslevel, comp, codsty,
> >                          precno, bandno, reslevelno,
> >                          log2_band_prec_width, log2_band_prec_height);
> >          if (ret < 0)
>
> > @@ -614,6 +621,8 @@ void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, i
> >                              av_freep(&cblk->passes);
> >                              av_freep(&cblk->lengthinc);
> >                              av_freep(&cblk->data_start);
> > +                            if (isencoder)
> > +                                av_freep(&cblk->layers);
>
> why does this need a isencoder check ?
> isnt it NULL otherwise ?
> iam asking as this might avoid the need for the isencoder argument
Yes, it would be NULL. I was not too sure if I could pass a reference
to a pointer
which points to NULL. If that works, I'll remove this and the previous patch.
>
> thx
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Opposition brings concord. Out of discord comes the fairest harmony.
> -- Heraclitus
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".



-- 
-------------
Gautam |


More information about the ffmpeg-devel mailing list