From 7759f4eb2e4674e4f4190be385ed0bc2b32a56d5 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Wed, 15 Apr 2026 18:02:53 +0300 Subject: [PATCH] Revert "avplayer/videodec fixup (#4225)" (#4264) This reverts commit f242655fbb5f57dcb9ab607cde420d14a4e5d9d9. --- .../libraries/avplayer/avplayer_source.cpp | 26 +++++++---------- src/core/libraries/videodec/videodec_impl.cpp | 29 ++++--------------- 2 files changed, 17 insertions(+), 38 deletions(-) diff --git a/src/core/libraries/avplayer/avplayer_source.cpp b/src/core/libraries/avplayer/avplayer_source.cpp index 24609e494..7a4686a6c 100644 --- a/src/core/libraries/avplayer/avplayer_source.cpp +++ b/src/core/libraries/avplayer/avplayer_source.cpp @@ -551,22 +551,18 @@ static void CopyNV12Data(u8* dst, const AVFrame& src, bool use_vdec2) { height = Common::AlignUp(height, 16); } - // Copy Y plane: source stride is linesize[0], destination stride is width. - if (u32(src.linesize[0]) == width) { - std::memcpy(dst, src.data[0], width * src.height); + if (src.width == width) { + std::memcpy(dst, src.data[0], src.width * src.height); + std::memcpy(dst + src.width * height, src.data[1], (src.width * src.height) / 2); } else { - for (u32 y = 0; y < u32(src.height); ++y) { - std::memcpy(dst + y * width, src.data[0] + y * src.linesize[0], src.width); + const auto luma_dst = dst; + for (u32 y = 0; y < src.height; ++y) { + std::memcpy(luma_dst + y * width, src.data[0] + y * src.width, src.width); } - } - - // Copy interleaved UV plane: source stride is linesize[1], destination stride is width. - const auto chroma_dst = dst + width * height; - if (u32(src.linesize[1]) == width) { - std::memcpy(chroma_dst, src.data[1], width * (src.height / 2)); - } else { - for (u32 y = 0; y < u32(src.height) / 2; ++y) { - std::memcpy(chroma_dst + y * width, src.data[1] + y * src.linesize[1], src.width); + const auto chroma_dst = dst + width * height; + for (u32 y = 0; y < src.height / 2; ++y) { + std::memcpy(chroma_dst + y * (width / 2), src.data[0] + y * (src.width / 2), + src.width / 2); } } } @@ -609,7 +605,7 @@ Frame AvPlayerSource::PrepareVideoFrame(GuestBuffer buffer, const AVFrame& frame .crop_top_offset = u32(frame.crop_top), .crop_bottom_offset = u32(frame.crop_bottom + (height - frame.height)), - .pitch = width, + .pitch = u32(frame.linesize[0]), .luma_bit_depth = 8, .chroma_bit_depth = 8, }, diff --git a/src/core/libraries/videodec/videodec_impl.cpp b/src/core/libraries/videodec/videodec_impl.cpp index 26641e37c..b5f72e9ce 100644 --- a/src/core/libraries/videodec/videodec_impl.cpp +++ b/src/core/libraries/videodec/videodec_impl.cpp @@ -13,27 +13,10 @@ namespace Libraries::Videodec { static inline void CopyNV12Data(u8* dst, const AVFrame& src) { - const u32 width = Common::AlignUp(u32(src.width), 16); - const u32 height = Common::AlignUp(u32(src.height), 16); - - // Copy Y plane: source stride is linesize[0], destination stride is width. - if (u32(src.linesize[0]) == width) { - std::memcpy(dst, src.data[0], width * src.height); - } else { - for (u32 y = 0; y < u32(src.height); ++y) { - std::memcpy(dst + y * width, src.data[0] + y * src.linesize[0], src.width); - } - } - - // Copy interleaved UV plane: source stride is linesize[1], destination stride is width. - const auto chroma_dst = dst + width * height; - if (u32(src.linesize[1]) == width) { - std::memcpy(chroma_dst, src.data[1], width * (src.height / 2)); - } else { - for (u32 y = 0; y < u32(src.height) / 2; ++y) { - std::memcpy(chroma_dst + y * width, src.data[1] + y * src.linesize[1], src.width); - } - } + u32 width = Common::AlignUp((u32)src.width, 16); + u32 height = Common::AlignUp((u32)src.height, 16); + std::memcpy(dst, src.data[0], src.width * src.height); + std::memcpy(dst + src.width * height, src.data[1], (src.width * src.height) / 2); } VdecDecoder::VdecDecoder(const OrbisVideodecConfigInfo& pCfgInfoIn, @@ -117,7 +100,7 @@ s32 VdecDecoder::Decode(const OrbisVideodecInputData& pInputDataIn, pPictureInfoOut.codecType = 0; pPictureInfoOut.frameWidth = Common::AlignUp((u32)frame->width, 16); pPictureInfoOut.frameHeight = Common::AlignUp((u32)frame->height, 16); - pPictureInfoOut.framePitch = Common::AlignUp((u32)frame->width, 16); + pPictureInfoOut.framePitch = frame->linesize[0]; pPictureInfoOut.isValid = true; pPictureInfoOut.isErrorPic = false; @@ -167,7 +150,7 @@ s32 VdecDecoder::Flush(OrbisVideodecFrameBuffer& pFrameBufferInOut, pPictureInfoOut.codecType = 0; pPictureInfoOut.frameWidth = Common::AlignUp((u32)frame->width, 16); pPictureInfoOut.frameHeight = Common::AlignUp((u32)frame->height, 16); - pPictureInfoOut.framePitch = Common::AlignUp((u32)frame->width, 16); + pPictureInfoOut.framePitch = frame->linesize[0]; pPictureInfoOut.isValid = true; pPictureInfoOut.isErrorPic = false;