From bd257ec4a32daab4ecd18932fdf59aee42a591ae Mon Sep 17 00:00:00 2001 From: wang-bin Date: Sat, 27 Jun 2015 02:34:26 +0800 Subject: [PATCH] vda: simd copy back from gpu to map to host memory gpu copy with cache may crash, new function does not --- src/VideoFrame.cpp | 1 - src/codec/video/VideoDecoderVDA.cpp | 9 +++------ src/utils/GPUMemCopy.cpp | 1 + 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/VideoFrame.cpp b/src/VideoFrame.cpp index 82f9a0e8..a5e5f69b 100644 --- a/src/VideoFrame.cpp +++ b/src/VideoFrame.cpp @@ -66,7 +66,6 @@ VideoFrame VideoFrame::fromGPU(const VideoFormat& fmt, int width, int height, in } VideoFrame frame; if (optimized) { - qDebug("simd"); int yuv_size = 0; for (int i = 0; i < nb_planes; ++i) { yuv_size += pitch[i]*h[i]; diff --git a/src/codec/video/VideoDecoderVDA.cpp b/src/codec/video/VideoDecoderVDA.cpp index d4ae5137..0e9175e9 100755 --- a/src/codec/video/VideoDecoderVDA.cpp +++ b/src/codec/video/VideoDecoderVDA.cpp @@ -229,8 +229,6 @@ VideoFrame VideoDecoderVDA::frame() } void* mapToHost(const VideoFormat &format, void *handle, int plane) { Q_UNUSED(plane); - if (!format.isRGB()) - return NULL; CVPixelBufferLockBaseAddress(cvbuf, 0); const VideoFormat fmt(format_from_cv(CVPixelBufferGetPixelFormatType(cvbuf))); if (!fmt.isValid()) { @@ -248,10 +246,9 @@ VideoFrame VideoDecoderVDA::frame() } CVPixelBufferUnlockBaseAddress(cvbuf, 0); //CVPixelBufferRelease(cv_buffer); // release when video frame is destroyed - VideoFrame frame = VideoFrame(w, h, fmt); - frame.setBits(src); - frame.setBytesPerLine(pitch); - frame = frame.to(format); + VideoFrame frame(VideoFrame::fromGPU(fmt, w, h, h, src, pitch)); + if (fmt != format) + frame = frame.to(format); VideoFrame *f = reinterpret_cast(handle); frame.setTimestamp(f->timestamp()); *f = frame; diff --git a/src/utils/GPUMemCopy.cpp b/src/utils/GPUMemCopy.cpp index 512676dd..2c880b9f 100644 --- a/src/utils/GPUMemCopy.cpp +++ b/src/utils/GPUMemCopy.cpp @@ -21,6 +21,7 @@ #include "GPUMemCopy.h" #include "QtAV/QtAV_Global.h" +#include //memcpy #include extern "C" { #include