[x265] [PATCH 5 of 5] add functions in the picyuv to support the opencl svm buffer
vignesh at multicorewareinc.com
vignesh at multicorewareinc.com
Tue May 9 10:44:16 CEST 2017
# HG changeset patch
# User weixuan
# Date 1490336062 -28800
# Fri Mar 24 14:14:22 2017 +0800
# Node ID 76d4ad6f554fd86d71e39c34304d7a00d07d7a8a
# Parent 1b538bbc0021244c55565f5095bf8a4289638e79
add functions in the picyuv to support the opencl svm buffer
diff -r 1b538bbc0021 -r 76d4ad6f554f source/common/picyuv.cpp
--- a/source/common/picyuv.cpp Tue Apr 11 12:44:37 2017 +0530
+++ b/source/common/picyuv.cpp Fri Mar 24 14:14:22 2017 +0800
@@ -52,7 +52,7 @@
m_vChromaShift = 0;
}
-bool PicYuv::create(uint32_t picWidth, uint32_t picHeight, uint32_t picCsp)
+bool PicYuv::create(uint32_t picWidth, uint32_t picHeight, uint32_t picCsp, pixel *bufSVM)
{
m_picWidth = picWidth;
m_picHeight = picHeight;
@@ -68,8 +68,13 @@
m_stride = (numCuInWidth * g_maxCUSize) + (m_lumaMarginX << 1);
int maxHeight = numCuInHeight * g_maxCUSize;
- CHECKED_MALLOC(m_picBuf[0], pixel, m_stride * (maxHeight + (m_lumaMarginY * 2)));
- m_picOrg[0] = m_picBuf[0] + m_lumaMarginY * m_stride + m_lumaMarginX;
+ if (bufSVM)
+ m_picOrg[0] = bufSVM;
+ else
+ {
+ CHECKED_MALLOC(m_picBuf[0], pixel, m_stride * (maxHeight + (m_lumaMarginY * 2)));
+ m_picOrg[0] = m_picBuf[0] + m_lumaMarginY * m_stride + m_lumaMarginX;
+ }
if (picCsp != X265_CSP_I400)
{
@@ -94,6 +99,27 @@
return false;
}
+int PicYuv::getLumaBufLen(uint32_t picWidth, uint32_t picHeight, uint32_t picCsp)
+{
+ m_picWidth = picWidth;
+ m_picHeight = picHeight;
+ m_hChromaShift = CHROMA_H_SHIFT(picCsp);
+ m_vChromaShift = CHROMA_V_SHIFT(picCsp);
+ m_picCsp = picCsp;
+
+ uint32_t numCuInWidth = (m_picWidth + g_maxCUSize - 1) / g_maxCUSize;
+ uint32_t numCuInHeight = (m_picHeight + g_maxCUSize - 1) / g_maxCUSize;
+
+ m_lumaMarginX = g_maxCUSize + 32; // search margin and 8-tap filter half-length, padded for 32-byte alignment
+ m_lumaMarginY = g_maxCUSize + 16; // margin for 8-tap filter and infinite padding
+ m_stride = (numCuInWidth * g_maxCUSize) + (m_lumaMarginX << 1);
+
+ int maxHeight = numCuInHeight * g_maxCUSize;
+ int bufLen = (int)(m_stride * (maxHeight + (m_lumaMarginY * 2)));
+
+ return bufLen;
+}
+
/* the first picture allocated by the encoder will be asked to generate these
* offset arrays. Once generated, they will be provided to all future PicYuv
* allocated by the same encoder. */
diff -r 1b538bbc0021 -r 76d4ad6f554f source/common/picyuv.h
--- a/source/common/picyuv.h Tue Apr 11 12:44:37 2017 +0530
+++ b/source/common/picyuv.h Fri Mar 24 14:14:22 2017 +0800
@@ -65,9 +65,10 @@
PicYuv();
- bool create(uint32_t picWidth, uint32_t picHeight, uint32_t csp);
+ bool create(uint32_t picWidth, uint32_t picHeight, uint32_t csp, pixel *bufSVM = NULL);
bool createOffsets(const SPS& sps);
void destroy();
+ int getLumaBufLen(uint32_t picWidth, uint32_t picHeight, uint32_t picCsp);
void copyFromPicture(const x265_picture&, const x265_param& param, int padx, int pady);
More information about the x265-devel
mailing list