[x264-devel] Doubts in computing integral image

Aishwarya aishwarya.parvathy at gmail.com
Thu Oct 13 13:02:15 CEST 2016


Hi

I am trying to understand what frame->integral actually contains.  I
understand that frame->integral contains 2 planes. in the upper plane, each
element  the sum of an 8x8 pixel region with top-left corner on that point. and
in the lower plane, 4x4 sums (needed only with --partitions p4x4). I am
trying to understand how the values are getting filled. I am analyzing the
following snippet.

for( int y = start; y < height; y++ )
        {
            pixel    *pix  = frame->plane[0] + y * stride - PADH;
            uint16_t *sum8 = frame->integral + (y+1) * stride - PADH;
            uint16_t *sum4;
            if( h->frames.b_have_sub8x8_esa )
            {
                h->mc.integral_init4h( sum8, pix, stride );
                sum8 -= 8*stride;
                sum4 = sum8 + stride * (frame->i_lines[0] + PADV*2);
                if( y >= 8-PADV )
                    h->mc.integral_init4v( sum8, sum4, stride );
            }
            else
            {
                h->mc.integral_init8h( sum8, pix, stride );
                if( y >= 8-PADV )
                    h->mc.integral_init8v( sum8-8*stride, stride );
            }
        }

According to my understanding, in the above snippet, if sub8x8_esa is
present, integral 8x8 and integral 4x4 are computed and if sub8x8_esa is
absent, integral 8x8 is alone computed.
integral_init4h fills sum8 with horizontally adding 4 pixels at a time.
integral_init4v fills sum4 with vertically added 4 pixels at a time.
(thereby computing integral 4x4) and also fills integral 8x8.

static void integral_init4v( uint16_t *sum8, uint16_t *sum4, intptr_t
stride )
{
    for( int x = 0; x < stride-8; x++ )
        sum4[x] = sum8[x+4*stride] - sum8[x];
    for( int x = 0; x < stride-8; x++ )
        sum8[x] = sum8[x+8*stride] + sum8[x+8*stride+4] - sum8[x] -
sum8[x+4];
}
To get sum4, why the loop is upto stride-8? If my understanding is correct,
loop had to be upto stride - 4.

static void integral_init8v( uint16_t *sum8, intptr_t stride )
{
    for( int x = 0; x < stride-8; x++ )
        sum8[x] = sum8[x+8*stride] - sum8[x];
}
In the above function why the loop is only upto stride - 8? As far as I
understood, since it is for vertical, loop could go well till stride.
Someone please clarify if I went wrong in my understanding somewhere.

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x264-devel/attachments/20161013/8b5b09c7/attachment.html>


More information about the x264-devel mailing list