|
From: libvidcap c. m. <lib...@li...> - 2007-09-11 14:46:32
|
Revision: 13
http://libvidcap.svn.sourceforge.net/libvidcap/?rev=13&view=rev
Author: bcholew
Date: 2007-09-11 07:46:28 -0700 (Tue, 11 Sep 2007)
Log Message:
-----------
Add format VIDCAP_FOURCC_BOTTOM_UP_RGB24 and function conv_bottom_up_rgb24_to_rgb32() for DirectShow-derived images. Add destination buffer size checks on some of the conversion functions. Remove unused mapVidcapFourccToDirectShowMediaType().
Modified Paths:
--------------
trunk/src/conv.c
trunk/src/conv.h
trunk/src/conv_to_rgb.c
trunk/src/conv_to_yuy2.c
trunk/src/directshow/DirectShowSource.cpp
trunk/src/directshow/DirectShowSource.h
trunk/src/vidcap.c
Modified: trunk/src/conv.c
===================================================================
--- trunk/src/conv.c 2007-09-11 13:29:44 UTC (rev 12)
+++ trunk/src/conv.c 2007-09-11 14:46:28 UTC (rev 13)
@@ -29,6 +29,7 @@
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);
struct conv_info
{
@@ -49,6 +50,7 @@
{ VIDCAP_FOURCC_2VUY, VIDCAP_FOURCC_YUY2, conv_2vuy_to_yuy2 },
{ VIDCAP_FOURCC_2VUY, VIDCAP_FOURCC_I420, conv_2vuy_to_i420 },
{ VIDCAP_FOURCC_RGB24, VIDCAP_FOURCC_RGB32, conv_rgb24_to_rgb32 },
+ { VIDCAP_FOURCC_BOTTOM_UP_RGB24, VIDCAP_FOURCC_RGB32, conv_bottom_up_rgb24_to_rgb32 },
{ VIDCAP_FOURCC_YVU9, VIDCAP_FOURCC_I420, conv_yvu9_to_i420 },
};
Modified: trunk/src/conv.h
===================================================================
--- trunk/src/conv.h 2007-09-11 13:29:44 UTC (rev 12)
+++ trunk/src/conv.h 2007-09-11 14:46:28 UTC (rev 13)
@@ -31,10 +31,11 @@
enum vidcap_fourccs_extra
{
- VIDCAP_FOURCC_RGB24 = 200,
- VIDCAP_FOURCC_RGB555 = 201,
- VIDCAP_FOURCC_YVU9 = 202,
- VIDCAP_FOURCC_2VUY = 203,
+ VIDCAP_FOURCC_RGB555 = 200,
+ VIDCAP_FOURCC_YVU9 = 201,
+ VIDCAP_FOURCC_2VUY = 202,
+ VIDCAP_FOURCC_RGB24 = 203,
+ VIDCAP_FOURCC_BOTTOM_UP_RGB24 = 204,
};
typedef int (*conv_func)(int width, int height,
Modified: trunk/src/conv_to_rgb.c
===================================================================
--- trunk/src/conv_to_rgb.c 2007-09-11 13:29:44 UTC (rev 12)
+++ trunk/src/conv_to_rgb.c 2007-09-11 14:46:28 UTC (rev 13)
@@ -23,6 +23,7 @@
*
*/
+//#include <string.h>
#include <vidcap/converters.h>
enum {
@@ -163,6 +164,9 @@
unsigned int * d = (unsigned int *)dest;
int i, j;
+ if ( dest_size < width * height * 4 )
+ return -1;
+
if ( !tables_initialized )
init_yuv2rgb_tables();
@@ -194,6 +198,9 @@
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;
@@ -204,3 +211,25 @@
return 0;
}
+
+int conv_bottom_up_rgb24_to_rgb32(int width, int height,
+ const char * src,
+ char * dest, int dest_size)
+{
+ 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;
+ *d |= ((unsigned char)(*src_end--)) << 16; // red
+ *d |= ((unsigned char)(*src_end--)) << 8; // green
+ *d++ |= ((unsigned char)(*src_end--)); // blue
+ }
+
+ return 0;
+}
Modified: trunk/src/conv_to_yuy2.c
===================================================================
--- trunk/src/conv_to_yuy2.c 2007-09-11 13:29:44 UTC (rev 12)
+++ trunk/src/conv_to_yuy2.c 2007-09-11 14:46:28 UTC (rev 13)
@@ -50,6 +50,9 @@
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/directshow/DirectShowSource.cpp
===================================================================
--- trunk/src/directshow/DirectShowSource.cpp 2007-09-11 13:29:44 UTC (rev 12)
+++ trunk/src/directshow/DirectShowSource.cpp 2007-09-11 14:46:28 UTC (rev 13)
@@ -776,7 +776,7 @@
fourcc = VIDCAP_FOURCC_YUY2;
break;
case 0xe436eb7d:
- fourcc = VIDCAP_FOURCC_RGB24;
+ fourcc = VIDCAP_FOURCC_BOTTOM_UP_RGB24;
break;
case 0xe436eb7c:
fourcc = VIDCAP_FOURCC_RGB555;
@@ -791,26 +791,3 @@
return 0;
}
-
-int
-DirectShowSource::mapVidcapFourccToDirectShowMediaType(int fourcc, DWORD & data)
-{
- switch ( fourcc )
- {
- case VIDCAP_FOURCC_RGB32:
- data = 0xe436eb7e;
- break;
- case VIDCAP_FOURCC_I420:
- data = 0x30323449; // '024I' aka I420
- break;
- case VIDCAP_FOURCC_YUY2:
- data = 0x32595559;
- break;
- default:
- log_warn("failed to map '%s' to DShow media type\n",
- vidcap_fourcc_string_get(fourcc));
- return -1;
- }
-
- return 0;
-}
Modified: trunk/src/directshow/DirectShowSource.h
===================================================================
--- trunk/src/directshow/DirectShowSource.h 2007-09-11 13:29:44 UTC (rev 12)
+++ trunk/src/directshow/DirectShowSource.h 2007-09-11 14:46:28 UTC (rev 13)
@@ -81,7 +81,6 @@
BufferCB( double dblSampleTime, BYTE * pBuffer, long lBufferSize );
static int mapDirectShowMediaTypeToVidcapFourcc(DWORD data, int & fourcc);
- static int mapVidcapFourccToDirectShowMediaType(int fourcc, DWORD & data);
private:
struct sapi_src_context * sourceContext_;
Modified: trunk/src/vidcap.c
===================================================================
--- trunk/src/vidcap.c 2007-09-11 13:29:44 UTC (rev 12)
+++ trunk/src/vidcap.c 2007-09-11 14:46:28 UTC (rev 13)
@@ -500,6 +500,8 @@
return "rgb32";
case VIDCAP_FOURCC_RGB24:
return "rgb24";
+ case VIDCAP_FOURCC_BOTTOM_UP_RGB24:
+ return "bottom_up_rgb24";
case VIDCAP_FOURCC_RGB555:
return "rgb555";
case VIDCAP_FOURCC_YVU9:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|