[x265] [PATCH] slicetype: added Intra SATD Cost analysis
Steve Borho
steve at borho.org
Mon Aug 12 14:58:53 CEST 2013
On Mon, Aug 12, 2013 at 7:18 AM, <gopu at multicorewareinc.com> wrote:
> # HG changeset patch
> # User ggopu
> # Date 1376309907 -19800
> # Node ID 28af0c3bde0dadc175ef1536bf36de3158732406
> # Parent 9f604820f7ef0a2d780cb1476921860b94d26a42
> slicetype: added Intra SATD Cost analysis
>
> diff -r 9f604820f7ef -r 28af0c3bde0d source/encoder/motion.h
> --- a/source/encoder/motion.h Mon Aug 12 17:11:34 2013 +0530
> +++ b/source/encoder/motion.h Mon Aug 12 17:48:27 2013 +0530
> @@ -37,8 +37,7 @@
> protected:
>
> /* Aligned copy of original pixels, extra room for manual alignment */
> - pixel fenc_buf[64 * FENC_STRIDE + 32];
> - pixel *fenc;
> + pixel fenc_buf[64 * FENC_STRIDE + 32];
>
what change is this making to fenc_buf?
>
> pixel *fencplane;
> intptr_t fencLumaStride;
> @@ -57,6 +56,7 @@
>
> public:
>
> + pixel *fenc;
> MotionEstimate();
>
> ~MotionEstimate() {}
> diff -r 9f604820f7ef -r 28af0c3bde0d source/encoder/slicetype.cpp
> --- a/source/encoder/slicetype.cpp Mon Aug 12 17:11:34 2013 +0530
> +++ b/source/encoder/slicetype.cpp Mon Aug 12 17:48:27 2013 +0530
> @@ -211,7 +211,56 @@
> // TODO: add bidir
> }
>
> - // TODO: copy intra SATD cost analysis here (DC + planar + all-angs)
> + UInt numModesAvailable = 35; //total number of Intra modes
> + Int nLog2SizeMinus2 = g_convertToBit[cu_size]; // partition size
> + x265::pixelcmp_t sa8d = x265::primitives.sa8d[nLog2SizeMinus2]; //
> get the Primitive function
> + UInt b_cost = 0, cost = 0;
>
use bcost
> +
> + /* need review on this buffer */
> + pixel *pAbove0 = fenc->m_lumaPlane[0][0] + pel_offset -
> fenc->m_lumaStride;
> + pixel *pAbove1 = fenc->m_lumaPlane[0][0] + pel_offset -
> fenc->cuHeight;
> + pixel *pLeft0 = fenc->m_lumaPlane[0][0] + pel_offset +
> fenc->m_lumaStride;
> + pixel *pLeft1 = fenc->m_lumaPlane[0][0] + pel_offset + fenc->cuWidth;
>
there's a chance pAbove0 is correct. I'm certain the rest are all wrong.
> +
> + // 33 Angle modes once
> + ALIGN_VAR_32(pixel, buf_trans[32 * 32]);
> + ALIGN_VAR_32(pixel, tmp[33 * 32 * 32]);
> +
> + if (cu_size <= 32)
>
drop this if()
> + {
> + // 1
> + primitives.intra_pred_dc(pAbove0 + 1, pLeft0 + 1, me.fenc,
> stride, cu_size, (cu_size <= 16));
> + cost = b_cost = sa8d(fenc->m_lumaPlane[0][0], fenc->m_lumaStride,
> me.fenc, fenc->stride);
>
there's no point in assigning cost here.
You can't use me.fenc as an output buffer, it has the reference pixels in
it that you need to compare with. You should use the tmp[] buffer for
outputs
> +
> + // 0
> + pixel *above = pAbove0;
> + pixel *left = pLeft0;
> + if (cu_size >= 8 && cu_size <= 32)
>
cu_size is always <= 32
> + {
> + above = pAbove1;
> + left = pLeft1;
> + }
> + primitives.intra_pred_planar((pixel*)above + 1, (pixel*)left + 1,
> me.fenc, fenc->stride, cu_size);
> + b_cost = sa8d(fenc->m_lumaPlane[0][0], fenc->m_lumaStride,
> me.fenc, fenc->stride);
>
you're reversing the meaning of cost and 'best cost'
> + if(b_cost < cost)
> + cost = b_cost;
> +
> + // Transpose NxN
> + x265::primitives.transpose[nLog2SizeMinus2](buf_trans,
> (pixel*)fenc, stride);
>
casting fenc (a LookaheadFrame pointer) to (pixel*) can only lead to "Bad
Things" (tm)
> +
> + x265::primitives.intra_pred_allangs[nLog2SizeMinus2](tmp,
> pAbove0, pLeft0, pAbove1, pLeft1, (cu_size <= 16));
> +
> + // TODO: We need SATD_x4 here
>
drop this TODO, we don't need 3 copies of it
> + for (UInt mode = 2; mode < numModesAvailable; mode++)
> + {
> + bool modeHor = (mode < 18);
> + pixel *cmp = (modeHor ? buf_trans : fenc->m_lumaPlane[0][0]);
>
fenc->m_lumaPlane[0][0] should be me.fenc
> + intptr_t srcStride = (modeHor ? cu_size : stride);
> + b_cost = sa8d(cmp, srcStride, &tmp[(mode - 2) * (cu_size *
> cu_size)], cu_size);
> + if(b_cost < cost )
> + cost = b_cost; // cost always having least satd cost
> + }
>
least intra satd cost needs to be stored in lowresCosts[0][0][cu_xy]
> + }
> return 0;
> }
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> http://mailman.videolan.org/listinfo/x265-devel
>
--
Steve Borho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/private/x265-devel/attachments/20130812/857e9add/attachment.html>
More information about the x265-devel
mailing list