interrupt void i2s2_rx_isr(void) { static int index = 0; Int16 x0, y0; dataL = CSL_I2S2_REGS->I2SRXLT1; dataR = CSL_I2S2_REGS->I2SRXRT1; x0 = _smpy(31785, dataL); y0 = _sadd(x0, delay_array[index]); dataL = y0; y0 = _smpy(30802, y0); y0 = _ssub(y0, x0); delay_array[index] = y0; /* Overwrite buffer with new value */ if ( ++index >= period) index = 0; }
CV_IMPL void cvAbsDiff( const void* srcarr1, const void* srcarr2, void* dstarr ) { CV_FUNCNAME( "cvAbsDiff" ); __BEGIN__; int coi1 = 0, coi2 = 0, coi3 = 0; CvMat srcstub1, *src1 = (CvMat*)srcarr1; CvMat srcstub2, *src2 = (CvMat*)srcarr2; CvMat dststub, *dst = (CvMat*)dstarr; CvSize size; int type, depth, pixel_size; CV_CALL( src1 = cvGetMat( src1, &srcstub1, &coi1 )); CV_CALL( src2 = cvGetMat( src2, &srcstub2, &coi2 )); CV_CALL( dst = cvGetMat( dst, &dststub, &coi3 )); if( coi1 != 0 || coi2 != 0 || coi3 != 0 ) CV_ERROR( CV_BadCOI, "" ); if( !CV_ARE_SIZES_EQ( src1, src2 ) ) CV_ERROR_FROM_CODE( CV_StsUnmatchedSizes ); type = CV_MAT_TYPE(src1->type); depth = CV_MAT_DEPTH(type); if( !CV_ARE_SIZES_EQ( src1, dst )) CV_ERROR_FROM_CODE( CV_StsUnmatchedSizes ); if( !CV_ARE_TYPES_EQ( src1, src2 )) CV_ERROR_FROM_CODE( CV_StsUnmatchedFormats ); if( !CV_ARE_TYPES_EQ( src1, dst )) CV_ERROR_FROM_CODE( CV_StsUnmatchedFormats ); size.width = src1->step * src1->height; size.height = 1; pixel_size = CV_DEPTH_BYTES[depth]; if(depth == CV_8U) { int idx; unsigned char * p1; unsigned char * p2; unsigned char * pdst; p1 = src1->data.ptr ; p2 = src2->data.ptr; pdst = dst->data.ptr; #ifdef _TMS320C6X for (idx = 0; idx < size.width/pixel_size; idx+=4) { _amem4(pdst) = _subabs4(_amem4_const(p1), _amem4_const(p2) ); p1 += 4; p2 += 4; pdst += 4; } #else for (idx = 0; idx < size.width/pixel_size; idx+=1) { (*pdst) = abs((*p1)-(*p2)); pdst++; p1++; p2++; } #endif } else if(depth == CV_32S) { int idx; int * p1; int * p2; int * pdst; p1 = src1->data.i; p2 = src2->data.i; pdst = dst->data.i; for (idx = 0; idx < size.width/pixel_size; idx++) { #ifdef _TMS320C6X *pdst = _abs(_ssub(*p1, *p2)); #else *pdst = abs((*p1)-(*p2)); #endif p1 += 1; p2 += 1; pdst += 1; } } else { CV_ERROR( CV_StsUnsupportedFormat, "unsupported matrix type." ); } __END__; }