Skip to content

Commit

Permalink
Fixed VPP coverity issues.
Browse files Browse the repository at this point in the history
Signed-off-by: Alex1 Zhang [email protected]
  • Loading branch information
Alex1Zhang authored and XinfengZhang committed Nov 9, 2023
1 parent 1258c71 commit b0389f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 0 additions & 4 deletions videoprocess/vpp3dlut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1236,10 +1236,6 @@ video_frame_process_scaling(VASurfaceID in_surface_id,
vaDestroyBuffer(va_dpy, pipeline_param_buf_id);
}

if (filter_param_buf_id != VA_INVALID_ID) {
vaDestroyBuffer(va_dpy, filter_param_buf_id);
}

return va_status;
}

Expand Down
19 changes: 13 additions & 6 deletions videoprocess/vpphdr_tm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ bool read_frame_to_surface(FILE *fp, VASurfaceID surface_id)
unsigned char *y_dst = NULL, *u_dst = NULL, *v_dst = NULL;

int bytes_per_pixel = 2;

size_t n_items;
void *out_buf = NULL;
unsigned char *src_buffer = NULL;

Expand Down Expand Up @@ -560,8 +560,11 @@ bool read_frame_to_surface(FILE *fp, VASurfaceID surface_id)

src_buffer = (unsigned char*)malloc(frame_size);
assert(src_buffer);
fread(src_buffer, 1, frame_size, fp);

n_items = fread(src_buffer, 1, frame_size, fp);
if (n_items != frame_size)
{
printf("read file failed on VA_FOURCC_P010\n");
}
y_src = src_buffer;
u_src = src_buffer + y_size; // UV offset for P010

Expand All @@ -588,7 +591,11 @@ bool read_frame_to_surface(FILE *fp, VASurfaceID surface_id)
frame_size = va_image.width * va_image.height * 4;
src_buffer = (unsigned char*)malloc(frame_size);
assert(src_buffer);
fread(src_buffer, 1, frame_size, fp);
n_items = fread(src_buffer, 1, frame_size, fp);
if (n_items != frame_size)
{
printf("read file failed on VA_RT_FORMAT_RGB32_10BPP or VA_FOURCC_RGBA \n");
}
y_src = src_buffer;
y_dst = (unsigned char*)out_buf + va_image.offsets[0];

Expand Down Expand Up @@ -669,12 +676,12 @@ bool write_surface_to_frame(FILE *fp, VASurfaceID surface_id)
y_src = (unsigned char*)in_buf + va_image.offsets[0];
u_src = (unsigned char*)in_buf + va_image.offsets[1]; // U offset for P010
for (i = 0; i < va_image.height; i++) {
memcpy(y_dst, y_src, va_image.width * bytes_per_pixel);
memcpy(y_dst, y_src, static_cast<size_t>(va_image.width * bytes_per_pixel));
y_dst += va_image.width * bytes_per_pixel;
y_src += va_image.pitches[0];
}
for (i = 0; i < va_image.height >> 1; i++) {
memcpy(u_dst, u_src, va_image.width * bytes_per_pixel);
memcpy(u_dst, u_src, static_cast<size_t>(va_image.width * bytes_per_pixel));
u_dst += va_image.width * bytes_per_pixel;
u_src += va_image.pitches[1];
}
Expand Down

0 comments on commit b0389f4

Please sign in to comment.