[FFmpeg-devel] [PATCH 1/2] libavcodec/jpeg2000dec: Enhance pix fmt selection

Gautam Ramakrishnan gautamramk at gmail.com
Thu Jul 2 22:35:12 EEST 2020


On Thu, Jul 2, 2020 at 8:30 PM Michael Niedermayer
<michael at niedermayer.cc> wrote:
>
> On Thu, Jul 02, 2020 at 12:04:22AM +0530, gautamramk at gmail.com wrote:
> > From: Gautam Ramakrishnan <gautamramk at gmail.com>
> >
> > This patch assigns default pix format values when
> > a match does not take place.
> > ---
> >  libavcodec/jpeg2000dec.c | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> >
> > diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> > index 3f4a9ef96c..86f9170723 100644
> > --- a/libavcodec/jpeg2000dec.c
> > +++ b/libavcodec/jpeg2000dec.c
> > @@ -436,6 +436,15 @@ static int get_siz(Jpeg2000DecoderContext *s)
> >                  s->cdef[3] = 3;
> >                  i = 0;
> >              }
> > +        } else if (ncomponents == 3 && s->precision == 8) {
> > +            s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
> > +            i = 0;
> > +        } else if (ncomponents == 2 && s->precision == 8) {
> > +            s->avctx->pix_fmt = AV_PIX_FMT_YA8;
> > +            i = 0;
>
> I dont think 2 and 3 component formats can ignore the subsampling
> of the planes.
> They have to match even if they are not 1
> if they mismatch the differing plane would need to be rescaled
>
> Thats unless iam missing something, which is possible
I do not have a very good understanding of colour formats. But,
I checked out p1_07.j2k, which is a 2 component image. The subsampling
of the 2 layers are different. As a result, both components have different
dimensions. As a reference, I decoded the pgx files and saw the output.
It does match with what would happen with this patch applied. However,
that is probably because the samples are designed just to test the working
of the decoder and not to actually account for intricacies of the pixel formats.
As a compromise, do you think if would make sense if this patch can be applied
if the subsampling of all the planes are the same, but not the same as
that of rgb24
or ya8. Atleast, in that case, we will not have differing planes.
In case of YCC formats, it makes sense that every subsampling rate must match.
However, for rgb, from my understanding, it could also mean that the
final image is
just scaled according to the sample separation rate?


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


More information about the ffmpeg-devel mailing list