diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2009-04-27 23:20:30 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2009-04-27 23:20:30 +0000 |
commit | 5efccce2a9191ded328233ab68a0767661a26679 (patch) | |
tree | 07b028878e03463cc5b0806cd5efec25a846ff66 /libavcodec/pixdesc.c | |
parent | 859471565a2356a6e8b58879f73e84b229bfdc40 (diff) | |
download | ffmpeg-5efccce2a9191ded328233ab68a0767661a26679.tar.gz |
Implement av_get_bits_per_pixel().
Originally committed as revision 18709 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/pixdesc.c')
-rw-r--r-- | libavcodec/pixdesc.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libavcodec/pixdesc.c b/libavcodec/pixdesc.c index 162b5826d2..a313c95cf1 100644 --- a/libavcodec/pixdesc.c +++ b/libavcodec/pixdesc.c @@ -581,3 +581,16 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { .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; +} |