|
From: libvidcap c. m. <lib...@li...> - 2007-09-11 15:31:21
|
Revision: 14
http://libvidcap.svn.sourceforge.net/libvidcap/?rev=14&view=rev
Author: bcholew
Date: 2007-09-11 08:31:16 -0700 (Tue, 11 Sep 2007)
Log Message:
-----------
Remove all destination buffer size checks in conversion functions. Replace with notices for each class of conversion function.
Modified Paths:
--------------
trunk/examples/vidcapTester/Grabber.cpp
trunk/include/vidcap/converters.h
trunk/src/conv.c
trunk/src/conv.h
trunk/src/conv_to_i420.c
trunk/src/conv_to_rgb.c
trunk/src/conv_to_yuy2.c
trunk/src/sapi.c
Modified: trunk/examples/vidcapTester/Grabber.cpp
===================================================================
--- trunk/examples/vidcapTester/Grabber.cpp 2007-09-11 14:46:28 UTC (rev 13)
+++ trunk/examples/vidcapTester/Grabber.cpp 2007-09-11 15:31:16 UTC (rev 14)
@@ -134,13 +134,13 @@
rgb_buf.resize(width_ * height_ * 4);
vidcap_i420_to_rgb32(width_, height_, cap_info->video_data,
- rgb_buf.data(), rgb_buf.size());
+ rgb_buf.data());
break;
case VIDCAP_FOURCC_YUY2:
rgb_buf.resize(width_ * height_ * 4);
vidcap_yuy2_to_rgb32(width_, height_, cap_info->video_data,
- rgb_buf.data(), rgb_buf.size());
+ rgb_buf.data());
break;
Modified: trunk/include/vidcap/converters.h
===================================================================
--- trunk/include/vidcap/converters.h 2007-09-11 14:46:28 UTC (rev 13)
+++ trunk/include/vidcap/converters.h 2007-09-11 15:31:16 UTC (rev 14)
@@ -32,27 +32,27 @@
int
vidcap_i420_to_rgb32(int width, int height, const char * src,
- char * dest, int dest_size);
+ char * dest);
int
vidcap_i420_to_yuy2(int width, int height, const char * src,
- char * dest, int dest_size);
+ char * dest);
int
vidcap_yuy2_to_i420(int width, int height, const char * src,
- char * dest, int dest_size);
+ char * dest);
int
vidcap_yuy2_to_rgb32(int width, int height, const char * src,
- char * dest, int dest_size);
+ char * dest);
int
vidcap_rgb32_to_i420(int width, int height, const char * src,
- char * dest, int dest_size);
+ char * dest);
int
vidcap_rgb32_to_yuy2(int width, int height, const char * src,
- char * dest, int dest_size);
+ char * dest);
#ifdef __cplusplus
}
Modified: trunk/src/conv.c
===================================================================
--- trunk/src/conv.c 2007-09-11 14:46:28 UTC (rev 13)
+++ trunk/src/conv.c 2007-09-11 15:31:16 UTC (rev 14)
@@ -25,11 +25,11 @@
#include "conv.h"
-int conv_2vuy_to_i420(int w, int h, const char * s, char * d, int ds);
-int conv_2vuy_to_yuy2(int w, int h, const char * s, char * d, int ds);
-int conv_rgb24_to_rgb32(int w, int h, const char * s, char * d, int ds);
-int conv_yvu9_to_i420(int w, int h, const char * s, char * d, int ds);
-int conv_bottom_up_rgb24_to_rgb32(int w, int h, const char * s, char * d, int ds);
+int conv_2vuy_to_i420(int w, int h, const char * s, char * d);
+int conv_2vuy_to_yuy2(int w, int h, const char * s, char * d);
+int conv_rgb24_to_rgb32(int w, int h, const char * s, char * d);
+int conv_yvu9_to_i420(int w, int h, const char * s, char * d);
+int conv_bottom_up_rgb24_to_rgb32(int w, int h, const char * s, char * d);
struct conv_info
{
Modified: trunk/src/conv.h
===================================================================
--- trunk/src/conv.h 2007-09-11 14:46:28 UTC (rev 13)
+++ trunk/src/conv.h 2007-09-11 15:31:16 UTC (rev 14)
@@ -39,7 +39,7 @@
};
typedef int (*conv_func)(int width, int height,
- const char * src, char * dst, int dst_size);
+ const char * src, char * dst);
#ifdef __cplusplus
extern "C" {
Modified: trunk/src/conv_to_i420.c
===================================================================
--- trunk/src/conv_to_i420.c 2007-09-11 14:46:28 UTC (rev 13)
+++ trunk/src/conv_to_i420.c 2007-09-11 15:31:16 UTC (rev 14)
@@ -27,10 +27,13 @@
#include <vidcap/converters.h>
#include "logging.h"
+/* NOTE: size of dest must be >= width * height * 3 / 2
+ */
+
int
vidcap_rgb32_to_i420(int width, int height,
const char * src,
- char * dst, int dest_size)
+ char * dst)
{
log_error("vidcap_rgb32_to_i420() not implemented\n");
return -1;
@@ -39,7 +42,7 @@
int
vidcap_yuy2_to_i420(int width, int height,
const char * src,
- char * dst, int dest_size)
+ char * dst)
{
/* convert from a packed structure to a planar structure */
char * dst_y_even = dst;
@@ -51,9 +54,6 @@
int i, j;
- if ( dest_size < width * height * 3 / 2 )
- return -1;
-
/* yuy2 has a vertical sampling period (for u and v)
* half that for i420. Will toss half of the
* U and V data during repackaging.
@@ -88,7 +88,7 @@
int
conv_2vuy_to_i420(int width, int height,
const char * src,
- char * dst, int dest_size)
+ char * dst)
{
char * dst_y_even = dst;
char * dst_y_odd = dst + width;
@@ -99,9 +99,6 @@
int i, j;
- if ( dest_size < width * height * 3 / 2 )
- return -1;
-
for ( i = 0; i < height / 2; ++i )
{
for ( j = 0; j < width / 2; ++j )
@@ -132,7 +129,7 @@
int
conv_yvu9_to_i420(int width, int height,
const char * src,
- char * dst, int dest_size)
+ char * dst)
{
char * dst_y = dst;
char * dst_u_even = dst + width * height;
@@ -145,9 +142,6 @@
int i, j;
- if ( dest_size < width * height * 3 / 2 )
- return -1;
-
memcpy(dst_y, src_y, height * width);
for ( i = 0; i < height / 4; ++i )
Modified: trunk/src/conv_to_rgb.c
===================================================================
--- trunk/src/conv_to_rgb.c 2007-09-11 14:46:28 UTC (rev 13)
+++ trunk/src/conv_to_rgb.c 2007-09-11 15:31:16 UTC (rev 14)
@@ -23,7 +23,6 @@
*
*/
-//#include <string.h>
#include <vidcap/converters.h>
enum {
@@ -98,9 +97,13 @@
*
* Based on the formulas found at http://en.wikipedia.org/wiki/YUV
*/
+
+/* NOTE: size of dest buffer must be >= width * height * 4
+ */
+
int
vidcap_i420_to_rgb32(int width, int height, const char * src,
- char * dest, int dest_size)
+ char * dest)
{
const unsigned char * y_even;
const unsigned char * y_odd;
@@ -110,9 +113,6 @@
unsigned int *dst_odd;
int i, j;
- if ( dest_size < width * height * 4 )
- return -1;
-
if ( !tables_initialized )
init_yuv2rgb_tables();
@@ -159,14 +159,11 @@
* chroma (Cr and Cb aka v and u) sample use for both pixels.
*/
int vidcap_yuy2_to_rgb32(int width, int height, const char * src,
- char * dest, int dest_size)
+ char * dest)
{
unsigned int * d = (unsigned int *)dest;
int i, j;
- if ( dest_size < width * height * 4 )
- return -1;
-
if ( !tables_initialized )
init_yuv2rgb_tables();
@@ -193,14 +190,11 @@
}
int conv_rgb24_to_rgb32(int width, int height, const char * src,
- char * dest, int dest_size)
+ char * dest)
{
int i;
unsigned int * d = (unsigned int *)dest;
- if ( dest_size < width * height * 4 )
- return -1;
-
for ( i = 0; i < width * height; ++i )
{
*d = 0xff000000;
@@ -214,15 +208,12 @@
int conv_bottom_up_rgb24_to_rgb32(int width, int height,
const char * src,
- char * dest, int dest_size)
+ char * dest)
{
int i;
unsigned int * d = (unsigned int *)dest;
const unsigned char *src_end = src - 1 + width * height * 3;
- if ( dest_size < width * height * 4 )
- return -1;
-
for ( i = 0; i < width * height; ++i )
{
*d = 0xff000000;
Modified: trunk/src/conv_to_yuy2.c
===================================================================
--- trunk/src/conv_to_yuy2.c 2007-09-11 14:46:28 UTC (rev 13)
+++ trunk/src/conv_to_yuy2.c 2007-09-11 15:31:16 UTC (rev 14)
@@ -26,9 +26,12 @@
#include <vidcap/converters.h>
#include "logging.h"
+/* NOTE: size of dest buffer must be >= width * height * 2
+ */
+
int
vidcap_rgb32_to_yuy2(int width, int height, const char * src,
- char * dest, int dest_size)
+ char * dest)
{
log_error("vidcap_rgb32_to_yuy2() not implemented\n");
return -1;
@@ -36,7 +39,7 @@
int
vidcap_i420_to_yuy2(int width, int height, const char * src,
- char * dest, int dest_size)
+ char * dest)
{
log_error("vidcap_i420_to_yuy2() not implemented\n");
return -1;
@@ -44,15 +47,12 @@
int
conv_2vuy_to_yuy2(int width, int height, const char * src,
- char * dest, int dest_size)
+ char * dest)
{
int i;
unsigned int * d = (unsigned int *)dest;
const unsigned int * s = (const unsigned int *)src;
- if ( dest_size < width * height * 2 )
- return -1;
-
for ( i = 0; i < width * height / 2; ++i )
{
*d++ = ((*s & 0xff000000) >> 8) |
Modified: trunk/src/sapi.c
===================================================================
--- trunk/src/sapi.c 2007-09-11 14:46:28 UTC (rev 13)
+++ trunk/src/sapi.c 2007-09-11 15:31:16 UTC (rev 14)
@@ -236,8 +236,7 @@
src_ctx->fmt_nominal.width,
src_ctx->fmt_nominal.height,
video_data,
- src_ctx->fmt_conv_buf,
- src_ctx->fmt_conv_buf_size) )
+ src_ctx->fmt_conv_buf) )
{
log_error("failed format conversion\n");
cap_info.error_status = -1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|