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