From 3ebff4c2e9a1d14370e45e75bff15d3479452363 Mon Sep 17 00:00:00 2001 From: "leozwang@webrtc.org" Date: Fri, 4 May 2012 17:07:30 +0000 Subject: [PATCH] Add ConvertToARGB and enable RGB565 Review URL: https://webrtc-codereview.appspot.com/566004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2174 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/common_video/libyuv/include/libyuv.h | 5 ++++- src/common_video/libyuv/libyuv.cc | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/common_video/libyuv/include/libyuv.h b/src/common_video/libyuv/include/libyuv.h index bf106f14b..6da862ff4 100644 --- a/src/common_video/libyuv/include/libyuv.h +++ b/src/common_video/libyuv/include/libyuv.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 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 @@ -149,6 +149,9 @@ int ConvertRGB24ToARGB(const uint8_t* src_frame, int ConvertNV12ToRGB565(const uint8_t* src_frame, uint8_t* dst_frame, int width, int height); +int ConvertI420ToARGB8888(const uint8_t* src_frame, + uint8_t* dst_frame, + int width, int height); // Mirror functions // The following 2 functions perform mirroring on a given image diff --git a/src/common_video/libyuv/libyuv.cc b/src/common_video/libyuv/libyuv.cc index 88afa9322..d4006c22e 100644 --- a/src/common_video/libyuv/libyuv.cc +++ b/src/common_video/libyuv/libyuv.cc @@ -143,6 +143,25 @@ int CalcBufferSize(VideoType src_video_type, return (length * dst_bits_per_pixel) / src_bits_per_pixel; } +int ConvertI420ToARGB8888(const uint8_t* src_frame, + uint8_t* dst_frame, + int width, int height) { + + const uint8_t* src_y = src_frame; + const uint8_t* src_u = src_y + width * height; + const uint8_t* src_v = src_u + (width * height / 4); + int src_stride_y = width; + int src_stride_u = width / 2; + int src_stride_v = width / 2; + int dst_stride_argb = width * 4; + + return libyuv::I420ToARGB(src_y, src_stride_y, + src_u, src_stride_u, + src_v, src_stride_v, + dst_frame, dst_stride_argb, + width, height); +} + int ConvertI420ToARGB4444(const uint8_t* src_frame, uint8_t* dst_frame, int width, int height, @@ -245,8 +264,9 @@ int ConvertVideoType(VideoType video_type) { return libyuv::FOURCC_24BG; case kABGR: return libyuv::FOURCC_ABGR; - case kARGB4444: case kRGB565: + return libyuv::FOURCC_RGBP; + case kARGB4444: case kARGB1555: // TODO(mikhal): Not supported; assert(false);