Hello,
I am trying to implement a fairly basic VICP routine which downsamples an 8-bit greyscale image by 2 using the imxenc_average2x2 command on a DM648. For some reason, approximately the bottom 205 pixels are only partially written out as well as the first 16 pixels on the first row. (See the two bitmap attachments for the output on two different images one 1280x720, the other 1280x1440.) I have tried changing several parameters, including processing block size, and this seems to have no effect on the output, including the nature of the artifacts.
I am not sure what could be going wrong here. Could it be a DMA bug? I have never seen anything use imxenc_average2x2. Am I using it wrong? I have also attached the relevant VICP functions in downSamp2VICP.c.
Thanks in advance
typedef struct { unsigned char *pxl; int high; int wide; int stride; } GImage; static Int32 checkDownSamp2Params( CPIS_BaseParms *base, void *p){ return 0; } Int32 _CPIS_setDownSampAverage2DmaOut( CPIS_IpRun *ipRun, CPIS_BaseParms *base, void *p){ /* This Dma structures are used to pass information about dma transfers to IP_RUN library */ IP_run *ipRunObj; Uint32 scaleFactorDst= 1; ipRunObj= &ipRun->ipRunObj; ipRunObj->numDmaOut= 1; /* * * Initialize dma parameters * */ ipRunObj->dmaOut= ipRunObj->dmaOut= &CPIS_obj.dmaOut[0]; /* IP_RUN will do dynamic channel allocation through dmac module. */ ipRunObj->dmaOut[0].useTferParamTable= 0; ipRunObj->dmaOut[0].dmaChNo = DMAC_CHAN_ANY; ipRunObj->dmaOut[0].ddrAddr= (Uint32)base->dstBuf[0].ptr; ipRunObj->dmaOut[0].imgBufAddr= (Int32)(ipRun->imgbufOutOfst[0] + IMGBUF_A_BASE); ipRunObj->dmaOut[0].ddrWidth = scaleFactorDst*base->dstBuf[0].stride; ipRunObj->dmaOut[0].imgBufWidth = ipRunObj->dmaOut[0].blockWidth = \ ipRunObj->dmaOut[0].ddrOfstNextBlock= scaleFactorDst*base->procBlockSize.width>>1; ipRunObj->dmaOut[0].blockHeight = base->procBlockSize.height>>1; ipRunObj->dmaOut[0].ddrOfstNextBlockRow= ipRunObj->dmaOut[0].ddrWidth * ipRunObj->dmaOut[0].blockHeight; return 0; } Int32 setProcessingDownSampAve2( CPIS_IpRun *ipRun, CPIS_BaseParms *base, void *p){ CPIS_Info info; Int32 blocksize; Int32 blockszds2; Int16 width, height; Int16 wds2, hds2; Int8 *outBuf; ipRun->imgbufInOfst = 0; info.imgbufptr= IMGBUF_A_BASE + ipRun->imgbufInOfst; info.imgbuflen= ipRun->imgbufLen; info.cmdptr= (Int16*) (CMDBUF_BASE + ipRun->cmdOfst); info.cmdlen= 0; info.coefptr= (Int16*) (COEFFBUF_BASE + ipRun->coefOfst); info.coeflen= 0; info.procBlockSize= base->procBlockSize; info.colorDsMode = CPIS_DS_NONE; width= info.procBlockSize.width; height= info.procBlockSize.height; wds2 = width>>1; hds2 = height>>1; blocksize= width*height; blockszds2 = (wds2)*(hds2); IMGBUF_switch(SELALLBUF, ALLBUFDSP); outBuf = (Int8 *)(info.imgbufptr + info.imgbuflen); outBuf = (Int8*)(((Uint32)outBuf + 15) & 0xFFFFFFF0); // align 128 bits info.cmdlen += imxenc_average2x2( (Int16 *)info.imgbufptr, (Int16 *)outBuf, width, wds2, width, height, IMXTYPE_UBYTE, IMXOTYPE_BYTE, 2, info.cmdptr+info.cmdlen ); info.cmdlen+=imxenc_set_saturation(255, 255, 0, 0, info.cmdptr + info.cmdlen); info.cmdlen+= imxenc_sleep(info.cmdptr + info.cmdlen); ipRun->imgbufLen= info.imgbuflen; /* info.imgbuflen is in number of bytes */ ipRun->cmdLen= info.cmdlen<<1; /* info.cmdlen is in number of words */ ipRun->cmdOfst = 0; ipRun->coefLen= info.coeflen<<1; /* info.coeflen is in number of words */ ipRun->coefOfst = 0; ipRun->imgbufOutOfst[0] = ipRun->imgbufInOfst + ipRun->imgbufLen; BCACHE_wb(info.cmdptr, info.cmdlen, 1); BCACHE_wb(info.coefptr, info.coeflen, 1); IMGBUF_switch(SELIMGBUFA, IMGBUFAVICP); IMGBUF_switch(SELIMGBUFB, IMGBUFBVICP); IMGBUF_switch(SELCOEFBUF, COEFFBUFAUTO); IMGBUF_switch(SELCMDBUF, CMDBUFAUTO); return 0; } int DownSampAve2VICP(void *vHandle, GImage *dst, GImage *src, int wait) { int rv; CPIS_BaseParms base; CPIS_FuncStruct func; base.numInput = 1; base.srcBuf[0].ptr = src->pxl; base.srcBuf[0].stride = src->stride; base.srcFormat[0] = CPIS_unsigned charBIT; base.numOutput = 1; base.dstBuf[0].ptr = dst->pxl; base.dstBuf[0].stride = dst->stride; base.dstFormat[0] = CPIS_unsigned charBIT; base.roiSize.height = src->high; base.roiSize.width = src->wide; base.procBlockSize.width = 320; base.procBlockSize.height = 12; func.checkFunc = &checkDownSamp2Params; func.resetFunc = NULL; func.setDmaInFunc = NULL; func.procFunc = &setProcessingDownSampAve2; func.setDmaOutFunc = &_CPIS_setDownSampAverage2DmaOut; //debugFunc; rv = _CPIS_genericCall(&vHandle, &base, NULL, CPIS_ASYNC, &func); if(rv){ return -1; } CPIS_reset(vHandle); CPIS_start(vHandle); if(wait){ CPIS_wait(vHandle); CPIS_delete(vHandle); } return 0; }