diff --git a/rpcs3/rpcs3qt/qt_camera_handler.cpp b/rpcs3/rpcs3qt/qt_camera_handler.cpp index 20914b7a2f..ae84fa2817 100644 --- a/rpcs3/rpcs3qt/qt_camera_handler.cpp +++ b/rpcs3/rpcs3qt/qt_camera_handler.cpp @@ -303,7 +303,13 @@ void qt_camera_handler::update_camera_settings() QCameraViewfinderSettings settings; // Set resolution if possible. - for (const QSize& resolution : m_camera->supportedViewfinderResolutions(settings)) + const QList resolutions = m_camera->supportedViewfinderResolutions(settings); + if (resolutions.isEmpty()) + { + camera_log.error("No resolution available for the view finder settings: frame_rate=%f, width=%d, height=%d, pixel_format=%d", + settings.maximumFrameRate(), settings.resolution().width(), settings.resolution().height(), static_cast(settings.pixelFormat())); + } + for (const QSize& resolution : resolutions) { if (m_width == resolution.width() && m_height == resolution.height()) { @@ -313,7 +319,13 @@ void qt_camera_handler::update_camera_settings() } // Set frame rate if possible. - for (const QCamera::FrameRateRange& frame_rate : m_camera->supportedViewfinderFrameRateRanges(settings)) + const QList frame_rate_ranges = m_camera->supportedViewfinderFrameRateRanges(settings); + if (frame_rate_ranges.isEmpty()) + { + camera_log.error("No frame rate available for the view finder settings: frame_rate=%f, width=%d, height=%d, pixel_format=%d", + settings.maximumFrameRate(), settings.resolution().width(), settings.resolution().height(), static_cast(settings.pixelFormat())); + } + for (const QCamera::FrameRateRange& frame_rate : frame_rate_ranges) { // Some cameras do not have an exact match, so let's approximate. if (static_cast(m_frame_rate) >= (frame_rate.maximumFrameRate - 0.5) && static_cast(m_frame_rate) <= (frame_rate.maximumFrameRate + 0.5)) @@ -326,7 +338,13 @@ void qt_camera_handler::update_camera_settings() } // Set pixel format if possible. (Unused for now, because formats differ between Qt and cell) - //for (const QVideoFrame::PixelFormat& pixel_format : m_camera->supportedViewfinderPixelFormats(settings)) + const QList pixel_formats = m_camera->supportedViewfinderPixelFormats(settings); + if (pixel_formats.isEmpty()) + { + camera_log.error("No pixel format available for the view finder settings: frame_rate=%f, width=%d, height=%d, pixel_format=%d", + settings.maximumFrameRate(), settings.resolution().width(), settings.resolution().height(), static_cast(settings.pixelFormat())); + } + //for (const QVideoFrame::PixelFormat& pixel_format : pixel_formats) //{ // if (pixel_format matches m_format) // { diff --git a/rpcs3/rpcs3qt/qt_camera_video_surface.cpp b/rpcs3/rpcs3qt/qt_camera_video_surface.cpp index eb2cdd3c88..f19d5ddab2 100644 --- a/rpcs3/rpcs3qt/qt_camera_video_surface.cpp +++ b/rpcs3/rpcs3qt/qt_camera_video_surface.cpp @@ -131,11 +131,11 @@ bool qt_camera_video_surface::present(const QVideoFrame& frame) case CELL_CAMERA_RAW8: // The game seems to expect BGGR { // Let's use a very simple algorithm to convert the image to raw BGGR - const auto convert_to_bggr = [&image_buffer, &image](int y_begin, int y_end) + const auto convert_to_bggr = [&image_buffer, &image](u32 y_begin, u32 y_end) { - for (int y = y_begin; y < std::min(image_buffer.height, image.height()) && y < y_end; y++) + for (u32 y = y_begin; y < std::min(image_buffer.height, image.height()) && y < y_end; y++) { - for (int x = 0; x < std::min(image_buffer.width, image.width()); x++) + for (u32 x = 0; x < std::min(image_buffer.width, image.width()); x++) { u8& pixel = image_buffer.data[image_buffer.width * y + x]; const bool is_left_pixel = (x % 2) == 0; @@ -159,9 +159,9 @@ bool qt_camera_video_surface::present(const QVideoFrame& frame) // Use a multithreaded workload. The faster we get this done, the better. constexpr u32 thread_count = 4; - const int lines_per_thread = std::ceil(image_buffer.height / static_cast(thread_count)); - int y_begin = 0; - int y_end = lines_per_thread; + const u32 lines_per_thread = std::ceil(image_buffer.height / static_cast(thread_count)); + u32 y_begin = 0; + u32 y_end = lines_per_thread; QFutureSynchronizer synchronizer; for (u32 i = 0; i < thread_count; i++) @@ -178,7 +178,7 @@ bool qt_camera_video_surface::present(const QVideoFrame& frame) case CELL_CAMERA_V_Y1_U_Y0: { // Simple RGB to Y0_U_Y1_V conversion from stackoverflow. - const auto convert_to_yuv422 = [&image_buffer, &image, format = m_format](int y_begin, int y_end) + const auto convert_to_yuv422 = [&image_buffer, &image, format = m_format](u32 y_begin, u32 y_end) { constexpr int yuv_bytes_per_pixel = 2; const int yuv_pitch = image_buffer.width * yuv_bytes_per_pixel; @@ -188,11 +188,11 @@ bool qt_camera_video_surface::present(const QVideoFrame& frame) const int y1_offset = (format == CELL_CAMERA_Y0_U_Y1_V) ? 2 : 1; const int v_offset = (format == CELL_CAMERA_Y0_U_Y1_V) ? 3 : 0; - for (u32 y = y_begin; y < std::min(image_buffer.height, image.height()) && y < y_end; y++) + for (u32 y = y_begin; y < std::min(image_buffer.height, image.height()) && y < y_end; y++) { uint8_t* yuv_row_ptr = &image_buffer.data[y * yuv_pitch]; - for (u32 x = 0; x < std::min(image_buffer.width, image.width()) - 1; x += 2) + for (u32 x = 0; x < std::min(image_buffer.width, image.width()) - 1; x += 2) { const QRgb pixel_1 = image.pixel(x, y); const QRgb pixel_2 = image.pixel(x + 1, y); @@ -220,9 +220,9 @@ bool qt_camera_video_surface::present(const QVideoFrame& frame) // Use a multithreaded workload. The faster we get this done, the better. constexpr u32 thread_count = 4; - const int lines_per_thread = std::ceil(image_buffer.height / static_cast(thread_count)); - int y_begin = 0; - int y_end = lines_per_thread; + const u32 lines_per_thread = std::ceil(image_buffer.height / static_cast(thread_count)); + u32 y_begin = 0; + u32 y_end = lines_per_thread; QFutureSynchronizer synchronizer; for (u32 i = 0; i < thread_count; i++)