[FFmpeg-devel] [PATCH 6/8] Make avcodec_pix_fmt_string() use the information in the pixel format descriptors for printing the number of planes. Also replace the term "nb_channels" with "nb_planes" which is more correct.

Stefano Sabatini stefano.sabatini-lala
Sun Nov 7 19:49:45 CET 2010


On date Sunday 2010-11-07 19:08:28 +0100, Michael Niedermayer encoded:
> On Sun, Nov 07, 2010 at 02:47:47PM +0100, Stefano Sabatini wrote:
> > On date Friday 2010-11-05 12:01:38 +0100, Stefano Sabatini encoded:
> > > ---
> > >  libavcodec/imgconvert.c |   12 ++++++++----
> > >  1 files changed, 8 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
> > > index e9477c4..0c30304 100644
> > > --- a/libavcodec/imgconvert.c
> > > +++ b/libavcodec/imgconvert.c
> > > @@ -434,15 +434,19 @@ void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt)
> > >      /* print header */
> > >      if (pix_fmt < 0)
> > >          snprintf (buf, buf_size,
> > > -                  "name      " " nb_channels" " depth"
> > > +                  "name      " " nb_planes" " depth"
> > >              );
> > >      else{
> > > -        PixFmtInfo info= pix_fmt_info[pix_fmt];
> > > +        const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
> > > +        int i, nb_planes = 0;
> > > +        for (i = 0; i < pixdesc->nb_components; i++)
> > > +            nb_planes = FFMAX(pixdesc->comp[i].plane, nb_planes);
> > > +        nb_planes++;
> > >  
> > >          snprintf (buf, buf_size,
> > > -                  "%-11s %5d %9d",
> > > +                  "%-11s %5d %7d",
> > >                    av_pix_fmt_descriptors[pix_fmt].name,
> > > -                  info.nb_channels,
> > > +                  nb_planes,
> > >                    av_get_bits_per_pixel(&av_pix_fmt_descriptors[pix_fmt])
> > >              );
> > 
> > nb_planes != nb_channels
> 
> well you can print one, you can print the other or both.
> iam not sure i like the nb_components renaming though

Also I discovered they're two different things, indeed nb_channels for
RGB8, RGB4, RGB4_BYTE, BGR8... is 1, while the number of components is
3 (so I have no idea what's the meaning of the hackish definition of
PixFmt.nb_channels).

So I think it's better to use nb_component to make the distinction
clear.

Regards.
-- 
FFmpeg = Fundamental Faithless Mystic Portable Eretic Gadget



More information about the ffmpeg-devel mailing list