[FFmpeg-cvslog] r18709 - in trunk/libavcodec: pixdesc.c pixdesc.h
stefano
subversion
Tue Apr 28 01:20:31 CEST 2009
Author: stefano
Date: Tue Apr 28 01:20:30 2009
New Revision: 18709
Log:
Implement av_get_bits_per_pixel().
Modified:
trunk/libavcodec/pixdesc.c
trunk/libavcodec/pixdesc.h
Modified: trunk/libavcodec/pixdesc.c
==============================================================================
--- trunk/libavcodec/pixdesc.c Mon Apr 27 20:35:54 2009 (r18708)
+++ trunk/libavcodec/pixdesc.c Tue Apr 28 01:20:30 2009 (r18709)
@@ -581,3 +581,16 @@ const AVPixFmtDescriptor av_pix_fmt_desc
.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;
+}
Modified: trunk/libavcodec/pixdesc.h
==============================================================================
--- trunk/libavcodec/pixdesc.h Mon Apr 27 20:35:54 2009 (r18708)
+++ trunk/libavcodec/pixdesc.h Tue Apr 28 01:20:30 2009 (r18709)
@@ -193,4 +193,14 @@ static inline void write_line(const uint
}
}
+/**
+ * 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 */
More information about the ffmpeg-cvslog
mailing list