Update of /cvsroot/playerstage/code/player/utils/playercam
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9713/utils/playercam
Modified Files:
Tag: b_thjc_dynamic_arrays
playercam.c
Log Message:
static array sizes removed from player
client library updated to use dynamic arrays
Index: playercam.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/utils/playercam/playercam.c,v
retrieving revision 1.14
retrieving revision 1.14.2.1
diff -C2 -d -r1.14 -r1.14.2.1
*** playercam.c 13 Nov 2006 18:03:13 -0000 1.14
--- playercam.c 10 Sep 2007 04:11:01 -0000 1.14.2.1
***************
*** 91,94 ****
--- 91,96 ----
#include <libplayerc/playerc.h>
+ #define PLAYERCAM_MAX_BLOBS 256
+
char g_hostname[255] = "localhost";
int32_t g_port = 6665;
***************
*** 102,106 ****
playerc_blobfinder_t* g_blobfinder = NULL;
! player_blobfinder_blob_t g_blobs[PLAYER_BLOBFINDER_MAX_BLOBS];
uint16_t g_blob_count = 0;
--- 104,108 ----
playerc_blobfinder_t* g_blobfinder = NULL;
! player_blobfinder_blob_t g_blobs[PLAYERCAM_MAX_BLOBS];
uint16_t g_blob_count = 0;
***************
*** 111,115 ****
uint16_t g_height = 0;
GdkPixbuf* g_pixbuf = NULL;
! guchar g_img[PLAYER_CAMERA_IMAGE_SIZE];
int player_init(int argc, char *argv[]);
--- 113,118 ----
uint16_t g_height = 0;
GdkPixbuf* g_pixbuf = NULL;
! size_t allocated_size = 0;
! guchar *g_img = NULL;
int player_init(int argc, char *argv[]);
***************
*** 415,424 ****
g_width = g_camera->width;
g_height = g_camera->height;
}
else // try the blobfinder
{
- // set the image data to 0 since we don't have a camera
- memset(g_img, 128, PLAYER_CAMERA_IMAGE_SIZE);
-
g_print("blobfinder: [w %d h %d]\n",
g_blobfinder->width, g_blobfinder->height);
--- 418,429 ----
g_width = g_camera->width;
g_height = g_camera->height;
+ if (allocated_size != usize)
+ {
+ g_img = realloc(g_img, usize);
+ allocated_size = usize;
+ }
}
else // try the blobfinder
{
g_print("blobfinder: [w %d h %d]\n",
g_blobfinder->width, g_blobfinder->height);
***************
*** 426,429 ****
--- 431,442 ----
g_width = g_blobfinder->width;
g_height = g_blobfinder->height;
+ usize = g_width * g_height * 3;
+ if (allocated_size != usize)
+ {
+ g_img = realloc(g_img, usize);
+ allocated_size = usize;
+ }
+ // set the image data to 0 since we don't have a camera
+ memset(g_img, 128, usize);
}
}
***************
*** 453,456 ****
--- 466,470 ----
switch (g_camera->format)
{
+ assert(allocated_size > g_camera->image_count*3);
case PLAYER_CAMERA_FORMAT_MONO8:
// we should try to use the alpha layer,
***************
*** 459,477 ****
for (i=0;i<g_camera->image_count;++i)
{
memcpy(g_img+i*3, g_camera->image+i, 3);
}
break;
case PLAYER_CAMERA_FORMAT_MONO16:
! {
! int j = 0;
! // Transform to MONO8
! for (i = 0; i < g_camera->image_count; i++, j+=2)
! {
! g_img[i*3+1] = g_img[i*3+2] = g_img[i*3+3] =
! ((unsigned char)(g_camera->image[j]) << 8) +
! (unsigned char)(g_camera->image[j+1]);
! }
break;
! }
case PLAYER_CAMERA_FORMAT_RGB888:
// do nothing
--- 473,492 ----
for (i=0;i<g_camera->image_count;++i)
{
+
memcpy(g_img+i*3, g_camera->image+i, 3);
}
break;
case PLAYER_CAMERA_FORMAT_MONO16:
! {
! int j = 0;
! // Transform to MONO8
! for (i = 0; i < g_camera->image_count; i++, j+=2)
! {
! g_img[i*3+1] = g_img[i*3+2] = g_img[i*3+3] =
! ((unsigned char)(g_camera->image[j]) << 8) +
! (unsigned char)(g_camera->image[j+1]);
! }
break;
! }
case PLAYER_CAMERA_FORMAT_RGB888:
// do nothing
***************
*** 485,501 ****
g_height = g_camera->height;
}
- else
- {
- // set the image data to 0 since we don't have a camera
- memset(g_img, 128, PLAYER_CAMERA_IMAGE_SIZE);
- }
if (NULL != g_blobfinder)
{
memcpy(g_blobs,
g_blobfinder->blobs,
! g_blobfinder->blobs_count*sizeof(player_blobfinder_blob_t));
- g_blob_count = g_blobfinder->blobs_count;
if ((g_width != g_blobfinder->width) ||
--- 500,511 ----
g_height = g_camera->height;
}
if (NULL != g_blobfinder)
{
+ g_blob_count = PLAYERCAM_MAX_BLOBS < g_blobfinder->blobs_count ?
PLAYERCAM_MAX_BLOBS : g_blobfinder->blobs_count;
memcpy(g_blobs,
g_blobfinder->blobs,
! g_blob_count*sizeof(player_blobfinder_blob_t));
if ((g_width != g_blobfinder->width) ||
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit