This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Problem downsampling image using DMA

I'm currently using ACPY3 to downsample a raw image on the  platform of 6467. And the results showed it's not what i expected.

Did I configure it wrong? Thanks.

Here's the code:

 

 

Int downsampling(VEHDET_ALG_Handle obj, UInt8 *src, UInt16 width,

        UInt16 height, UInt16 stride, UInt factor, UInt8 *dst,

        UInt16 *dst_width, UInt16 *dst_height, UInt16 *dst_stride) {

    ACPY3_Params acpy3_params;

    IDMA3_Handle hDMA = obj->dmaHandle1TransA;

 

    if (factor == 2 || factor == 4 || factor == 8)

        ;

    else {

        ERR1("Bad downsampling factor %d\n", factor);

        return -1;

    }

 

    *dst_width = width / factor;

    *dst_height = height / factor;

    *dst_stride = ((stride / factor + 127) >> 7) << 7;

 

    ACPY3_activate(hDMA);

 

    // Extract rows

    acpy3_params.transferType = ACPY3_2D2D;

    acpy3_params.waitId = -1;

    acpy3_params.numFrames = 1;

    acpy3_params.elementSize = stride;

    acpy3_params.numElements = *dst_height;

    acpy3_params.srcElementIndex = factor * stride;

    acpy3_params.dstElementIndex = (*dst_stride) * factor;

    acpy3_params.srcAddr = src;

    acpy3_params.dstAddr = obj->pTemp;

 

    ACPY3_configure(hDMA, &acpy3_params, 0);

    ACPY3_start(hDMA);

    ACPY3_wait(hDMA);

 

    // Extract columns

    acpy3_params.transferType = ACPY3_2D1D;

    acpy3_params.elementSize = 1;

    acpy3_params.numElements = (*dst_height) * (*dst_stride);

    acpy3_params.srcElementIndex = factor;

    acpy3_params.srcAddr = obj->pTemp;

    acpy3_params.dstAddr = dst;

 

    ACPY3_configure(hDMA, &acpy3_params, 0);

    ACPY3_start(hDMA);

    ACPY3_wait(hDMA);

 

    ACPY3_deactivate(hDMA);

 

    VEHDET_cacheInv((Ptr) dst, (*dst_stride) * (*dst_height));

 

#if 1 // Test copy results

    {

        int i, j, cnt = 0;

        int w = *dst_width;

        int h = *dst_height;

        int s = *dst_stride;

        int f = factor;

        DBG4(DBG_INFO, "Input scale:  w=%d h=%d stride=%d factor=%d\n", width,

                height, stride, factor);

        DBG3(DBG_INFO, "Output scale: w=%d h=%d stride=%d\n", *dst_width,

                *dst_height, *dst_stride);

        for (i = 0; i < h; i++) {

            for (j = 0; j < w; j++) {

                UInt8 srcVal = src[f * i * stride + f * j];

                UInt8 dstVal = dst[i * s + j];

                if (srcVal != dstVal) {

                    cnt++;

                    //DBG4(DBG_INFO, "Difference found at (%d, %d), src=%d, dst=%d\n", j, i, srcVal, dstVal);

                }

            }

        }

        DBG1(DBG_INFO, "# of different pixel found: %d\n", cnt);

    }

#endif

}