Commit 5343a730 authored by fbarchard@google.com's avatar fbarchard@google.com

Make Bayer functions with same parameters as RGB conversions allowing consistant…

Make Bayer functions with same parameters as RGB conversions allowing consistant usage and testing.  Functions are implemented with wrappers to single function for 4 fourccs.  New I420ToBayer functions implemented similar to 2 step I420ToRGB565 etc.
BUG=none
TEST=none
Review URL: https://webrtc-codereview.appspot.com/367002

git-svn-id: http://libyuv.googlecode.com/svn/trunk@150 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 94602791
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 149
Version: 150
License: BSD
License File: LICENSE
......
......@@ -18,25 +18,127 @@ namespace libyuv {
extern "C" {
#endif
// Converts any Bayer RGB format to I420.
int BayerRGBToI420(const uint8* src_bayer, int src_stride_bayer,
uint32 src_fourcc_bayer,
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);
// Converts any Bayer RGB format to ARGB.
int BayerRGBToARGB(const uint8* src_bayer, int src_stride_bayer,
uint32 src_fourcc_bayer,
uint8* dst_rgb, int dst_stride_rgb,
int width, int height);
// Converts ARGB to any Bayer RGB format.
int ARGBToBayerRGB(const uint8* src_rgb, int src_stride_rgb,
uint8* dst_bayer, int dst_stride_bayer,
uint32 dst_fourcc_bayer,
int width, int height);
// Convert Bayer RGB formats to I420.
int BayerBGGRToI420(const uint8* src_bayer, int src_stride_bayer,
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);
int BayerGBRGToI420(const uint8* src_bayer, int src_stride_bayer,
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);
int BayerGRBGToI420(const uint8* src_bayer, int src_stride_bayer,
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);
int BayerRGGBToI420(const uint8* src_bayer, int src_stride_bayer,
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);
// Temporary API mapper
#define BayerRGBToI420(b,bs,f,y,ys,u,us,v,vs,w,h) \
BayerToI420(b,bs,y,ys,u,us,v,vs,w,h,f)
int BayerToI420(const uint8* src_bayer, int src_stride_bayer,
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,
uint32 src_fourcc_bayer);
// Convert I420 to Bayer RGB formats.
int I420ToBayerBGGR(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_frame, int dst_stride_frame,
int width, int height);
int I420ToBayerGBRG(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_frame, int dst_stride_frame,
int width, int height);
int I420ToBayerGRBG(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_frame, int dst_stride_frame,
int width, int height);
int I420ToBayerRGGB(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_frame, int dst_stride_frame,
int width, int height);
// Temporary API mapper
#define I420ToBayerRGB(y,ys,u,us,v,vs,b,bs,f,w,h) \
I420ToBayer(y,ys,u,us,v,vs,b,bs,w,h,f)
int I420ToBayer(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_frame, int dst_stride_frame,
int width, int height,
uint32 dst_fourcc_bayer);
// Convert Bayer RGB formats to ARGB.
int BayerBGGRToARGB(const uint8* src_bayer, int src_stride_bayer,
uint8* dst_argb, int dst_stride_argb,
int width, int height);
int BayerGBRGToARGB(const uint8* src_bayer, int src_stride_bayer,
uint8* dst_argb, int dst_stride_argb,
int width, int height);
int BayerGRBGToARGB(const uint8* src_bayer, int src_stride_bayer,
uint8* dst_argb, int dst_stride_argb,
int width, int height);
int BayerRGGBToARGB(const uint8* src_bayer, int src_stride_bayer,
uint8* dst_argb, int dst_stride_argb,
int width, int height);
// Temporary API mapper
#define BayerRGBToARGB(b,bs,f,a,as,w,h) BayerToARGB(b,bs,a,as,w,h,f)
int BayerToARGB(const uint8* src_bayer, int src_stride_bayer,
uint8* dst_argb, int dst_stride_argb,
int width, int height,
uint32 src_fourcc_bayer);
// Converts ARGB to Bayer RGB formats.
int ARGBToBayerBGGR(const uint8* src_argb, int src_stride_argb,
uint8* dst_bayer, int dst_stride_bayer,
int width, int height);
int ARGBToBayerGBRG(const uint8* src_argb, int src_stride_argb,
uint8* dst_bayer, int dst_stride_bayer,
int width, int height);
int ARGBToBayerGRBG(const uint8* src_argb, int src_stride_argb,
uint8* dst_bayer, int dst_stride_bayer,
int width, int height);
int ARGBToBayerRGGB(const uint8* src_argb, int src_stride_argb,
uint8* dst_bayer, int dst_stride_bayer,
int width, int height);
// Temporary API mapper
#define ARGBToBayerRGB(a,as,b,bs,f,w,h) ARGBToBayer(b,bs,a,as,w,h,f)
int ARGBToBayer(const uint8* src_argb, int src_stride_argb,
uint8* dst_bayer, int dst_stride_bayer,
int width, int height,
uint32 dst_fourcc_bayer);
#ifdef __cplusplus
} // extern "C"
......
......@@ -930,16 +930,44 @@ int ConvertToI420(const uint8* sample, size_t sample_size,
v, v_stride,
dst_width, inv_dst_height);
break;
// TODO(fbarchard): Support cropping Bayer by odd numbers
// by adjusting fourcc.
case FOURCC_BGGR:
case FOURCC_RGGB:
case FOURCC_GRBG:
src = sample + (src_width * crop_y + crop_x);
BayerBGGRToI420(src, src_width,
y, y_stride,
u, u_stride,
v, v_stride,
dst_width, inv_dst_height);
break;
case FOURCC_GBRG:
// TODO(fbarchard): Support cropping by odd numbers by adjusting fourcc.
src = sample + (src_width * crop_y + crop_x);
BayerRGBToI420(src, src_width, format,
y, y_stride, u, u_stride, v, v_stride,
dst_width, inv_dst_height);
BayerGBRGToI420(src, src_width,
y, y_stride,
u, u_stride,
v, v_stride,
dst_width, inv_dst_height);
break;
case FOURCC_GRBG:
src = sample + (src_width * crop_y + crop_x);
BayerGRBGToI420(src, src_width,
y, y_stride,
u, u_stride,
v, v_stride,
dst_width, inv_dst_height);
break;
case FOURCC_RGGB:
src = sample + (src_width * crop_y + crop_x);
BayerRGGBToI420(src, src_width,
y, y_stride,
u, u_stride,
v, v_stride,
dst_width, inv_dst_height);
break;
case FOURCC_I400:
src = sample + src_width * crop_y + crop_x;
I400ToI420(src, src_width,
......
......@@ -113,20 +113,38 @@ int ConvertFromI420(const uint8* y, int y_stride,
dst_sample_stride ? dst_sample_stride : width * 4,
width, height);
break;
#ifdef HAVEI420TOBAYER
case FOURCC_BGGR:
case FOURCC_RGGB:
case FOURCC_GRBG:
I420ToBayerBGGR(y, y_stride,
u, u_stride,
v, v_stride,
dst_sample,
dst_sample_stride ? dst_sample_stride : width,
width, height);
break;
case FOURCC_GBRG:
I420ToBayerRGB(y, y_stride,
u, u_stride,
v, v_stride,
dst_sample,
dst_sample_stride ? dst_sample_stride : width,
format,
width, height);
I420ToBayerGBRG(y, y_stride,
u, u_stride,
v, v_stride,
dst_sample,
dst_sample_stride ? dst_sample_stride : width,
width, height);
break;
case FOURCC_GRBG:
I420ToBayerGRBG(y, y_stride,
u, u_stride,
v, v_stride,
dst_sample,
dst_sample_stride ? dst_sample_stride : width,
width, height);
break;
case FOURCC_RGGB:
I420ToBayerRGGB(y, y_stride,
u, u_stride,
v, v_stride,
dst_sample,
dst_sample_stride ? dst_sample_stride : width,
width, height);
break;
#endif
case FOURCC_I400:
I400Copy(y, y_stride,
dst_sample,
......
This diff is collapsed.
......@@ -1615,10 +1615,10 @@ int I420ToABGR(const uint8* src_y, int src_stride_y,
// Convert I420 to RGB24.
int I420ToRGB24(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_argb, int dst_stride_argb,
int width, int height) {
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_argb, int dst_stride_argb,
int width, int height) {
// Negative height means invert the image.
if (height < 0) {
height = -height;
......@@ -1781,10 +1781,10 @@ int I420ToRGB565(const uint8* src_y, int src_stride_y,
// Convert I420 to ARGB1555.
int I420ToARGB1555(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_argb, int dst_stride_argb,
int width, int height) {
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_argb, int dst_stride_argb,
int width, int height) {
// Negative height means invert the image.
if (height < 0) {
height = -height;
......@@ -1835,10 +1835,10 @@ int I420ToARGB1555(const uint8* src_y, int src_stride_y,
// Convert I420 to ARGB4444.
int I420ToARGB4444(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_argb, int dst_stride_argb,
int width, int height) {
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_argb, int dst_stride_argb,
int width, int height) {
// Negative height means invert the image.
if (height < 0) {
height = -height;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment