aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/pixdesc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-11-21 16:45:54 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-11-21 17:05:50 +0100
commit649d8bd8a56d8bffe9dd3143cd48082ae187961a (patch)
treec97d92cba511d3d479677fc0603f34abe08a3b89 /libavutil/pixdesc.c
parentad9333d5ef82f74dc470744f19f1350fabc93aa4 (diff)
downloadffmpeg-649d8bd8a56d8bffe9dd3143cd48082ae187961a.tar.gz
pixdesc: add av_get_padded_bits_per_pixel()
This will be needed to allow removing the PixFmtInfo table Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/pixdesc.c')
-rw-r--r--libavutil/pixdesc.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index e5e3fa8551..c7ef57ccd8 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -1712,6 +1712,26 @@ int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
return bits >> log2_pixels;
}
+int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
+{
+ int c, bits = 0;
+ int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
+ int steps[4] = {0};
+
+ for (c = 0; c < pixdesc->nb_components; c++) {
+ AVComponentDescriptor *comp = &pixdesc->comp[c];
+ int s = c == 1 || c == 2 ? 0 : log2_pixels;
+ steps[comp->plane] = (comp->step_minus1 + 1) << s;
+ }
+ for (c = 0; c < 4; c++)
+ bits += steps[c];
+
+ if(!(pixdesc->flags & PIX_FMT_BITSTREAM))
+ bits *= 8;
+
+ return bits >> log2_pixels;
+}
+
char *av_get_pix_fmt_string (char *buf, int buf_size, enum AVPixelFormat pix_fmt)
{
/* print header */