Originally committed as revision 18709 to svn://svn.ffmpeg.org/ffmpeg/trunk
Stefano Sabatini authored on 2009/04/28 08:20:30... | ... |
@@ -581,3 +581,16 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { |
581 | 581 |
.flags = PIX_FMT_BE, |
582 | 582 |
}, |
583 | 583 |
}; |
584 |
+ |
|
585 |
+int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc) |
|
586 |
+{ |
|
587 |
+ int c, bits = 0; |
|
588 |
+ int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h; |
|
589 |
+ |
|
590 |
+ for (c = 0; c < pixdesc->nb_channels; c++) { |
|
591 |
+ int s = c==1 || c==2 ? 0 : log2_pixels; |
|
592 |
+ bits += (pixdesc->comp[c].depth_minus1+1) << s; |
|
593 |
+ } |
|
594 |
+ |
|
595 |
+ return bits >> log2_pixels; |
|
596 |
+} |
... | ... |
@@ -193,4 +193,14 @@ static inline void write_line(const uint16_t *src, uint8_t *data[4], const int l |
193 | 193 |
} |
194 | 194 |
} |
195 | 195 |
|
196 |
+/** |
|
197 |
+ * Returns the number of bits per pixel used by the pixel format |
|
198 |
+ * described by pixdesc. |
|
199 |
+ * |
|
200 |
+ * The returned number of bits refers to the number of bits actually |
|
201 |
+ * used for storing the pixel information, that is padding bits are |
|
202 |
+ * not counted. |
|
203 |
+ */ |
|
204 |
+int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc); |
|
205 |
+ |
|
196 | 206 |
#endif /* AVCODEC_PIXDESC_H */ |