summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/command_classes/vic.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/video_core/command_classes/vic.cpp b/src/video_core/command_classes/vic.cpp
index 0a8b82f2b..43ac20728 100644
--- a/src/video_core/command_classes/vic.cpp
+++ b/src/video_core/command_classes/vic.cpp
@@ -119,28 +119,27 @@ void Vic::Execute() {
119 119
120 const std::size_t surface_width = config.surface_width_minus1 + 1; 120 const std::size_t surface_width = config.surface_width_minus1 + 1;
121 const std::size_t surface_height = config.surface_height_minus1 + 1; 121 const std::size_t surface_height = config.surface_height_minus1 + 1;
122 const std::size_t half_width = surface_width / 2; 122 const auto frame_width = std::min(surface_width, static_cast<size_t>(frame->width));
123 const std::size_t half_height = config.surface_height_minus1 / 2; 123 const auto frame_height = std::min(surface_height, static_cast<size_t>(frame->height));
124 const std::size_t half_width = frame_width / 2;
125 const std::size_t half_height = frame_height / 2;
124 const std::size_t aligned_width = (surface_width + 0xff) & ~0xff; 126 const std::size_t aligned_width = (surface_width + 0xff) & ~0xff;
125 127
126 const auto* luma_ptr = frame->data[0]; 128 const auto* luma_ptr = frame->data[0];
127 const auto* chroma_b_ptr = frame->data[1]; 129 const auto* chroma_b_ptr = frame->data[1];
128 const auto* chroma_r_ptr = frame->data[2]; 130 const auto* chroma_r_ptr = frame->data[2];
129 const auto stride = frame->linesize[0]; 131 const auto stride = static_cast<size_t>(frame->linesize[0]);
130 const auto half_stride = frame->linesize[1]; 132 const auto half_stride = static_cast<size_t>(frame->linesize[1]);
131 133
132 luma_buffer.resize(aligned_width * surface_height); 134 luma_buffer.resize(aligned_width * surface_height);
133 chroma_buffer.resize(aligned_width * half_height); 135 chroma_buffer.resize(aligned_width * surface_height / 2);
134 136
135 // Populate luma buffer 137 // Populate luma buffer
136 for (std::size_t y = 0; y < surface_height - 1; ++y) { 138 for (std::size_t y = 0; y < frame_height; ++y) {
137 const std::size_t src = y * stride; 139 const std::size_t src = y * stride;
138 const std::size_t dst = y * aligned_width; 140 const std::size_t dst = y * aligned_width;
139 141 for (std::size_t x = 0; x < frame_width; ++x) {
140 const std::size_t size = surface_width; 142 luma_buffer[dst + x] = luma_ptr[src + x];
141
142 for (std::size_t offset = 0; offset < size; ++offset) {
143 luma_buffer[dst + offset] = luma_ptr[src + offset];
144 } 143 }
145 } 144 }
146 gpu.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(), 145 gpu.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(),