[FFmpeg-devel] [PATCH] Implement function to compute bits per pixel

Michael Niedermayer michaelni
Mon Apr 27 14:16:15 CEST 2009


On Sun, Apr 26, 2009 at 03:15:24PM +0200, Stefano Sabatini wrote:
> On date Sunday 2009-04-26 13:29:58 +0200, Stefano Sabatini encoded:
> > On date Sunday 2009-04-26 12:55:33 +0200, Michael Niedermayer encoded:
> > > On Sun, Apr 26, 2009 at 12:19:28PM +0200, Stefano Sabatini wrote:
> > > > Hi, as in subject.
> > > > 
> > > > This is the output of the test program:
> > > > yuv420p: bits_per_pixel: 12
> > > > yuyv422: bits_per_pixel: 12
> > > 
> > > interresting
> > 
> > Ouch, fixed.
[...]
> Index: libavfilter-soc/ffmpeg/libavcodec/pixdesc.c
> ===================================================================
> --- libavfilter-soc.orig/ffmpeg/libavcodec/pixdesc.c	2009-04-26 11:57:43.000000000 +0200
> +++ libavfilter-soc/ffmpeg/libavcodec/pixdesc.c	2009-04-26 15:12:36.000000000 +0200
> @@ -581,3 +581,37 @@
>          .flags = PIX_FMT_BE,
>      },
>  };
> +
> +int av_pixdesc_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)



> +{
> +    int c = 0;

> +    int pixels = pow(2, pixdesc->log2_chroma_w + pixdesc->log2_chroma_h);

<<

> +    int bits = (pixdesc->comp[0].depth_minus1+1) * pixels;
> +
> +    /* add the total number of bits used to contain the components after the first one */
> +    for (c = 1; c < pixdesc->nb_channels && (c < 3); c++)
> +        bits += pixdesc->comp[c].depth_minus1+1;
> +
> +    if (pixdesc->nb_channels == 4) /* add alpha component bits */
> +        bits += (pixdesc->comp[3].depth_minus1+1) * pixels;

for (c = 1; c < pixdesc->nb_channels; c++){
    int s= c==1 || c==2 ? ...
}


[...]
> Index: libavfilter-soc/ffmpeg/libavcodec/pixdesc.h
> ===================================================================
> --- libavfilter-soc.orig/ffmpeg/libavcodec/pixdesc.h	2009-04-26 11:30:27.000000000 +0200
> +++ libavfilter-soc/ffmpeg/libavcodec/pixdesc.h	2009-04-26 12:15:37.000000000 +0200
> @@ -193,4 +193,10 @@
>      }
>  }
>  
> +/**
> + * Returns the number of bits per pixel used by the pixel format
> + * described by pixdesc.
> + */
> +int av_pixdesc_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);

av_get_bits_per_pixel
or
av_bits_per_pixel

seem better names

also a formal definition of bits per pixel is needed, what you have is unclear
in respect to "padding bits"

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090427/964125e0/attachment.pgp>



More information about the ffmpeg-devel mailing list