diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-26 23:30:51 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-26 23:30:51 +0000 |
commit | 88fa6bf2a6300335381178004eb434df99595f04 (patch) | |
tree | dcfc9976760f0f0132081f01df2179b224ee8617 /media | |
parent | 769c0eabac88d21875c5c1812687889d79e6dbef (diff) | |
download | chromium_src-88fa6bf2a6300335381178004eb434df99595f04.zip chromium_src-88fa6bf2a6300335381178004eb434df99595f04.tar.gz chromium_src-88fa6bf2a6300335381178004eb434df99595f04.tar.bz2 |
VideoCaptureHost
This is the patch containing code necessary for communicating with the VideoCaptureMessageFilter from the browser process and transferring Transport Dibs filled with video frames in I420 color format. It also contain code for color converting video frames to I420.
Color conversion has been tested on Linux and Windows by using video_capture_host_unittest and dumping I420 frames to file. See #define DUMP_VIDEO #define TEST_REAL_CAPTURE_DEVICE.
Patch by perk@google.com:
http://codereview.chromium.org/7002027/
BUG=none
TEST=try bots
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86927 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/base/yuv_convert.cc | 21 | ||||
-rw-r--r-- | media/base/yuv_convert.h | 16 | ||||
-rw-r--r-- | media/base/yuv_convert_c.cc | 58 | ||||
-rw-r--r-- | media/base/yuv_convert_internal.h | 19 |
4 files changed, 114 insertions, 0 deletions
diff --git a/media/base/yuv_convert.cc b/media/base/yuv_convert.cc index 2e4af1d..b4972083 100644 --- a/media/base/yuv_convert.cc +++ b/media/base/yuv_convert.cc @@ -374,4 +374,25 @@ void ConvertRGB32ToYUV(const uint8* rgbframe, rgbstride, ystride, uvstride); } +void ConvertRGB24ToYUV(const uint8* rgbframe, + uint8* yplane, + uint8* uplane, + uint8* vplane, + int width, + int height, + int rgbstride, + int ystride, + int uvstride) { + ConvertRGB24ToYUV_C(rgbframe, yplane, uplane, vplane, width, height, + rgbstride, ystride, uvstride); +} + +void ConvertYUY2ToYUV(const uint8* src, + uint8* yplane, + uint8* uplane, + uint8* vplane, + int width, + int height) { + ConvertYUY2ToYUV_C(src, yplane, uplane, vplane, width, height); +} } // namespace media diff --git a/media/base/yuv_convert.h b/media/base/yuv_convert.h index ab908b2..12dab83 100644 --- a/media/base/yuv_convert.h +++ b/media/base/yuv_convert.h @@ -77,6 +77,22 @@ void ConvertRGB32ToYUV(const uint8* rgbframe, int ystride, int uvstride); +void ConvertRGB24ToYUV(const uint8* rgbframe, + uint8* yplane, + uint8* uplane, + uint8* vplane, + int width, + int height, + int rgbstride, + int ystride, + int uvstride); + +void ConvertYUY2ToYUV(const uint8* src, + uint8* yplane, + uint8* uplane, + uint8* vplane, + int width, + int height); } // namespace media #endif // MEDIA_BASE_YUV_CONVERT_H_ diff --git a/media/base/yuv_convert_c.cc b/media/base/yuv_convert_c.cc index 986bf8e..b5a835b 100644 --- a/media/base/yuv_convert_c.cc +++ b/media/base/yuv_convert_c.cc @@ -48,4 +48,62 @@ void ConvertRGB32ToYUV_C(const uint8* rgbframe, } } +void ConvertRGB24ToYUV_C(const uint8* rgbframe, + uint8* yplane, + uint8* uplane, + uint8* vplane, + int width, + int height, + int rgbstride, + int ystride, + int uvstride) { + for (int i = 0; i < height; ++i) { + for (int j = 0; j < width; ++j) { + // Since the input pixel format is RGB24, there are 3 bytes per pixel. + const uint8* pixel = rgbframe + 3 * j; + yplane[j] = clip_byte(((pixel[2] * 66 + pixel[1] * 129 + + pixel[0] * 25 + 128) >> 8) + 16); + if (i % 2 == 0 && j % 2 == 0) { + uplane[j / 2] = clip_byte(((pixel[2] * -38 + pixel[1] * -74 + + pixel[0] * 112 + 128) >> 8) + 128); + vplane[j / 2] = clip_byte(((pixel[2] * 112 + pixel[1] * -94 + + pixel[1] * -18 + 128) >> 8) + 128); + } + } + + rgbframe += rgbstride; + yplane += ystride; + if (i % 2 == 0) { + uplane += uvstride; + vplane += uvstride; + } + } +} + +void ConvertYUY2ToYUV_C(const uint8* src, + uint8* yplane, + uint8* uplane, + uint8* vplane, + int width, + int height) { + for (int i = 0; i < height / 2; ++i) { + for (int j = 0; j < (width / 2); ++j) { + yplane[0] = src[0]; + *uplane = src[1]; + yplane[1] = src[2]; + *vplane = src[3]; + src += 4; + yplane += 2; + uplane++; + vplane++; + } + for (int j = 0; j < (width / 2); ++j) { + yplane[0] = src[0]; + yplane[1] = src[2]; + src += 4; + yplane += 2; + } + } +} + } // namespace media diff --git a/media/base/yuv_convert_internal.h b/media/base/yuv_convert_internal.h index 7a8ee34..da41be3 100644 --- a/media/base/yuv_convert_internal.h +++ b/media/base/yuv_convert_internal.h @@ -34,6 +34,25 @@ void ConvertRGB32ToYUV_C(const uint8* rgbframe, int ystride, int uvstride); +// C version of converting RGB24 to YV12. +void ConvertRGB24ToYUV_C(const uint8* rgbframe, + uint8* yplane, + uint8* uplane, + uint8* vplane, + int width, + int height, + int rgbstride, + int ystride, + int uvstride); + +// C version of converting YUY2 to YV12. +void ConvertYUY2ToYUV_C(const uint8* src, + uint8* yplane, + uint8* uplane, + uint8* vplane, + int width, + int height); + } // namespace media #endif // MEDIA_BASE_YUV_CONVERT_INTERNAL_H_ |