diff --git a/src/core/libraries/videodec/videodec2_impl.cpp b/src/core/libraries/videodec/videodec2_impl.cpp index 667fb79ac..2ad3d7e19 100644 --- a/src/core/libraries/videodec/videodec2_impl.cpp +++ b/src/core/libraries/videodec/videodec2_impl.cpp @@ -15,8 +15,22 @@ std::vector gPictureInfos; std::vector gLegacyPictureInfos; static inline void CopyNV12Data(u8* dst, const AVFrame& src) { - std::memcpy(dst, src.data[0], src.width * src.height); - std::memcpy(dst + (src.width * src.height), src.data[1], (src.width * src.height) / 2); + if (src.width == src.linesize[0]) { + std::memcpy(dst, src.data[0], src.width * src.height); + std::memcpy(dst + (src.width * src.height), src.data[1], (src.width * src.height) / 2); + return; + } + + for (u16 row = 0; row < src.height; row++) { + u64 dst_offset = row * src.width; + std::memcpy(dst + dst_offset, src.data[0] + (row * src.linesize[0]), src.width); + } + + u64 dst_base = src.width * src.height; + for (u16 row = 0; row < src.height / 2; row++) { + u64 dst_offset = row * src.width; + std::memcpy(dst + dst_base + dst_offset, src.data[1] + (row * src.linesize[1]), src.width); + } } VdecDecoder::VdecDecoder(const OrbisVideodec2DecoderConfigInfo& configInfo, @@ -110,7 +124,7 @@ s32 VdecDecoder::Decode(const OrbisVideodec2InputData& inputData, outputInfo.codecType = 1; // FIXME: Hardcoded to AVC outputInfo.frameWidth = frame->width; outputInfo.frameHeight = frame->height; - outputInfo.framePitch = frame->linesize[0]; + outputInfo.framePitch = frame->width; outputInfo.frameBufferSize = frameBuffer.frameBufferSize; outputInfo.frameBuffer = frameBuffer.frameBuffer; @@ -121,7 +135,7 @@ s32 VdecDecoder::Decode(const OrbisVideodec2InputData& inputData, // For proper compatibility with older games, check the inputted OutputInfo struct size. if (outputInfo.thisSize == sizeof(OrbisVideodec2OutputInfo)) { // framePitchInBytes only exists in the newer struct. - outputInfo.framePitchInBytes = frame->linesize[0]; + outputInfo.framePitchInBytes = frame->width; if (outputInfo.isValid) { OrbisVideodec2AvcPictureInfo pictureInfo = {};