From 8b6d7d72f94985386b5b046587389c3fc88106ed Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Fri, 16 Dec 2011 19:43:29 +0000 Subject: [PATCH] I400 to 420 for MJPG internals BUG=none TEST=none Review URL: http://webrtc-codereview.appspot.com/328008 git-svn-id: http://libyuv.googlecode.com/svn/trunk@113 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/planar_functions.h | 7 +++++++ source/planar_functions.cc | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/README.chromium b/README.chromium index e82f2d815..e660effc3 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 112 +Version: 113 License: BSD License File: LICENSE diff --git a/include/libyuv/planar_functions.h b/include/libyuv/planar_functions.h index e96442328..62857ce87 100644 --- a/include/libyuv/planar_functions.h +++ b/include/libyuv/planar_functions.h @@ -63,6 +63,13 @@ int I444ToI420(const uint8* src_y, int src_stride_y, uint8* dst_v, int dst_stride_v, int width, int height); +// Convert I400 (grey) to I420. +int I400ToI420(const uint8* src_y, int src_stride_y, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height); + // Convert NV12 to I420. Also used for NV21. int NV12ToI420(const uint8* src_y, int src_stride_y, const uint8* src_uv, int src_stride_uv, diff --git a/source/planar_functions.cc b/source/planar_functions.cc index 5b92f8640..4dbcee007 100644 --- a/source/planar_functions.cc +++ b/source/planar_functions.cc @@ -2069,6 +2069,26 @@ int ARGBRect(uint8* dst_argb, int dst_stride_argb, return 0; } +// I400 is greyscale typically used in MJPG +int I400ToI420(const uint8* src_y, int src_stride_y, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height) { + // Negative height means invert the image. + if (height < 0) { + height = -height; + src_y = src_y + (height - 1) * src_stride_y; + src_stride_y = -src_stride_y; + } + int halfwidth = (width + 1) >> 1; + int halfheight = (height + 1) >> 1; + CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); + SetPlane(dst_u, dst_stride_u, halfwidth, halfheight, 128); + SetPlane(dst_v, dst_stride_v, halfwidth, halfheight, 128); + return 0; +} + #ifdef __cplusplus } // extern "C" } // namespace libyuv