diff --git a/base/cvd/cuttlefish/host/frontend/webrtc/screenshot_handler.cpp b/base/cvd/cuttlefish/host/frontend/webrtc/screenshot_handler.cpp index 5ff1b20b05b..34d0e7aae1a 100644 --- a/base/cvd/cuttlefish/host/frontend/webrtc/screenshot_handler.cpp +++ b/base/cvd/cuttlefish/host/frontend/webrtc/screenshot_handler.cpp @@ -16,6 +16,7 @@ #include "cuttlefish/host/frontend/webrtc/screenshot_handler.h" +#include #include #include #include @@ -42,7 +43,7 @@ Result> FrameToRgb( const std::shared_ptr& frame) { const int width = frame->width(); const int height = frame->height(); - std::vector rgb_frame(width * height * 3, 0); + std::vector rgb_frame(static_cast(width) * height * 3, 0); const uint32_t format = frame->PixelFormat(); int convert_res = -1; @@ -93,7 +94,8 @@ Result PngScreenshot(const std::shared_ptr& frame, png_write_info(png_ptr, info_ptr); for (int y = 0; y < height; ++y) { - png_write_row(png_ptr, rgb_frame.data() + y * width * 3); + png_write_row(png_ptr, + rgb_frame.data() + static_cast(y) * width * 3); } // Finalize @@ -120,9 +122,12 @@ Result JpegScreenshot(const std::shared_ptr& frame, const int stride_uv = (((width + 1) / 2 + kStrideAlignment - 1) / kStrideAlignment) * kStrideAlignment; - std::vector y_plane(stride_y * height + kPlanePadding); - std::vector u_plane(stride_uv * ((height + 1) / 2) + kPlanePadding); - std::vector v_plane(stride_uv * ((height + 1) / 2) + kPlanePadding); + std::vector y_plane(static_cast(stride_y) * height + + kPlanePadding); + std::vector u_plane( + static_cast(stride_uv) * ((height + 1) / 2) + kPlanePadding); + std::vector v_plane( + static_cast(stride_uv) * ((height + 1) / 2) + kPlanePadding); const uint32_t format = frame->PixelFormat(); int convert_res = -1; @@ -191,14 +196,14 @@ Result JpegScreenshot(const std::shared_ptr& frame, // If the image height is not a multiple of kScanRows it will be padded with // rows from the previous iteration. for (int r = 0; r < kScanRows && r + row < cinfo.image_height; ++r) { - int offset = (row + r) * stride_y; + size_t offset = static_cast(row + r) * stride_y; y_rows[r] = &y_plane[offset]; } for (int r = 0; r < kScanRows / 2 && r + row / 2 < (cinfo.image_height + 1) / 2; ++r) { - int offset_u = (row / 2 + r) * stride_uv; + size_t offset_u = static_cast(row / 2 + r) * stride_uv; u_rows[r] = &u_plane[offset_u]; - int offset_v = (row / 2 + r) * stride_uv; + size_t offset_v = static_cast(row / 2 + r) * stride_uv; v_rows[r] = &v_plane[offset_v]; } jpeg_write_raw_data(&cinfo, rows, kScanRows);