Fix compiler signedness warnings

This commit is contained in:
Mr-Dave
2024-07-21 15:09:45 -06:00
parent 0da6af0bf5
commit 5f71dbadc6
32 changed files with 405 additions and 333 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. */
memset(labels, 0, width * height * sizeof(*labels));
mymemset(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. */
memset(row2, 0, width);
memcpy(row3, img, width);
mymemset(row2, 0, width);
mymemcpy(row3, img, 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) {
memset(row3, 0, width);
mymemset(row3, 0, width);
} else {
memcpy(row3, yp + width, width);
mymemcpy(row3, yp + width, 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. */
memset(row2, 0, width);
memcpy(row3, img, width);
mymemset(row2, 0, width);
mymemcpy(row3, img, 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) {
memset(row3, 0, width);
mymemset(row3, 0, width);
} else {
memcpy(row3, yp + width, width);
mymemcpy(row3, yp + width, 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;
memset(Row2, flag, width);
memcpy(Row3, img, width);
mymemset(Row2, flag, width);
mymemcpy(Row3, img, width);
for (y = 0; y < height; y++) {
memcpy(Row1, Row2, width);
memcpy(Row2, Row3, width);
mymemcpy(Row1, Row2, width);
mymemcpy(Row2, Row3, width);
if (y == height - 1) {
memset(Row3, flag, width);
mymemset(Row3, flag, width);
} else {
memcpy(Row3, img + (y + 1) * width, width);
mymemcpy(Row3, img + (y + 1) * width, 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;
memset(Row2, flag, width);
memcpy(Row3, img, width);
mymemset(Row2, flag, width);
mymemcpy(Row3, img, width);
for (y = 0; y < height; y++) {
memcpy(Row1, Row2, width);
memcpy(Row2, Row3, width);
mymemcpy(Row1, Row2, width);
mymemcpy(Row2, Row3, width);
if (y == height - 1) {
memset(Row3, flag, width);
mymemset(Row3, flag, width);
} else {
memcpy(Row3, img + (y + 1) * width, width);
mymemcpy(Row3, img + (y + 1) * width, width);
}
for (i = width - 2; i >= 1; i--) {
@@ -503,7 +503,8 @@ static int alg_erode5(unsigned char *img, int width, int height, void *buffer, u
static void alg_despeckle(ctx_dev *cam)
{
int diffs, width, height, done, i, len;
int diffs, width, height, done;
uint i, len;
unsigned char *out, *common_buffer;
if ((cam->conf->despeckle_filter == "") || cam->current_image->diffs <= 0) {
@@ -518,7 +519,7 @@ static void alg_despeckle(ctx_dev *cam)
width = cam->imgs.width;
height = cam->imgs.height;
done = 0;
len = (int)cam->conf->despeckle_filter.length();
len = (uint)cam->conf->despeckle_filter.length();
common_buffer = cam->imgs.common_buffer;
cam->current_image->total_labels = 0;
cam->imgs.largest_label = 0;
@@ -632,8 +633,8 @@ static void alg_diff_nomask(ctx_dev *cam)
int noise = cam->noise;
int lrgchg = cam->conf->threshold_ratio_change;
memset(out + imgsz, 128, (imgsz / 2));
memset(out, 0, imgsz);
mymemset(out + imgsz, 128, (imgsz / 2));
mymemset(out, 0, imgsz);
for (i = 0; i < imgsz; i++) {
curdiff = (*ref - *new_img);
@@ -675,8 +676,8 @@ static void alg_diff_mask(ctx_dev *cam)
int noise = cam->noise;
int lrgchg = cam->conf->threshold_ratio_change;
memset(out + imgsz, 128, (imgsz / 2));
memset(out, 0, imgsz);
mymemset(out + imgsz, 128, (imgsz / 2));
mymemset(out, 0, imgsz);
for (i = 0; i < imgsz; i++) {
curdiff = (*ref - *new_img);
@@ -728,8 +729,8 @@ static void alg_diff_smart(ctx_dev *cam)
int lrgchg = cam->conf->threshold_ratio_change;
imgsz = cam->imgs.motionsize;
memset(out + imgsz, 128, (imgsz / 2));
memset(out, 0, imgsz);
mymemset(out + imgsz, 128, (imgsz / 2));
mymemset(out, 0, imgsz);
for (i = 0; i < imgsz; i++) {
curdiff = (*ref - *new_img);
@@ -787,8 +788,8 @@ static void alg_diff_masksmart(ctx_dev *cam)
int lrgchg = cam->conf->threshold_ratio_change;
imgsz= cam->imgs.motionsize;
memset(out + imgsz, 128, (imgsz / 2));
memset(out, 0, imgsz);
mymemset(out + imgsz, 128, (imgsz / 2));
mymemset(out, 0, imgsz);
for (i = 0; i < imgsz; i++) {
curdiff = (*ref - *new_img);
@@ -896,8 +897,8 @@ static void alg_lightswitch(ctx_dev *cam)
if (cam->conf->lightswitch_percent >= 1 && !cam->lost_connection) {
if (cam->current_image->diffs > (cam->imgs.motionsize * cam->conf->lightswitch_percent / 100)) {
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, _("Lightswitch detected"));
if (cam->frame_skip < (unsigned int)cam->conf->lightswitch_frames) {
cam->frame_skip = (unsigned int)cam->conf->lightswitch_frames;
if (cam->frame_skip < cam->conf->lightswitch_frames) {
cam->frame_skip = cam->conf->lightswitch_frames;
}
cam->current_image->diffs = 0;
alg_update_reference_frame(cam, RESET_REF_FRAME);
@@ -965,9 +966,10 @@ 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 */
memcpy(cam->imgs.ref, cam->imgs.image_vprvcy, cam->imgs.size_norm);
mymemcpy(cam->imgs.ref, cam->imgs.image_vprvcy, cam->imgs.size_norm);
/* Reset static objects */
memset(cam->imgs.ref_dyn, 0, cam->imgs.motionsize * sizeof(*cam->imgs.ref_dyn));
mymemset(cam->imgs.ref_dyn, 0
,(uint)cam->imgs.motionsize * sizeof(*cam->imgs.ref_dyn));
}
}
@@ -976,7 +978,7 @@ void alg_new_update_frame(ctx_dev *cam)
{
/* There used to be a lot more to this function before.....*/
memcpy(cam->imgs.ref, cam->imgs.image_vprvcy, cam->imgs.size_norm);
mymemcpy(cam->imgs.ref, cam->imgs.image_vprvcy, cam->imgs.size_norm);
}
@@ -1032,7 +1034,7 @@ static void alg_location_dist(ctx_dev *cam)
ctx_coord *cent = &cam->current_image->location;
unsigned char *out = imgs->image_motion.image_norm;
int x, y, centc = 0, xdist = 0, ydist = 0;
uint64_t variance_x, variance_y, variance_xy, distance_mean;
int64_t variance_x, variance_y, variance_xy, distance_mean;
/* Note that the term variance refers to the statistical calulation. It is
* not really precise however since we are using integers rather than floats.
@@ -1052,7 +1054,7 @@ static void alg_location_dist(ctx_dev *cam)
if (*(out++)) {
variance_x += ((x - cent->x) * (x - cent->x));
variance_y += ((y - cent->y) * (y - cent->y));
distance_mean += (uint64_t)sqrt(
distance_mean += (int64_t)sqrt(
((x - cent->x) * (x - cent->x)) +
((y - cent->y) * (y - cent->y)));
@@ -1080,7 +1082,7 @@ static void alg_location_dist(ctx_dev *cam)
cent->maxy = cent->y + ydist / centc * 3;
cent->stddev_x = (int)sqrt((variance_x / centc));
cent->stddev_y = (int)sqrt((variance_y / centc));
distance_mean = (uint64_t)(distance_mean / centc);
distance_mean = (int64_t)(distance_mean / centc);
} else {
cent->stddev_y = 0;
cent->stddev_x = 0;
@@ -1093,9 +1095,9 @@ static void alg_location_dist(ctx_dev *cam)
for (x = 0; x < width; x++) {
if (*(out++)) {
variance_xy += (
((uint64_t)sqrt(((x - cent->x) * (x - cent->x)) +
((int64_t)sqrt(((x - cent->x) * (x - cent->x)) +
((y - cent->y) * (y - cent->y))) - distance_mean) *
((uint64_t)sqrt(((x - cent->x) * (x - cent->x)) +
((int64_t)sqrt(((x - cent->x) * (x - cent->x)) +
((y - cent->y) * (y - cent->y))) - distance_mean));
}
}

View File

@@ -168,7 +168,7 @@ static void algsec_image_label(ctx_dev *cam, Mat &mat_dst
label = format("%s: %.4f"
, (algmdl->dnn_classes.empty() ?
format("Class #%d", classIdPoint.x).c_str() :
algmdl->dnn_classes[classIdPoint.x].c_str())
algmdl->dnn_classes[(uint)classIdPoint.x].c_str())
, confidence);
putText(mat_dst , label, Point(0, 15)
@@ -714,7 +714,7 @@ void algsec_detect(ctx_dev *cam)
if (cam->algsec->detecting){
cam->algsec->frame_missed++;
} else {
memcpy(cam->algsec->image_norm
mymemcpy(cam->algsec->image_norm
, cam->imgs.image_virgin
, cam->imgs.size_norm);

View File

@@ -23,12 +23,16 @@
#ifdef HAVE_OPENCV
#pragma GCC diagnostic push
#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#pragma clang diagnostic ignored "-Wc11-extensions"
#include "opencv2/objdetect.hpp"
#include "opencv2/dnn.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#pragma clang diagnostic pop
#pragma GCC diagnostic pop
#endif

View File

@@ -3667,7 +3667,9 @@ void conf_camera_add(ctx_motapp *motapp)
motapp->cam_cnt++;
motapp->cam_list = (ctx_dev **)myrealloc(
motapp->cam_list, sizeof(ctx_dev *) * (motapp->cam_cnt + 1), "config_camera");
motapp->cam_list
, sizeof(ctx_dev *) * (uint)(motapp->cam_cnt + 1)
, "config_camera");
motapp->cam_list[motapp->cam_cnt-1] = new ctx_dev;
memset(motapp->cam_list[motapp->cam_cnt-1],0,sizeof(ctx_dev));
@@ -3757,7 +3759,9 @@ void conf_sound_add(ctx_motapp *motapp)
motapp->snd_cnt++;
motapp->snd_list = (ctx_dev **)myrealloc(
motapp->snd_list, sizeof(ctx_dev *) * (motapp->snd_cnt + 1), "config_sound");
motapp->snd_list
, sizeof(ctx_dev *) * (uint)(motapp->snd_cnt + 1)
, "config_sound");
motapp->snd_list[motapp->snd_cnt-1] = new ctx_dev;
memset(motapp->snd_list[motapp->snd_cnt-1],0,sizeof(ctx_dev));

View File

@@ -111,7 +111,7 @@ static void dbse_cols_list(ctx_motapp *motapp)
/* 50 is an arbitrary "high" number */
motapp->dbse->cols_cnt = 50;
motapp->dbse->cols_list =(ctx_dbse_col *)
mymalloc(sizeof(ctx_dbse_col) * motapp->dbse->cols_cnt);
mymalloc(sizeof(ctx_dbse_col) * (uint)motapp->dbse->cols_cnt);
/* The size of 30 is arbitrary */
for (indx=0; indx<motapp->dbse->cols_cnt; indx++) {
@@ -205,7 +205,7 @@ static void dbse_rec_default(ctx_dbse_rec *rec)
/* Assign values to rec from the database */
static void dbse_rec_assign(ctx_dbse_rec *rec, char *col_nm, char *col_val)
{
int flen;
size_t flen;
struct stat statbuf;
if (mystrceq(col_nm,"record_id")) {
@@ -216,19 +216,19 @@ static void dbse_rec_assign(ctx_dbse_rec *rec, char *col_nm, char *col_val)
} else if (mystrceq(col_nm,"movie_nm")) {
free(rec->movie_nm);
flen = (int)strlen(col_val);
flen = strlen(col_val);
rec->movie_nm = (char*)mymalloc(flen + 1);
snprintf(rec->movie_nm, flen+1,"%s",col_val);
} else if (mystrceq(col_nm,"movie_dir")) {
free(rec->movie_dir);
flen = (int)strlen(col_val);
flen = strlen(col_val);
rec->movie_dir = (char*)mymalloc(flen + 1);
snprintf(rec->movie_dir, flen+1,"%s",col_val);
} else if (mystrceq(col_nm,"full_nm")) {
free(rec->full_nm);
flen = (int)strlen(col_val);
flen = strlen(col_val);
rec->full_nm = (char*)mymalloc(flen + 1);
snprintf(rec->full_nm, flen+1,"%s",col_val);
if (stat(rec->full_nm, &statbuf) == 0) {
@@ -243,19 +243,15 @@ static void dbse_rec_assign(ctx_dbse_rec *rec, char *col_nm, char *col_val)
} else if (mystrceq(col_nm,"movie_tmc")) {
free(rec->movie_tmc);
flen = (int)strlen(col_val);
rec->movie_tmc =
(char*)mymalloc(flen + 1);
snprintf(rec->movie_tmc
,flen+1,"%s",col_val);
flen = strlen(col_val);
rec->movie_tmc = (char*)mymalloc(flen + 1);
snprintf(rec->movie_tmc, flen+1,"%s",col_val);
} else if (mystrceq(col_nm,"movie_tml")) {
free(rec->movie_tml);
flen = (int)strlen(col_val);
rec->movie_tml =
(char*)mymalloc(flen + 1);
snprintf(rec->movie_tml
,flen+1,"%s",col_val);
flen = strlen(col_val);
rec->movie_tml = (char*)mymalloc(flen + 1);
snprintf(rec->movie_tml,flen+1,"%s",col_val);
} else if (mystrceq(col_nm,"diff_avg")) {
rec->diff_avg =atoi(col_val);
@@ -569,7 +565,7 @@ static void dbse_sqlite3_movlst(ctx_motapp *motapp, int device_id)
if (motapp->dbse->movie_cnt > 0) {
motapp->dbse->movie_list =(ctx_dbse_rec *)
mymalloc(sizeof(ctx_dbse_rec)*motapp->dbse->movie_cnt);
mymalloc(sizeof(ctx_dbse_rec)*(uint)motapp->dbse->movie_cnt);
motapp->dbse->rec_indx = 0;
motapp->dbse->dbse_action = DBSE_MOV_SELECT;
@@ -622,7 +618,7 @@ static void dbse_mariadb_exec (ctx_motapp *motapp, const char *sqlquery)
MOTPLS_LOG(DBG, TYPE_DB, NO_ERRNO, "Executing MariaDB query");
retcd = mysql_query(motapp->dbse->database_mariadb, sqlquery);
if (retcd != 0) {
retcd = mysql_errno(motapp->dbse->database_mariadb);
retcd = (int)mysql_errno(motapp->dbse->database_mariadb);
MOTPLS_LOG(ERR, TYPE_DB, SHOW_ERRNO
, _("MariaDB query '%s' failed. %s error code %d")
, sqlquery, mysql_error(motapp->dbse->database_mariadb)
@@ -634,7 +630,7 @@ static void dbse_mariadb_exec (ctx_motapp *motapp, const char *sqlquery)
}
retcd = mysql_query(motapp->dbse->database_mariadb, "commit;");
if (retcd != 0) {
retcd = mysql_errno(motapp->dbse->database_mariadb);
retcd = (int)mysql_errno(motapp->dbse->database_mariadb);
MOTPLS_LOG(ERR, TYPE_DB, SHOW_ERRNO
, _("MariaDB query commit failed. %s error code %d")
, mysql_error(motapp->dbse->database_mariadb), retcd);
@@ -671,9 +667,9 @@ static void dbse_mariadb_recs (ctx_motapp *motapp, const char *sqlquery)
return;
}
qry_fields = mysql_num_fields(qry_result);
qry_fields = (int)mysql_num_fields(qry_result);
cols =(ctx_dbse_col *)
mymalloc(sizeof(ctx_dbse_col) * qry_fields);
mymalloc(sizeof(ctx_dbse_col) * (uint)qry_fields);
for(indx = 0; indx < qry_fields; indx++) {
qry_col = mysql_fetch_field(qry_result);
cols[indx].col_nm = (char*)mymalloc(qry_col->name_length + 1);
@@ -815,7 +811,7 @@ static void dbse_mariadb_init(ctx_motapp *motapp)
, motapp->dbse->database_user.c_str()
, motapp->dbse->database_password.c_str()
, motapp->dbse->database_dbname.c_str()
, motapp->dbse->database_port, NULL, 0) == NULL) {
, (uint)motapp->dbse->database_port, NULL, 0) == NULL) {
MOTPLS_LOG(ERR, TYPE_DB, NO_ERRNO
, _("Cannot connect to MariaDB database %s on host %s with user %s")
@@ -862,7 +858,7 @@ static void dbse_mariadb_movlst(ctx_motapp *motapp, int device_id )
if (motapp->dbse->movie_cnt > 0) {
motapp->dbse->movie_list =(ctx_dbse_rec *)
mymalloc(sizeof(ctx_dbse_rec)*motapp->dbse->movie_cnt);
mymalloc(sizeof(ctx_dbse_rec)*(uint)motapp->dbse->movie_cnt);
motapp->dbse->dbse_action = DBSE_MOV_SELECT;
dbse_sql_motpls(motapp->dbse, sql, device_id);
@@ -1104,7 +1100,7 @@ static void dbse_pgsql_movlst(ctx_motapp *motapp, int device_id)
if (motapp->dbse->movie_cnt > 0) {
motapp->dbse->movie_list =(ctx_dbse_rec *)
mymalloc(sizeof(ctx_dbse_rec)*motapp->dbse->movie_cnt);
mymalloc(sizeof(ctx_dbse_rec)*(uint)motapp->dbse->movie_cnt);
motapp->dbse->dbse_action = DBSE_MOV_SELECT;
dbse_sql_motpls(motapp->dbse, sql, device_id);

View File

@@ -171,7 +171,7 @@ static void event_image_snapshot(ctx_dev *cam)
offset = 1;
}
if (cam->conf->snapshot_filename.compare(offset, 8, "lastsnap") != 0) {
if (cam->conf->snapshot_filename.compare((uint)offset, 8, "lastsnap") != 0) {
mypicname(cam, filename,"%s/%s.%s"
, cam->conf->snapshot_filename
, cam->conf->picture_type);

View File

@@ -137,7 +137,7 @@ static void put_direntry(struct tiff_writing *into, const char *data, uint lengt
static void put_stringentry(struct tiff_writing *into, uint tag, const char *str, int with_nul)
{
uint stringlength = (int)strlen(str) + (with_nul?1:0);
uint stringlength = (uint)strlen(str) + (with_nul?1:0);
put_uint16(into->buf, tag);
put_uint16(into->buf + 2, TIFF_TYPE_ASCII);
@@ -155,10 +155,10 @@ static void put_subjectarea(struct tiff_writing *into, ctx_coord *box)
put_uint32(into->buf + 8, into->data_offset);
into->buf += 12;
JOCTET *ool = into->base + into->data_offset;
put_uint16(ool , box->x); /* Center.x */
put_uint16(ool+2, box->y); /* Center.y */
put_uint16(ool+4, box->width);
put_uint16(ool+6, box->height);
put_uint16(ool , (uint)box->x); /* Center.x */
put_uint16(ool+2, (uint)box->y); /* Center.y */
put_uint16(ool+4, (uint)box->width);
put_uint16(ool+6, (uint)box->height);
into->data_offset += 8;
}
@@ -224,7 +224,7 @@ void jpgutl_exif_tags(ctx_exif_info *exif_info)
/* Count up the number of tags and max amount of OOL data */
if (exif_info->description != nullptr) {
exif_info->ifd0_tagcount ++;
exif_info->datasize += 5 + (int)strlen(exif_info->description); /* Add 5 for NUL and alignment */
exif_info->datasize += 5 + (uint)strlen(exif_info->description); /* Add 5 for NUL and alignment */
}
if (exif_info->datetime != nullptr) {
@@ -239,12 +239,12 @@ void jpgutl_exif_tags(ctx_exif_info *exif_info)
exif_info->ifd0_tagcount++;
/* It would be nice to use the same offset for both tags' values,
* but I don't want to write the bookkeeping for that right now */
exif_info->datasize += 2 * (5 + (int)strlen(exif_info->datetime));
exif_info->datasize += 2 * (5 + (uint)strlen(exif_info->datetime));
}
if (exif_info->subtime != nullptr) {
exif_info->ifd1_tagcount++;
exif_info->datasize += 5 + (int)strlen(exif_info->subtime);
exif_info->datasize += 5 + (uint)strlen(exif_info->subtime);
}
if (exif_info->box) {
@@ -270,7 +270,7 @@ void jpgutl_exif_tags(ctx_exif_info *exif_info)
void jpgutl_exif_writeifd0(ctx_exif_info *exif_info)
{
/* Note that tags are stored in numerical order */
put_uint16(exif_info->writing.buf, exif_info->ifd0_tagcount);
put_uint16(exif_info->writing.buf, (uint)exif_info->ifd0_tagcount);
exif_info->writing.buf += 2;
if (exif_info->description) {
@@ -285,7 +285,7 @@ void jpgutl_exif_writeifd0(ctx_exif_info *exif_info)
if (exif_info->ifd1_tagcount > 0) {
/* Offset of IFD1 - TIFF header + IFD0 size. */
uint ifd1_offset = 8 + 6 + ( 12 * exif_info->ifd0_tagcount );
uint ifd1_offset = 8 + 6 + ( 12 * (uint)exif_info->ifd0_tagcount);
memcpy(exif_info->writing.buf, exif_subifd_tag, 8);
put_uint32(exif_info->writing.buf + 8, ifd1_offset);
exif_info->writing.buf += 12;
@@ -294,7 +294,7 @@ void jpgutl_exif_writeifd0(ctx_exif_info *exif_info)
if (exif_info->datetime) {
memcpy(exif_info->writing.buf, exif_tzoffset_tag, 12);
put_sint16(exif_info->writing.buf+8
, int(exif_info->timestamp_tm.tm_gmtoff / 3600));
, (int)(exif_info->timestamp_tm.tm_gmtoff / 3600));
exif_info->writing.buf += 12;
}
@@ -308,7 +308,7 @@ void jpgutl_exif_writeifd1(ctx_exif_info *exif_info)
/* Write IFD 1 */
if (exif_info->ifd1_tagcount > 0) {
/* (remember that the tags in any IFD must be in numerical order by tag) */
put_uint16(exif_info->writing.buf, exif_info->ifd1_tagcount);
put_uint16(exif_info->writing.buf, (uint)exif_info->ifd1_tagcount);
memcpy(exif_info->writing.buf + 2, exif_version_tag, 12); /* tag 0x9000 */
exif_info->writing.buf += 14;
@@ -332,7 +332,7 @@ void jpgutl_exif_writeifd1(ctx_exif_info *exif_info)
}
int jpgutl_exif(u_char **exif, ctx_dev *cam, timespec *ts_in1, ctx_coord *box)
uint jpgutl_exif(u_char **exif, ctx_dev *cam, timespec *ts_in1, ctx_coord *box)
{
struct ctx_exif_info *exif_info;
int buffer_size;
@@ -353,7 +353,7 @@ int 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 + exif_info->datasize;
exif_info->ifds_size + (int)exif_info->datasize;
marker =(JOCTET *)mymalloc(buffer_size);
memcpy(marker, exif_marker_start, 14); /* EXIF and TIFF headers */
@@ -413,7 +413,7 @@ static void add_huff_table(j_decompress_ptr dinfo, JHUFF_TBL **htblptr, const UI
MOTPLS_LOG(ERR, TYPE_ALL, NO_ERRNO, _("%s: Given jpeg buffer was too small"));
}
memcpy((*htblptr)->huffval, val, nsymbols * sizeof(UINT8));
memcpy((*htblptr)->huffval, val, (uint)nsymbols * sizeof(UINT8));
}
static void std_huff_tables (j_decompress_ptr dinfo){
@@ -584,7 +584,7 @@ static void jpgutl_buffer_src(j_decompress_ptr cinfo, u_char *buffer, long buffe
cinfo->src->skip_input_data = jpgutl_skip_data;
cinfo->src->resync_to_restart = jpeg_resync_to_restart; /* Use default method */
cinfo->src->term_source = jpgutl_term_source;
cinfo->src->bytes_in_buffer = buffer_len;
cinfo->src->bytes_in_buffer = (ulong)buffer_len;
cinfo->src->next_input_byte = (JOCTET *) buffer;
@@ -720,7 +720,7 @@ static void put_jpeg_exif(j_compress_ptr cinfo, ctx_dev *cam,
timespec *ts1, ctx_coord *box)
{
u_char *exif = NULL;
int exif_len = jpgutl_exif(&exif, cam, ts1, box);
uint exif_len = jpgutl_exif(&exif, cam, ts1, box);
if(exif_len > 0) {
/* EXIF data lives in a JPEG APP1 marker */
@@ -802,8 +802,9 @@ int jpgutl_decode_jpeg (u_char *jpeg_data_in, int jpeg_data_len,
img_cr = img_cb + (dinfo.output_width * dinfo.output_height) / 4;
/* Allocate space for one line. */
line = (*dinfo.mem->alloc_sarray)((j_common_ptr) &dinfo, JPOOL_IMAGE,
dinfo.output_width * dinfo.output_components, 1);
line = (*dinfo.mem->alloc_sarray)
((j_common_ptr) &dinfo, JPOOL_IMAGE
,dinfo.output_width * (uint)dinfo.output_components, 1);
wline = line[0];
offset_y = 0;
@@ -876,8 +877,8 @@ int jpgutl_put_yuv420p(u_char *dest_image, int image_size,
return -1;
}
cinfo.image_width = width;
cinfo.image_height = height;
cinfo.image_width = (uint)width;
cinfo.image_height = (uint)height;
cinfo.input_components = 3;
jpeg_set_defaults(&cinfo);
@@ -897,8 +898,7 @@ int jpgutl_put_yuv420p(u_char *dest_image, int image_size,
jpeg_set_quality(&cinfo, quality, TRUE);
cinfo.dct_method = JDCT_FASTEST;
_jpeg_mem_dest(&cinfo, dest_image, image_size); // Data written to mem
_jpeg_mem_dest(&cinfo, dest_image, (uint)image_size);
jpeg_start_compress(&cinfo, TRUE);
@@ -959,8 +959,8 @@ int jpgutl_put_grey(u_char *dest_image, int image_size,
return -1;
}
cjpeg.image_width = width;
cjpeg.image_height = height;
cjpeg.image_width = (uint)width;
cjpeg.image_height = (uint)height;
cjpeg.input_components = 1; /* One colour component */
cjpeg.in_color_space = JCS_GRAYSCALE;
@@ -968,7 +968,7 @@ int jpgutl_put_grey(u_char *dest_image, int image_size,
jpeg_set_quality(&cjpeg, quality, TRUE);
cjpeg.dct_method = JDCT_FASTEST;
_jpeg_mem_dest(&cjpeg, dest_image, image_size); // Data written to mem
_jpeg_mem_dest(&cjpeg, dest_image, (uint)image_size);
jpeg_start_compress (&cjpeg, TRUE);

View File

@@ -29,7 +29,7 @@
int jpgutl_put_grey(unsigned char *dest_image, int image_size,
unsigned char *input_image, int width, int height, int quality,
ctx_dev *cam, timespec *ts1, ctx_coord *box);
int jpgutl_exif(u_char **exif, ctx_dev *cam
uint jpgutl_exif(u_char **exif, ctx_dev *cam
, timespec *ts_in1, ctx_coord *box);
#endif /* _INCLUDE_JPEGUTILS_HPP_ */

View File

@@ -239,7 +239,6 @@ int cls_libcam::start_mgr()
{
int retcd;
std::string camid;
libcamera::Size picsz;
MOTPLS_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "Starting.");
@@ -363,8 +362,8 @@ void cls_libcam::config_control_item(std::string pname, std::string pvalue)
Rectangle crop;
crop.x = mtoi(mtok(pvalue,"|"));
crop.y = mtoi(mtok(pvalue,"|"));
crop.width = mtoi(mtok(pvalue,"|"));
crop.height = mtoi(mtok(pvalue,"|"));
crop.width =(uint)mtoi(mtok(pvalue,"|"));
crop.height =(uint)mtoi(mtok(pvalue,"|"));
controls.set(controls::ScalerCrop, crop);
}
if (pname == "DigitalGain") {
@@ -401,8 +400,8 @@ void cls_libcam::config_control_item(std::string pname, std::string pvalue)
Rectangle afwin[1];
afwin[0].x = mtoi(mtok(pvalue,"|"));
afwin[0].y = mtoi(mtok(pvalue,"|"));
afwin[0].width = mtoi(mtok(pvalue,"|"));
afwin[0].height = mtoi(mtok(pvalue,"|"));
afwin[0].width = (uint)mtoi(mtok(pvalue,"|"));
afwin[0].height = (uint)mtoi(mtok(pvalue,"|"));
controls.set(controls::AfWindows, afwin);
}
if (pname == "AfTrigger") {
@@ -553,7 +552,6 @@ void cls_libcam:: config_orientation()
int cls_libcam::start_config()
{
int retcd;
libcamera::Size picsz;
MOTPLS_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "Starting.");
@@ -561,8 +559,8 @@ int cls_libcam::start_config()
config->at(0).pixelFormat = PixelFormat::fromString("YUV420");
config->at(0).size.width = conf_width;
config->at(0).size.height = conf_height;
config->at(0).size.width = (uint)conf_width;
config->at(0).size.height = (uint)conf_height;
config->at(0).bufferCount = 1;
config->at(0).stride = 0;
@@ -594,8 +592,8 @@ int cls_libcam::start_config()
, config->at(0).size.width, config->at(0).size.height);
}
cam->imgs.width = config->at(0).size.width;
cam->imgs.height = config->at(0).size.height;
cam->imgs.width = (int)config->at(0).size.width;
cam->imgs.height = (int)config->at(0).size.height;
cam->imgs.size_norm = (cam->imgs.width * cam->imgs.height * 3) / 2;
cam->imgs.motionsize = cam->imgs.width * cam->imgs.height;
@@ -661,14 +659,14 @@ int cls_libcam::start_req()
bytes = 0;
for (indx=0; indx<(int)buffer->planes().size(); indx++){
bytes += buffer->planes()[indx].length;
bytes += buffer->planes()[(uint)indx].length;
MOTPLS_LOG(DBG, TYPE_VIDEO, NO_ERRNO, "Plane %d of %d length %d"
, indx, buffer->planes().size()
, buffer->planes()[indx].length);
, buffer->planes()[(uint)indx].length);
}
if (bytes > cam->imgs.size_norm) {
width = (buffer->planes()[0].length / cam->imgs.height);
width = ((int)buffer->planes()[0].length / cam->imgs.height);
if (((int)buffer->planes()[0].length != (width * cam->imgs.height)) ||
(bytes > ((width * cam->imgs.height * 3)/2))) {
MOTPLS_LOG(ERR, TYPE_VIDEO, NO_ERRNO
@@ -684,7 +682,7 @@ int cls_libcam::start_req()
cam->imgs.motionsize = cam->imgs.width * cam->imgs.height;
}
membuf.buf = (uint8_t *)mmap(NULL, bytes, PROT_READ
membuf.buf = (uint8_t *)mmap(NULL, (uint)bytes, PROT_READ
, MAP_SHARED, plane0.fd.get(), 0);
membuf.bufsz = bytes;
@@ -817,7 +815,7 @@ int cls_libcam::next(ctx_image_data *img_data)
if (req_queue.empty() == false) {
Request *request = this->req_queue.front();
memcpy(img_data->image_norm, membuf.buf, membuf.bufsz);
mymemcpy(img_data->image_norm, membuf.buf, membuf.bufsz);
this->req_queue.pop();
request->reuse(Request::ReuseBuffers);

View File

@@ -81,7 +81,7 @@ void cls_log::write_flood(int loglvl)
}
}
void cls_log::write_norm(int loglvl, int prefixlen)
void cls_log::write_norm(int loglvl, uint prefixlen)
{
flood_cnt = 1;
@@ -145,7 +145,7 @@ void cls_log::set_log_file(std::string pname)
}
if (log_file_name == "") {
set_mode(LOGMODE_SYSLOG);
log_file_name == "syslog";
log_file_name = "syslog";
MOTPLS_LOG(NTC, TYPE_ALL, NO_ERRNO, "Logging to syslog");
}
@@ -170,9 +170,10 @@ void cls_log::set_log_file(std::string pname)
}
}
void cls_log::write_msg(int loglvl, int msg_type, int flgerr, bool flgfnc, ...)
void cls_log::write_msg(int loglvl, int msg_type, int flgerr, int flgfnc, ...)
{
int err_save, n, prefixlen;
int err_save, n;
uint prefixlen;
std::string usrfmt;
char msg_time[32];
char threadname[32];
@@ -203,14 +204,17 @@ void cls_log::write_msg(int loglvl, int msg_type, int flgerr, bool flgfnc, ...)
, "[%s][%s][%s] "
, log_level_str[loglvl],log_type_str[msg_type], threadname );
}
prefixlen = n;
prefixlen = (uint)n;
/* flgfnc must be an int. Bool has compile error*/
va_start(ap, flgfnc);
usrfmt = va_arg(ap, char *);
if (flgfnc) {
if (flgfnc == 1) {
usrfmt.append(": ").append(va_arg(ap, char *));
}
n += vsnprintf(msg_full + n, sizeof(msg_full)-n-1, usrfmt.c_str(), ap);
n += vsnprintf(msg_full + n
, sizeof(msg_full) - (uint)n - 1
, usrfmt.c_str(), ap);
va_end(ap);
add_errmsg(flgerr, err_save);

View File

@@ -51,8 +51,8 @@
#define TYPE_DEFAULT TYPE_ALL /* Default type */
#define TYPE_DEFAULT_STR "ALL" /* Default name logs */
#define MOTPLS_LOG(x, y, z, ...) motlog->write_msg(x, y, z, true, __FUNCTION__, __VA_ARGS__)
#define MOTPLS_SHT(x, y, z, ...) motlog->write_msg(x, y, z, false, __VA_ARGS__)
#define MOTPLS_LOG(x, y, z, ...) motlog->write_msg(x, y, z, 1, __FUNCTION__, __VA_ARGS__)
#define MOTPLS_SHT(x, y, z, ...) motlog->write_msg(x, y, z, 0, __VA_ARGS__)
class cls_log {
public:
@@ -61,7 +61,7 @@
int log_level;
int log_fflevel;
void set_log_file(std::string pname);
void write_msg(int loglvl, int msg_type, int flgerr, bool flgfnc, ...);
void write_msg(int loglvl, int msg_type, int flgerr, int flgfnc, ...);
private:
ctx_motapp *c_motapp;
pthread_mutex_t mtx;
@@ -74,7 +74,7 @@
int flood_cnt;
void set_mode(int mode);
void write_flood(int loglvl);
void write_norm(int loglvl, int prefixlen);
void write_norm(int loglvl, uint prefixlen);
void add_errmsg(int flgerr, int err_save);
void log_stop();

View File

@@ -52,14 +52,14 @@ static void mlp_ring_resize(ctx_dev *cam)
MOTPLS_LOG(NTC, TYPE_ALL, NO_ERRNO
,_("Resizing buffer to %d items"), new_size);
tmp =(ctx_image_data*) mymalloc(new_size * sizeof(ctx_image_data));
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);
memset(tmp[i].image_norm, 0x80, cam->imgs.size_norm);
mymemset(tmp[i].image_norm, 0x80, cam->imgs.size_norm);
if (cam->imgs.size_high > 0) {
tmp[i].image_high =(unsigned char*) mymalloc(cam->imgs.size_high);
memset(tmp[i].image_high, 0x80, cam->imgs.size_high);
mymemset(tmp[i].image_high, 0x80, cam->imgs.size_high);
}
}
@@ -246,8 +246,8 @@ static void mlp_detected(ctx_dev *cam)
/* Calculate how centric motion is if configured preview center*/
if (cam->new_img & NEWIMG_CENTER) {
distX = abs((cam->imgs.width / 2) - cam->current_image->location.x );
distY = abs((cam->imgs.height / 2) - cam->current_image->location.y);
distX = (uint)abs((cam->imgs.width / 2) - cam->current_image->location.x );
distY = (uint)abs((cam->imgs.height / 2) - cam->current_image->location.y);
cam->current_image->cent_dist = distX * distX + distY * distY;
}
@@ -410,6 +410,8 @@ int mlp_cam_next(ctx_dev *cam, ctx_image_data *img_data)
cam->rotate->process(img_data);
} else if (cam->camera_type == CAMERA_TYPE_V4L2) {
retcd = cam->v4l2cam->next(img_data);
} else {
retcd = -1;
}
return retcd;
@@ -460,7 +462,7 @@ 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++) {
memset(cam->imgs.image_ring[indx].image_norm
mymemset(cam->imgs.image_ring[indx].image_norm
, 0x80, cam->imgs.size_norm);
draw_text(cam->imgs.image_ring[indx].image_norm
, cam->imgs.width, cam->imgs.height
@@ -530,14 +532,14 @@ 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_dyn =(int*) mymalloc(cam->imgs.motionsize * sizeof(*cam->imgs.ref_dyn));
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.smartmask_buffer =(int*) mymalloc(cam->imgs.motionsize * sizeof(*cam->imgs.smartmask_buffer));
cam->imgs.labels =(int*)mymalloc(cam->imgs.motionsize * sizeof(*cam->imgs.labels));
cam->imgs.labelsize =(int*) mymalloc((cam->imgs.motionsize/2+1) * sizeof(*cam->imgs.labelsize));
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);
@@ -547,9 +549,9 @@ static void mlp_init_buffers(ctx_dev *cam)
cam->imgs.image_preview.image_high = NULL;
}
memset(cam->imgs.smartmask, 0, cam->imgs.motionsize);
memset(cam->imgs.smartmask_final, 255, cam->imgs.motionsize);
memset(cam->imgs.smartmask_buffer, 0, cam->imgs.motionsize * sizeof(*cam->imgs.smartmask_buffer));
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));
}
/* Initialize loop values */
@@ -609,11 +611,11 @@ static void mlp_init_cam_start(ctx_dev *cam)
/* initialize reference images*/
static void mlp_init_ref(ctx_dev *cam)
{
memcpy(cam->imgs.image_virgin, cam->current_image->image_norm, cam->imgs.size_norm);
mymemcpy(cam->imgs.image_virgin, cam->current_image->image_norm, cam->imgs.size_norm);
mlp_mask_privacy(cam);
memcpy(cam->imgs.image_vprvcy, cam->current_image->image_norm, cam->imgs.size_norm);
mymemcpy(cam->imgs.image_vprvcy, cam->current_image->image_norm, cam->imgs.size_norm);
alg_update_reference_frame(cam, RESET_REF_FRAME);
}
@@ -749,7 +751,7 @@ static void mlp_areadetect(ctx_dev *cam)
(cam->current_image->flags & IMAGE_TRIGGER)) {
j = (int)cam->conf->area_detect.length();
for (i = 0; i < j; i++) {
z = cam->conf->area_detect[i] - 49; /* characters are stored as ascii 48-57 (0-9) */
z = cam->conf->area_detect[(uint)i] - 49; /* characters are stored as ascii 48-57 (0-9) */
if ((z >= 0) && (z < 9)) {
if (cam->current_image->location.x > cam->area_minx[z] &&
cam->current_image->location.x < cam->area_maxx[z] &&
@@ -882,9 +884,9 @@ static int mlp_capture(ctx_dev *cam)
event(cam, EVENT_CAMERA_FOUND);
}
cam->missing_frame_counter = 0;
memcpy(cam->imgs.image_virgin, cam->current_image->image_norm, cam->imgs.size_norm);
mymemcpy(cam->imgs.image_virgin, cam->current_image->image_norm, cam->imgs.size_norm);
mlp_mask_privacy(cam);
memcpy(cam->imgs.image_vprvcy, cam->current_image->image_norm, cam->imgs.size_norm);
mymemcpy(cam->imgs.image_vprvcy, cam->current_image->image_norm, cam->imgs.size_norm);
} else {
if (cam->connectionlosttime.tv_sec == 0) {
@@ -896,7 +898,7 @@ static int mlp_capture(ctx_dev *cam)
if ((cam->device_status == STATUS_OPENED) &&
(cam->missing_frame_counter <
(cam->conf->device_tmo * cam->conf->framerate))) {
memcpy(cam->current_image->image_norm, cam->imgs.image_vprvcy, cam->imgs.size_norm);
mymemcpy(cam->current_image->image_norm, cam->imgs.image_vprvcy, cam->imgs.size_norm);
} else {
cam->lost_connection = 1;
if (cam->device_status == STATUS_OPENED) {
@@ -905,7 +907,7 @@ static int mlp_capture(ctx_dev *cam)
tmpin = "UNABLE TO OPEN VIDEO DEVICE\\nSINCE %Y-%m-%d %T";
}
memset(cam->current_image->image_norm, 0x80, cam->imgs.size_norm);
mymemset(cam->current_image->image_norm, 0x80, cam->imgs.size_norm);
cam->current_image->imgts =cam->connectionlosttime;
mystrftime(cam, tmpout, sizeof(tmpout), tmpin, NULL);
draw_text(cam->current_image->image_norm, cam->imgs.width, cam->imgs.height,
@@ -1183,8 +1185,8 @@ static void mlp_actions(ctx_dev *cam)
(cam->current_image->diffs < cam->threshold_maximum)) {
cam->current_image->flags |= IMAGE_MOTION;
cam->info_diff_cnt++;
cam->info_diff_tot += cam->current_image->diffs;
cam->info_sdev_tot += cam->current_image->location.stddev_xy;
cam->info_diff_tot += (uint)cam->current_image->diffs;
cam->info_sdev_tot += (uint)cam->current_image->location.stddev_xy;
if (cam->info_sdev_min > cam->current_image->location.stddev_xy ) {
cam->info_sdev_min = cam->current_image->location.stddev_xy;
}
@@ -1357,8 +1359,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) {
memset(cam->imgs.smartmask, 0, cam->imgs.motionsize);
memset(cam->imgs.smartmask_final, 255, cam->imgs.motionsize);
mymemset(cam->imgs.smartmask, 0, cam->imgs.motionsize);
mymemset(cam->imgs.smartmask_final, 255, cam->imgs.motionsize);
}
cam->smartmask_lastrate = cam->lastrate;
cam->smartmask_speed = cam->conf->smart_mask_speed;

View File

@@ -964,7 +964,7 @@ static void motpls_cam_delete(ctx_motapp *motapp)
}
MOTPLS_LOG(NTC, TYPE_ALL, NO_ERRNO, "Camera stopped");
tmp = (ctx_dev **)mymalloc(sizeof(ctx_dev *) * (motapp->cam_cnt));
tmp = (ctx_dev **)mymalloc(sizeof(ctx_dev *) * (uint)(motapp->cam_cnt));
tmp[motapp->cam_cnt-1] = NULL;
indx2 = 0;

View File

@@ -516,12 +516,12 @@ struct ctx_dev {
time_t lasttime;
time_t movie_start_time;
struct timespec connectionlosttime; /* timestamp from connection lost */
unsigned int lastrate;
unsigned int startup_frames;
unsigned int frame_skip;
int lastrate;
int startup_frames;
int frame_skip;
volatile bool pause;
int missing_frame_counter; /* counts failed attempts to fetch picture frame from camera */
unsigned int lost_connection;
int lost_connection;
int pipe;
int mpipe;
@@ -539,7 +539,7 @@ struct ctx_dev {
int smartmask_ratio;
int smartmask_count;
unsigned int smartmask_lastrate;
int smartmask_lastrate;
int previous_diffs, previous_location_x, previous_location_y;
bool passflag; //flag first frame vs all others.

View File

@@ -60,17 +60,17 @@ 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*) malloc(nal_info_len);
nal_info =(char*)mymalloc(nal_info_len);
if (nal_info) {
memcpy(nal_info, &pkt->data[0], nal_info_len);
mymemcpy(nal_info, &pkt->data[0], nal_info_len);
} else {
nal_info_len = 0;
}
} else if (nal_info) {
int old_size = pkt->size;
av_grow_packet(pkt, nal_info_len);
memmove(&pkt->data[nal_info_len], &pkt->data[0], old_size);
memcpy(&pkt->data[0], nal_info, nal_info_len);
memmove(&pkt->data[nal_info_len], &pkt->data[0],(uint)old_size);
mymemcpy(&pkt->data[0], nal_info, nal_info_len);
free_nal();
}
}
@@ -94,7 +94,7 @@ int cls_movie::timelapse_append(AVPacket *p_pkt)
return -1;
}
fwrite(p_pkt->data, 1, p_pkt->size, file);
fwrite(p_pkt->data, 1, (uint)p_pkt->size, file);
myfclose(file);
@@ -492,7 +492,9 @@ int cls_movie::alloc_video_buffer(AVFrame *frame, int align)
return AVERROR(EINVAL);
}
if ((ret = av_image_check_size(frame->width, frame->height, 0, nullptr)) < 0) {
if ((ret = av_image_check_size(
(uint)frame->width, (uint)frame->height
, 0, nullptr)) < 0) {
return ret;
}
@@ -526,13 +528,13 @@ int cls_movie::alloc_video_buffer(AVFrame *frame, int align)
return ret;
}
frame->buf[0] = av_buffer_alloc(ret + 4*plane_padding);
frame->buf[0] = av_buffer_alloc((uint)ret + 4*(uint)plane_padding);
if (!frame->buf[0]) {
ret = AVERROR(ENOMEM);
av_frame_unref(frame);
return ret;
}
frame->buf[1] = av_buffer_alloc(ret + 4*plane_padding);
frame->buf[1] = av_buffer_alloc((uint)ret + 4*(uint)plane_padding);
if (!frame->buf[1]) {
ret = AVERROR(ENOMEM);
av_frame_unref(frame);
@@ -1302,7 +1304,7 @@ int cls_movie::extpipe_put()
if (fileno(extpipe_stream) > 0) {
if ((cam->imgs.size_high > 0) && (cam->movie_passthrough == false)) {
if (!fwrite(cam->current_image->image_high
, cam->imgs.size_high, 1, extpipe_stream)) {
, (uint)cam->imgs.size_high, 1, extpipe_stream)) {
MOTPLS_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO
, _("Error writing in pipe , state error %d")
, ferror(extpipe_stream));
@@ -1310,7 +1312,7 @@ int cls_movie::extpipe_put()
}
} else {
if (!fwrite(cam->current_image->image_norm
, cam->imgs.size_norm, 1, extpipe_stream)) {
, (uint)cam->imgs.size_norm, 1, extpipe_stream)) {
MOTPLS_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO
,_("Error writing in pipe , state error %d")
, ferror(extpipe_stream));

View File

@@ -189,7 +189,7 @@ void cls_netcam::filelist_load()
MOTPLS_LOG(INF, TYPE_NETCAM, NO_ERRNO
, _("Directory/file not found: %s"), filedir.c_str());
} else {
path = filelist[filenbr].fullnm;
path = filelist[(uint)filenbr].fullnm;
}
MOTPLS_LOG(DBG, TYPE_NETCAM, NO_ERRNO
, _("Netcam Path: %s"),path.c_str());
@@ -200,7 +200,7 @@ void cls_netcam::check_buffsize(netcam_buff_ptr buff, size_t numbytes)
{
int min_size_to_alloc;
int real_alloc;
int new_size;
uint new_size;
if ((buff->size - buff->used) >= numbytes) {
return;
@@ -213,10 +213,9 @@ void cls_netcam::check_buffsize(netcam_buff_ptr buff, size_t numbytes)
real_alloc += NETCAM_BUFFSIZE;
}
new_size = (int)(buff->size + real_alloc);
new_size = (uint)buff->size + (uint)real_alloc;
buff->ptr =(char*) myrealloc(buff->ptr, new_size,
"check_buf_size");
buff->ptr =(char*) myrealloc(buff->ptr, new_size,"check_buf_size");
buff->size = new_size;
}
@@ -229,7 +228,7 @@ char *cls_netcam::url_match(regmatch_t m, const char *input)
len = m.rm_eo - m.rm_so;
if ((match =(char*) mymalloc(len + 1)) != NULL) {
strncpy(match, input + m.rm_so, len);
strncpy(match, input + m.rm_so, (uint)len);
match[len] = '\0';
}
}
@@ -437,9 +436,9 @@ void cls_netcam::pktarray_resize()
pthread_mutex_lock(&mutex_pktarray);
if ((pktarray_size < newsize) || (pktarray_size < 30)) {
tmp =(ctx_packet_item*) mymalloc(newsize * sizeof(ctx_packet_item));
tmp =(ctx_packet_item*) mymalloc((uint)newsize * sizeof(ctx_packet_item));
if (pktarray_size > 0 ) {
memcpy(tmp, pktarray, sizeof(ctx_packet_item) * pktarray_size);
memcpy(tmp, pktarray, sizeof(ctx_packet_item) * (uint)pktarray_size);
}
for(indx = pktarray_size; indx < newsize; indx++) {
tmp[indx].packet = nullptr;
@@ -754,8 +753,8 @@ int cls_netcam::decode_packet()
(enum AVPixelFormat) frame->format
, frame->width, frame->height, 1);
check_buffsize(img_recv, frame_size);
check_buffsize(img_latest, frame_size);
check_buffsize(img_recv, (uint)frame_size);
check_buffsize(img_latest, (uint)frame_size);
retcd = av_image_copy_to_buffer(
(uint8_t *)img_recv->ptr
@@ -771,7 +770,7 @@ int cls_netcam::decode_packet()
return -1;
}
img_recv->used = frame_size;
img_recv->used = (uint)frame_size;
return frame_size;
}
@@ -1220,8 +1219,8 @@ int cls_netcam::open_sws()
}
/* the image buffers must be big enough to hold the final frame after resizing */
check_buffsize(img_recv, swsframe_size);
check_buffsize(img_latest, swsframe_size);
check_buffsize(img_recv, (uint)swsframe_size);
check_buffsize(img_latest, (uint)swsframe_size);
return 0;
}
@@ -1258,7 +1257,7 @@ int cls_netcam::resize()
return -1;
}
buffer_out=(uint8_t *)av_malloc(swsframe_size*sizeof(uint8_t));
buffer_out=(uint8_t *)av_malloc((uint)swsframe_size*sizeof(uint8_t));
retcd = av_image_fill_arrays(
swsframe_out->data
@@ -1312,7 +1311,7 @@ int cls_netcam::resize()
context_close();
return -1;
}
img_recv->used = swsframe_size;
img_recv->used = (uint)swsframe_size;
av_free(buffer_out);

View File

@@ -30,7 +30,7 @@ void cls_picture::webp_exif(WebPMux* webp_mux
, timespec *ts1, ctx_coord *box)
{
u_char *exif = NULL;
int exif_len = jpgutl_exif(&exif, cam, ts1, box);
uint exif_len = jpgutl_exif(&exif, cam, ts1, box);
if(exif_len > 0) {
WebPData webp_exif;
@@ -147,7 +147,7 @@ void cls_picture::save_yuv420p(FILE *fp, u_char *image, int width, int height,
u_char *buf =(u_char*) mymalloc(image_size);
sz = jpgutl_put_yuv420p(buf, image_size, image, width, height, quality, cam ,ts1, box);
fwrite(buf, sz, 1, fp);
fwrite(buf, (uint)sz, 1, fp);
free(buf);
@@ -164,7 +164,7 @@ void cls_picture::save_grey(FILE *picture, u_char *image, int width, int height,
u_char *buf =(u_char*) mymalloc(image_size);
sz = jpgutl_put_grey(buf, image_size, image, width, height, quality, cam ,ts1, box);
fwrite(buf, sz, 1, picture);
fwrite(buf, (uint)sz, 1, picture);
free(buf);
}
@@ -335,7 +335,9 @@ void cls_picture::save_roi(char *file, u_char *image)
img =(u_char*) mymalloc(image_size);
for (indxh=bx->miny; indxh< bx->miny + bx->height; indxh++){
memcpy(img+((indxh - bx->miny)* bx->width), image+(indxh*cam->imgs.width) + bx->minx, bx->width);
mymemcpy(img+((indxh - bx->miny)* bx->width)
, image+(indxh*cam->imgs.width) + bx->minx
, bx->width);
}
sz = jpgutl_put_grey(buf, image_size, img
@@ -343,7 +345,7 @@ void cls_picture::save_roi(char *file, u_char *image)
, picture_quality, cam
,&(cam->current_image->imgts), bx);
fwrite(buf, sz, 1, picture);
fwrite(buf, (uint)sz, 1, picture);
free(buf);
free(img);
@@ -406,7 +408,7 @@ u_char *cls_picture::load_pgm(FILE *picture, int width, int height)
image =(u_char*) mymalloc((mask_width * mask_height * 3) / 2);
for (y = 0; y < mask_height; y++) {
if ((int)fread(&image[y * mask_width], 1, mask_width, picture) != mask_width) {
if ((int)fread(&image[y * mask_width], 1, (uint)mask_width, picture) != mask_width) {
MOTPLS_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "Failed reading image data from pgm file");
}
@@ -459,7 +461,7 @@ void cls_picture::write_mask(const char *file)
}
return;
}
memset(cam->imgs.image_motion.image_norm, 255, cam->imgs.motionsize); /* Initialize to unset */
mymemset(cam->imgs.image_motion.image_norm, 255, cam->imgs.motionsize); /* Initialize to unset */
/* Write pgm-header. */
fprintf(picture, "P5\n");
@@ -467,7 +469,7 @@ void cls_picture::write_mask(const char *file)
fprintf(picture, "%d\n", 255);
/* Write pgm image data at once. */
if ((int)fwrite(cam->imgs.image_motion.image_norm, cfg_w, cfg_h, picture) != cfg_h) {
if ((int)fwrite(cam->imgs.image_motion.image_norm, (uint)cfg_w, (uint)cfg_h, picture) != cfg_h) {
MOTPLS_LOG(ERR, TYPE_ALL, SHOW_ERRNO
,_("Failed writing default mask as pgm file"));
return;
@@ -514,10 +516,10 @@ void cls_picture::save_preview()
cam->imgs.image_preview.image_high = image_high;
/* Copy the actual images for norm and high */
memcpy(cam->imgs.image_preview.image_norm
mymemcpy(cam->imgs.image_preview.image_norm
, cam->current_image->image_norm, cam->imgs.size_norm);
if (cam->imgs.size_high > 0) {
memcpy(cam->imgs.image_preview.image_high
mymemcpy(cam->imgs.image_preview.image_high
, cam->current_image->image_high, cam->imgs.size_high);
}

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);
memcpy(img, temp_buff, size);
mymemcpy(img, temp_buff, 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);
memcpy(img, temp_buff, size);
mymemcpy(img, temp_buff, size);
break;
default:
break;

View File

@@ -235,7 +235,7 @@ static void snd_alsa_list_subdev(ctx_dev *snd)
, snd_pcm_info_get_subdevices_avail(alsa->pcm_info),cnt);
for (indx=0; indx<cnt; indx++) {
snd_pcm_info_set_subdevice(alsa->pcm_info,indx);
snd_pcm_info_set_subdevice(alsa->pcm_info, (uint)indx);
retcd = snd_ctl_pcm_info(alsa->ctl_hdl, alsa->pcm_info);
if (retcd < 0) {
MOTPLS_LOG(ERR, TYPE_ALL, NO_ERRNO
@@ -272,7 +272,7 @@ static void snd_alsa_list_card(ctx_dev *snd)
}
while (alsa->device_id >= 0) {
snd_pcm_info_set_device(alsa->pcm_info, alsa->device_id);
snd_pcm_info_set_device(alsa->pcm_info, (uint)alsa->device_id);
snd_pcm_info_set_subdevice(alsa->pcm_info, 0);
snd_pcm_info_set_stream(alsa->pcm_info, SND_PCM_STREAM_CAPTURE);
retcd = snd_ctl_pcm_info(alsa->ctl_hdl, alsa->pcm_info);
@@ -341,7 +341,7 @@ static void snd_alsa_start(ctx_dev *snd)
unsigned int actl_rate, smpl_rate;
int retcd;
frames_per = info->frames;
frames_per = (uint)info->frames;
smpl_rate = (unsigned int)info->sample_rate;
retcd = snd_pcm_open(&alsa->pcm_dev
@@ -403,7 +403,7 @@ static void snd_alsa_start(ctx_dev *snd)
}
retcd = snd_pcm_hw_params_set_channels(alsa->pcm_dev
, hw_params, info->channels);
, hw_params, (uint)info->channels);
if (retcd < 0) {
MOTPLS_LOG(ERR, TYPE_ALL, NO_ERRNO
, _("error: snd_pcm_hw_params_set_channels(%s)")
@@ -485,8 +485,8 @@ static void snd_alsa_start(ctx_dev *snd)
/*************************************************************/
info->frames = (int)frames_per;
info->buffer_size = info->frames * 2;
info->buffer = (int16_t*)mymalloc(info->buffer_size * sizeof(int16_t));
memset(info->buffer, 0x00, info->buffer_size * sizeof(int16_t));
info->buffer = (int16_t*)mymalloc((uint)info->buffer_size * sizeof(int16_t));
mymemset(info->buffer, 0x00, (uint)info->buffer_size * sizeof(int16_t));
MOTPLS_LOG(NTC, TYPE_ALL, NO_ERRNO, "Started.");
snd->device_status =STATUS_OPENED;
@@ -528,7 +528,7 @@ static void snd_alsa_capture(ctx_dev *snd)
ctx_snd_alsa *alsa = snd->snd_info->snd_alsa;
long int retcd;
retcd = snd_pcm_readi(alsa->pcm_dev, info->buffer, info->frames);
retcd = snd_pcm_readi(alsa->pcm_dev, info->buffer, (uint)info->frames);
if (retcd != info->frames) {
MOTPLS_LOG(ERR, TYPE_ALL, NO_ERRNO
, _("error: read from audio interface failed (%s)")
@@ -587,8 +587,8 @@ static void snd_pulse_init(ctx_dev *snd)
return;
}
info->buffer_size = info->frames * 2;
info->buffer = (int16_t*)mymalloc(info->buffer_size * sizeof(int16_t));
memset(info->buffer, 0x00, info->buffer_size * sizeof(int16_t));
info->buffer = (int16_t*)mymalloc((uint)info->buffer_size * sizeof(int16_t));
mymemset(info->buffer, 0x00, (uint)info->buffer_size * sizeof(int16_t));
MOTPLS_LOG(NTC, TYPE_ALL, NO_ERRNO, "Started.");
snd->device_status =STATUS_OPENED;
@@ -608,7 +608,7 @@ static void snd_pulse_capture(ctx_dev *snd)
int errcd, retcd;
retcd = pa_simple_read(pulse->dev, info->buffer
, info->buffer_size, &errcd);
, (uint)info->buffer_size, &errcd);
if (retcd < 0) {
MOTPLS_LOG(ERR, TYPE_ALL, NO_ERRNO
, _("Error capturing PulseAudio (%s)")
@@ -656,9 +656,9 @@ static void snd_fftw_open(ctx_dev *snd)
, _("Opening FFTW plan"));
fftw->ff_in = (double*) fftw_malloc(
sizeof(fftw_complex) * info->frames);
sizeof(fftw_complex) * (uint)info->frames);
fftw->ff_out = (fftw_complex*) fftw_malloc(
sizeof(fftw_complex) * info->frames);
sizeof(fftw_complex) * (uint)info->frames);
fftw->ff_plan = fftw_plan_dft_r2c_1d(
info->frames, fftw->ff_in, fftw->ff_out, FFTW_MEASURE);

View File

@@ -119,6 +119,25 @@ 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) {
@@ -130,6 +149,36 @@ 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)
{
@@ -282,7 +331,7 @@ static void mystrftime_long (const ctx_dev *cam,
int width, const char *word, int l, char *out)
{
#define SPECIFIERWORD(k) ((strlen(k)==l) && (!strncmp (k, word, l)))
#define SPECIFIERWORD(k) ((strlen(k)==(uint)l) && (!strncmp(k, word, (uint)l)))
if (SPECIFIERWORD("host")) {
snprintf (out, PATH_MAX, "%*s", width, cam->hostname);

View File

@@ -74,9 +74,17 @@
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);
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);
FILE *myfopen(const char *path, const char *mode);

View File

@@ -345,7 +345,7 @@ void cls_convert::uyvyto420p(u_char *img_dst, u_char *img_src)
u_char *pY = img_dst;
u_char *pU = pY + (width * height);
u_char *pV = pU + (width * height) / 4;
unsigned int uv_offset = width * 2 * sizeof(u_char);
unsigned int uv_offset = (uint)width * 2 * sizeof(u_char);
int ix, jx;
for (ix = 0; ix < height; ix++) {
@@ -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;
memset(u, 0, width * height / 4);
memset(v, 0, width * height / 4);
mymemset(u, 0, width * height / 4);
mymemset(v, 0, width * height / 4);
for (loop = 0; loop < height; loop++) {
for (i = 0; i < width; i += 2) {
@@ -449,7 +449,7 @@ int cls_convert::mjpegtoyuv420p(u_char *img_dst, u_char *img_src, int size)
size_t soi_pos = 0;
int ret = 0;
ptr_buffer =(u_char*) memmem(img_src, size, "\xff\xd8", 2);
ptr_buffer =(u_char*) memmem(img_src, (uint)size, "\xff\xd8", 2);
if (ptr_buffer == NULL) {
MOTPLS_LOG(CRT, TYPE_VIDEO, NO_ERRNO,_("Corrupt image ... continue"));
return 1;
@@ -458,19 +458,21 @@ int cls_convert::mjpegtoyuv420p(u_char *img_dst, u_char *img_src, int size)
Some cameras are sending multiple SOIs in the buffer.
Move the pointer to the last SOI in the buffer and proceed.
*/
while (ptr_buffer != NULL && ((size - soi_pos - 1) > 2) ){
soi_pos = ptr_buffer - img_src;
ptr_buffer =(u_char*) memmem(img_src + soi_pos + 1, size - soi_pos - 1, "\xff\xd8", 2);
while (ptr_buffer != NULL && (((uint)size - soi_pos - 1) > 2) ){
soi_pos = (uint)(ptr_buffer - img_src);
ptr_buffer =(u_char*) memmem(
img_src + soi_pos + 1
, (uint)size - soi_pos - 1, "\xff\xd8", 2);
}
if (soi_pos != 0) {
MOTPLS_LOG(INF, TYPE_VIDEO, NO_ERRNO,_("SOI position adjusted by %d bytes."), soi_pos);
}
memmove(img_src, img_src + soi_pos, size - soi_pos);
memmove(img_src, img_src + soi_pos, (uint)size - soi_pos);
size -= (unsigned int)soi_pos;
ret = jpgutl_decode_jpeg(img_src,size, width, height, img_dst);
ret = jpgutl_decode_jpeg(img_src,size, (uint)width, (uint)height, img_dst);
if (ret == -1) {
MOTPLS_LOG(CRT, TYPE_VIDEO, NO_ERRNO,_("Corrupt image ... continue"));
@@ -491,27 +493,27 @@ void cls_convert::y10torgb24(u_char *img_dst, u_char *img_src, int shift)
int src_size[2] = {width,height};
int bpp = 16;
unsigned int src_stride = (src_size[0] * bpp) / 8;
unsigned int rgb_stride = src_size[0] * 3;
int src_stride =((src_size[0] * bpp) / 8);
int rgb_stride =(src_size[0] * 3);
int a = 0;
int src_x = 0, src_y = 0;
int dst_x = 0, dst_y = 0;
for (src_y = 0, dst_y = 0; dst_y < src_size[1]; src_y++, dst_y++) {
for (src_x = 0, dst_x = 0; dst_x < src_size[0]; src_x++, dst_x++) {
a = (img_src[src_y*src_stride + src_x*2+0] |
(img_src[src_y*src_stride + src_x*2+1] << 8)) >> shift;
img_dst[dst_y*rgb_stride+3*dst_x+0] = (u_char)a;
img_dst[dst_y*rgb_stride+3*dst_x+1] = (u_char)a;
img_dst[dst_y*rgb_stride+3*dst_x+2] = (u_char)a;
a = (img_src[(uint)(src_y*src_stride + src_x*2+0)] |
(img_src[(uint)(src_y*src_stride + src_x*2+1)] << 8)) >> shift;
img_dst[(uint)(dst_y*rgb_stride+3*dst_x+0)] = (u_char)a;
img_dst[(uint)(dst_y*rgb_stride+3*dst_x+1)] = (u_char)a;
img_dst[(uint)(dst_y*rgb_stride+3*dst_x+2)] = (u_char)a;
}
}
}
void cls_convert::greytoyuv420p(u_char *img_dst, u_char *img_src)
{
memcpy(img_dst, img_src, (width*height));
memset(img_dst+(width*height), 128, (width * height) / 2);
memcpy(img_dst, img_src, (uint)(width*height));
mymemset(img_dst+(width*height), 128, (width * height) / 2);
}
/* Convert captured image to the standard pixel format*/
@@ -537,7 +539,7 @@ int cls_convert::process(u_char *img_dst, u_char *img_src, int clen)
return 0;
case V4L2_PIX_FMT_YUV420:
memcpy(img_dst, img_src, clen);
mymemcpy(img_dst, img_src, clen);
return 0;
case V4L2_PIX_FMT_PJPG:

View File

@@ -204,11 +204,11 @@ int vlp_startpipe(const char *dev_name, int width, int height)
vlp_show_vfmt(&v);
v.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
v.fmt.pix.width = width;
v.fmt.pix.height = height;
v.fmt.pix.width = (uint)width;
v.fmt.pix.height = (uint)height;
v.fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420;
v.fmt.pix.sizeimage = 3 * width * height / 2;
v.fmt.pix.bytesperline = width;
v.fmt.pix.sizeimage =(uint)(3 * width * height / 2);
v.fmt.pix.bytesperline = (uint)width;
v.fmt.pix.field = V4L2_FIELD_NONE;
v.fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
MOTPLS_LOG(INF, TYPE_VIDEO, NO_ERRNO,_("Proposed pipe specifications"));
@@ -231,7 +231,7 @@ int vlp_putpipe(int dev, unsigned char *image, int imgsize)
{
#if (defined(HAVE_V4L2)) && (!defined(BSD))
return (int)write(dev, image, imgsize);
return (int)write(dev, image, (uint)imgsize);
#else
(void)dev;
(void)image;

View File

@@ -132,7 +132,7 @@ void cls_v4l2cam::ctrls_list()
}
device_ctrls.clear();
memset(&vid_ctrl, 0, sizeof(struct v4l2_queryctrl));
mymemset(&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,9 +154,9 @@ void cls_v4l2cam::ctrls_list()
if (vid_ctrl.type == V4L2_CTRL_TYPE_MENU) {
for (indx = vid_ctrl.minimum; indx <= vid_ctrl.maximum; indx++) {
memset(&vid_menu, 0, sizeof(struct v4l2_querymenu));
mymemset(&vid_menu, 0, sizeof(struct v4l2_querymenu));
vid_menu.id = vid_ctrl.id;
vid_menu.index = indx;
vid_menu.index = (uint)indx;
if (xioctl(VIDIOC_QUERYMENU, &vid_menu) == 0) {
vid_item.ctrl_id = vid_ctrl.id;
vid_item.ctrl_type = 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) {
memset(&vid_ctrl, 0, sizeof (struct v4l2_control));
mymemset(&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,11 +285,11 @@ void cls_v4l2cam::set_input()
}
}
memset(&input, 0, sizeof (struct v4l2_input));
mymemset(&input, 0, sizeof (struct v4l2_input));
if (spec == -1) {
input.index = 0;
} else {
input.index = spec;
input.index = (uint)spec;
}
if (xioctl(VIDIOC_ENUMINPUT, &input) == -1) {
@@ -321,8 +321,8 @@ void cls_v4l2cam::set_input()
return;
}
device_type = input.type;
device_tuner = input.tuner;
device_type = (int)input.type;
device_tuner = (int)input.tuner;
return;
}
@@ -355,7 +355,7 @@ void cls_v4l2cam::set_norm()
}
if (std_id) {
memset(&standard, 0, sizeof(struct v4l2_standard));
mymemset(&standard, 0, sizeof(struct v4l2_standard));
standard.index = 0;
while (xioctl(VIDIOC_ENUMSTD, &standard) == 0) {
@@ -419,8 +419,8 @@ 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. */
memset(&tuner, 0, sizeof(struct v4l2_tuner));
tuner.index = device_tuner;
mymemset(&tuner, 0, sizeof(struct v4l2_tuner));
tuner.index = (uint)device_tuner;
if (xioctl(VIDIOC_G_TUNER, &tuner) == -1) {
MOTPLS_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO
@@ -431,8 +431,8 @@ void cls_v4l2cam::set_frequency()
MOTPLS_LOG(NTC, TYPE_VIDEO, NO_ERRNO, _("Set tuner %d"), tuner.index);
/* Set the frequency. */
memset(&freq, 0, sizeof(struct v4l2_frequency));
freq.tuner = device_tuner;
mymemset(&freq, 0, sizeof(struct v4l2_frequency));
freq.tuner = (uint)device_tuner;
freq.type = V4L2_TUNER_ANALOG_TV;
freq.frequency = (uint)((spec / 1000) * 16);
@@ -452,11 +452,11 @@ int cls_v4l2cam::pixfmt_try(uint pixformat)
{
int retcd;
memset(&vidfmt, 0, sizeof(struct v4l2_format));
mymemset(&vidfmt, 0, sizeof(struct v4l2_format));
vidfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
vidfmt.fmt.pix.width = width;
vidfmt.fmt.pix.height = height;
vidfmt.fmt.pix.width = (uint)width;
vidfmt.fmt.pix.height = (uint)height;
vidfmt.fmt.pix.pixelformat = pixformat;
vidfmt.fmt.pix.field = V4L2_FIELD_ANY;
@@ -542,8 +542,8 @@ int cls_v4l2cam::pixfmt_adjust()
,vidfmt.fmt.pix.width
,vidfmt.fmt.pix.height);
width = vidfmt.fmt.pix.width;
height = vidfmt.fmt.pix.height;
width = (int)vidfmt.fmt.pix.width;
height = (int)vidfmt.fmt.pix.height;
if ((width % 8) || (height % 8)) {
MOTPLS_LOG(ERR, TYPE_VIDEO, NO_ERRNO
@@ -581,7 +581,7 @@ int cls_v4l2cam::pixfmt_set(uint pixformat)
return -1;
}
pixfmt_src = pixformat;
pixfmt_src = (int)pixformat;
MOTPLS_LOG(NTC, TYPE_VIDEO, NO_ERRNO
,_("Using palette %c%c%c%c (%dx%d)")
@@ -640,8 +640,8 @@ int cls_v4l2cam::pixfmt_list()
MOTPLS_LOG(NTC, TYPE_VIDEO, NO_ERRNO, _("Supported palettes:"));
v4l2_pal = 0;
memset(&fmtd, 0, sizeof(struct v4l2_fmtdesc));
fmtd.index = v4l2_pal;
mymemset(&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 */
@@ -652,14 +652,14 @@ int cls_v4l2cam::pixfmt_list()
, fmtd.pixelformat >> 16, fmtd.pixelformat >> 24
, fmtd.description);
for (indx = 0; indx < (int)palette.size(); indx++) {
if (palette[indx].v4l2id == fmtd.pixelformat) {
if (palette[(uint)indx].v4l2id == fmtd.pixelformat) {
indx_palette = indx;
}
}
v4l2_pal++;
memset(&fmtd, 0, sizeof(struct v4l2_fmtdesc));
fmtd.index = v4l2_pal;
mymemset(&fmtd, 0, sizeof(struct v4l2_fmtdesc));
fmtd.index = (uint)v4l2_pal;
fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
@@ -687,14 +687,14 @@ void cls_v4l2cam::palette_set()
}
}
retcd = pixfmt_set(palette[indxp].v4l2id);
retcd = pixfmt_set(palette[(uint)indxp].v4l2id);
if (retcd == 0) {
return;
}
MOTPLS_LOG(NTC, TYPE_VIDEO, NO_ERRNO
,_("Configuration palette index %d (%s) for %dx%d doesn't work.")
, indxp, palette[indxp].fourcc.c_str()
, indxp, palette[(uint)indxp].fourcc.c_str()
,width, height);
indxp = pixfmt_list();
@@ -705,18 +705,18 @@ void cls_v4l2cam::palette_set()
return;
}
retcd = pixfmt_set(palette[indxp].v4l2id);
retcd = pixfmt_set(palette[(uint)indxp].v4l2id);
if (retcd < 0) {
MOTPLS_LOG(ERR, TYPE_VIDEO, NO_ERRNO
, _("Palette selection failed for format %s")
, palette[indxp].fourcc.c_str());
, palette[(uint)indxp].fourcc.c_str());
device_close();
return;
}
MOTPLS_LOG(NTC, TYPE_VIDEO, NO_ERRNO
,_("Selected palette index %d (%s)")
,indxp, palette[indxp].fourcc.c_str());
,indxp, palette[(uint)indxp].fourcc.c_str());
}
@@ -735,7 +735,7 @@ void cls_v4l2cam::set_mmap()
return;
}
memset(&vidreq, 0, sizeof(struct v4l2_requestbuffers));
mymemset(&vidreq, 0, sizeof(struct v4l2_requestbuffers));
vidreq.count = MMAP_BUFFERS;
vidreq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -747,7 +747,7 @@ void cls_v4l2cam::set_mmap()
device_close();
return;
}
buffer_count = vidreq.count;
buffer_count = (int)vidreq.count;
MOTPLS_LOG(DBG, TYPE_VIDEO, NO_ERRNO
,_("mmap information: frames=%d"), buffer_count);
@@ -760,7 +760,7 @@ void cls_v4l2cam::set_mmap()
return;
}
buffers =(video_buff*) calloc(buffer_count, sizeof(video_buff));
buffers =(video_buff*) calloc((uint)buffer_count, sizeof(video_buff));
if (buffers == nullptr) {
MOTPLS_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, _("Out of memory."));
device_close();
@@ -770,11 +770,11 @@ void cls_v4l2cam::set_mmap()
for (buffer_index = 0; buffer_index < buffer_count; buffer_index++) {
struct v4l2_buffer p_buf;
memset(&p_buf, 0, sizeof(struct v4l2_buffer));
mymemset(&p_buf, 0, sizeof(struct v4l2_buffer));
p_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
p_buf.memory = V4L2_MEMORY_MMAP;
p_buf.index = buffer_index;
p_buf.index = (uint)buffer_index;
if (xioctl(VIDIOC_QUERYBUF, &p_buf) == -1) {
MOTPLS_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO
,_("Error querying buffer %i\nVIDIOC_QUERYBUF: ")
@@ -803,11 +803,11 @@ void cls_v4l2cam::set_mmap()
}
for (buffer_index = 0; buffer_index < buffer_count; buffer_index++) {
memset(&vidbuf, 0, sizeof(struct v4l2_buffer));
mymemset(&vidbuf, 0, sizeof(struct v4l2_buffer));
vidbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
vidbuf.memory = V4L2_MEMORY_MMAP;
vidbuf.index = buffer_index;
vidbuf.index = (uint)buffer_index;
if (xioctl(VIDIOC_QBUF, &vidbuf) == -1) {
MOTPLS_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "VIDIOC_QBUF");
@@ -869,7 +869,7 @@ int cls_v4l2cam::capture()
}
}
memset(&vidbuf, 0, sizeof(struct v4l2_buffer));
mymemset(&vidbuf, 0, sizeof(struct v4l2_buffer));
vidbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
vidbuf.memory = V4L2_MEMORY_MMAP;
@@ -882,9 +882,9 @@ int cls_v4l2cam::capture()
return -1;
}
pframe = vidbuf.index;
pframe = (int)vidbuf.index;
buffers[vidbuf.index].used = vidbuf.bytesused;
buffers[vidbuf.index].content_length = vidbuf.bytesused;
buffers[vidbuf.index].content_length = (int)vidbuf.bytesused;
pthread_sigmask(SIG_UNBLOCK, &old, nullptr); /*undo the signal blocking */
return 0;
@@ -1010,7 +1010,7 @@ void cls_v4l2cam::log_formats()
return;
}
memset(&dev_format, 0, sizeof(struct v4l2_fmtdesc));
mymemset(&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);
memset(&dev_sizes, 0, sizeof(struct v4l2_frmsizeenum));
mymemset(&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);
memset(&dev_frameint, 0, sizeof(struct v4l2_frmivalenum));
mymemset(&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,18 +1041,18 @@ void cls_v4l2cam::log_formats()
,_(" Framerate %d/%d")
,dev_frameint.discrete.numerator
,dev_frameint.discrete.denominator);
memset(&dev_frameint, 0, sizeof(struct v4l2_frmivalenum));
dev_frameint.index = ++indx_frameint;
mymemset(&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;
}
memset(&dev_sizes, 0, sizeof(struct v4l2_frmsizeenum));
dev_sizes.index = ++indx_sizes;
mymemset(&dev_sizes, 0, sizeof(struct v4l2_frmsizeenum));
dev_sizes.index = (uint)(++indx_sizes);
dev_sizes.pixel_format = dev_format.pixelformat;
}
memset(&dev_format, 0, sizeof(struct v4l2_fmtdesc));
dev_format.index = ++indx_format;
mymemset(&dev_format, 0, sizeof(struct v4l2_fmtdesc));
dev_format.index = (uint)(++indx_format);
dev_format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
@@ -1068,11 +1068,11 @@ void cls_v4l2cam::set_fps()
return;
}
memset(&setfps, 0, sizeof(struct v4l2_streamparm));
mymemset(&setfps, 0, sizeof(struct v4l2_streamparm));
setfps.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
setfps.parm.capture.timeperframe.numerator = 1;
setfps.parm.capture.timeperframe.denominator = fps;
setfps.parm.capture.timeperframe.denominator = (uint)fps;
MOTPLS_LOG(INF, TYPE_VIDEO, NO_ERRNO
, _("Trying to set fps to %d")

View File

@@ -188,7 +188,7 @@ void cls_webu::mhd_loadfile(std::string fname,std::string &filestr)
infile = myfopen(fname.c_str() , "rbe");
if (infile != NULL) {
fseek(infile, 0, SEEK_END);
file_size = ftell(infile);
file_size = (size_t)(infile);
if (file_size > 0 ) {
file_char = (char*)mymalloc(file_size +1);
fseek(infile, 0, SEEK_SET);

View File

@@ -148,7 +148,7 @@ void cls_webu_ans::parms_edit()
if (uri_camid.length() > 0) {
is_nbr = true;
for (indx=0; indx < (int)uri_camid.length(); indx++) {
if ((uri_camid[indx] > '9') || (uri_camid[indx] < '0')) {
if ((uri_camid[(uint)indx] > '9') || (uri_camid[(uint)indx] < '0')) {
is_nbr = false;
}
}
@@ -505,13 +505,13 @@ void cls_webu_ans::mhd_auth_parse()
if (col_pos == NULL) {
auth_user = (char*)mymalloc(auth_len+1);
auth_pass = (char*)mymalloc(2);
snprintf(auth_user, auth_len + 1, "%s"
snprintf(auth_user, (uint)auth_len + 1, "%s"
,app->conf->webcontrol_authentication.c_str());
snprintf(auth_pass, 2, "%s","");
} else {
auth_user = (char*)mymalloc(auth_len - strlen(col_pos) + 1);
auth_user = (char*)mymalloc((uint)auth_len - strlen(col_pos) + 1);
auth_pass =(char*)mymalloc(strlen(col_pos));
snprintf(auth_user, auth_len - strlen(col_pos) + 1, "%s"
snprintf(auth_user, (uint)auth_len - strlen(col_pos) + 1, "%s"
,app->conf->webcontrol_authentication.c_str());
snprintf(auth_pass, strlen(col_pos), "%s", col_pos + 1);
}

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;
memset(dst, 0x00, (size_t)img_sz);
mymemset(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;
memset(resp_image, '\0', resp_size);
mymemset(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);
memset(all_img_data , 0x80, (size_t)a_u);
memset(all_img_data + a_u, 0x80, (size_t)(a_u/2));
mymemset(all_img_data , 0x80, (size_t)a_u);
mymemset(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];
@@ -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);
memset(src_img, 0x00, src_sz);
mymemset(src_img, 0x00, src_sz);
} else {
memcpy(src_img, strm->img_data, src_sz);
mymemcpy(src_img, strm->img_data, 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++) {
memcpy(all_img_data + a_y, dst_img + c_y, dst_w);
mymemcpy(all_img_data + a_y, dst_img + c_y, dst_w);
a_y += all_sz->width;
c_y += dst_w;
if (row % 2) {
memcpy(all_img_data + a_u, dst_img + c_u, dst_w / 2);
//memset(webui->all_img_data + a_u, 0xFA, dst_w/2);
mymemcpy(all_img_data + a_u, dst_img + c_u, 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);
memcpy(all_img_data + a_v, dst_img + c_v, dst_w / 2);
mymemcpy(all_img_data + a_v, dst_img + c_v, dst_w / 2);
a_v += (all_sz->width / 2);
c_v += (dst_w / 2);
}
@@ -561,8 +561,8 @@ void cls_webu_common::one_buffer()
myfree(&resp_image);
}
resp_image = (unsigned char*) mymalloc(webua->cam->imgs.size_norm);
memset(resp_image,'\0',webua->cam->imgs.size_norm);
resp_size = webua->cam->imgs.size_norm;
mymemset(resp_image,'\0',webua->cam->imgs.size_norm);
resp_size = (uint)webua->cam->imgs.size_norm;
resp_used = 0;
}
}
@@ -573,9 +573,9 @@ void cls_webu_common::all_buffer()
if (resp_image != nullptr) {
myfree(&resp_image);
}
resp_size = app->all_sizes->img_sz;
resp_size = (uint)app->all_sizes->img_sz;
resp_image = (unsigned char*) mymalloc(resp_size);
memset(resp_image, '\0', resp_size);
mymemset(resp_image, '\0', resp_size);
resp_used = 0;
}
if ((all_img_data == nullptr) &&

View File

@@ -33,7 +33,7 @@ static ssize_t webu_file_reader (void *cls, uint64_t pos, char *buf, size_t max)
cls_webu_ans *webu_ans =(cls_webu_ans *)cls;
(void)fseek (webu_ans->req_file, (long)pos, SEEK_SET);
return fread (buf, 1, max, webu_ans->req_file);
return (ssize_t)fread (buf, 1, max, webu_ans->req_file);
}
/* Close the requested file */
@@ -98,10 +98,10 @@ void cls_webu_file::main() {
"</head><body>Bad File</body></html>";
webua->resp_type = WEBUI_RESP_HTML;
webua->mhd_send();
retcd = MHD_YES;
} else {
response = MHD_create_response_from_callback (
statbuf.st_size, 32 * 1024
(size_t)statbuf.st_size, 32 * 1024
, &webu_file_reader
, this
, &webu_file_free);

View File

@@ -127,7 +127,7 @@ static void webu_getimg_norm(ctx_dev *cam)
if (cam->stream.norm.img_data == NULL) {
cam->stream.norm.img_data =(unsigned char*)mymalloc(cam->imgs.size_norm);
}
memcpy(cam->stream.norm.img_data, cam->current_image->image_norm, cam->imgs.size_norm);
mymemcpy(cam->stream.norm.img_data, cam->current_image->image_norm, cam->imgs.size_norm);
}
}
@@ -194,9 +194,9 @@ static void webu_getimg_sub(ctx_dev *cam)
,cam->imgs.height
,cam->current_image->image_norm
,cam->imgs.image_substream);
memcpy(cam->stream.sub.img_data, cam->imgs.image_substream, subsize);
mymemcpy(cam->stream.sub.img_data, cam->imgs.image_substream, subsize);
} else {
memcpy(cam->stream.sub.img_data, cam->current_image->image_norm, cam->imgs.size_norm);
mymemcpy(cam->stream.sub.img_data, cam->current_image->image_norm, cam->imgs.size_norm);
}
}
@@ -230,7 +230,7 @@ static void webu_getimg_motion(ctx_dev *cam)
if (cam->stream.motion.img_data == NULL) {
cam->stream.motion.img_data =(unsigned char*)mymalloc(cam->imgs.size_norm);
}
memcpy(cam->stream.motion.img_data
mymemcpy(cam->stream.motion.img_data
, cam->imgs.image_motion.image_norm
, cam->imgs.size_norm);
}
@@ -264,7 +264,7 @@ static void webu_getimg_source(ctx_dev *cam)
if (cam->stream.source.img_data == NULL) {
cam->stream.source.img_data =(unsigned char*)mymalloc(cam->imgs.size_norm);
}
memcpy(cam->stream.source.img_data
mymemcpy(cam->stream.source.img_data
, cam->imgs.image_virgin
, cam->imgs.size_norm);
}
@@ -286,7 +286,7 @@ static void webu_getimg_secondary(ctx_dev *cam)
cam->stream.secondary.jpg_data =(unsigned char*)mymalloc(cam->imgs.size_norm);
}
memcpy(cam->stream.secondary.jpg_data,cam->imgs.image_secondary,cam->imgs.size_secondary);
mymemcpy(cam->stream.secondary.jpg_data,cam->imgs.image_secondary,cam->imgs.size_secondary);
cam->stream.secondary.jpg_sz = cam->imgs.size_secondary;
pthread_mutex_unlock(&cam->algsec->mutex);
} else {
@@ -297,7 +297,7 @@ static void webu_getimg_secondary(ctx_dev *cam)
if (cam->stream.secondary.img_data == NULL) {
cam->stream.secondary.img_data =(unsigned char*)mymalloc(cam->imgs.size_norm);
}
memcpy(cam->stream.secondary.img_data
mymemcpy(cam->stream.secondary.img_data
, cam->current_image->image_norm, cam->imgs.size_norm);
}

View File

@@ -152,7 +152,7 @@ int cls_webu_mpegts::getimg()
clock_gettime(CLOCK_REALTIME, &curr_ts);
memset(webuc->resp_image, '\0', webuc->resp_size);
mymemset(webuc->resp_image, '\0', webuc->resp_size);
webuc->resp_used = 0;
if (webua->device_id > 0) {
@@ -175,9 +175,9 @@ int cls_webu_mpegts::getimg()
img_data = (unsigned char*) mymalloc(img_sz);
pthread_mutex_lock(&webua->cam->stream.mutex);
if (strm->img_data == NULL) {
memset(img_data, 0x00, img_sz);
mymemset(img_data, 0x00, img_sz);
} else {
memcpy(img_data, strm->img_data, img_sz);
mymemcpy(img_data, strm->img_data, img_sz);
strm->consumed = true;
}
pthread_mutex_unlock(&webua->cam->stream.mutex);
@@ -186,7 +186,7 @@ int cls_webu_mpegts::getimg()
img_data = (unsigned char*) mymalloc(app->all_sizes->img_sz);
memcpy(img_data, webuc->all_img_data, app->all_sizes->img_sz);
mymemcpy(img_data, webuc->all_img_data, app->all_sizes->img_sz);
}
if (pic_send(img_data) < 0) {
@@ -204,8 +204,8 @@ int cls_webu_mpegts::getimg()
int cls_webu_mpegts::avio_buf(myuint *buf, int buf_size)
{
if (webuc->resp_size < (size_t)(buf_size + webuc->resp_used)) {
webuc->resp_size = (size_t)(buf_size + webuc->resp_used);
if (webuc->resp_size < (size_t)buf_size + webuc->resp_used) {
webuc->resp_size = (size_t)buf_size + webuc->resp_used;
webuc->resp_image = (unsigned char*)realloc(
webuc->resp_image, webuc->resp_size);
MOTPLS_LOG(ERR, TYPE_STREAM, NO_ERRNO
@@ -215,8 +215,8 @@ int cls_webu_mpegts::avio_buf(myuint *buf, int buf_size)
,buf_size);
}
memcpy(webuc->resp_image + webuc->resp_used, buf, buf_size);
webuc->resp_used += buf_size;
mymemcpy(webuc->resp_image + webuc->resp_used, buf, buf_size);
webuc->resp_used += (uint)buf_size;
return buf_size;
}
@@ -249,14 +249,14 @@ ssize_t cls_webu_mpegts::response(char *buf, size_t max)
sent_bytes = webuc->resp_used - stream_pos;
}
memcpy(buf, webuc->resp_image + stream_pos, sent_bytes);
mymemcpy(buf, webuc->resp_image + stream_pos, sent_bytes);
stream_pos = stream_pos + sent_bytes;
if (stream_pos >= webuc->resp_used) {
stream_pos = 0;
}
return sent_bytes;
return (ssize_t)sent_bytes;
}
int cls_webu_mpegts::open_mpegts()

View File

@@ -408,10 +408,10 @@ void cls_webu_post::action_user()
}
}
for (indx2 = 0; indx2<(int)tmp.length(); indx2++) {
if (isalnum(tmp.at(indx2)) == false) {
if (isalnum(tmp.at((uint)indx2)) == false) {
MOTPLS_LOG(NTC, TYPE_STREAM, NO_ERRNO
, _("Invalid character included in action user \"%c\"")
, tmp.at(indx2));
, tmp.at((uint)indx2));
return;
}
}
@@ -430,10 +430,10 @@ void cls_webu_post::action_user()
}
}
for (indx2 = 0; indx2<(int)tmp.length(); indx2++) {
if (isalnum(tmp.at(indx2)) == false) {
if (isalnum(tmp.at((uint)indx2)) == false) {
MOTPLS_LOG(NTC, TYPE_STREAM, NO_ERRNO
, _("Invalid character included in action user \"%c\"")
, tmp.at(indx2));
, tmp.at((uint)indx2));
return;
}
}
@@ -686,7 +686,7 @@ void cls_webu_post::iterate_post_new(const char *key
post_info = (ctx_key *)malloc(sizeof(ctx_key));
} else {
post_info = (ctx_key *)realloc(post_info
, post_sz * sizeof(ctx_key));
, (uint)post_sz * sizeof(ctx_key));
}
post_info[post_sz-1].key_nm = (char*)malloc(strlen(key)+1);

View File

@@ -94,10 +94,10 @@ void cls_webu_stream::mjpeg_all_img()
"Content-type: image/jpeg\r\n"
"Content-Length: %9d\r\n\r\n"
,jpg_sz);
memcpy(webuc->resp_image, resp_head, header_len);
memcpy(webuc->resp_image + header_len, jpg_data, jpg_sz);
memcpy(webuc->resp_image + header_len + jpg_sz,"\r\n",2);
webuc->resp_used = header_len + jpg_sz + 2;
mymemcpy(webuc->resp_image, resp_head, header_len);
mymemcpy(webuc->resp_image + header_len, jpg_data, 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,13 +143,13 @@ void cls_webu_stream::mjpeg_one_img()
"Content-type: image/jpeg\r\n"
"Content-Length: %9d\r\n\r\n"
,strm->jpg_sz);
memcpy(webuc->resp_image, resp_head, header_len);
memcpy(webuc->resp_image + header_len
mymemcpy(webuc->resp_image, resp_head, header_len);
mymemcpy(webuc->resp_image + header_len
,strm->jpg_data
,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 = header_len + strm->jpg_sz + 2;
webuc->resp_used =(uint)(header_len + strm->jpg_sz + 2);
strm->consumed = true;
pthread_mutex_unlock(&webua->cam->stream.mutex);
@@ -187,14 +187,14 @@ ssize_t cls_webu_stream::mjpeg_response (char *buf, size_t max)
sent_bytes = webuc->resp_used - stream_pos;
}
memcpy(buf, webuc->resp_image + stream_pos, sent_bytes);
mymemcpy(buf, webuc->resp_image + stream_pos, sent_bytes);
stream_pos = stream_pos + sent_bytes;
if (stream_pos >= webuc->resp_used) {
stream_pos = 0;
}
return sent_bytes;
return (ssize_t)sent_bytes;
}
/* Increment the all camera stream counters */
@@ -241,10 +241,10 @@ void cls_webu_stream::static_all_img()
all_sz = app->all_sizes;
jpg_data = (unsigned char*)mymalloc((size_t)all_sz->img_sz);
webuc->resp_used = jpgutl_put_yuv420p(jpg_data
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);
memcpy(webuc->resp_image, jpg_data, webuc->resp_used);
mymemcpy(webuc->resp_image, jpg_data, webuc->resp_used);
myfree(&jpg_data);
}
@@ -313,10 +313,10 @@ void cls_webu_stream::static_one_img()
pthread_mutex_unlock(&webua->cam->stream.mutex);
return;
}
memcpy(webuc->resp_image
mymemcpy(webuc->resp_image
,strm->jpg_data
,strm->jpg_sz);
webuc->resp_used =strm->jpg_sz;
webuc->resp_used =(uint)strm->jpg_sz;
strm->consumed = true;
pthread_mutex_unlock(&webua->cam->stream.mutex);