Mercurial > libavcodec.hg
changeset 9579:8665a1518257 libavcodec
Implement av_get_bits_per_pixel().
author | stefano |
---|---|
date | Mon, 27 Apr 2009 23:20:30 +0000 |
parents | 14b9819158a8 |
children | 51e8f5ab8f1e |
files | pixdesc.c pixdesc.h |
diffstat | 2 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pixdesc.c Mon Apr 27 18:35:54 2009 +0000 +++ b/pixdesc.c Mon Apr 27 23:20:30 2009 +0000 @@ -581,3 +581,16 @@ .flags = PIX_FMT_BE, }, }; + +int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc) +{ + int c, bits = 0; + int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h; + + for (c = 0; c < pixdesc->nb_channels; c++) { + int s = c==1 || c==2 ? 0 : log2_pixels; + bits += (pixdesc->comp[c].depth_minus1+1) << s; + } + + return bits >> log2_pixels; +}
--- a/pixdesc.h Mon Apr 27 18:35:54 2009 +0000 +++ b/pixdesc.h Mon Apr 27 23:20:30 2009 +0000 @@ -193,4 +193,14 @@ } } +/** + * Returns the number of bits per pixel used by the pixel format + * described by pixdesc. + * + * The returned number of bits refers to the number of bits actually + * used for storing the pixel information, that is padding bits are + * not counted. + */ +int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc); + #endif /* AVCODEC_PIXDESC_H */