[FFmpeg-cvslog] pixdesc: add av_get_padded_bits_per_pixel()
Michael Niedermayer
git at videolan.org
Wed Nov 21 17:11:37 CET 2012
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Nov 21 16:45:54 2012 +0100| [649d8bd8a56d8bffe9dd3143cd48082ae187961a] | committer: Michael Niedermayer
pixdesc: add av_get_padded_bits_per_pixel()
This will be needed to allow removing the PixFmtInfo table
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=649d8bd8a56d8bffe9dd3143cd48082ae187961a
---
libavutil/pixdesc.c | 20 ++++++++++++++++++++
libavutil/pixdesc.h | 6 ++++++
2 files changed, 26 insertions(+)
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index e5e3fa8..c7ef57c 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 */
diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h
index 59fd1ff..ca0722e 100644
--- a/libavutil/pixdesc.h
+++ b/libavutil/pixdesc.h
@@ -189,6 +189,12 @@ char *av_get_pix_fmt_string (char *buf, int buf_size, enum AVPixelFormat pix_fmt
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
/**
+ * Return the number of bits per pixel for the pixel format
+ * described by pixdesc, including any padding or unused bits.
+ */
+int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
+
+/**
* @return a pixel format descriptor for provided pixel format or NULL if
* this pixel format is unknown.
*/
More information about the ffmpeg-cvslog
mailing list