Revise method to cast variables for mem functions

This commit is contained in:
Mr-Dave
2024-07-24 19:25:25 -06:00
parent e3bcf5c4b5
commit 5b3bb97d0c
19 changed files with 197 additions and 236 deletions

View File

@@ -216,7 +216,7 @@ static int alg_labeling(ctx_dev *cam)
imgs->labels_above = 0;
/* Init: 0 means no label set / not checked. */
mymemset(labels, 0,(uint)(width * height) * sizeof(*labels));
memset(labels, 0,(uint)(width * height) * sizeof(*labels));
pixelpos = 0;
for (iy = 0; iy < height - 1; iy++) {
@@ -284,8 +284,8 @@ static int alg_dilate9(unsigned char *img, int width, int height, void *buffer)
row3 = row2 + width;
/* Init rows 2 and 3. */
mymemset(row2, 0, width);
mymemcpy(row3, img, width);
memset(row2, 0, (uint)width);
memcpy(row3, img, (uint)width);
/* Pointer to the current row in img. */
yp = img;
@@ -299,9 +299,9 @@ static int alg_dilate9(unsigned char *img, int width, int height, void *buffer)
/* If we're at the last row, fill with zeros, otherwise copy from img. */
if (y == height - 1) {
mymemset(row3, 0, width);
memset(row3, 0, (uint)width);
} else {
mymemcpy(row3, yp + width, width);
memcpy(row3, yp + width, (uint)width);
}
/* Init slots 0 and 1 in the moving window. */
@@ -367,8 +367,8 @@ static int alg_dilate5(unsigned char *img, int width, int height, void *buffer)
row3 = row2 + width;
/* Init rows 2 and 3. */
mymemset(row2, 0, width);
mymemcpy(row3, img, width);
memset(row2, 0, (uint)width);
memcpy(row3, img, (uint)width);
/* Pointer to the current row in img. */
yp = img;
@@ -382,9 +382,9 @@ static int alg_dilate5(unsigned char *img, int width, int height, void *buffer)
/* If we're at the last row, fill with zeros, otherwise copy from img. */
if (y == height - 1) {
mymemset(row3, 0, width);
memset(row3, 0, (uint)width);
} else {
mymemcpy(row3, yp + width, width);
memcpy(row3, yp + width, (uint)width);
}
/* Init mem and set blob to force an evaluation of the entire + shape. */
@@ -428,17 +428,17 @@ static int alg_erode9(unsigned char *img, int width, int height, void *buffer, u
Row1 = (char *)buffer;
Row2 = Row1 + width;
Row3 = Row1 + 2 * width;
mymemset(Row2, flag, width);
mymemcpy(Row3, img, width);
memset(Row2, flag, (uint)width);
memcpy(Row3, img, (uint)width);
for (y = 0; y < height; y++) {
mymemcpy(Row1, Row2, width);
mymemcpy(Row2, Row3, width);
memcpy(Row1, Row2, (uint)width);
memcpy(Row2, Row3, (uint)width);
if (y == height - 1) {
mymemset(Row3, flag, width);
memset(Row3, flag, (uint)width);
} else {
mymemcpy(Row3, img + (y + 1) * width, width);
memcpy(Row3, img + (y + 1) * width, (uint)width);
}
for (i = width - 2; i >= 1; i--) {
@@ -471,17 +471,17 @@ static int alg_erode5(unsigned char *img, int width, int height, void *buffer, u
Row1 = (char *)buffer;
Row2 = Row1 + width;
Row3 = Row1 + 2 * width;
mymemset(Row2, flag, width);
mymemcpy(Row3, img, width);
memset(Row2, flag, (uint)width);
memcpy(Row3, img, (uint)width);
for (y = 0; y < height; y++) {
mymemcpy(Row1, Row2, width);
mymemcpy(Row2, Row3, width);
memcpy(Row1, Row2, (uint)width);
memcpy(Row2, Row3, (uint)width);
if (y == height - 1) {
mymemset(Row3, flag, width);
memset(Row3, flag, (uint)width);
} else {
mymemcpy(Row3, img + (y + 1) * width, width);
memcpy(Row3, img + (y + 1) * width, (uint)width);
}
for (i = width - 2; i >= 1; i--) {
@@ -633,8 +633,8 @@ static void alg_diff_nomask(ctx_dev *cam)
int noise = cam->noise;
int lrgchg = cam->conf->threshold_ratio_change;
mymemset(out + imgsz, 128, (imgsz / 2));
mymemset(out, 0, imgsz);
memset(out + imgsz, 128, (uint)(imgsz / 2));
memset(out, 0, (uint)imgsz);
for (i = 0; i < imgsz; i++) {
curdiff = (*ref - *new_img);
@@ -676,8 +676,8 @@ static void alg_diff_mask(ctx_dev *cam)
int noise = cam->noise;
int lrgchg = cam->conf->threshold_ratio_change;
mymemset(out + imgsz, 128, (imgsz / 2));
mymemset(out, 0, imgsz);
memset(out + imgsz, 128, (uint)(imgsz / 2));
memset(out, 0, (uint)imgsz);
for (i = 0; i < imgsz; i++) {
curdiff = (*ref - *new_img);
@@ -729,8 +729,8 @@ static void alg_diff_smart(ctx_dev *cam)
int lrgchg = cam->conf->threshold_ratio_change;
imgsz = cam->imgs.motionsize;
mymemset(out + imgsz, 128, (imgsz / 2));
mymemset(out, 0, imgsz);
memset(out + imgsz, 128, (uint)(imgsz / 2));
memset(out, 0, (uint)imgsz);
for (i = 0; i < imgsz; i++) {
curdiff = (*ref - *new_img);
@@ -788,8 +788,8 @@ static void alg_diff_masksmart(ctx_dev *cam)
int lrgchg = cam->conf->threshold_ratio_change;
imgsz= cam->imgs.motionsize;
mymemset(out + imgsz, 128, (imgsz / 2));
mymemset(out, 0, imgsz);
memset(out + imgsz, 128, ((uint)imgsz / 2));
memset(out, 0, (uint)imgsz);
for (i = 0; i < imgsz; i++) {
curdiff = (*ref - *new_img);
@@ -966,9 +966,9 @@ void alg_update_reference_frame(ctx_dev *cam, int action)
} else { /* action == RESET_REF_FRAME - also used to initialize the frame at startup. */
/* Copy fresh image */
mymemcpy(cam->imgs.ref, cam->imgs.image_vprvcy, cam->imgs.size_norm);
memcpy(cam->imgs.ref, cam->imgs.image_vprvcy, (uint)cam->imgs.size_norm);
/* Reset static objects */
mymemset(cam->imgs.ref_dyn, 0
memset(cam->imgs.ref_dyn, 0
,(uint)cam->imgs.motionsize * sizeof(*cam->imgs.ref_dyn));
}
}
@@ -978,7 +978,7 @@ void alg_new_update_frame(ctx_dev *cam)
{
/* There used to be a lot more to this function before.....*/
mymemcpy(cam->imgs.ref, cam->imgs.image_vprvcy, cam->imgs.size_norm);
memcpy(cam->imgs.ref, cam->imgs.image_vprvcy, (uint)cam->imgs.size_norm);
}

View File

@@ -533,7 +533,7 @@ static void algsec_load_params(ctx_dev *cam)
cam->algsec->height = cam->imgs.height;
cam->algsec->width = cam->imgs.width;
cam->algsec->models.method = cam->conf->secondary_method;
cam->algsec->image_norm = (unsigned char*)mymalloc(cam->imgs.size_norm);
cam->algsec->image_norm = (unsigned char*)mymalloc((size_t)cam->imgs.size_norm);
cam->algsec->frame_missed = 0;
cam->algsec->too_slow = 0;
cam->algsec->detecting = false;
@@ -714,9 +714,9 @@ void algsec_detect(ctx_dev *cam)
if (cam->algsec->detecting){
cam->algsec->frame_missed++;
} else {
mymemcpy(cam->algsec->image_norm
memcpy(cam->algsec->image_norm
, cam->imgs.image_virgin
, cam->imgs.size_norm);
, (uint)cam->imgs.size_norm);
/*Set the bool to detect on the new image and reset interval */
cam->algsec->detecting = true;

View File

@@ -170,10 +170,10 @@ struct ctx_exif_info {
char *description;
char *datetime;
char *subtime;
int ifd0_tagcount;
int ifd1_tagcount;
uint ifd0_tagcount;
uint ifd1_tagcount;
uint datasize;
int ifds_size;
uint ifds_size;
struct tiff_writing writing;
};
@@ -334,7 +334,7 @@ void jpgutl_exif_writeifd1(ctx_exif_info *exif_info)
uint jpgutl_exif(u_char **exif, ctx_dev *cam, timespec *ts_in1, ctx_coord *box)
{
struct ctx_exif_info *exif_info;
int buffer_size;
uint buffer_size;
uint marker_len;
JOCTET *marker;
@@ -353,7 +353,7 @@ uint jpgutl_exif(u_char **exif, ctx_dev *cam, timespec *ts_in1, ctx_coord *box)
}
buffer_size = 14 + /* EXIF and TIFF headers */
exif_info->ifds_size + (int)exif_info->datasize;
exif_info->ifds_size + exif_info->datasize;
marker =(JOCTET *)mymalloc(buffer_size);
memcpy(marker, exif_marker_start, 14); /* EXIF and TIFF headers */

View File

@@ -815,7 +815,7 @@ int cls_libcam::next(ctx_image_data *img_data)
if (req_queue.empty() == false) {
Request *request = this->req_queue.front();
mymemcpy(img_data->image_norm, membuf.buf, membuf.bufsz);
memcpy(img_data->image_norm, membuf.buf, (uint)membuf.bufsz);
this->req_queue.pop();
request->reuse(Request::ReuseBuffers);

View File

@@ -53,11 +53,11 @@ static void mlp_ring_resize(ctx_dev *cam)
tmp =(ctx_image_data*) mymalloc((uint)new_size * sizeof(ctx_image_data));
for(i = 0; i < new_size; i++) {
tmp[i].image_norm =(unsigned char*) mymalloc(cam->imgs.size_norm);
mymemset(tmp[i].image_norm, 0x80, cam->imgs.size_norm);
tmp[i].image_norm =(unsigned char*) mymalloc((uint)cam->imgs.size_norm);
memset(tmp[i].image_norm, 0x80, (uint)cam->imgs.size_norm);
if (cam->imgs.size_high > 0) {
tmp[i].image_high =(unsigned char*) mymalloc(cam->imgs.size_high);
mymemset(tmp[i].image_high, 0x80, cam->imgs.size_high);
tmp[i].image_high =(unsigned char*) mymalloc((uint)cam->imgs.size_high);
memset(tmp[i].image_high, 0x80, (uint)cam->imgs.size_high);
}
}
@@ -484,8 +484,8 @@ static void mlp_init_firstimage(ctx_dev *cam)
}
MOTPLS_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s", msg);
for (indx = 0; indx<cam->imgs.ring_size; indx++) {
mymemset(cam->imgs.image_ring[indx].image_norm
, 0x80, cam->imgs.size_norm);
memset(cam->imgs.image_ring[indx].image_norm
, 0x80, (uint)cam->imgs.size_norm);
cam->draw->text(cam->imgs.image_ring[indx].image_norm
, cam->imgs.width, cam->imgs.height
, 10, 20 * cam->text_scale
@@ -553,28 +553,28 @@ static void mlp_init_areadetect(ctx_dev *cam)
/** Allocate the required buffers */
static void mlp_init_buffers(ctx_dev *cam)
{
cam->imgs.ref =(unsigned char*) mymalloc(cam->imgs.size_norm);
cam->imgs.image_motion.image_norm = (unsigned char*)mymalloc(cam->imgs.size_norm);
cam->imgs.ref =(unsigned char*) mymalloc((uint)cam->imgs.size_norm);
cam->imgs.image_motion.image_norm = (unsigned char*)mymalloc((uint)cam->imgs.size_norm);
cam->imgs.ref_dyn =(int*) mymalloc((uint)cam->imgs.motionsize * sizeof(*cam->imgs.ref_dyn));
cam->imgs.image_virgin =(unsigned char*) mymalloc(cam->imgs.size_norm);
cam->imgs.image_vprvcy = (unsigned char*)mymalloc(cam->imgs.size_norm);
cam->imgs.smartmask =(unsigned char*) mymalloc(cam->imgs.motionsize);
cam->imgs.smartmask_final =(unsigned char*) mymalloc(cam->imgs.motionsize);
cam->imgs.image_virgin =(unsigned char*) mymalloc((uint)cam->imgs.size_norm);
cam->imgs.image_vprvcy = (unsigned char*)mymalloc((uint)cam->imgs.size_norm);
cam->imgs.smartmask =(unsigned char*) mymalloc((uint)cam->imgs.motionsize);
cam->imgs.smartmask_final =(unsigned char*) mymalloc((uint)cam->imgs.motionsize);
cam->imgs.smartmask_buffer =(int*) mymalloc((uint)cam->imgs.motionsize * sizeof(*cam->imgs.smartmask_buffer));
cam->imgs.labels =(int*)mymalloc((uint)cam->imgs.motionsize * sizeof(*cam->imgs.labels));
cam->imgs.labelsize =(int*) mymalloc((uint)(cam->imgs.motionsize/2+1) * sizeof(*cam->imgs.labelsize));
cam->imgs.image_preview.image_norm =(unsigned char*) mymalloc(cam->imgs.size_norm);
cam->imgs.common_buffer =(unsigned char*) mymalloc(3 * cam->imgs.width * cam->imgs.height);
cam->imgs.image_secondary =(unsigned char*) mymalloc(3 * cam->imgs.width * cam->imgs.height);
cam->imgs.image_preview.image_norm =(unsigned char*) mymalloc((uint)cam->imgs.size_norm);
cam->imgs.common_buffer =(unsigned char*) mymalloc((uint)(3 * cam->imgs.width * cam->imgs.height));
cam->imgs.image_secondary =(unsigned char*) mymalloc((uint)(3 * cam->imgs.width * cam->imgs.height));
if (cam->imgs.size_high > 0) {
cam->imgs.image_preview.image_high =(unsigned char*) mymalloc(cam->imgs.size_high);
cam->imgs.image_preview.image_high =(unsigned char*) mymalloc((uint)cam->imgs.size_high);
} else {
cam->imgs.image_preview.image_high = NULL;
}
mymemset(cam->imgs.smartmask, 0, cam->imgs.motionsize);
mymemset(cam->imgs.smartmask_final, 255, cam->imgs.motionsize);
mymemset(cam->imgs.smartmask_buffer, 0, (uint)cam->imgs.motionsize * sizeof(*cam->imgs.smartmask_buffer));
memset(cam->imgs.smartmask, 0, (uint)cam->imgs.motionsize);
memset(cam->imgs.smartmask_final, 255, (uint)cam->imgs.motionsize);
memset(cam->imgs.smartmask_buffer, 0, (uint)cam->imgs.motionsize * sizeof(*cam->imgs.smartmask_buffer));
}
/* Initialize loop values */
@@ -643,11 +643,13 @@ static void mlp_init_cam_start(ctx_dev *cam)
/* initialize reference images*/
static void mlp_init_ref(ctx_dev *cam)
{
mymemcpy(cam->imgs.image_virgin, cam->current_image->image_norm, cam->imgs.size_norm);
memcpy(cam->imgs.image_virgin, cam->current_image->image_norm
, (uint)cam->imgs.size_norm);
mlp_mask_privacy(cam);
mymemcpy(cam->imgs.image_vprvcy, cam->current_image->image_norm, cam->imgs.size_norm);
memcpy(cam->imgs.image_vprvcy, cam->current_image->image_norm
, (uint)cam->imgs.size_norm);
alg_update_reference_frame(cam, RESET_REF_FRAME);
}
@@ -926,9 +928,11 @@ static int mlp_capture(ctx_dev *cam)
}
}
cam->missing_frame_counter = 0;
mymemcpy(cam->imgs.image_virgin, cam->current_image->image_norm, cam->imgs.size_norm);
memcpy(cam->imgs.image_virgin, cam->current_image->image_norm
, (uint)cam->imgs.size_norm);
mlp_mask_privacy(cam);
mymemcpy(cam->imgs.image_vprvcy, cam->current_image->image_norm, cam->imgs.size_norm);
memcpy(cam->imgs.image_vprvcy, cam->current_image->image_norm
, (uint)cam->imgs.size_norm);
} else {
if (cam->connectionlosttime.tv_sec == 0) {
@@ -940,7 +944,8 @@ static int mlp_capture(ctx_dev *cam)
if ((cam->device_status == STATUS_OPENED) &&
(cam->missing_frame_counter <
(cam->conf->device_tmo * cam->conf->framerate))) {
mymemcpy(cam->current_image->image_norm, cam->imgs.image_vprvcy, cam->imgs.size_norm);
memcpy(cam->current_image->image_norm, cam->imgs.image_vprvcy
, (uint)cam->imgs.size_norm);
} else {
cam->lost_connection = 1;
if (cam->device_status == STATUS_OPENED) {
@@ -949,7 +954,7 @@ static int mlp_capture(ctx_dev *cam)
tmpin = "UNABLE TO OPEN VIDEO DEVICE\\nSINCE %Y-%m-%d %T";
}
mymemset(cam->current_image->image_norm, 0x80, cam->imgs.size_norm);
memset(cam->current_image->image_norm, 0x80, (uint)cam->imgs.size_norm);
cam->current_image->imgts =cam->connectionlosttime;
mystrftime(cam, tmpout, sizeof(tmpout), tmpin, NULL);
cam->draw->text(cam->current_image->image_norm
@@ -1419,8 +1424,8 @@ static void mlp_parmsupdate(ctx_dev *cam)
if (cam->conf->smart_mask_speed != cam->smartmask_speed ||
cam->smartmask_lastrate != cam->lastrate) {
if (cam->conf->smart_mask_speed == 0) {
mymemset(cam->imgs.smartmask, 0, cam->imgs.motionsize);
mymemset(cam->imgs.smartmask_final, 255, cam->imgs.motionsize);
memset(cam->imgs.smartmask, 0, (uint)cam->imgs.motionsize);
memset(cam->imgs.smartmask_final, 255, (uint)cam->imgs.motionsize);
}
cam->smartmask_lastrate = cam->lastrate;
cam->smartmask_speed = cam->conf->smart_mask_speed;

View File

@@ -59,9 +59,9 @@ void cls_movie::encode_nal()
if ((pkt->pts == 0) && (!(pkt->flags & AV_PKT_FLAG_KEY))) {
free_nal();
nal_info_len = pkt->size;
nal_info =(char*)mymalloc(nal_info_len);
nal_info =(char*)mymalloc((uint)nal_info_len);
if (nal_info) {
mymemcpy(nal_info, &pkt->data[0], nal_info_len);
memcpy(nal_info, &pkt->data[0], (uint)nal_info_len);
} else {
nal_info_len = 0;
}
@@ -69,7 +69,7 @@ void cls_movie::encode_nal()
int old_size = pkt->size;
av_grow_packet(pkt, nal_info_len);
memmove(&pkt->data[nal_info_len], &pkt->data[0],(uint)old_size);
mymemcpy(&pkt->data[0], nal_info, nal_info_len);
memcpy(&pkt->data[0], nal_info, (uint)nal_info_len);
free_nal();
}
}

View File

@@ -226,10 +226,11 @@ char *cls_netcam::url_match(regmatch_t m, const char *input)
if (m.rm_so != -1) {
len = m.rm_eo - m.rm_so;
if ((match =(char*) mymalloc(len + 1)) != NULL) {
strncpy(match, input + m.rm_so, (uint)len);
match[len] = '\0';
if (len > 0) {
if ((match =(char*) mymalloc(uint(len + 1))) != NULL) {
strncpy(match, input + m.rm_so, (uint)len);
match[len] = '\0';
}
}
}

View File

@@ -293,7 +293,7 @@ void cls_picture::save_yuv420p(FILE *fp, u_char *image, int width, int height
int sz, image_size;
image_size = (width * height * 3)/2;
u_char *buf =(u_char*) mymalloc(image_size);
u_char *buf =(u_char*) mymalloc((uint)image_size);
sz = jpgutl_put_yuv420p(buf, image_size, image, width, height
, cfg_picture_quality, cam ,ts1, box);
@@ -311,7 +311,7 @@ void cls_picture::save_grey(FILE *picture, u_char *image, int width, int height
image_size = (width * height * 3)/2;
u_char *buf =(u_char*) mymalloc(image_size);
u_char *buf =(u_char*) mymalloc((uint)image_size);
sz = jpgutl_put_grey(buf, image_size, image, width, height
, cfg_picture_quality, cam ,ts1, box);
@@ -483,13 +483,13 @@ void cls_picture::save_roi(char *file, u_char *image)
image_size = bx->width * bx->height;
buf =(u_char*) mymalloc(image_size);
img =(u_char*) mymalloc(image_size);
buf =(u_char*) mymalloc((uint)image_size);
img =(u_char*) mymalloc((uint)image_size);
for (indxh=bx->miny; indxh< bx->miny + bx->height; indxh++){
mymemcpy(img+((indxh - bx->miny)* bx->width)
memcpy(img+((indxh - bx->miny)* bx->width)
, image+(indxh*cam->imgs.width) + bx->minx
, bx->width);
, (uint)bx->width);
}
sz = jpgutl_put_grey(buf, image_size, img
@@ -557,7 +557,7 @@ u_char *cls_picture::load_pgm(FILE *picture, int width, int height)
** this image for masking privacy which needs the space for
** the cr / cb components
*/
image =(u_char*) mymalloc((mask_width * mask_height * 3) / 2);
image =(u_char*) mymalloc((uint)((mask_width * mask_height * 3) / 2));
for (y = 0; y < mask_height; y++) {
if ((int)fread(&image[y * mask_width], 1, (uint)mask_width, picture) != mask_width) {
@@ -578,7 +578,7 @@ u_char *cls_picture::load_pgm(FILE *picture, int width, int height)
,_("Attempting to resize mask image from %dx%d to %dx%d")
,mask_width, mask_height, width, height);
resized_image =(u_char*) mymalloc((width * height * 3) / 2);
resized_image =(u_char*) mymalloc((uint)((width * height * 3) / 2));
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
@@ -613,7 +613,7 @@ void cls_picture::write_mask(const char *file)
}
return;
}
mymemset(cam->imgs.image_motion.image_norm, 255, cam->imgs.motionsize); /* Initialize to unset */
memset(cam->imgs.image_motion.image_norm, 255, (uint)cam->imgs.motionsize); /* Initialize to unset */
/* Write pgm-header. */
fprintf(picture, "P5\n");
@@ -668,11 +668,11 @@ void cls_picture::save_preview()
cam->imgs.image_preview.image_high = image_high;
/* Copy the actual images for norm and high */
mymemcpy(cam->imgs.image_preview.image_norm
, cam->current_image->image_norm, cam->imgs.size_norm);
memcpy(cam->imgs.image_preview.image_norm
, cam->current_image->image_norm, (uint)cam->imgs.size_norm);
if (cam->imgs.size_high > 0) {
mymemcpy(cam->imgs.image_preview.image_high
, cam->current_image->image_high, cam->imgs.size_high);
memcpy(cam->imgs.image_preview.image_high
, cam->current_image->image_high, (uint)cam->imgs.size_high);
}
/*
@@ -716,13 +716,15 @@ void cls_picture::init_privacy()
cam->imgs.mask_privacy = load_pgm(picture, cam->imgs.width, cam->imgs.height);
/* We only need the "or" mask for the U & V chrominance area. */
cam->imgs.mask_privacy_uv =(u_char*) mymalloc((cam->imgs.height * cam->imgs.width) / 2);
cam->imgs.mask_privacy_uv =(u_char*) mymalloc((uint)
((cam->imgs.height * cam->imgs.width) / 2));
if (cam->imgs.size_high > 0) {
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO
,_("Opening high resolution privacy mask file"));
rewind(picture);
cam->imgs.mask_privacy_high = load_pgm(picture, cam->imgs.width_high, cam->imgs.height_high);
cam->imgs.mask_privacy_high_uv =(u_char*) mymalloc((cam->imgs.height_high * cam->imgs.width_high) / 2);
cam->imgs.mask_privacy_high_uv =(u_char*) mymalloc((uint)
((cam->imgs.height_high * cam->imgs.width_high) / 2));
}
myfclose(picture);

View File

@@ -191,7 +191,7 @@ void cls_rotate::process(ctx_image_data *img_data)
rot90cw(img, temp_buff, wh, width, height);
rot90cw(img + wh, temp_buff + wh, wh4, w2, h2);
rot90cw(img + wh + wh4, temp_buff + wh + wh4, wh4, w2, h2);
mymemcpy(img, temp_buff, size);
memcpy(img, temp_buff, (uint)size);
break;
case 180:
reverse_inplace_quad(img, wh);
@@ -202,7 +202,7 @@ void cls_rotate::process(ctx_image_data *img_data)
rot90ccw(img, temp_buff, wh, width, height);
rot90ccw(img + wh, temp_buff + wh, wh4, w2, h2);
rot90ccw(img + wh + wh4, temp_buff + wh + wh4, wh4, w2, h2);
mymemcpy(img, temp_buff, size);
memcpy(img, temp_buff, (uint)size);
break;
default:
break;
@@ -268,9 +268,9 @@ cls_rotate::cls_rotate(ctx_dev *p_cam)
}
if ((degrees == 90) || (degrees == 270)) {
buffer_norm =(u_char*) mymalloc(size_norm);
buffer_norm =(u_char*) mymalloc((uint)size_norm);
if (size_high > 0 ) {
buffer_high =(u_char*) mymalloc(size_high);
buffer_high =(u_char*) mymalloc((uint)size_high);
}
}

View File

@@ -486,7 +486,7 @@ static void snd_alsa_start(ctx_dev *snd)
info->frames = (int)frames_per;
info->buffer_size = info->frames * 2;
info->buffer = (int16_t*)mymalloc((uint)info->buffer_size * sizeof(int16_t));
mymemset(info->buffer, 0x00, (uint)info->buffer_size * sizeof(int16_t));
memset(info->buffer, 0x00, (uint)info->buffer_size * sizeof(int16_t));
MOTPLS_LOG(NTC, TYPE_ALL, NO_ERRNO, "Started.");
snd->device_status =STATUS_OPENED;
@@ -588,7 +588,7 @@ static void snd_pulse_init(ctx_dev *snd)
}
info->buffer_size = info->frames * 2;
info->buffer = (int16_t*)mymalloc((uint)info->buffer_size * sizeof(int16_t));
mymemset(info->buffer, 0x00, (uint)info->buffer_size * sizeof(int16_t));
memset(info->buffer, 0x00, (uint)info->buffer_size * sizeof(int16_t));
MOTPLS_LOG(NTC, TYPE_ALL, NO_ERRNO, "Started.");
snd->device_status =STATUS_OPENED;

View File

@@ -119,26 +119,6 @@ void myunquote(std::string &parm)
}
void mymemset(void *dst, int src, int sz)
{
memset(dst, src, (ulong)sz);
}
void mymemset(void *dst, int src, ulong sz)
{
memset(dst, src, sz);
}
void mymemcpy(void *dst, void *src, int sz)
{
memcpy(dst, src, (ulong)sz);
}
void mymemcpy(void *dst, void *src, ulong sz)
{
memcpy(dst, src, sz);
}
/* Free memory and set the pointer to NULL*/
void myfree(void *ptr_addr) {
void **ptr = (void **)ptr_addr;
@@ -149,36 +129,6 @@ void myfree(void *ptr_addr) {
}
}
/** mymalloc */
void *mymalloc(int nbytes)
{
void *dummy = calloc((size_t)nbytes, 1);
if (!dummy) {
MOTPLS_LOG(EMG, TYPE_ALL, SHOW_ERRNO
, _("Could not allocate %d bytes of memory!")
, nbytes);
exit(1);
}
return dummy;
}
/** mymalloc */
void *mymalloc(uint nbytes)
{
void *dummy = calloc((size_t)nbytes, 1);
if (!dummy) {
MOTPLS_LOG(EMG, TYPE_ALL, SHOW_ERRNO
, _("Could not allocate %llu bytes of memory!")
, (unsigned long long)nbytes);
exit(1);
}
return dummy;
}
/** mymalloc */
void *mymalloc(size_t nbytes)
{

View File

@@ -74,17 +74,10 @@
typedef const uint8_t myuint;
#endif
void mymemset(void *dst, int src, int sz);
void mymemset(void *dst, int src, ulong sz);
void mymemcpy(void *dst, void *src, int sz);
void mymemcpy(void *dst, void *src, ulong sz);
void myfree(void *ptr_addr);
#define mydelete(x) {if(x!=nullptr) {delete x; x=nullptr;}}
void *mymalloc(size_t nbytes);
void *mymalloc(uint nbytes);
void *mymalloc(int nbytes);
void *myrealloc(void *ptr, size_t size, const char *desc);
int mycreate_path(const char *path);

View File

@@ -394,8 +394,8 @@ void cls_convert::rgb_bgr(u_char *img_dst, u_char *img_src, int rgb)
y = img_dst;
u = y + width * height;
v = u + (width * height) / 4;
mymemset(u, 0, width * height / 4);
mymemset(v, 0, width * height / 4);
memset(u, 0, (uint)(width * height) / 4);
memset(v, 0, (uint)(width * height) / 4);
for (loop = 0; loop < height; loop++) {
for (i = 0; i < width; i += 2) {
@@ -513,7 +513,7 @@ void cls_convert::y10torgb24(u_char *img_dst, u_char *img_src, int shift)
void cls_convert::greytoyuv420p(u_char *img_dst, u_char *img_src)
{
memcpy(img_dst, img_src, (uint)(width*height));
mymemset(img_dst+(width*height), 128, (width * height) / 2);
memset(img_dst+(width*height), 128, (uint)(width * height) / 2);
}
/* Convert captured image to the standard pixel format*/
@@ -539,7 +539,7 @@ int cls_convert::process(u_char *img_dst, u_char *img_src, int clen)
return 0;
case V4L2_PIX_FMT_YUV420:
mymemcpy(img_dst, img_src, clen);
memcpy(img_dst, img_src, (uint)clen);
return 0;
case V4L2_PIX_FMT_PJPG:
@@ -602,7 +602,7 @@ cls_convert::cls_convert(ctx_dev *p_cam, int p_pix, int p_w, int p_h)
height = p_h;
pixfmt_src = p_pix;
common_buffer =(u_char*) mymalloc(3 * width * height);
common_buffer =(u_char*) mymalloc((uint)(3 * width * height));
}

View File

@@ -132,7 +132,7 @@ void cls_v4l2cam::ctrls_list()
}
device_ctrls.clear();
mymemset(&vid_ctrl, 0, sizeof(struct v4l2_queryctrl));
memset(&vid_ctrl, 0, sizeof(struct v4l2_queryctrl));
vid_ctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
while (xioctl(VIDIOC_QUERYCTRL, &vid_ctrl) == 0) {
if (vid_ctrl.type == V4L2_CTRL_TYPE_CTRL_CLASS) {
@@ -154,7 +154,7 @@ void cls_v4l2cam::ctrls_list()
if (vid_ctrl.type == V4L2_CTRL_TYPE_MENU) {
for (indx = vid_ctrl.minimum; indx <= vid_ctrl.maximum; indx++) {
mymemset(&vid_menu, 0, sizeof(struct v4l2_querymenu));
memset(&vid_menu, 0, sizeof(struct v4l2_querymenu));
vid_menu.id = vid_ctrl.id;
vid_menu.index = (uint)indx;
if (xioctl(VIDIOC_QUERYMENU, &vid_menu) == 0) {
@@ -196,7 +196,7 @@ void cls_v4l2cam::ctrls_set()
for (it = device_ctrls.begin();it!=device_ctrls.end();it++) {
if (it->ctrl_menuitem == false) {
if (it->ctrl_currval != it->ctrl_newval) {
mymemset(&vid_ctrl, 0, sizeof (struct v4l2_control));
memset(&vid_ctrl, 0, sizeof (struct v4l2_control));
vid_ctrl.id = it->ctrl_id;
vid_ctrl.value = it->ctrl_newval;
retcd = xioctl(VIDIOC_S_CTRL, &vid_ctrl);
@@ -285,7 +285,7 @@ void cls_v4l2cam::set_input()
}
}
mymemset(&input, 0, sizeof (struct v4l2_input));
memset(&input, 0, sizeof (struct v4l2_input));
if (spec == -1) {
input.index = 0;
} else {
@@ -355,7 +355,7 @@ void cls_v4l2cam::set_norm()
}
if (std_id) {
mymemset(&standard, 0, sizeof(struct v4l2_standard));
memset(&standard, 0, sizeof(struct v4l2_standard));
standard.index = 0;
while (xioctl(VIDIOC_ENUMSTD, &standard) == 0) {
@@ -419,7 +419,7 @@ void cls_v4l2cam::set_frequency()
/* If this input is attached to a tuner, set the frequency. */
if (device_type & V4L2_INPUT_TYPE_TUNER) {
/* Query the tuners capabilities. */
mymemset(&tuner, 0, sizeof(struct v4l2_tuner));
memset(&tuner, 0, sizeof(struct v4l2_tuner));
tuner.index = (uint)device_tuner;
if (xioctl(VIDIOC_G_TUNER, &tuner) == -1) {
@@ -431,7 +431,7 @@ void cls_v4l2cam::set_frequency()
MOTPLS_LOG(NTC, TYPE_VIDEO, NO_ERRNO, _("Set tuner %d"), tuner.index);
/* Set the frequency. */
mymemset(&freq, 0, sizeof(struct v4l2_frequency));
memset(&freq, 0, sizeof(struct v4l2_frequency));
freq.tuner = (uint)device_tuner;
freq.type = V4L2_TUNER_ANALOG_TV;
freq.frequency = (uint)((spec / 1000) * 16);
@@ -452,7 +452,7 @@ int cls_v4l2cam::pixfmt_try(uint pixformat)
{
int retcd;
mymemset(&vidfmt, 0, sizeof(struct v4l2_format));
memset(&vidfmt, 0, sizeof(struct v4l2_format));
vidfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
vidfmt.fmt.pix.width = (uint)width;
@@ -640,7 +640,7 @@ int cls_v4l2cam::pixfmt_list()
MOTPLS_LOG(NTC, TYPE_VIDEO, NO_ERRNO, _("Supported palettes:"));
v4l2_pal = 0;
mymemset(&fmtd, 0, sizeof(struct v4l2_fmtdesc));
memset(&fmtd, 0, sizeof(struct v4l2_fmtdesc));
fmtd.index = (uint)v4l2_pal;
fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
indx_palette = -1; /* -1 says not yet selected */
@@ -658,7 +658,7 @@ int cls_v4l2cam::pixfmt_list()
}
v4l2_pal++;
mymemset(&fmtd, 0, sizeof(struct v4l2_fmtdesc));
memset(&fmtd, 0, sizeof(struct v4l2_fmtdesc));
fmtd.index = (uint)v4l2_pal;
fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
@@ -735,7 +735,7 @@ void cls_v4l2cam::set_mmap()
return;
}
mymemset(&vidreq, 0, sizeof(struct v4l2_requestbuffers));
memset(&vidreq, 0, sizeof(struct v4l2_requestbuffers));
vidreq.count = MMAP_BUFFERS;
vidreq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -770,7 +770,7 @@ void cls_v4l2cam::set_mmap()
for (buffer_index = 0; buffer_index < buffer_count; buffer_index++) {
struct v4l2_buffer p_buf;
mymemset(&p_buf, 0, sizeof(struct v4l2_buffer));
memset(&p_buf, 0, sizeof(struct v4l2_buffer));
p_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
p_buf.memory = V4L2_MEMORY_MMAP;
@@ -803,7 +803,7 @@ void cls_v4l2cam::set_mmap()
}
for (buffer_index = 0; buffer_index < buffer_count; buffer_index++) {
mymemset(&vidbuf, 0, sizeof(struct v4l2_buffer));
memset(&vidbuf, 0, sizeof(struct v4l2_buffer));
vidbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
vidbuf.memory = V4L2_MEMORY_MMAP;
@@ -869,7 +869,7 @@ int cls_v4l2cam::capture()
}
}
mymemset(&vidbuf, 0, sizeof(struct v4l2_buffer));
memset(&vidbuf, 0, sizeof(struct v4l2_buffer));
vidbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
vidbuf.memory = V4L2_MEMORY_MMAP;
@@ -1010,7 +1010,7 @@ void cls_v4l2cam::log_formats()
return;
}
mymemset(&dev_format, 0, sizeof(struct v4l2_fmtdesc));
memset(&dev_format, 0, sizeof(struct v4l2_fmtdesc));
dev_format.index = indx_format = 0;
dev_format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
while (xioctl(VIDIOC_ENUM_FMT, &dev_format) != -1) {
@@ -1022,7 +1022,7 @@ void cls_v4l2cam::log_formats()
,dev_format.pixelformat >> 16
,dev_format.pixelformat >> 24);
mymemset(&dev_sizes, 0, sizeof(struct v4l2_frmsizeenum));
memset(&dev_sizes, 0, sizeof(struct v4l2_frmsizeenum));
dev_sizes.index = indx_sizes = 0;
dev_sizes.pixel_format = dev_format.pixelformat;
while (xioctl(VIDIOC_ENUM_FRAMESIZES, &dev_sizes) != -1) {
@@ -1031,7 +1031,7 @@ void cls_v4l2cam::log_formats()
,dev_sizes.discrete.width
,dev_sizes.discrete.height);
mymemset(&dev_frameint, 0, sizeof(struct v4l2_frmivalenum));
memset(&dev_frameint, 0, sizeof(struct v4l2_frmivalenum));
dev_frameint.index = indx_frameint = 0;
dev_frameint.pixel_format = dev_format.pixelformat;
dev_frameint.width = dev_sizes.discrete.width;
@@ -1041,17 +1041,17 @@ void cls_v4l2cam::log_formats()
,_(" Framerate %d/%d")
,dev_frameint.discrete.numerator
,dev_frameint.discrete.denominator);
mymemset(&dev_frameint, 0, sizeof(struct v4l2_frmivalenum));
memset(&dev_frameint, 0, sizeof(struct v4l2_frmivalenum));
dev_frameint.index = (uint)(++indx_frameint);
dev_frameint.pixel_format = dev_format.pixelformat;
dev_frameint.width = dev_sizes.discrete.width;
dev_frameint.height = dev_sizes.discrete.height;
}
mymemset(&dev_sizes, 0, sizeof(struct v4l2_frmsizeenum));
memset(&dev_sizes, 0, sizeof(struct v4l2_frmsizeenum));
dev_sizes.index = (uint)(++indx_sizes);
dev_sizes.pixel_format = dev_format.pixelformat;
}
mymemset(&dev_format, 0, sizeof(struct v4l2_fmtdesc));
memset(&dev_format, 0, sizeof(struct v4l2_fmtdesc));
dev_format.index = (uint)(++indx_format);
dev_format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
@@ -1068,7 +1068,7 @@ void cls_v4l2cam::set_fps()
return;
}
mymemset(&setfps, 0, sizeof(struct v4l2_streamparm));
memset(&setfps, 0, sizeof(struct v4l2_streamparm));
setfps.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
setfps.parm.capture.timeperframe.numerator = 1;

View File

@@ -503,7 +503,7 @@ void cls_webu_ans::mhd_auth_parse()
auth_len = (int)app->conf->webcontrol_authentication.length();
col_pos =(char*) strstr(app->conf->webcontrol_authentication.c_str() ,":");
if (col_pos == NULL) {
auth_user = (char*)mymalloc(auth_len+1);
auth_user = (char*)mymalloc((uint)(auth_len+1));
auth_pass = (char*)mymalloc(2);
snprintf(auth_user, (uint)auth_len + 1, "%s"
,app->conf->webcontrol_authentication.c_str());

View File

@@ -137,7 +137,7 @@ void cls_webu_common::img_resize(ctx_dev *p_cam
src_w = p_cam->imgs.width;
img_sz = (dst_h * dst_w * 3)/2;
mymemset(dst, 0x00, (size_t)img_sz);
memset(dst, 0x00, (size_t)img_sz);
frm_in = av_frame_alloc();
if (frm_in == NULL) {
@@ -244,7 +244,7 @@ void cls_webu_common::all_getimg()
ctx_all_sizes *all_sz;
ctx_dev *p_cam;
mymemset(resp_image, '\0', resp_size);
memset(resp_image, '\0', resp_size);
all_sz = app->all_sizes;
@@ -252,8 +252,8 @@ void cls_webu_common::all_getimg()
a_u = (all_sz->width * all_sz->height);
a_v = a_u + (a_u / 4);
mymemset(all_img_data , 0x80, (size_t)a_u);
mymemset(all_img_data + a_u, 0x80, (size_t)(a_u/2));
memset(all_img_data , 0x80, (size_t)a_u);
memset(all_img_data + a_u, 0x80, (size_t)(a_u/2));
for (indx=0; indx<app->cam_cnt; indx++) {
p_cam = app->cam_list[indx];
@@ -287,8 +287,8 @@ void cls_webu_common::all_getimg()
return;
}
dst_img = (unsigned char*) mymalloc(dst_sz);
src_img = (unsigned char*) mymalloc(src_sz);
dst_img = (unsigned char*) mymalloc((uint)dst_sz);
src_img = (unsigned char*) mymalloc((uint)src_sz);
pthread_mutex_lock(&p_cam->stream.mutex);
indx1=0;
@@ -308,9 +308,9 @@ void cls_webu_common::all_getimg()
if (strm->img_data == NULL) {
MOTPLS_LOG(DBG, TYPE_STREAM, NO_ERRNO
, "Could not get image for device %d", p_cam->device_id);
mymemset(src_img, 0x00, src_sz);
memset(src_img, 0x00, (uint)src_sz);
} else {
mymemcpy(src_img, strm->img_data, src_sz);
memcpy(src_img, strm->img_data, (uint)src_sz);
}
pthread_mutex_unlock(&p_cam->stream.mutex);
@@ -341,15 +341,15 @@ void cls_webu_common::all_getimg()
*/
for (row=0; row<dst_h; row++) {
mymemcpy(all_img_data + a_y, dst_img + c_y, dst_w);
memcpy(all_img_data + a_y, dst_img + c_y, (uint)dst_w);
a_y += all_sz->width;
c_y += dst_w;
if (row % 2) {
mymemcpy(all_img_data + a_u, dst_img + c_u, dst_w / 2);
memcpy(all_img_data + a_u, dst_img + c_u, (uint)dst_w / 2);
//mymemset(webui->all_img_data + a_u, 0xFA, dst_w/2);
a_u += (all_sz->width / 2);
c_u += (dst_w / 2);
mymemcpy(all_img_data + a_v, dst_img + c_v, dst_w / 2);
memcpy(all_img_data + a_v, dst_img + c_v, (uint)dst_w / 2);
a_v += (all_sz->width / 2);
c_v += (dst_w / 2);
}
@@ -560,8 +560,8 @@ void cls_webu_common::one_buffer()
if (resp_image != NULL) {
myfree(&resp_image);
}
resp_image = (unsigned char*) mymalloc(webua->cam->imgs.size_norm);
mymemset(resp_image,'\0',webua->cam->imgs.size_norm);
resp_image = (unsigned char*) mymalloc((uint)webua->cam->imgs.size_norm);
memset(resp_image,'\0', (uint)webua->cam->imgs.size_norm);
resp_size = (uint)webua->cam->imgs.size_norm;
resp_used = 0;
}
@@ -575,7 +575,7 @@ void cls_webu_common::all_buffer()
}
resp_size = (uint)app->all_sizes->img_sz;
resp_image = (unsigned char*) mymalloc(resp_size);
mymemset(resp_image, '\0', resp_size);
memset(resp_image, '\0', resp_size);
resp_used = 0;
}
if ((all_img_data == nullptr) &&

View File

@@ -110,7 +110,8 @@ static void webu_getimg_norm(ctx_dev *cam)
if (cam->stream.norm.jpg_cnct > 0) {
if (cam->stream.norm.jpg_data == NULL) {
cam->stream.norm.jpg_data =(unsigned char*)mymalloc(cam->imgs.size_norm);
cam->stream.norm.jpg_data =(unsigned char*)
mymalloc((uint)cam->imgs.size_norm);
}
if (cam->current_image->image_norm != NULL && cam->stream.norm.consumed) {
cam->stream.norm.jpg_sz = cam->picture->put_memory(
@@ -125,9 +126,11 @@ static void webu_getimg_norm(ctx_dev *cam)
}
if ((cam->stream.norm.ts_cnct > 0) || (cam->stream.norm.all_cnct > 0)) {
if (cam->stream.norm.img_data == NULL) {
cam->stream.norm.img_data =(unsigned char*)mymalloc(cam->imgs.size_norm);
cam->stream.norm.img_data =(unsigned char*)
mymalloc((uint)cam->imgs.size_norm);
}
mymemcpy(cam->stream.norm.img_data, cam->current_image->image_norm, cam->imgs.size_norm);
memcpy(cam->stream.norm.img_data, cam->current_image->image_norm
, (uint)cam->imgs.size_norm);
}
}
@@ -144,7 +147,8 @@ static void webu_getimg_sub(ctx_dev *cam)
if (cam->stream.sub.jpg_cnct > 0) {
if (cam->stream.sub.jpg_data == NULL) {
cam->stream.sub.jpg_data =(unsigned char*)mymalloc(cam->imgs.size_norm);
cam->stream.sub.jpg_data =(unsigned char*)
mymalloc((uint)cam->imgs.size_norm);
}
if (cam->current_image->image_norm != NULL && cam->stream.sub.consumed) {
/* Resulting substream image must be multiple of 8 */
@@ -153,7 +157,8 @@ static void webu_getimg_sub(ctx_dev *cam)
subsize = ((cam->imgs.width / 2) * (cam->imgs.height / 2) * 3 / 2);
if (cam->imgs.image_substream == NULL) {
cam->imgs.image_substream =(unsigned char*)mymalloc(subsize);
cam->imgs.image_substream =(unsigned char*)
mymalloc((uint)subsize);
}
cam->picture->scale_img(cam->imgs.width
,cam->imgs.height
@@ -182,21 +187,22 @@ static void webu_getimg_sub(ctx_dev *cam)
if ((cam->stream.sub.ts_cnct > 0) || (cam->stream.sub.all_cnct > 0)) {
if (cam->stream.sub.img_data == NULL) {
cam->stream.sub.img_data =(unsigned char*)mymalloc(cam->imgs.size_norm);
cam->stream.sub.img_data =(unsigned char*)mymalloc((uint)cam->imgs.size_norm);
}
if (((cam->imgs.width % 16) == 0) &&
((cam->imgs.height % 16) == 0)) {
subsize = ((cam->imgs.width / 2) * (cam->imgs.height / 2) * 3 / 2);
if (cam->imgs.image_substream == NULL) {
cam->imgs.image_substream =(unsigned char*)mymalloc(subsize);
cam->imgs.image_substream =(unsigned char*)mymalloc((uint)subsize);
}
cam->picture->scale_img(cam->imgs.width
,cam->imgs.height
,cam->current_image->image_norm
,cam->imgs.image_substream);
mymemcpy(cam->stream.sub.img_data, cam->imgs.image_substream, subsize);
memcpy(cam->stream.sub.img_data, cam->imgs.image_substream, (uint)subsize);
} else {
mymemcpy(cam->stream.sub.img_data, cam->current_image->image_norm, cam->imgs.size_norm);
memcpy(cam->stream.sub.img_data, cam->current_image->image_norm
, (uint)cam->imgs.size_norm);
}
}
@@ -213,7 +219,7 @@ static void webu_getimg_motion(ctx_dev *cam)
if (cam->stream.motion.jpg_cnct > 0) {
if (cam->stream.motion.jpg_data == NULL) {
cam->stream.motion.jpg_data =(unsigned char*)mymalloc(cam->imgs.size_norm);
cam->stream.motion.jpg_data =(unsigned char*)mymalloc((uint)cam->imgs.size_norm);
}
if (cam->imgs.image_motion.image_norm != NULL && cam->stream.motion.consumed) {
cam->stream.motion.jpg_sz = cam->picture->put_memory(
@@ -228,11 +234,11 @@ static void webu_getimg_motion(ctx_dev *cam)
}
if ((cam->stream.motion.ts_cnct > 0) || (cam->stream.motion.all_cnct > 0)) {
if (cam->stream.motion.img_data == NULL) {
cam->stream.motion.img_data =(unsigned char*)mymalloc(cam->imgs.size_norm);
cam->stream.motion.img_data =(unsigned char*)mymalloc((uint)cam->imgs.size_norm);
}
mymemcpy(cam->stream.motion.img_data
memcpy(cam->stream.motion.img_data
, cam->imgs.image_motion.image_norm
, cam->imgs.size_norm);
, (uint)cam->imgs.size_norm);
}
}
@@ -247,7 +253,7 @@ static void webu_getimg_source(ctx_dev *cam)
if (cam->stream.source.jpg_cnct > 0) {
if (cam->stream.source.jpg_data == NULL) {
cam->stream.source.jpg_data =(unsigned char*)mymalloc(cam->imgs.size_norm);
cam->stream.source.jpg_data =(unsigned char*)mymalloc((uint)cam->imgs.size_norm);
}
if (cam->imgs.image_virgin != NULL && cam->stream.source.consumed) {
cam->stream.source.jpg_sz = cam->picture->put_memory(
@@ -262,11 +268,11 @@ static void webu_getimg_source(ctx_dev *cam)
}
if ((cam->stream.source.ts_cnct > 0) || (cam->stream.source.all_cnct > 0)) {
if (cam->stream.source.img_data == NULL) {
cam->stream.source.img_data =(unsigned char*)mymalloc(cam->imgs.size_norm);
cam->stream.source.img_data =(unsigned char*)mymalloc((uint)cam->imgs.size_norm);
}
mymemcpy(cam->stream.source.img_data
memcpy(cam->stream.source.img_data
, cam->imgs.image_virgin
, cam->imgs.size_norm);
, (uint)cam->imgs.size_norm);
}
}
@@ -283,10 +289,13 @@ static void webu_getimg_secondary(ctx_dev *cam)
if (cam->imgs.size_secondary>0) {
pthread_mutex_lock(&cam->algsec->mutex);
if (cam->stream.secondary.jpg_data == NULL) {
cam->stream.secondary.jpg_data =(unsigned char*)mymalloc(cam->imgs.size_norm);
cam->stream.secondary.jpg_data =(unsigned char*)
mymalloc((uint)cam->imgs.size_norm);
}
mymemcpy(cam->stream.secondary.jpg_data,cam->imgs.image_secondary,cam->imgs.size_secondary);
memcpy(cam->stream.secondary.jpg_data
, cam->imgs.image_secondary
, (uint)cam->imgs.size_secondary);
cam->stream.secondary.jpg_sz = cam->imgs.size_secondary;
pthread_mutex_unlock(&cam->algsec->mutex);
} else {
@@ -295,10 +304,11 @@ static void webu_getimg_secondary(ctx_dev *cam)
}
if ((cam->stream.secondary.ts_cnct > 0) || (cam->stream.secondary.all_cnct > 0)) {
if (cam->stream.secondary.img_data == NULL) {
cam->stream.secondary.img_data =(unsigned char*)mymalloc(cam->imgs.size_norm);
cam->stream.secondary.img_data =(unsigned char*)
mymalloc((uint)cam->imgs.size_norm);
}
mymemcpy(cam->stream.secondary.img_data
, cam->current_image->image_norm, cam->imgs.size_norm);
memcpy(cam->stream.secondary.img_data
, cam->current_image->image_norm, (uint)cam->imgs.size_norm);
}
}

View File

@@ -152,7 +152,7 @@ int cls_webu_mpegts::getimg()
clock_gettime(CLOCK_REALTIME, &curr_ts);
mymemset(webuc->resp_image, '\0', webuc->resp_size);
memset(webuc->resp_image, '\0', webuc->resp_size);
webuc->resp_used = 0;
if (webua->device_id > 0) {
@@ -172,21 +172,21 @@ int cls_webu_mpegts::getimg()
return 0;
}
img_sz = (ctx_codec->width * ctx_codec->height * 3)/2;
img_data = (unsigned char*) mymalloc(img_sz);
img_data = (unsigned char*) mymalloc((uint)img_sz);
pthread_mutex_lock(&webua->cam->stream.mutex);
if (strm->img_data == NULL) {
mymemset(img_data, 0x00, img_sz);
memset(img_data, 0x00, (uint)img_sz);
} else {
mymemcpy(img_data, strm->img_data, img_sz);
memcpy(img_data, strm->img_data, (uint)img_sz);
strm->consumed = true;
}
pthread_mutex_unlock(&webua->cam->stream.mutex);
} else {
webuc->all_getimg();
img_data = (unsigned char*) mymalloc(app->all_sizes->img_sz);
img_data = (unsigned char*) mymalloc((uint)app->all_sizes->img_sz);
mymemcpy(img_data, webuc->all_img_data, app->all_sizes->img_sz);
memcpy(img_data, webuc->all_img_data, (uint)app->all_sizes->img_sz);
}
if (pic_send(img_data) < 0) {
@@ -249,7 +249,7 @@ ssize_t cls_webu_mpegts::response(char *buf, size_t max)
sent_bytes = webuc->resp_used - stream_pos;
}
mymemcpy(buf, webuc->resp_image + stream_pos, sent_bytes);
memcpy(buf, webuc->resp_image + stream_pos, (uint)sent_bytes);
stream_pos = stream_pos + sent_bytes;
if (stream_pos >= webuc->resp_used) {

View File

@@ -82,7 +82,7 @@ void cls_webu_stream::mjpeg_all_img()
all_sz = app->all_sizes;
jpg_data = (unsigned char*) mymalloc(all_sz->img_sz);
jpg_data = (unsigned char*) mymalloc((uint)all_sz->img_sz);
jpg_sz = jpgutl_put_yuv420p(jpg_data, all_sz->img_sz
, webuc->all_img_data, all_sz->width, all_sz->height
@@ -94,8 +94,8 @@ void cls_webu_stream::mjpeg_all_img()
"Content-type: image/jpeg\r\n"
"Content-Length: %9d\r\n\r\n"
,jpg_sz);
mymemcpy(webuc->resp_image, resp_head, header_len);
mymemcpy(webuc->resp_image + header_len, jpg_data, jpg_sz);
memcpy(webuc->resp_image, resp_head, (uint)header_len);
memcpy(webuc->resp_image + header_len, jpg_data, (uint)jpg_sz);
memcpy(webuc->resp_image + header_len + jpg_sz,"\r\n",(uint)2);
webuc->resp_used =(uint)(header_len + jpg_sz + 2);
myfree(&jpg_data);
@@ -143,10 +143,10 @@ void cls_webu_stream::mjpeg_one_img()
"Content-type: image/jpeg\r\n"
"Content-Length: %9d\r\n\r\n"
,strm->jpg_sz);
mymemcpy(webuc->resp_image, resp_head, header_len);
mymemcpy(webuc->resp_image + header_len
,strm->jpg_data
,strm->jpg_sz);
memcpy(webuc->resp_image, resp_head, (uint)header_len);
memcpy(webuc->resp_image + header_len
, strm->jpg_data
, (uint)strm->jpg_sz);
/* Copy in the terminator after the jpg data at the end*/
memcpy(webuc->resp_image + header_len + strm->jpg_sz,"\r\n",2);
webuc->resp_used =(uint)(header_len + strm->jpg_sz + 2);
@@ -187,7 +187,7 @@ ssize_t cls_webu_stream::mjpeg_response (char *buf, size_t max)
sent_bytes = webuc->resp_used - stream_pos;
}
mymemcpy(buf, webuc->resp_image + stream_pos, sent_bytes);
memcpy(buf, webuc->resp_image + stream_pos, sent_bytes);
stream_pos = stream_pos + sent_bytes;
if (stream_pos >= webuc->resp_used) {
@@ -239,12 +239,12 @@ void cls_webu_stream::static_all_img()
webuc->all_getimg();
all_sz = app->all_sizes;
jpg_data = (unsigned char*)mymalloc((size_t)all_sz->img_sz);
jpg_data = (unsigned char*)mymalloc((uint)all_sz->img_sz);
webuc->resp_used = (uint)jpgutl_put_yuv420p(jpg_data
, all_sz->img_sz, webuc->all_img_data, all_sz->width
, all_sz->height, 70, NULL,NULL,NULL);
mymemcpy(webuc->resp_image, jpg_data, webuc->resp_used);
memcpy(webuc->resp_image, jpg_data, webuc->resp_used);
myfree(&jpg_data);
}
@@ -313,9 +313,9 @@ void cls_webu_stream::static_one_img()
pthread_mutex_unlock(&webua->cam->stream.mutex);
return;
}
mymemcpy(webuc->resp_image
,strm->jpg_data
,strm->jpg_sz);
memcpy(webuc->resp_image
, strm->jpg_data
, (uint)strm->jpg_sz);
webuc->resp_used =(uint)strm->jpg_sz;
strm->consumed = true;
pthread_mutex_unlock(&webua->cam->stream.mutex);