From e39de16fa59903eb785f4f0f50f991c779ae1a90 Mon Sep 17 00:00:00 2001 From: "mikhal@webrtc.org" Date: Tue, 27 Dec 2011 23:45:30 +0000 Subject: [PATCH] Moving video type convert functionality to libyuv. deleting vplibConversions as it is no longer needed. Review URL: http://webrtc-codereview.appspot.com/338002 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1298 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/common_video/libyuv/include/libyuv.h | 5 ++ src/common_video/libyuv/libyuv.cc | 32 ++++++++++++ .../main/source/video_capture.gypi | 2 - .../main/source/video_capture_impl.cc | 11 ++-- .../main/source/vplib_conversions.cc | 51 ------------------- .../main/source/vplib_conversions.h | 26 ---------- 6 files changed, 43 insertions(+), 84 deletions(-) delete mode 100644 src/modules/video_capture/main/source/vplib_conversions.cc delete mode 100644 src/modules/video_capture/main/source/vplib_conversions.h diff --git a/src/common_video/libyuv/include/libyuv.h b/src/common_video/libyuv/include/libyuv.h index 984600537..468706377 100644 --- a/src/common_video/libyuv/include/libyuv.h +++ b/src/common_video/libyuv/include/libyuv.h @@ -15,6 +15,7 @@ #ifndef WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_LIBYUV_H_ #define WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_LIBYUV_H_ +#include "common_types.h" // RawVideoTypes. #include "typedefs.h" namespace webrtc { @@ -43,6 +44,10 @@ enum VideoType { kNumberOfVideoTypes }; +// Conversion between the RawVideoType and the LibYuv videoType. +// TODO(wu): Consolidate types into one type throughout WebRtc. +VideoType RawVideoTypeToCommonVideoVideoType(RawVideoType type); + // Supported rotation // Direction of rotation - clockwise. enum VideoRotationMode { diff --git a/src/common_video/libyuv/libyuv.cc b/src/common_video/libyuv/libyuv.cc index 1464d0415..178dad343 100644 --- a/src/common_video/libyuv/libyuv.cc +++ b/src/common_video/libyuv/libyuv.cc @@ -21,6 +21,38 @@ namespace webrtc { +VideoType RawVideoTypeToCommonVideoVideoType(RawVideoType type) { + switch (type) { + case kVideoI420: + return kI420; + case kVideoIYUV: + return kIYUV; + case kVideoRGB24: + return kRGB24; + case kVideoARGB: + return kARGB; + case kVideoARGB4444: + return kARGB4444; + case kVideoRGB565: + return kRGB565; + case kVideoARGB1555: + return kARGB1555; + case kVideoYUY2: + return kYUY2; + case kVideoYV12: + return kYV12; + case kVideoUYVY: + return kUYVY; + case kVideoNV21: + return kNV21; + case kVideoNV12: + return kNV12; + default: + assert(false); + } + return kUnknown; +} + int CalcBufferSize(VideoType type, int width, int height) { int bits_per_pixel = 32; switch (type) { diff --git a/src/modules/video_capture/main/source/video_capture.gypi b/src/modules/video_capture/main/source/video_capture.gypi index 74ebf84fc..41b9798c4 100644 --- a/src/modules/video_capture/main/source/video_capture.gypi +++ b/src/modules/video_capture/main/source/video_capture.gypi @@ -37,13 +37,11 @@ 'video_capture_config.h', 'video_capture_delay.h', 'video_capture_impl.h', - 'vplib_conversions.h', 'device_info_impl.h', # DEFINE PLATFORM INDEPENDENT SOURCE FILES 'video_capture_factory.cc', 'video_capture_impl.cc', - 'vplib_conversions.cc', 'device_info_impl.cc', ], 'conditions': [ diff --git a/src/modules/video_capture/main/source/video_capture_impl.cc b/src/modules/video_capture/main/source/video_capture_impl.cc index 486b08924..b96cac1d4 100644 --- a/src/modules/video_capture/main/source/video_capture_impl.cc +++ b/src/modules/video_capture/main/source/video_capture_impl.cc @@ -9,13 +9,14 @@ */ #include "video_capture_impl.h" -#include "trace.h" + +#include "common_video/libyuv/include/libyuv.h" #include "critical_section_wrapper.h" -#include "tick_util.h" -#include "vplib_conversions.h" -#include "video_capture_config.h" #include "module_common_types.h" #include "ref_count.h" +#include "tick_util.h" +#include "trace.h" +#include "video_capture_config.h" #ifdef WEBRTC_ANDROID #include "video_capture_android.h" // Need inclusion here to set Java environment. @@ -304,7 +305,7 @@ WebRtc_Word32 VideoCaptureImpl::IncomingFrame(WebRtc_UWord8* videoFrame, if (frameInfo.codecType == kVideoCodecUnknown) // None encoded. Convert to I420. { - const VideoType commonVideoType = videocapturemodule:: + const VideoType commonVideoType = RawVideoTypeToCommonVideoVideoType(frameInfo.rawType); int size = CalcBufferSize(commonVideoType, width, height); if (size != videoFrameLength) diff --git a/src/modules/video_capture/main/source/vplib_conversions.cc b/src/modules/video_capture/main/source/vplib_conversions.cc deleted file mode 100644 index e8d54114b..000000000 --- a/src/modules/video_capture/main/source/vplib_conversions.cc +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "vplib_conversions.h" - -namespace webrtc -{ -namespace videocapturemodule -{ -VideoType RawVideoTypeToCommonVideoVideoType(RawVideoType type) -{ - switch (type) - { - case kVideoI420: - return kI420; - case kVideoIYUV: - return kIYUV; - case kVideoRGB24: - return kRGB24; - case kVideoARGB: - return kARGB; - case kVideoARGB4444: - return kARGB4444; - case kVideoRGB565: - return kRGB565; - case kVideoARGB1555: - return kARGB1555; - case kVideoYUY2: - return kYUY2; - case kVideoYV12: - return kYV12; - case kVideoUYVY: - return kUYVY; - case kVideoNV21: - return kNV21; - case kVideoNV12: - return kNV12; - default: - assert(!"RawVideoTypeToCommonVideoVideoType unknown type"); - } - return kUnknown; -} -} //namespace videocapturemodule -}//namespace webrtc diff --git a/src/modules/video_capture/main/source/vplib_conversions.h b/src/modules/video_capture/main/source/vplib_conversions.h deleted file mode 100644 index 390d12e14..000000000 --- a/src/modules/video_capture/main/source/vplib_conversions.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_VPLIB_CONVERSIONS_H_ -#define WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_VPLIB_CONVERSIONS_H_ - -#include "video_capture.h" -#include "common_video/libyuv/include/libyuv.h" - -// TODO (mikhal): Update file name -namespace webrtc -{ -namespace videocapturemodule -{ - VideoType RawVideoTypeToCommonVideoVideoType(RawVideoType type); -} // namespace videocapturemodule -} // namespace webrtc -#endif // WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_VPLIB_CONVERSIONS_H_ -