Commit 782659b0 authored by fbarchard@google.com's avatar fbarchard@google.com

ConvertFromI420Stride is same as ConvertFromI420 but accepts a stride per row. …

ConvertFromI420Stride is same as ConvertFromI420 but accepts a stride per row.  Only works on single plane formats
BUG=none
TEST=none
Review URL: https://webrtc-codereview.appspot.com/353007

git-svn-id: http://libyuv.googlecode.com/svn/trunk@137 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent ecb3f4cc
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 136 Version: 137
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -162,6 +162,16 @@ int ConvertFromI420(const uint8* y, int y_stride, ...@@ -162,6 +162,16 @@ int ConvertFromI420(const uint8* y, int y_stride,
int width, int height, int width, int height,
uint32 format); uint32 format);
// Convert I420 to specified format with stride.
// stride applies to first plane. If zero, width is used to compute stride.
int ConvertFromI420Stride(const uint8* y, int y_stride,
const uint8* u, int u_stride,
const uint8* v, int v_stride,
uint8* dst_sample, size_t dst_sample_stride,
size_t dst_sample_size,
int width, int height,
uint32 format);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
} // namespace libyuv } // namespace libyuv
......
...@@ -20,17 +20,15 @@ namespace libyuv { ...@@ -20,17 +20,15 @@ namespace libyuv {
extern "C" { extern "C" {
#endif #endif
// Convert I420 to specified format. // Convert I420 to specified format
// TODO(fbarchard): sample_size should be used to ensure the low levels do int ConvertFromI420Stride(const uint8* y, int y_stride,
// not read outside the buffer provided. It is measured in bytes and is the const uint8* u, int u_stride,
// size of the frame. With MJPEG it is the compressed size of the frame. const uint8* v, int v_stride,
// TODO(fbarchard): add I400, I444 and RAW support. uint8* dst_sample, size_t dst_sample_stride,
int ConvertFromI420(const uint8* y, int y_stride, size_t dst_sample_size,
const uint8* u, int u_stride, int width, int height,
const uint8* v, int v_stride, uint32 format) {
uint8* dst_sample, size_t dst_sample_size,
int width, int height,
uint32 format) {
if (y == NULL || u == NULL || v == NULL || dst_sample == NULL) { if (y == NULL || u == NULL || v == NULL || dst_sample == NULL) {
return -1; return -1;
} }
...@@ -40,70 +38,80 @@ int ConvertFromI420(const uint8* y, int y_stride, ...@@ -40,70 +38,80 @@ int ConvertFromI420(const uint8* y, int y_stride,
I420ToYUY2(y, y_stride, I420ToYUY2(y, y_stride,
u, u_stride, u, u_stride,
v, v_stride, v, v_stride,
dst_sample, width * 2, dst_sample,
dst_sample_stride ? dst_sample_stride : width * 2,
width, height); width, height);
break; break;
case FOURCC_UYVY: case FOURCC_UYVY:
I420ToUYVY(y, y_stride, I420ToUYVY(y, y_stride,
u, u_stride, u, u_stride,
v, v_stride, v, v_stride,
dst_sample, width * 2, dst_sample,
dst_sample_stride ? dst_sample_stride : width * 2,
width, height); width, height);
break; break;
case FOURCC_RGBP: case FOURCC_RGBP:
I420ToRGB565(y, y_stride, I420ToRGB565(y, y_stride,
u, u_stride, u, u_stride,
v, v_stride, v, v_stride,
dst_sample, width * 2, dst_sample,
dst_sample_stride ? dst_sample_stride : width * 2,
width, height); width, height);
break; break;
case FOURCC_RGBO: case FOURCC_RGBO:
I420ToARGB1555(y, y_stride, I420ToARGB1555(y, y_stride,
u, u_stride, u, u_stride,
v, v_stride, v, v_stride,
dst_sample, width * 2, dst_sample,
dst_sample_stride ? dst_sample_stride : width * 2,
width, height); width, height);
break; break;
case FOURCC_R444: case FOURCC_R444:
I420ToARGB4444(y, y_stride, I420ToARGB4444(y, y_stride,
u, u_stride, u, u_stride,
v, v_stride, v, v_stride,
dst_sample, width * 2, dst_sample,
dst_sample_stride ? dst_sample_stride : width * 2,
width, height); width, height);
break; break;
case FOURCC_24BG: case FOURCC_24BG:
I420ToRGB24(y, y_stride, I420ToRGB24(y, y_stride,
u, u_stride, u, u_stride,
v, v_stride, v, v_stride,
dst_sample, width * 3, dst_sample,
dst_sample_stride ? dst_sample_stride : width * 3,
width, height); width, height);
break; break;
case FOURCC_RAW: case FOURCC_RAW:
I420ToRAW(y, y_stride, I420ToRAW(y, y_stride,
u, u_stride, u, u_stride,
v, v_stride, v, v_stride,
dst_sample, width * 3, dst_sample,
dst_sample_stride ? dst_sample_stride : width * 3,
width, height); width, height);
break; break;
case FOURCC_ARGB: case FOURCC_ARGB:
I420ToARGB(y, y_stride, I420ToARGB(y, y_stride,
u, u_stride, u, u_stride,
v, v_stride, v, v_stride,
dst_sample, width * 4, dst_sample,
dst_sample_stride ? dst_sample_stride : width * 4,
width, height); width, height);
break; break;
case FOURCC_BGRA: case FOURCC_BGRA:
I420ToBGRA(y, y_stride, I420ToBGRA(y, y_stride,
u, u_stride, u, u_stride,
v, v_stride, v, v_stride,
dst_sample, width * 4, dst_sample,
dst_sample_stride ? dst_sample_stride : width * 4,
width, height); width, height);
break; break;
case FOURCC_ABGR: case FOURCC_ABGR:
I420ToABGR(y, y_stride, I420ToABGR(y, y_stride,
u, u_stride, u, u_stride,
v, v_stride, v, v_stride,
dst_sample, width * 4, dst_sample,
dst_sample_stride ? dst_sample_stride : width * 4,
width, height); width, height);
break; break;
#ifdef HAVEI420TOBAYER #ifdef HAVEI420TOBAYER
...@@ -114,16 +122,20 @@ int ConvertFromI420(const uint8* y, int y_stride, ...@@ -114,16 +122,20 @@ int ConvertFromI420(const uint8* y, int y_stride,
I420ToBayerRGB(y, y_stride, I420ToBayerRGB(y, y_stride,
u, u_stride, u, u_stride,
v, v_stride, v, v_stride,
dst_sample, width, format, dst_sample,
dst_sample_stride ? dst_sample_stride : width,
format,
width, height); width, height);
break; break;
#endif #endif
case FOURCC_I400: case FOURCC_I400:
I400Copy(y, y_stride, I400Copy(y, y_stride,
dst_sample, width, dst_sample,
dst_sample_stride ? dst_sample_stride : width,
width, height); width, height);
break; break;
// Triplanar formats // Triplanar formats
// TODO(fbarchard): halfstride instead of halfwidth
case FOURCC_I420: case FOURCC_I420:
case FOURCC_YV12: { case FOURCC_YV12: {
int halfwidth = (width + 1) / 2; int halfwidth = (width + 1) / 2;
...@@ -195,6 +207,24 @@ int ConvertFromI420(const uint8* y, int y_stride, ...@@ -195,6 +207,24 @@ int ConvertFromI420(const uint8* y, int y_stride,
return 0; return 0;
} }
// Convert I420 to specified format.
// TODO(fbarchard): sample_size should be used to ensure the low levels do
// not read outside the buffer provided. It is measured in bytes and is the
// size of the frame. With MJPEG it is the compressed size of the frame.
// TODO(fbarchard): add I400, I444 and RAW support.
int ConvertFromI420(const uint8* y, int y_stride,
const uint8* u, int u_stride,
const uint8* v, int v_stride,
uint8* dst_sample, size_t dst_sample_size,
int width, int height,
uint32 format) {
return ConvertFromI420Stride(y, y_stride,
u, u_stride,
v, v_stride,
dst_sample, 0, dst_sample_size,
width, height, format);
}
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
} // namespace libyuv } // namespace libyuv
......
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