<div dir="ltr">Please ignore the previous mail. I'll resend the patch with few minor corrections.<div><br></div><div>S.Santhoshini</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 4, 2015 at 3:11 PM, <span dir="ltr"><<a href="mailto:santhoshini@multicorewareinc.com" target="_blank">santhoshini@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 Santhoshini Sekar<<a href="mailto:santhoshini@multicorewareinc.com">santhoshini@multicorewareinc.com</a>><br>
# Date 1438679012 -19800<br>
# Tue Aug 04 14:33:32 2015 +0530<br>
# Node ID e0d248f6b8ab5ec1e1b4891c807086a62279c72b<br>
# Parent d5278c76d341b3bac405938dbfb64cb7e2d9bce5<br>
add API and implemenation for Region of Interest(ROI)<br>
<br>
diff -r d5278c76d341 -r e0d248f6b8ab source/common/frame.h<br>
--- a/source/common/frame.h Mon Aug 03 10:18:46 2015 -0500<br>
+++ b/source/common/frame.h Tue Aug 04 14:33:32 2015 +0530<br>
@@ -59,6 +59,8 @@<br>
bool m_lowresInit; // lowres init complete (pre-analysis)<br>
bool m_bChromaExtended; // orig chroma planes motion extended for weight analysis<br>
<br>
+ float *quantOffsets; // points to quantOffsets in x265_picture<br>
+<br>
/* Frame Parallelism - notification between FrameEncoders of available motion reference rows */<br>
ThreadSafeInteger m_reconRowCount; // count of CTU rows completely reconstructed and extended for motion reference<br>
volatile uint32_t m_countRefEncoders; // count of FrameEncoder threads monitoring m_reconRowCount<br>
diff -r d5278c76d341 -r e0d248f6b8ab source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Mon Aug 03 10:18:46 2015 -0500<br>
+++ b/source/encoder/encoder.cpp Tue Aug 04 14:33:32 2015 +0530<br>
@@ -465,6 +465,7 @@<br>
inFrame->m_pts = pic_in->pts;<br>
inFrame->m_forceqp = pic_in->forceqp;<br>
inFrame->m_param = m_reconfigured ? m_latestParam : m_param;<br>
+ inFrame->quantOffsets = pic_in->quantOffsets;<br>
<br>
if (m_pocLast == 0)<br>
m_firstPts = inFrame->m_pts;<br>
@@ -484,6 +485,9 @@<br>
}<br>
}<br>
<br>
+ if(pic_in->quantOffsets_free)<br>
+ pic_in->quantOffsets_free(pic_in->quantOffsets);<br>
+<br>
/* Use the frame types from the first pass, if available */<br>
int sliceType = (m_param->rc.bStatRead) ? m_rateControl->rateControlSliceType(inFrame->m_poc) : pic_in->sliceType;<br>
<br>
diff -r d5278c76d341 -r e0d248f6b8ab source/encoder/slicetype.cpp<br>
--- a/source/encoder/slicetype.cpp Mon Aug 03 10:18:46 2015 -0500<br>
+++ b/source/encoder/slicetype.cpp Tue Aug 04 14:33:32 2015 +0530<br>
@@ -96,6 +96,7 @@<br>
int maxRow = curFrame->m_fencPic->m_picHeight;<br>
int blockCount = curFrame->m_lowres.maxBlocksInRow * curFrame->m_lowres.maxBlocksInCol;<br>
<br>
+ float* quantOffsets = curFrame->quantOffsets;<br>
for (int y = 0; y < 3; y++)<br>
{<br>
curFrame->m_lowres.wp_ssd[y] = 0;<br>
@@ -113,10 +114,21 @@<br>
<br>
if (param->rc.aqMode && param->rc.aqStrength == 0)<br>
{<br>
- memset(curFrame->m_lowres.qpCuTreeOffset, 0, cuCount * sizeof(double));<br>
- memset(curFrame->m_lowres.qpAqOffset, 0, cuCount * sizeof(double));<br>
- for (int cuxy = 0; cuxy < cuCount; cuxy++)<br>
- curFrame->m_lowres.invQscaleFactor[cuxy] = 256;<br>
+ if (quantOffsets)<br>
+ {<br>
+ for (int cuxy = 0; cuxy < cuCount; cuxy++)<br>
+ {<br>
+ curFrame->m_lowres.qpCuTreeOffset[cuxy] = curFrame->m_lowres.qpAqOffset[cuxy] = quantOffsets[cuxy];<br>
+ curFrame->m_lowres.invQscaleFactor[cuxy] = x265_exp2fix8(curFrame->m_lowres.qpCuTreeOffset[cuxy]);<br>
+ }<br>
+ }<br>
+ else<br>
+ {<br>
+ memset(curFrame->m_lowres.qpCuTreeOffset, 0, cuCount * sizeof(double));<br>
+ memset(curFrame->m_lowres.qpAqOffset, 0, cuCount * sizeof(double));<br>
+ for (int cuxy = 0; cuxy < cuCount; cuxy++)<br>
+ curFrame->m_lowres.invQscaleFactor[cuxy] = 256;<br>
+ }<br>
}<br>
<br>
/* Need variance data for weighted prediction */<br>
@@ -177,6 +189,8 @@<br>
uint32_t energy = acEnergyCu(curFrame, blockX, blockY, param->internalCsp);<br>
qp_adj = strength * (X265_LOG2(X265_MAX(energy, 1)) - (14.427f + 2 * (X265_DEPTH - 8)));<br>
}<br>
+ if (quantOffsets)<br>
+ qp_adj += quantOffsets[blockXY];<br>
curFrame->m_lowres.qpAqOffset[blockXY] = qp_adj;<br>
curFrame->m_lowres.qpCuTreeOffset[blockXY] = qp_adj;<br>
curFrame->m_lowres.invQscaleFactor[blockXY] = x265_exp2fix8(qp_adj);<br>
diff -r d5278c76d341 -r e0d248f6b8ab source/x265.h<br>
--- a/source/x265.h Mon Aug 03 10:18:46 2015 -0500<br>
+++ b/source/x265.h Tue Aug 04 14:33:32 2015 +0530<br>
@@ -205,6 +205,17 @@<br>
* this data structure */<br>
x265_analysis_data analysisData;<br>
<br>
+ /* An array of quantizer offsets to be applied to this image during encoding.<br>
+ * These are added on top of the decisions made by rateControl.<br>
+ * Adaptive quantization must be enabled to use this feature. These quantizer<br>
+ * offsets should be given for each 16x16 block. Behavior if quant<br>
+ * offsets differ between encoding passes is undefined. */<br>
+ float *quantOffsets;<br>
+<br>
+ /* optional callback to free quant_offsets when used.<br>
+ * Useful if one wants to use a different quant_offset array for each frame. */<br>
+ void (*quantOffsets_free)( void* );<br>
+<br>
/* Frame level statistics */<br>
x265_frame_stats frameData;<br>
<br>
</blockquote></div><br></div>