Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix VPP coverity issues #350

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where to destroy filter_param_buf_id?

Copy link
Contributor Author

@Alex1Zhang Alex1Zhang Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trigger the deadcode error, this code always not be entered, so remove it.

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
Loading