diff --git a/glsl/shader-bundle-tool.c b/glsl/shader-bundle-tool.c index 8cfe028..de378ce 100644 --- a/glsl/shader-bundle-tool.c +++ b/glsl/shader-bundle-tool.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -6,6 +7,7 @@ #include #include + int main(int argc, char *argv[]) { @@ -73,13 +75,19 @@ main(int argc, char *argv[]) } struct stat sb; - fstat(fileno(fp_tmp), &sb); + if (fstat(fileno(fp_tmp), &sb) != 0) { + printf("can't fstat, errno = %d\n", errno); + return 4; + } char *buf = malloc(sb.st_size); if (!buf) { printf("not enough memory\n"); return 3; } - fread(buf, sb.st_size, 1, fp_tmp); + if (fread(buf, sb.st_size, 1, fp_tmp) != 1) { + printf("can't read data from file\n"); + return 5; + } fclose(fp_tmp); fprintf(fp_c, " {\n"); diff --git a/src/api-device.c b/src/api-device.c index 702ce48..48bfc1b 100644 --- a/src/api-device.c +++ b/src/api-device.c @@ -139,9 +139,6 @@ compile_shaders(VdpDeviceData *deviceData) case glsl_red_to_alpha_swizzle: deviceData->shaders[k].uniform.tex_0 = glGetUniformLocation(program, "tex_0"); break; - default: - /* nothing */ - break; } } diff --git a/src/api-presentation-queue.c b/src/api-presentation-queue.c index c42a7a1..e624976 100644 --- a/src/api-presentation-queue.c +++ b/src/api-presentation-queue.c @@ -474,7 +474,7 @@ vdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue, VdpOutputSu return VDP_STATUS_INVALID_HANDLE; // push work to queue - while (pqData->queue.used >= PRESENTATION_QUEUE_LENGTH) { + while (pqData && pqData->queue.used >= PRESENTATION_QUEUE_LENGTH) { // wait while queue is full // TODO: check for deadlock here handle_release(presentation_queue); @@ -482,6 +482,9 @@ vdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue, VdpOutputSu pqData = handle_acquire(presentation_queue, HANDLETYPE_PRESENTATION_QUEUE); } + if (NULL == pqData) + return VDP_STATUS_INVALID_HANDLE; + VdpOutputSurfaceData *surfData = handle_acquire(surface, HANDLETYPE_OUTPUT_SURFACE); if (NULL == surfData) { handle_release(presentation_queue); diff --git a/src/api-video-surface.c b/src/api-video-surface.c index 89db0ec..450e693 100644 --- a/src/api-video-surface.c +++ b/src/api-video-surface.c @@ -194,8 +194,9 @@ vdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface, VdpYCbCrFormat destination_ if (destination_pitches[0] == q.pitches[0] && destination_pitches[1] == q.pitches[1]) { - memcpy(destination_data[0], img_data + q.offsets[0], q.width * q.height); - memcpy(destination_data[1], img_data + q.offsets[1], q.width * q.height / 2); + const uint32_t sz = (uint32_t)q.width * (uint32_t)q.height; + memcpy(destination_data[0], img_data + q.offsets[0], sz); + memcpy(destination_data[1], img_data + q.offsets[1], sz / 2); } else { uint8_t *src = img_data + q.offsets[0]; uint8_t *dst = destination_data[0]; @@ -221,7 +222,8 @@ vdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface, VdpYCbCrFormat destination_ // Y plane if (destination_pitches[0] == q.pitches[0]) { - memcpy(destination_data[0], img_data + q.offsets[0], q.width * q.height); + const uint32_t sz = (uint32_t)q.width * (uint32_t)q.height; + memcpy(destination_data[0], img_data + q.offsets[0], sz); } else { uint8_t *src = img_data + q.offsets[0]; uint8_t *dst = destination_data[0]; @@ -505,13 +507,6 @@ vdpVideoSurfacePutBitsYCbCr_glsl(VdpVideoSurface surface, VdpYCbCrFormat source_ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dstSurfData->width, dstSurfData->height, 0, GL_RED, GL_UNSIGNED_BYTE, source_data[0]); break; - case VDP_YCBCR_FORMAT_UYVY: - case VDP_YCBCR_FORMAT_YUYV: - case VDP_YCBCR_FORMAT_Y8U8V8A8: - case VDP_YCBCR_FORMAT_V8U8Y8A8: - default: - /* never reached */ - break; } glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); @@ -537,13 +532,6 @@ vdpVideoSurfacePutBitsYCbCr_glsl(VdpVideoSurface surface, VdpYCbCrFormat source_ glUniform1i(deviceData->shaders[glsl_YV12_RGBA].uniform.tex_0, 0); glUniform1i(deviceData->shaders[glsl_YV12_RGBA].uniform.tex_1, 1); break; - case VDP_YCBCR_FORMAT_UYVY: - case VDP_YCBCR_FORMAT_YUYV: - case VDP_YCBCR_FORMAT_Y8U8V8A8: - case VDP_YCBCR_FORMAT_V8U8Y8A8: - default: - /* do nothing */ - break; } glBegin(GL_QUADS); diff --git a/src/h264-parse.c b/src/h264-parse.c index 206c506..f4e3369 100644 --- a/src/h264-parse.c +++ b/src/h264-parse.c @@ -263,7 +263,7 @@ parse_slice_header(rbsp_state_t *st, const VAPictureParameterBufferH264 *vapp, const int ChromaArrayType, unsigned int p_num_ref_idx_l0_active_minus1, unsigned int p_num_ref_idx_l1_active_minus1, VASliceParameterBufferH264 *vasp) { - struct slice_parameters sp; + struct slice_parameters sp = { 0 }; for (int k = 0; k < 32; k ++) { reset_va_picture_h264(&sp.RefPicList0[k]); diff --git a/src/reverse-constant.c b/src/reverse-constant.c index afda490..7ec8b3b 100644 --- a/src/reverse-constant.c +++ b/src/reverse-constant.c @@ -508,7 +508,8 @@ reverse_output_surface_render_rotate(int flags) case VDP_OUTPUT_SURFACE_RENDER_ROTATE_0: return "VDP_OUTPUT_SURFACE_RENDER_ROTATE_0"; case VDP_OUTPUT_SURFACE_RENDER_ROTATE_90: return "VDP_OUTPUT_SURFACE_RENDER_ROTATE_90"; case VDP_OUTPUT_SURFACE_RENDER_ROTATE_180: return "VDP_OUTPUT_SURFACE_RENDER_ROTATE_180"; - case VDP_OUTPUT_SURFACE_RENDER_ROTATE_270: return "VDP_OUTPUT_SURFACE_RENDER_ROTATE_270"; - default: return "Unknown render rotate"; + default: + // The only possible case execution get here is VDP_OUTPUT_SURFACE_RENDER_ROTATE_270 case. + return "VDP_OUTPUT_SURFACE_RENDER_ROTATE_270"; } }