summaryrefslogtreecommitdiff
path: root/src/video_core/command_classes
diff options
context:
space:
mode:
authorGravatar Fernando S2021-07-15 15:17:50 +0200
committerGravatar GitHub2021-07-15 15:17:50 +0200
commitda4ca4f2f94d2d685584b124106c3b344faee6e7 (patch)
treeaba358012ef82ecf200c5b8a1cec2ecd381de6db /src/video_core/command_classes
parentMerge pull request #6641 from Morph1984/web_browser_urls (diff)
parentvic: Fix dimension compuation of YUV frames (diff)
downloadyuzu-da4ca4f2f94d2d685584b124106c3b344faee6e7.tar.gz
yuzu-da4ca4f2f94d2d685584b124106c3b344faee6e7.tar.xz
yuzu-da4ca4f2f94d2d685584b124106c3b344faee6e7.zip
Merge pull request #6525 from ameerj/nvdec-fixes
nvdec: Fix Submit Ioctl data source, vic frame dimension computations
Diffstat (limited to 'src/video_core/command_classes')
-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 ff3db0aee..ffb7c82a1 100644
--- a/src/video_core/command_classes/vic.cpp
+++ b/src/video_core/command_classes/vic.cpp
@@ -129,28 +129,27 @@ void Vic::Execute() {
129 129
130 const std::size_t surface_width = config.surface_width_minus1 + 1; 130 const std::size_t surface_width = config.surface_width_minus1 + 1;
131 const std::size_t surface_height = config.surface_height_minus1 + 1; 131 const std::size_t surface_height = config.surface_height_minus1 + 1;
132 const std::size_t half_width = surface_width / 2; 132 const auto frame_width = std::min(surface_width, static_cast<size_t>(frame->width));
133 const std::size_t half_height = config.surface_height_minus1 / 2; 133 const auto frame_height = std::min(surface_height, static_cast<size_t>(frame->height));
134 const std::size_t half_width = frame_width / 2;
135 const std::size_t half_height = frame_height / 2;
134 const std::size_t aligned_width = (surface_width + 0xff) & ~0xff; 136 const std::size_t aligned_width = (surface_width + 0xff) & ~0xff;
135 137
136 const auto* luma_ptr = frame->data[0]; 138 const auto* luma_ptr = frame->data[0];
137 const auto* chroma_b_ptr = frame->data[1]; 139 const auto* chroma_b_ptr = frame->data[1];
138 const auto* chroma_r_ptr = frame->data[2]; 140 const auto* chroma_r_ptr = frame->data[2];
139 const auto stride = frame->linesize[0]; 141 const auto stride = static_cast<size_t>(frame->linesize[0]);
140 const auto half_stride = frame->linesize[1]; 142 const auto half_stride = static_cast<size_t>(frame->linesize[1]);
141 143
142 luma_buffer.resize(aligned_width * surface_height); 144 luma_buffer.resize(aligned_width * surface_height);
143 chroma_buffer.resize(aligned_width * half_height); 145 chroma_buffer.resize(aligned_width * surface_height / 2);
144 146
145 // Populate luma buffer 147 // Populate luma buffer
146 for (std::size_t y = 0; y < surface_height - 1; ++y) { 148 for (std::size_t y = 0; y < frame_height; ++y) {
147 const std::size_t src = y * stride; 149 const std::size_t src = y * stride;
148 const std::size_t dst = y * aligned_width; 150 const std::size_t dst = y * aligned_width;
149 151 for (std::size_t x = 0; x < frame_width; ++x) {
150 const std::size_t size = surface_width; 152 luma_buffer[dst + x] = luma_ptr[src + x];
151
152 for (std::size_t offset = 0; offset < size; ++offset) {
153 luma_buffer[dst + offset] = luma_ptr[src + offset];
154 } 153 }
155 } 154 }
156 gpu.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(), 155 gpu.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(),