Index: media/base/video_frame.cc |
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc |
index d2808356111d86c56b19644a2f6a51d602c4ca2b..7ff020f687205baf49d344a9ef5b93d1c9320c48 100644 |
--- a/media/base/video_frame.cc |
+++ b/media/base/video_frame.cc |
@@ -795,6 +795,53 @@ std::string VideoFrame::AsHumanReadableString() { |
return s.str(); |
} |
+int VideoFrame::BitsPerChannel(VideoPixelFormat format) { |
+ int bits_per_channel = 0; |
+ switch (format) { |
+ case media::PIXEL_FORMAT_UNKNOWN: |
+ NOTREACHED(); |
+ // Fall through! |
+ case media::PIXEL_FORMAT_I420: |
+ case media::PIXEL_FORMAT_YV12: |
+ case media::PIXEL_FORMAT_YV16: |
+ case media::PIXEL_FORMAT_YV12A: |
+ case media::PIXEL_FORMAT_YV24: |
+ case media::PIXEL_FORMAT_NV12: |
+ case media::PIXEL_FORMAT_NV21: |
+ case media::PIXEL_FORMAT_UYVY: |
+ case media::PIXEL_FORMAT_YUY2: |
+ case media::PIXEL_FORMAT_ARGB: |
+ case media::PIXEL_FORMAT_XRGB: |
+ case media::PIXEL_FORMAT_RGB24: |
+ case media::PIXEL_FORMAT_RGB32: |
+ case media::PIXEL_FORMAT_MJPEG: |
+ case media::PIXEL_FORMAT_MT21: |
+ case media::PIXEL_FORMAT_Y8: |
+ case media::PIXEL_FORMAT_I422: |
+ bits_per_channel = 8; |
+ break; |
+ case media::PIXEL_FORMAT_YUV420P9: |
+ case media::PIXEL_FORMAT_YUV422P9: |
+ case media::PIXEL_FORMAT_YUV444P9: |
+ bits_per_channel = 9; |
+ break; |
+ case media::PIXEL_FORMAT_YUV420P10: |
+ case media::PIXEL_FORMAT_YUV422P10: |
+ case media::PIXEL_FORMAT_YUV444P10: |
+ bits_per_channel = 10; |
+ break; |
+ case media::PIXEL_FORMAT_YUV420P12: |
+ case media::PIXEL_FORMAT_YUV422P12: |
+ case media::PIXEL_FORMAT_YUV444P12: |
+ bits_per_channel = 12; |
+ break; |
+ case media::PIXEL_FORMAT_Y16: |
+ bits_per_channel = 16; |
+ break; |
+ } |
+ return bits_per_channel; |
+} |
+ |
// static |
scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage( |
VideoPixelFormat format, |