[FFmpeg-devel] snowenc.c

yann.lepetitcorps at free.fr yann.lepetitcorps at free.fr
Mon Jan 9 02:59:11 CET 2012


Hi,


I see this into the libavcodec/snowenc.c :

//near copy & paste from dsputil, FIXME
static int pix_sum(uint8_t * pix, int line_size, int w)
{
    int s, i, j;

    s = 0;
    for (i = 0; i < w; i++) {
        for (j = 0; j < w; j++) {
            s += pix[0];
            pix ++;
        }
        pix += line_size - w;
    }
    return s;
}

=> it was a reason for to use this :

    for (i = 0; i < w; i++) {
        for (j = 0; j < w; j++) {
            s += pix[0];
            pix ++;
        }
        pix += line_size - w;
    }

instead this ?

    for (i = 0; i < w; i++) {
        for (j = 0; j < w; j++) {
            s += pix[j];
        }
        pix += line_size;
    }


(if not, I think that a similar modification can be make at the pix_norm1() func
too)

And is this used for make the sum of values of a w*w quad started on the pixel
pointed by pix ?

In this case, why not using a w*h **rectangular** quad instead a **square** w*w
quad ?
(this is more generic, so can be certainly reused in more places)

// Extend the initial pix_sum() functionnality by a variable height
static int pix_sum_rectangular(uint8_t * pix, int line_size, int w, int h=0)
{
    int s, i, j;

    s = 0;

    if (h == 0 )
        h = w;

    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            s += pix[j];
        }
        pix += line_size;
    }
    return s;
}




@+
Yannoo


More information about the ffmpeg-devel mailing list