[x265] [PATCH 1 of 4] add function to copy analysis data after z scan
Pradeep Ramachandran
pradeep at multicorewareinc.com
Tue Nov 7 06:17:26 CET 2017
On Mon, Nov 6, 2017 at 5:22 PM, Sean McGovern <gseanmcg at gmail.com> wrote:
> Hi,
>
> Same as I noted for other changes, please be sure to export this in the .
> def.in
This is not an API function - doesn't need to be exported. For the others,
I concur.
>
>
> -- Sean McG.
>
>
> Original Message
> From: santhoshini at multicorewareinc.com
> Sent: November 6, 2017 3:35 AM
> To: x265-devel at videolan.org
> Reply-to: x265-devel at videolan.org
> Subject: [x265] [PATCH 1 of 4] add function to copy analysis data after z
> scan
>
> # HG changeset patch
> # User Santhoshini Sekar <santhoshini at multicorewareinc.com>
> # Date 1502258938 -19800
> # Wed Aug 09 11:38:58 2017 +0530
> # Node ID 2508de5ad27440f650a6ba68a42febc273a2cd17
> # Parent aa9649a2aa8c30bcb84ee8287839fa877978d4a7
> add function to copy analysis data after z scan
>
> The pointer to x265_analysis_data sent as parameter to this function has
> data for
> 16x16 blocks stored continuously. To store this data in bigger CTU
> sizes(32x32 or 64x64) we
> need to perform z-scan of constituent 16x16 blocks before copying.
>
> diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp
> +++ b/source/encoder/encoder.cpp
> @@ -487,6 +487,95 @@
> return 0;
> }
>
> +int Encoder::setAnalysisDataAfterZScan(x265_analysis_data
> *analysis_data, Frame* curFrame)
> +{
> + int mbImageWidth, mbImageHeight;
> + mbImageWidth = (curFrame->m_fencPic->m_picWidth + 16 - 1) >> 4;
> //AVC block sizes
> + mbImageHeight = (curFrame->m_fencPic->m_picHeight + 16 - 1) >> 4;
> + if (analysis_data->sliceType == X265_TYPE_IDR ||
> analysis_data->sliceType == X265_TYPE_I)
> + {
> + curFrame->m_analysisData.sliceType = X265_TYPE_I;
> + if (m_param->analysisReuseLevel < 7)
> + return -1;
> + curFrame->m_analysisData.numPartitions =
> m_param->num4x4Partitions;
> + int num16x16inCUWidth = m_param->maxCUSize >> 4;
> + uint32_t ctuAddr, offset, cuPos;
> + analysis_intra_data * intraData = (analysis_intra_data
> *)curFrame->m_analysisData.intraData;
> + analysis_intra_data * srcIntraData = (analysis_intra_data
> *)analysis_data->intraData;
> + for (int i = 0; i < mbImageHeight; i++)
> + {
> + for (int j = 0; j < mbImageWidth; j++)
> + {
> + int mbIndex = j + i * mbImageWidth;
> + ctuAddr = (j / num16x16inCUWidth + ((i /
> num16x16inCUWidth) * (mbImageWidth / num16x16inCUWidth)));
> + offset = ((i % num16x16inCUWidth) << 5) + ((j %
> num16x16inCUWidth) << 4);
> + if ((j % 4 >= 2) && m_param->maxCUSize == 64)
> + offset += (2 * 16);
> + if ((i % 4 >= 2) && m_param->maxCUSize == 64)
> + offset += (2 * 32);
> + cuPos = ctuAddr * curFrame->m_analysisData.numPartitions
> + offset;
> + memcpy(&(intraData)->depth[cuPos],
> &(srcIntraData)->depth[mbIndex * 16], 16);
> + memcpy(&(intraData)->chromaModes[cuPos],
> &(srcIntraData)->chromaModes[mbIndex * 16], 16);
> + memcpy(&(intraData)->partSizes[cuPos],
> &(srcIntraData)->partSizes[mbIndex * 16], 16);
> + memcpy(&(intraData)->partSizes[cuPos],
> &(srcIntraData)->partSizes[mbIndex * 16], 16);
> + }
> + }
> + memcpy(&(intraData)->modes, (srcIntraData)->modes,
> curFrame->m_analysisData.numPartitions * analysis_data->numCUsInFrame);
> + }
> + else
> + {
> + uint32_t numDir = analysis_data->sliceType == X265_TYPE_P ? 1 : 2;
> + if (m_param->analysisReuseLevel < 7)
> + return -1;
> + curFrame->m_analysisData.numPartitions =
> m_param->num4x4Partitions;
> + int num16x16inCUWidth = m_param->maxCUSize >> 4;
> + uint32_t ctuAddr, offset, cuPos;
> + analysis_inter_data * interData = (analysis_inter_data
> *)curFrame->m_analysisData.interData;
> + analysis_inter_data * srcInterData = (analysis_inter_data*)
> analysis_data->interData;
> + for (int i = 0; i < mbImageHeight; i++)
> + {
> + for (int j = 0; j < mbImageWidth; j++)
> + {
> + int mbIndex = j + i * mbImageWidth;
> + ctuAddr = (j / num16x16inCUWidth + ((i /
> num16x16inCUWidth) * (mbImageWidth / num16x16inCUWidth)));
> + offset = ((i % num16x16inCUWidth) << 5) + ((j %
> num16x16inCUWidth) << 4);
> + if ((j % 4 >= 2) && m_param->maxCUSize == 64)
> + offset += (2 * 16);
> + if ((i % 4 >= 2) && m_param->maxCUSize == 64)
> + offset += (2 * 32);
> + cuPos = ctuAddr * curFrame->m_analysisData.numPartitions
> + offset;
> + memcpy(&(interData)->depth[cuPos],
> &(srcInterData)->depth[mbIndex * 16], 16);
> + memcpy(&(interData)->modes[cuPos],
> &(srcInterData)->modes[mbIndex * 16], 16);
> +
> + memcpy(&(interData)->partSize[cuPos],
> &(srcInterData)->partSize[mbIndex * 16], 16);
> +
> + int bytes = curFrame->m_analysisData.numPartitions >>
> ((srcInterData)->depth[mbIndex * 16] * 2);
> + int cuCount = 1;
> + if (bytes < 16)
> + cuCount = 4;
> + for (int cuI = 0; cuI < cuCount; cuI++)
> + {
> + int numPU = nbPartsTable[(srcInterData)->partSize[mbIndex
> * 16 + cuI * bytes]];
> + for (int pu = 0; pu < numPU; pu++)
> + {
> + int cuOffset = cuI * bytes + pu;
> + (interData)->mergeFlag[cuPos + cuOffset] =
> (srcInterData)->mergeFlag[(mbIndex * 16) + cuOffset];
> +
> + (interData)->interDir[cuPos + cuOffset] =
> (srcInterData)->interDir[(mbIndex * 16) + cuOffset];
> + for (uint32_t k = 0; k < numDir; k++)
> + {
> + (interData)->mvpIdx[k][cuPos + cuOffset] =
> (srcInterData)->mvpIdx[k][(mbIndex * 16) + cuOffset];
> + (interData)->refIdx[k][cuPos + cuOffset] =
> (srcInterData)->refIdx[k][(mbIndex * 16) + cuOffset];
> + memcpy(&(interData)->mv[k][cuPos +
> cuOffset], &(srcInterData)->mv[k][(mbIndex * 16) + cuOffset], sizeof(MV));
> + }
> + }
> + }
> + }
> + }
> + }
> + return 0;
> +}
> +
> void Encoder::destroy()
> {
> #if ENABLE_HDR10_PLUS
> diff --git a/source/encoder/encoder.h b/source/encoder/encoder.h
> --- a/source/encoder/encoder.h
> +++ b/source/encoder/encoder.h
> @@ -209,6 +209,8 @@
>
> int getRefFrameList(PicYuv** l0, PicYuv** l1, int sliceType, int poc);
>
> + int setAnalysisDataAfterZScan(x265_analysis_data *analysis_data,
> Frame* curFrame);
> +
> void getStreamHeaders(NALList& list, Entropy& sbacCoder, Bitstream&
> bs);
>
> void fetchStats(x265_stats* stats, size_t statsSizeBytes);
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
> _______________________________________________
> 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/20171107/357b29b5/attachment.html>
More information about the x265-devel
mailing list