[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
Tue Nov 9 23:59:13 CET 2010
On date Monday 2010-11-08 15:36:36 +0100, Michael Niedermayer encoded:
> On Sun, Nov 07, 2010 at 07:49:45PM +0100, Stefano Sabatini wrote:
> > 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,
>
> that i would call planes, which is 1 for packed pixel formats
>
>
> > 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.
>
> iam not sure if channel of component is better. In Audio terminology
> channel is clear in relation to packing several into one plane
> but iam not saying iam against the renaming, just that iam unsure
I like to keep a strict relation between exposed and internal
terminology, both us and our users will be less confused.
Also "channel" for the old API has quite a weird definition, so to
make clear that we're using a different "definition", and that the new
values under that column will actually have different values (at lease
in some case), I think it is better to adopt the new term
"nb_components".
--
FFmpeg = Foolish and Fast Martial Puritan Eager Genius
More information about the ffmpeg-devel
mailing list