[x265] [PATCH] add API and implementation for Region of Interest(ROI)
Deepthi Nandakumar
deepthi at multicorewareinc.com
Wed Aug 12 08:00:57 CEST 2015
Sorry, in my zeal to push the Quant bug fix patch, I ended up pushing this
test patch as well.
The new (or rather X265_MALLOC) should be inside Frame::create().
On Tue, Aug 11, 2015 at 3:16 PM, <santhoshini at multicorewareinc.com> wrote:
> # HG changeset patch
> # User Santhoshini Sekar<santhoshini at multicorewareinc.com>
> # Date 1438839704 -19800
> # Thu Aug 06 11:11:44 2015 +0530
> # Node ID 8dcbdddb663d0d93ad32ac36c764146dcbd9e883
> # Parent cbdefdfca87723342d21d90c41a93254553ed3d1
> add API and implementation for Region of Interest(ROI)
>
> diff -r cbdefdfca877 -r 8dcbdddb663d source/CMakeLists.txt
> --- a/source/CMakeLists.txt Thu Aug 06 14:23:43 2015 +0530
> +++ b/source/CMakeLists.txt Thu Aug 06 11:11:44 2015 +0530
> @@ -30,7 +30,7 @@
> mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
>
> # X265_BUILD must be incremented each time the public API is changed
> -set(X265_BUILD 68)
> +set(X265_BUILD 69)
> configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
> "${PROJECT_BINARY_DIR}/x265.def")
> configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r cbdefdfca877 -r 8dcbdddb663d source/common/frame.cpp
> --- a/source/common/frame.cpp Thu Aug 06 14:23:43 2015 +0530
> +++ b/source/common/frame.cpp Thu Aug 06 11:11:44 2015 +0530
> @@ -36,6 +36,7 @@
> m_countRefEncoders = 0;
> m_encData = NULL;
> m_reconPic = NULL;
> + m_quantOffsets = NULL;
> m_next = NULL;
> m_prev = NULL;
> m_param = NULL;
> @@ -100,5 +101,10 @@
> m_reconPic = NULL;
> }
>
> + if (m_quantOffsets)
> + {
> + delete[] m_quantOffsets;
> + }
> +
> m_lowres.destroy();
> }
> diff -r cbdefdfca877 -r 8dcbdddb663d source/common/frame.h
> --- a/source/common/frame.h Thu Aug 06 14:23:43 2015 +0530
> +++ b/source/common/frame.h Thu Aug 06 11:11:44 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 cbdefdfca877 -r 8dcbdddb663d source/encoder/api.cpp
> --- a/source/encoder/api.cpp Thu Aug 06 14:23:43 2015 +0530
> +++ b/source/encoder/api.cpp Thu Aug 06 11:11:44 2015 +0530
> @@ -268,6 +268,7 @@
> pic->bitDepth = param->internalBitDepth;
> pic->colorSpace = param->internalCsp;
> pic->forceqp = X265_QP_AUTO;
> + pic->quantOffsets = NULL;
> if (param->analysisMode)
> {
> uint32_t widthInCU = (param->sourceWidth + g_maxCUSize -
> 1) >> g_maxLog2CUSize;
> diff -r cbdefdfca877 -r 8dcbdddb663d source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp Thu Aug 06 14:23:43 2015 +0530
> +++ b/source/encoder/encoder.cpp Thu Aug 06 11:11:44 2015 +0530
> @@ -407,6 +407,7 @@
> }
>
> Frame *inFrame;
> + int cuCount;
> if (m_dpb->m_freeList.empty())
> {
> inFrame = new Frame;
> @@ -441,6 +442,11 @@
> m_buOffsetY = inFrame->m_fencPic->m_buOffsetY;
> }
> }
> + if (pic_in->quantOffsets != NULL)
> + {
> + cuCount = inFrame->m_lowres.maxBlocksInRow *
> inFrame->m_lowres.maxBlocksInCol;
> + inFrame->m_quantOffsets = new float[cuCount];
> + }
> }
> else
> {
> @@ -465,6 +471,8 @@
> inFrame->m_pts = pic_in->pts;
> inFrame->m_forceqp = pic_in->forceqp;
> inFrame->m_param = m_reconfigured ? m_latestParam : m_param;
> + if (pic_in->quantOffsets != NULL)
> + memcpy(inFrame->m_quantOffsets, pic_in->quantOffsets, cuCount
> * sizeof(float));
>
> if (m_pocLast == 0)
> m_firstPts = inFrame->m_pts;
> diff -r cbdefdfca877 -r 8dcbdddb663d source/encoder/slicetype.cpp
> --- a/source/encoder/slicetype.cpp Thu Aug 06 14:23:43 2015 +0530
> +++ b/source/encoder/slicetype.cpp Thu Aug 06 11:11:44 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 != NULL)
> + 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 cbdefdfca877 -r 8dcbdddb663d source/x265.h
> --- a/source/x265.h Thu Aug 06 14:23:43 2015 +0530
> +++ b/source/x265.h Thu Aug 06 11:11:44 2015 +0530
> @@ -205,6 +205,13 @@
> * 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;
> +
> /* Frame level statistics */
> x265_frame_stats frameData;
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20150812/92f1478b/attachment.html>
More information about the x265-devel
mailing list