<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 14, 2017 at 3:41 PM, <span dir="ltr"><<a href="mailto:kavitha@multicorewareinc.com" target="_blank">kavitha@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Kavitha Sampath <<a href="mailto:kavitha@multicorewareinc.com">kavitha@multicorewareinc.com</a>><br>
# Date 1510637409 -19800<br>
# Tue Nov 14 11:00:09 2017 +0530<br>
# Node ID dd9772385d152528201d335efbc6f7<wbr>5fdc43b08c<br>
# Parent 6ac1b12bcde91b691ef1de8bb936e2<wbr>3c0f29b6ff<br>
Add CLI option to enable or disable picture copy to internal frame buffer<br></blockquote><div><br></div><div>Pushed to default branch</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
diff -r 6ac1b12bcde9 -r dd9772385d15 doc/reST/cli.rst<br>
--- a/doc/reST/cli.rst Fri Nov 10 19:02:48 2017 +0530<br>
+++ b/doc/reST/cli.rst Tue Nov 14 11:00:09 2017 +0530<br>
@@ -399,6 +399,18 @@<br>
<br>
Default: 1 slice per frame. **Experimental feature**<br>
<br>
+.. option:: --copy-pic, --no-copy-pic<br>
+<br>
+ Allow encoder to copy input x265 pictures to internal frame buffers. When disabled,<br>
+ x265 will not make an internal copy of the input picture and will work with the<br>
+ application's buffers. While this allows for deeper integration, it is the responsbility<br>
+ of the application to (a) ensure that the allocated picture has extra space for padding<br>
+ that will be done by the library, and (b) the buffers aren't recycled until the library<br>
+ has completed encoding this frame (which can be figured out by tracking NALs output by x265)<br>
+<br>
+ Default: enabled<br>
+<br>
+<br>
Input/Output File Options<br>
=========================<br>
<br>
diff -r 6ac1b12bcde9 -r dd9772385d15 source/CMakeLists.txt<br>
--- a/source/CMakeLists.txt Fri Nov 10 19:02:48 2017 +0530<br>
+++ b/source/CMakeLists.txt Tue Nov 14 11:00:09 2017 +0530<br>
@@ -29,7 +29,7 @@<br>
option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)<br>
mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)<br>
# X265_BUILD must be incremented each time the public API is changed<br>
-set(X265_BUILD 144)<br>
+set(X265_BUILD 145)<br>
configure_file("${PROJECT_<wbr>SOURCE_DIR}/<a href="http://x265.def.in" rel="noreferrer" target="_blank">x265.def.in</a>"<br>
"${PROJECT_BINARY_DIR}/x265.<wbr>def")<br>
configure_file("${PROJECT_<wbr>SOURCE_DIR}/<a href="http://x265_config.h.in" rel="noreferrer" target="_blank">x265_config.h.in</a>"<br>
diff -r 6ac1b12bcde9 -r dd9772385d15 source/common/frame.cpp<br>
--- a/source/common/frame.cpp Fri Nov 10 19:02:48 2017 +0530<br>
+++ b/source/common/frame.cpp Tue Nov 14 11:00:09 2017 +0530<br>
@@ -85,7 +85,7 @@<br>
m_analysis2Pass.<wbr>analysisFramedata = NULL;<br>
}<br>
<br>
- if (m_fencPic->create(param) && m_lowres.create(m_fencPic, param->bframes, !!param->rc.aqMode || !!param->bAQMotion, param->rc.qgSize))<br>
+ if (m_fencPic->create(param, !!m_param->bCopyPicToFrame) && m_lowres.create(m_fencPic, param->bframes, !!param->rc.aqMode || !!param->bAQMotion, param->rc.qgSize))<br>
{<br>
X265_CHECK((m_reconColCount == NULL), "m_reconColCount was initialized");<br>
m_numRows = (m_fencPic->m_picHeight + param->maxCUSize - 1) / param->maxCUSize;<br>
@@ -158,7 +158,8 @@<br>
<br>
if (m_fencPic)<br>
{<br>
- m_fencPic->destroy();<br>
+ if (m_param->bCopyPicToFrame)<br>
+ m_fencPic->destroy();<br>
delete m_fencPic;<br>
m_fencPic = NULL;<br>
}<br>
diff -r 6ac1b12bcde9 -r dd9772385d15 source/common/param.cpp<br>
--- a/source/common/param.cpp Fri Nov 10 19:02:48 2017 +0530<br>
+++ b/source/common/param.cpp Tue Nov 14 11:00:09 2017 +0530<br>
@@ -290,6 +290,7 @@<br>
param->csvfpt = NULL;<br>
param->forceFlush = 0;<br>
param->bDisableLookahead = 0;<br>
+ param->bCopyPicToFrame = 1;<br>
<br>
/* DCT Approximations */<br>
param->bLowPassDct = 0;<br>
@@ -987,6 +988,7 @@<br>
OPT("lowpass-dct") p->bLowPassDct = atobool(value);<br>
OPT("vbv-end") p->vbvBufferEnd = atof(value);<br>
OPT("vbv-end-fr-adj") p->vbvEndFrameAdjust = atof(value);<br>
+ OPT("copy-pic") p->bCopyPicToFrame = atobool(value);<br>
OPT("refine-mv-type")<br>
{<br>
if (strcmp(strdup(value), "avc") == 0)<br>
@@ -1718,6 +1720,7 @@<br>
s += sprintf(s, " ctu-info=%d", p->bCTUInfo);<br>
BOOL(p->bLowPassDct, "lowpass-dct");<br>
s += sprintf(s, " refine-mv-type=%d", p->bMVType);<br>
+ s += sprintf(s, " copy-pic=%d", p->bCopyPicToFrame);<br>
#undef BOOL<br>
return buf;<br>
}<br>
diff -r 6ac1b12bcde9 -r dd9772385d15 source/common/picyuv.cpp<br>
--- a/source/common/picyuv.cpp Fri Nov 10 19:02:48 2017 +0530<br>
+++ b/source/common/picyuv.cpp Tue Nov 14 11:00:09 2017 +0530<br>
@@ -69,7 +69,7 @@<br>
m_vChromaShift = 0;<br>
}<br>
<br>
-bool PicYuv::create(x265_param* param, pixel *pixelbuf)<br>
+bool PicYuv::create(x265_param* param, bool picAlloc, pixel *pixelbuf)<br>
{<br>
m_param = param;<br>
uint32_t picWidth = m_param->sourceWidth;<br>
@@ -93,8 +93,11 @@<br>
m_picOrg[0] = pixelbuf;<br>
else<br>
{<br>
- CHECKED_MALLOC(m_picBuf[0], pixel, m_stride * (maxHeight + (m_lumaMarginY * 2)));<br>
- m_picOrg[0] = m_picBuf[0] + m_lumaMarginY * m_stride + m_lumaMarginX;<br>
+ if (picAlloc)<br>
+ {<br>
+ CHECKED_MALLOC(m_picBuf[0], pixel, m_stride * (maxHeight + (m_lumaMarginY * 2)));<br>
+ m_picOrg[0] = m_picBuf[0] + m_lumaMarginY * m_stride + m_lumaMarginX;<br>
+ }<br>
}<br>
<br>
if (picCsp != X265_CSP_I400)<br>
@@ -102,12 +105,14 @@<br>
m_chromaMarginX = m_lumaMarginX; // keep 16-byte alignment for chroma CTUs<br>
m_chromaMarginY = m_lumaMarginY >> m_vChromaShift;<br>
m_strideC = ((numCuInWidth * m_param->maxCUSize) >> m_hChromaShift) + (m_chromaMarginX * 2);<br>
+ if (picAlloc)<br>
+ {<br>
+ CHECKED_MALLOC(m_picBuf[1], pixel, m_strideC * ((maxHeight >> m_vChromaShift) + (m_chromaMarginY * 2)));<br>
+ CHECKED_MALLOC(m_picBuf[2], pixel, m_strideC * ((maxHeight >> m_vChromaShift) + (m_chromaMarginY * 2)));<br>
<br>
- CHECKED_MALLOC(m_picBuf[1], pixel, m_strideC * ((maxHeight >> m_vChromaShift) + (m_chromaMarginY * 2)));<br>
- CHECKED_MALLOC(m_picBuf[2], pixel, m_strideC * ((maxHeight >> m_vChromaShift) + (m_chromaMarginY * 2)));<br>
-<br>
- m_picOrg[1] = m_picBuf[1] + m_chromaMarginY * m_strideC + m_chromaMarginX;<br>
- m_picOrg[2] = m_picBuf[2] + m_chromaMarginY * m_strideC + m_chromaMarginX;<br>
+ m_picOrg[1] = m_picBuf[1] + m_chromaMarginY * m_strideC + m_chromaMarginX;<br>
+ m_picOrg[2] = m_picBuf[2] + m_chromaMarginY * m_strideC + m_chromaMarginX;<br>
+ }<br>
}<br>
else<br>
{<br>
@@ -236,8 +241,10 @@<br>
uint64_t crSum;<br>
lumaSum = cbSum = crSum = 0;<br>
<br>
- if (pic.bitDepth == 8)<br>
+ if (m_param->bCopyPicToFrame)<br>
{<br>
+ if (pic.bitDepth == 8)<br>
+ {<br>
#if (X265_DEPTH > 8)<br>
{<br>
pixel *yPixel = m_picOrg[0];<br>
@@ -260,7 +267,7 @@<br>
}<br>
}<br>
#else /* Case for (X265_DEPTH == 8) */<br>
- // TODO: Does we need this path? may merge into above in future<br>
+ // TODO: Does we need this path? may merge into above in future<br>
{<br>
pixel *yPixel = m_picOrg[0];<br>
uint8_t *yChar = (uint8_t*)pic.planes[0];<br>
@@ -294,47 +301,54 @@<br>
}<br>
}<br>
#endif /* (X265_DEPTH > 8) */<br>
- }<br>
- else /* pic.bitDepth > 8 */<br>
- {<br>
- /* defensive programming, mask off bits that are supposed to be zero */<br>
- uint16_t mask = (1 << X265_DEPTH) - 1;<br>
- int shift = abs(pic.bitDepth - X265_DEPTH);<br>
- pixel *yPixel = m_picOrg[0];<br>
-<br>
- uint16_t *yShort = (uint16_t*)pic.planes[0];<br>
-<br>
- if (pic.bitDepth > X265_DEPTH)<br>
+ }<br>
+ else /* pic.bitDepth > 8 */<br>
{<br>
- /* shift right and mask pixels to final size */<br>
- primitives.planecopy_sp(<wbr>yShort, pic.stride[0] / sizeof(*yShort), yPixel, m_stride, width, height, shift, mask);<br>
- }<br>
- else /* Case for (pic.bitDepth <= X265_DEPTH) */<br>
- {<br>
- /* shift left and mask pixels to final size */<br>
- primitives.planecopy_sp_shl(<wbr>yShort, pic.stride[0] / sizeof(*yShort), yPixel, m_stride, width, height, shift, mask);<br>
- }<br>
+ /* defensive programming, mask off bits that are supposed to be zero */<br>
+ uint16_t mask = (1 << X265_DEPTH) - 1;<br>
+ int shift = abs(pic.bitDepth - X265_DEPTH);<br>
+ pixel *yPixel = m_picOrg[0];<br>
<br>
- if (param.internalCsp != X265_CSP_I400)<br>
- {<br>
- pixel *uPixel = m_picOrg[1];<br>
- pixel *vPixel = m_picOrg[2];<br>
-<br>
- uint16_t *uShort = (uint16_t*)pic.planes[1];<br>
- uint16_t *vShort = (uint16_t*)pic.planes[2];<br>
+ uint16_t *yShort = (uint16_t*)pic.planes[0];<br>
<br>
if (pic.bitDepth > X265_DEPTH)<br>
{<br>
- primitives.planecopy_sp(<wbr>uShort, pic.stride[1] / sizeof(*uShort), uPixel, m_strideC, width >> m_hChromaShift, height >> m_vChromaShift, shift, mask);<br>
- primitives.planecopy_sp(<wbr>vShort, pic.stride[2] / sizeof(*vShort), vPixel, m_strideC, width >> m_hChromaShift, height >> m_vChromaShift, shift, mask);<br>
+ /* shift right and mask pixels to final size */<br>
+ primitives.planecopy_sp(<wbr>yShort, pic.stride[0] / sizeof(*yShort), yPixel, m_stride, width, height, shift, mask);<br>
}<br>
else /* Case for (pic.bitDepth <= X265_DEPTH) */<br>
{<br>
- primitives.planecopy_sp_shl(<wbr>uShort, pic.stride[1] / sizeof(*uShort), uPixel, m_strideC, width >> m_hChromaShift, height >> m_vChromaShift, shift, mask);<br>
- primitives.planecopy_sp_shl(<wbr>vShort, pic.stride[2] / sizeof(*vShort), vPixel, m_strideC, width >> m_hChromaShift, height >> m_vChromaShift, shift, mask);<br>
+ /* shift left and mask pixels to final size */<br>
+ primitives.planecopy_sp_shl(<wbr>yShort, pic.stride[0] / sizeof(*yShort), yPixel, m_stride, width, height, shift, mask);<br>
+ }<br>
+<br>
+ if (param.internalCsp != X265_CSP_I400)<br>
+ {<br>
+ pixel *uPixel = m_picOrg[1];<br>
+ pixel *vPixel = m_picOrg[2];<br>
+<br>
+ uint16_t *uShort = (uint16_t*)pic.planes[1];<br>
+ uint16_t *vShort = (uint16_t*)pic.planes[2];<br>
+<br>
+ if (pic.bitDepth > X265_DEPTH)<br>
+ {<br>
+ primitives.planecopy_sp(<wbr>uShort, pic.stride[1] / sizeof(*uShort), uPixel, m_strideC, width >> m_hChromaShift, height >> m_vChromaShift, shift, mask);<br>
+ primitives.planecopy_sp(<wbr>vShort, pic.stride[2] / sizeof(*vShort), vPixel, m_strideC, width >> m_hChromaShift, height >> m_vChromaShift, shift, mask);<br>
+ }<br>
+ else /* Case for (pic.bitDepth <= X265_DEPTH) */<br>
+ {<br>
+ primitives.planecopy_sp_shl(<wbr>uShort, pic.stride[1] / sizeof(*uShort), uPixel, m_strideC, width >> m_hChromaShift, height >> m_vChromaShift, shift, mask);<br>
+ primitives.planecopy_sp_shl(<wbr>vShort, pic.stride[2] / sizeof(*vShort), vPixel, m_strideC, width >> m_hChromaShift, height >> m_vChromaShift, shift, mask);<br>
+ }<br>
}<br>
}<br>
}<br>
+ else<br>
+ {<br>
+ m_picOrg[0] = (pixel*)pic.planes[0];<br>
+ m_picOrg[1] = (pixel*)pic.planes[1];<br>
+ m_picOrg[2] = (pixel*)pic.planes[2];<br>
+ }<br>
<br>
pixel *Y = m_picOrg[0];<br>
pixel *U = m_picOrg[1];<br>
diff -r 6ac1b12bcde9 -r dd9772385d15 source/common/picyuv.h<br>
--- a/source/common/picyuv.h Fri Nov 10 19:02:48 2017 +0530<br>
+++ b/source/common/picyuv.h Tue Nov 14 11:00:09 2017 +0530<br>
@@ -76,7 +76,7 @@<br>
<br>
PicYuv();<br>
<br>
- bool create(x265_param* param, pixel *pixelbuf = NULL);<br>
+ bool create(x265_param* param, bool picAlloc = true, pixel *pixelbuf = NULL);<br>
bool createOffsets(const SPS& sps);<br>
void destroy();<br>
int getLumaBufLen(uint32_t picWidth, uint32_t picHeight, uint32_t picCsp);<br>
diff -r 6ac1b12bcde9 -r dd9772385d15 source/x265.h<br>
--- a/source/x265.h Fri Nov 10 19:02:48 2017 +0530<br>
+++ b/source/x265.h Tue Nov 14 11:00:09 2017 +0530<br>
@@ -1531,6 +1531,9 @@<br>
<br>
/* Reuse MV information obtained through API */<br>
int bMVType;<br>
+<br>
+ /* Allow the encoder to have a copy of the planes of x265_picture in Frame */<br>
+ int bCopyPicToFrame;<br>
} x265_param;<br>
<br>
/* x265_param_alloc:<br>
diff -r 6ac1b12bcde9 -r dd9772385d15 source/x265cli.h<br>
--- a/source/x265cli.h Fri Nov 10 19:02:48 2017 +0530<br>
+++ b/source/x265cli.h Tue Nov 14 11:00:09 2017 +0530<br>
@@ -286,6 +286,8 @@<br>
{ "no-splitrd-skip", no_argument, NULL, 0 },<br>
{ "lowpass-dct", no_argument, NULL, 0 },<br>
{ "refine-mv-type", required_argument, NULL, 0 },<br>
+ { "copy-pic", no_argument, NULL, 0 },<br>
+ { "no-copy-pic", no_argument, NULL, 0 },<br>
{ 0, 0, 0, 0 },<br>
{ 0, 0, 0, 0 },<br>
{ 0, 0, 0, 0 },<br>
@@ -339,6 +341,7 @@<br>
H0(" --seek <integer> First frame to encode\n");<br>
H1(" --[no-]interlace <bff|tff> Indicate input pictures are interlace fields in temporal order. Default progressive\n");<br>
H1(" --dither Enable dither if downscaling to 8 bit pixels. Default disabled\n");<br>
+ H0(" --[no-]copy-pic Copy buffers of input picture in frame. Default %s\n", OPT(param->bCopyPicToFrame));<br>
H0("\nQuality reporting metrics:\n");<br>
H0(" --[no-]ssim Enable reporting SSIM metric scores. Default %s\n", OPT(param->bEnableSsim));<br>
H0(" --[no-]psnr Enable reporting PSNR metric scores. Default %s\n", OPT(param->bEnablePsnr));<br>
______________________________<wbr>_________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/<wbr>listinfo/x265-devel</a><br>
</blockquote></div><br></div></div>