Skip to content
This repository was archived by the owner on Apr 5, 2025. It is now read-only.

Commit f1a06ee

Browse files
committed
Fix mpegts for combined camera
1 parent 0eb229e commit f1a06ee

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/allcam.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void cls_allcam::getimg(ctx_stream_data *strm_a, std::string imgtyp)
119119
int c_y, c_u, c_v; /* camera img y,u,v */
120120
int img_orow, img_ocol;
121121
int indx, row, dst_w, dst_h;
122-
u_char *dst_img, *src_img;
122+
u_char *dst_img, *src_img, *all_img;
123123
cls_camera *p_cam;
124124

125125
getsizes();
@@ -128,15 +128,15 @@ void cls_allcam::getimg(ctx_stream_data *strm_a, std::string imgtyp)
128128
a_u = (all_sizes.src_w * all_sizes.src_h);
129129
a_v = a_u + (a_u / 4);
130130

131-
memset(strm_a->img_data , 0x80, (size_t)a_u);
132-
memset(strm_a->img_data + a_u, 0x80, (size_t)(a_u/2));
131+
all_img = (unsigned char*) mymalloc((uint)all_sizes.src_sz);
132+
memset(all_img , 0x80, (size_t)a_u);
133+
memset(all_img + a_u, 0x80, (size_t)(a_u/2));
133134

134135
for (indx=0; indx<active_cnt; indx++) {
135136
p_cam = active_cam[indx];
136137
dst_w = p_cam->all_sizes.dst_w;
137138
dst_h = p_cam->all_sizes.dst_h;
138139

139-
140140
img_orow = p_cam->all_loc.offset_row;
141141
img_ocol = p_cam->all_loc.offset_col;
142142

@@ -155,15 +155,15 @@ void cls_allcam::getimg(ctx_stream_data *strm_a, std::string imgtyp)
155155
c_v = c_u + (c_u / 4);
156156

157157
for (row=0; row<dst_h; row++) {
158-
memcpy(strm_a->img_data + a_y, dst_img + c_y, (uint)dst_w);
158+
memcpy(all_img + a_y, dst_img + c_y, (uint)dst_w);
159159
a_y += all_sizes.src_w;
160160
c_y += dst_w;
161161
if (row % 2) {
162-
memcpy(strm_a->img_data + a_u, dst_img + c_u, (uint)dst_w / 2);
163-
//mymemset(strm_a->img_data + a_u, 0xFA, dst_w/2);
162+
memcpy(all_img + a_u, dst_img + c_u, (uint)dst_w / 2);
163+
//mymemset(all_img + a_u, 0xFA, dst_w/2);
164164
a_u += (all_sizes.src_w / 2);
165165
c_u += (dst_w / 2);
166-
memcpy(strm_a->img_data + a_v, dst_img + c_v, (uint)dst_w / 2);
166+
memcpy(all_img + a_v, dst_img + c_v, (uint)dst_w / 2);
167167
a_v += (all_sizes.src_w / 2);
168168
c_v += (dst_w / 2);
169169
}
@@ -173,13 +173,13 @@ void cls_allcam::getimg(ctx_stream_data *strm_a, std::string imgtyp)
173173
myfree(src_img);
174174
}
175175

176-
dst_img = (unsigned char*) mymalloc((uint)all_sizes.dst_sz);
177-
util_resize(strm_a->img_data
178-
, all_sizes.src_w, all_sizes.src_h
179-
, dst_img, all_sizes.dst_w, all_sizes.dst_h);
176+
memset(strm_a->img_data, 0x80, (size_t)all_sizes.dst_sz);
177+
util_resize(all_img, all_sizes.src_w, all_sizes.src_h
178+
, strm_a->img_data, all_sizes.dst_w, all_sizes.dst_h);
179+
myfree(all_img);
180180

181181
strm_a->jpg_sz = jpgutl_put_yuv420p(
182-
strm_a->jpg_data, all_sizes.src_sz,dst_img
182+
strm_a->jpg_data, all_sizes.dst_sz, strm_a->img_data
183183
, all_sizes.dst_w, all_sizes.dst_h
184184
, 70, NULL,NULL,NULL);
185185

@@ -228,7 +228,7 @@ void cls_allcam::stream_alloc()
228228
strm = &stream.sub;
229229
}
230230
strm->img_data = (unsigned char*)
231-
mymalloc((size_t)all_sizes.src_sz);
231+
mymalloc((size_t)all_sizes.dst_sz);
232232
strm->jpg_data = (unsigned char*)
233233
mymalloc((size_t)all_sizes.dst_sz);
234234
strm->consumed = true;

0 commit comments

Comments
 (0)