示例#1
0
文件: WaveOut.cpp 项目: HrochL/CWSL
///////////////////////////////////////////////////////////////////////////////
// Close device
void CWaveOut::Stop(void)
{int i;

 // are we started ?
 if (m_Dev != NULL) return;

 // remove all blocks from queue
 waveOutReset(m_Dev);

 // free output blocks
 if (m_B != NULL)
 {for (i = 0; i < m_nBlock; i++)
  {// if block is prepared, unprepare it
   if ((m_B[i].dwFlags & WHDR_PREPARED) == WHDR_PREPARED)
    waveOutUnprepareHeader(m_Dev, m_B+i, sizeof(m_B[i]));
  
   // if block has data, free it
   if (m_B[i].lpData != NULL) ippsFree(m_B[i].lpData);
  }
 
  // free array
  ippsFree(m_B);
  m_B = NULL;
 }
 
 // close device
 waveOutClose(m_Dev);
 m_Dev = NULL;
}
示例#2
0
int auxResize_8u_C1R(void * pSrc, int sstep, int sh, int sw,
                      int sr1, int sr2, int sc1, int sc2,
                      void * pDst, int dstep,
                      int dr1, int dr2, int dc1, int dc2,
                      int interp)
{
    IppiSize srcSize = {sw,sh};
    IppiRect srcRoi = {sc1,sr1,sc2-sc1+1,sr2-sr1+1};
    IppiSize dstRoi = {dc2-dc1+1,dr2-dr1+1};
    double xf = (double)(dc2-dc1+1)/(sc2-sc1+1);
    double yf = (double)(dr2-dr1+1)/(sr2-sr1+1);

#ifdef IPP71

    if (interp != ippLinear) printf("sorry, using linear resize\n");

    int specSize, initSize, bufSize, numLobes=2, nChannel=1;
    IppiSize srcSizeR = {sc2-sc1+1,sr2-sr1+1};
    IppiPoint dstOffset = {0,0};
    // get working buffer sizes
    ippiResizeGetSize_8u(srcSizeR,dstRoi,ippLinear, 0, &specSize, &initSize);

    // allocate working buffers
    //Ipp8u *pInitBuf=ippsMalloc_8u(initSize);
    IppiResizeSpec_32f* pSpec=(IppiResizeSpec_32f*)ippsMalloc_8u(specSize);

    ippiResizeLinearInit_8u(srcSizeR, dstRoi, pSpec);

    ippiResizeGetBufferSize_8u(pSpec,dstRoi,nChannel,&bufSize);
    Ipp8u* pBuffer=ippsMalloc_8u(bufSize);

    int r = ippiResizeLinear_8u_C1R(pSrc, sstep,
                                    pDst, dstep,
                                    dstOffset, dstRoi,
                                    ippBorderRepl, 0,
                                    pSpec, pBuffer);

    //ippsFree(pInitBuf);
    ippsFree(pSpec);
    ippsFree(pBuffer);

    return r;

#else

    return ippiResize_8u_C1R(pSrc,srcSize,sstep,srcRoi,pDst,dstep,dstRoi,xf,yf,interp);

#endif

}
示例#3
0
static void g729_release(struct ast_trans_pvt *pvt) {
	struct g729_coder_pvt *tmp = pvt->pvt;

	int i;
	for(i = 0; i < tmp->nbanks; i++) {
		if(tmp->pBanks[i].pMem)
			ippsFree(tmp->pBanks[i].pMem);	
		tmp->pBanks[i].pMem=NULL;
	}
	if(tmp->pBanks)
		ippsFree(tmp->pBanks);
	//free(tmp);
	localusecnt--;
	ast_update_use_count();
}
示例#4
0
static bool ipp_sqrDistance(const Mat& src, const Mat& tpl, Mat& dst)
{
    IppStatus status;

    IppiSize srcRoiSize = {src.cols,src.rows};
    IppiSize tplRoiSize = {tpl.cols,tpl.rows};

    Ipp8u *pBuffer;
    int bufSize=0;

    int depth = src.depth();

    ippimatchTemplate ippFunc =
            depth==CV_8U ? (ippimatchTemplate)ippiSqrDistanceNorm_8u32f_C1R:
            depth==CV_32F? (ippimatchTemplate)ippiSqrDistanceNorm_32f_C1R: 0;

    if (ippFunc==0)
        return false;

    IppEnum funCfg = (IppEnum)(ippAlgAuto | ippiNormNone | ippiROIValid);

    status = ippiSqrDistanceNormGetBufferSize(srcRoiSize, tplRoiSize, funCfg, &bufSize);
    if ( status < 0 )
        return false;

    pBuffer = ippsMalloc_8u( bufSize );

    status = ippFunc(src.ptr(), (int)src.step, srcRoiSize, tpl.ptr(), (int)tpl.step, tplRoiSize, dst.ptr<Ipp32f>(), (int)dst.step, funCfg, pBuffer);

    ippsFree( pBuffer );
    return status >= 0;
}
示例#5
0
static void g723_release(struct ast_trans_pvt *pvt) {
 	struct g723_coder_pvt *tmp = pvt->pvt;
	int i;
	if(tmp->encoder != NULL) {
		/* Free an encoder instance */
		ippsFree(tmp->encoder);

	} else {
		/* Free a decoder instance */
		ippsFree(tmp->decoder);
	}

	//free(pvt);
	localusecnt--;
	ast_update_use_count();
}
示例#6
0
OsStatus MpeIPPGAmr::freeEncode(void)
{
   // Free codec memory
   USCFree(&m_pCodec->uscParams);
   if (m_pInputBuffer)
   {
      ippsFree(m_pInputBuffer);
      m_pInputBuffer = NULL;
   }
   if (m_pOutputBuffer)
   {
      ippsFree(m_pOutputBuffer);
      m_pOutputBuffer = NULL;
   }

   return OS_SUCCESS;
}
示例#7
0
OsStatus MpeIPPG729::freeEncode(void)
{
   // Free codec memory
   USCFree(&codec->uscParams);
   if (inputBuffer)
   {
      ippsFree(inputBuffer);
      inputBuffer = NULL;
   }
   if (outputBuffer)
   {
      ippsFree(outputBuffer);
      outputBuffer = NULL;
   }

   return OS_SUCCESS;
}
示例#8
0
void IQSSBDemodulator::setFilter(Ipp64f lowFreq, Ipp64f highFreq)
{
	_lowFreq = lowFreq;
	_highFreq = highFreq;
	ippsZero_32f(_fir_taps_re, NFFT);
	ippsZero_32f(_fir_taps_im, NFFT);
	Ipp64f* fir_tmp = ippsMalloc_64f(_taps_len);
	ippsFIRGenBandpass_64f(_lowFreq, _highFreq, fir_tmp, _taps_len,
	                       ippWinHamming, ippTrue);
	ippsConvert_64f32f(fir_tmp, _fir_taps_re, _taps_len);
	ippsFree(fir_tmp);

	ippsFFTFwd_CToC_32f_I(_fir_taps_re, _fir_taps_im,
	                       _fft_specs, _fft_buf);
	ippsCartToPolar_32f(_fir_taps_re, _fir_taps_im,
	                    _fir_taps_m, _fir_taps_p,
	                    NFFT);
}
Biquad::~Biquad()
{
#if USE(WEBAUDIO_IPP)
    ippsFree(m_ippInternalBuffer);
#endif // USE(WEBAUDIO_IPP)
}
示例#10
0
void g729_release_decoder(PVT *hDecoder){
    int i;
    struct g72x_coder_pvt *state = hDecoder;
    ippsFree(state->coder);
    ippsFree(state->scratch_mem);
}
示例#11
0
static void
HoughLinesProbabilistic( Mat& image,
                         float rho, float theta, int threshold,
                         int lineLength, int lineGap,
                         std::vector<Vec4i>& lines, int linesMax )
{
    Point pt;
    float irho = 1 / rho;
    RNG rng((uint64)-1);

    CV_Assert( image.type() == CV_8UC1 );

    int width = image.cols;
    int height = image.rows;

    int numangle = cvRound(CV_PI / theta);
    int numrho = cvRound(((width + height) * 2 + 1) / rho);

#if defined HAVE_IPP && !defined(HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK
    CV_IPP_CHECK()
    {
        IppiSize srcSize = { width, height };
        IppPointPolar delta = { rho, theta };
        IppiHoughProbSpec* pSpec;
        int bufferSize, specSize;
        int ipp_linesMax = std::min(linesMax, numangle*numrho);
        int linesCount = 0;
        lines.resize(ipp_linesMax);
        IppStatus ok = ippiHoughProbLineGetSize_8u_C1R(srcSize, delta, &specSize, &bufferSize);
        Ipp8u* buffer = ippsMalloc_8u(bufferSize);
        pSpec = (IppiHoughProbSpec*) malloc(specSize);
        if (ok >= 0) ok = ippiHoughProbLineInit_8u32f_C1R(srcSize, delta, ippAlgHintNone, pSpec);
        if (ok >= 0) ok = ippiHoughProbLine_8u32f_C1R(image.data, image.step, srcSize, threshold, lineLength, lineGap, (IppiPoint*) &lines[0], ipp_linesMax, &linesCount, buffer, pSpec);

        free(pSpec);
        ippsFree(buffer);
        if (ok >= 0)
        {
            lines.resize(linesCount);
            CV_IMPL_ADD(CV_IMPL_IPP);
            return;
        }
        lines.clear();
        setIppErrorStatus();
    }
#endif

    Mat accum = Mat::zeros( numangle, numrho, CV_32SC1 );
    Mat mask( height, width, CV_8UC1 );
    std::vector<float> trigtab(numangle*2);

    for( int n = 0; n < numangle; n++ )
    {
        trigtab[n*2] = (float)(cos((double)n*theta) * irho);
        trigtab[n*2+1] = (float)(sin((double)n*theta) * irho);
    }
    const float* ttab = &trigtab[0];
    uchar* mdata0 = mask.ptr();
    std::vector<Point> nzloc;

    // stage 1. collect non-zero image points
    for( pt.y = 0; pt.y < height; pt.y++ )
    {
        const uchar* data = image.ptr(pt.y);
        uchar* mdata = mask.ptr(pt.y);
        for( pt.x = 0; pt.x < width; pt.x++ )
        {
            if( data[pt.x] )
            {
                mdata[pt.x] = (uchar)1;
                nzloc.push_back(pt);
            }
            else
                mdata[pt.x] = 0;
        }
    }

    int count = (int)nzloc.size();

    // stage 2. process all the points in random order
    for( ; count > 0; count-- )
    {
        // choose random point out of the remaining ones
        int idx = rng.uniform(0, count);
        int max_val = threshold-1, max_n = 0;
        Point point = nzloc[idx];
        Point line_end[2];
        float a, b;
        int* adata = accum.ptr<int>();
        int i = point.y, j = point.x, k, x0, y0, dx0, dy0, xflag;
        int good_line;
        const int shift = 16;

        // "remove" it by overriding it with the last element
        nzloc[idx] = nzloc[count-1];

        // check if it has been excluded already (i.e. belongs to some other line)
        if( !mdata0[i*width + j] )
            continue;

        // update accumulator, find the most probable line
        for( int n = 0; n < numangle; n++, adata += numrho )
        {
            int r = cvRound( j * ttab[n*2] + i * ttab[n*2+1] );
            r += (numrho - 1) / 2;
            int val = ++adata[r];
            if( max_val < val )
            {
                max_val = val;
                max_n = n;
            }
        }

        // if it is too "weak" candidate, continue with another point
        if( max_val < threshold )
            continue;

        // from the current point walk in each direction
        // along the found line and extract the line segment
        a = -ttab[max_n*2+1];
        b = ttab[max_n*2];
        x0 = j;
        y0 = i;
        if( fabs(a) > fabs(b) )
        {
            xflag = 1;
            dx0 = a > 0 ? 1 : -1;
            dy0 = cvRound( b*(1 << shift)/fabs(a) );
            y0 = (y0 << shift) + (1 << (shift-1));
        }
        else
        {
            xflag = 0;
            dy0 = b > 0 ? 1 : -1;
            dx0 = cvRound( a*(1 << shift)/fabs(b) );
            x0 = (x0 << shift) + (1 << (shift-1));
        }

        for( k = 0; k < 2; k++ )
        {
            int gap = 0, x = x0, y = y0, dx = dx0, dy = dy0;

            if( k > 0 )
                dx = -dx, dy = -dy;

            // walk along the line using fixed-point arithmetics,
            // stop at the image border or in case of too big gap
            for( ;; x += dx, y += dy )
            {
                uchar* mdata;
                int i1, j1;

                if( xflag )
                {
                    j1 = x;
                    i1 = y >> shift;
                }
                else
                {
                    j1 = x >> shift;
                    i1 = y;
                }

                if( j1 < 0 || j1 >= width || i1 < 0 || i1 >= height )
                    break;

                mdata = mdata0 + i1*width + j1;

                // for each non-zero point:
                //    update line end,
                //    clear the mask element
                //    reset the gap
                if( *mdata )
                {
                    gap = 0;
                    line_end[k].y = i1;
                    line_end[k].x = j1;
                }
                else if( ++gap > lineGap )
                    break;
            }
        }

        good_line = std::abs(line_end[1].x - line_end[0].x) >= lineLength ||
                    std::abs(line_end[1].y - line_end[0].y) >= lineLength;

        for( k = 0; k < 2; k++ )
        {
            int x = x0, y = y0, dx = dx0, dy = dy0;

            if( k > 0 )
                dx = -dx, dy = -dy;

            // walk along the line using fixed-point arithmetics,
            // stop at the image border or in case of too big gap
            for( ;; x += dx, y += dy )
            {
                uchar* mdata;
                int i1, j1;

                if( xflag )
                {
                    j1 = x;
                    i1 = y >> shift;
                }
                else
                {
                    j1 = x >> shift;
                    i1 = y;
                }

                mdata = mdata0 + i1*width + j1;

                // for each non-zero point:
                //    update line end,
                //    clear the mask element
                //    reset the gap
                if( *mdata )
                {
                    if( good_line )
                    {
                        adata = accum.ptr<int>();
                        for( int n = 0; n < numangle; n++, adata += numrho )
                        {
                            int r = cvRound( j1 * ttab[n*2] + i1 * ttab[n*2+1] );
                            r += (numrho - 1) / 2;
                            adata[r]--;
                        }
                    }
                    *mdata = 0;
                }

                if( i1 == line_end[k].y && j1 == line_end[k].x )
                    break;
            }
        }
示例#12
0
void deallocate(float *ptr)
{
    if (ptr) ippsFree((void *)ptr);
}
示例#13
0
void deallocate(double *ptr)
{
    if (ptr) ippsFree((void *)ptr);
}
示例#14
0
/* frees all the fields of bwtState structure */
void Free1State( bwtState *pState ) {
    ippsFree(pState->mainstream);
    ippsFree(pState);
} /* Free1State() */
Ipp32f (*ParticleStatistics(Image2D &image_localmax, Image2D &image_in,
					   const int mask_radius, const int feature_radius, int &counter))[8]
{

	IppStatus status;

	//setup kernels
	Convolution_Kernel ConvolutionKernels(mask_radius, image_localmax.get_width(), image_localmax.get_length());

	//Convert 32-bit FP image data in image_localmax to 8-bit integer data
	Ipp8u *localmaxdata = ippsMalloc_8u((int) image_localmax.get_numberofpixels());
	int stepsize = image_localmax.get_width();
	IppiSize fullROI = image_localmax.get_ROIfull();
	status = ippiConvert_32f8u_C1R(image_localmax.get_image2D(), image_localmax.get_stepsize(),
		localmaxdata, stepsize, fullROI, ippRndNear);
	//Determine the number of particles (raw; not yet excluded from border region)
	Ipp64f numberofmaxima = 0;
	status = ippiSum_8u_C1R(localmaxdata, stepsize, image_localmax.get_ROIfull(), &numberofmaxima);

	//Set up structures for counting particle data
	int numberofpixels = image_localmax.get_numberofpixels();
	Ipp32f (*particledata)[8] = new Ipp32f[(int) numberofmaxima + 1][8];

	//border region (local maxima here are excluded from future operations)
	int border = feature_radius;	//minimum distance from the border, in pixels
	int minx = border, miny = border;
	int maxx = image_localmax.get_width() - minx;
	int maxy = image_localmax.get_height() - miny;
	int xval = 0;
	int yval = 0;

	counter = 0;									//index that keeps track of which particle
	int imagewidth = image_in.get_width();
	//determine integer x and y values (in pixels) for each local maximum outside
	//of border exclusion area
	for(int j = 0; j < numberofpixels; j++) {
		if(localmaxdata[j] == 1) {
			xval = image_in.getx(j);
			yval = image_in.gety(j);

			if (xval > minx && xval < maxx && yval > miny && yval < maxy) {
				particledata[counter][0] = j;
				particledata[counter][1] = xval;
				particledata[counter][2] = yval;
				counter++;
			}
		}
	}

	//extract local region around each maximum
	int extract_radius = mask_radius;
	int extract_diameter = 2 * extract_radius + 1;
	int extract_size = extract_diameter * extract_diameter;
	int extract_step = 4 * extract_diameter;
	IppiSize extract_ROI = {extract_diameter, extract_diameter};
	int extract_offset = extract_radius * (1 + image_in.get_width());	//calculate _relative_ offset (in pixels) of the array index
	Ipp32f *extracted_square = ippsMalloc_32f(extract_size);
	Ipp32f *multiply_result = ippsMalloc_32f(extract_size);
	Ipp32f *inputimage = ippsMalloc_32f(image_in.get_numberofpixels());
	status = ippiCopy_32f_C1R(image_in.get_image2D(), image_in.get_stepsize(),
			inputimage, image_in.get_stepsize(), image_in.get_ROIfull());
	for(int i = 0; i < counter; i++) {

		int extract_index = particledata[i][0];
		int copy_offset = extract_index - extract_offset;							//this is the starting point for ROI (in pixels!!)
		status = ippiCopy_32f_C1R(inputimage + copy_offset, image_in.get_stepsize(),
			extracted_square, extract_step, extract_ROI);
		//Calculate mass
		Ipp64f total_mass = 0;
		status = ippiMul_32f_C1R(extracted_square, extract_step, ConvolutionKernels.get_circle_kernel(), ConvolutionKernels.get_kernel_step(),
			multiply_result, extract_step, extract_ROI);
		status = ippiSum_32f_C1R(multiply_result, extract_step, extract_ROI, &total_mass, ippAlgHintNone);

		//Calculate x-offset (to be added to integral position)
		Ipp64f x_sum = 0;
		status = ippiMul_32f_C1R(extracted_square, extract_step, ConvolutionKernels.get_ramp_x_kernel(), ConvolutionKernels.get_kernel_step(),
			multiply_result, extract_step, extract_ROI);
		status = ippiSum_32f_C1R(multiply_result, extract_step, extract_ROI, &x_sum, ippAlgHintNone);
		Ipp32f x_offset = (x_sum / total_mass) - extract_radius - 1;

		//Calculate y-offset (to be added to integral position)
		Ipp64f y_sum = 0;
		status = ippiMul_32f_C1R(extracted_square, extract_step, ConvolutionKernels.get_ramp_y_kernel(), ConvolutionKernels.get_kernel_step(),
			multiply_result, extract_step, extract_ROI);
		status = ippiSum_32f_C1R(multiply_result, extract_step, extract_ROI, &y_sum, ippAlgHintNone);
		Ipp32f y_offset = (y_sum / total_mass) - extract_radius - 1;

		//Calculate r^2
		Ipp64f r2_sum = 0;
		status = ippiMul_32f_C1R(extracted_square, extract_step, ConvolutionKernels.get_r2_kernel(), ConvolutionKernels.get_kernel_step(),
			multiply_result, extract_step, extract_ROI);
		status = ippiSum_32f_C1R(multiply_result, extract_step, extract_ROI, &r2_sum, ippAlgHintNone);
		Ipp32f r2_val = r2_sum / total_mass;

		//Calculate "multiplicity": how many particles are within the area calculated by the masks
		Ipp64f multiplicity = 0;
		status = ippiSum_32f_C1R(image_localmax.get_image2D()+copy_offset, image_localmax.get_stepsize(),
			extract_ROI, &multiplicity, ippAlgHintNone);
		Ipp32f multiplicity_val = multiplicity;

		//assign values to particle data array
		if (total_mass > 0) {
		particledata[i][1] += x_offset;
		particledata[i][2] += y_offset;
		particledata[i][3] = x_offset;
		particledata[i][4] = y_offset;
		particledata[i][5] = total_mass;
		particledata[i][6] = r2_val;
		particledata[i][7] = multiplicity_val;
		}
	}

	//Cleanup memory (this part is critical---program otherwise crashes!!)
	ippsFree(extracted_square);
	extracted_square = NULL;

	ippsFree(multiply_result);
	multiply_result = NULL;

	ippsFree(inputimage);
	inputimage = NULL;

	ippsFree(localmaxdata);
	localmaxdata = NULL;

	return particledata;
}
示例#16
0
Ipp32s WINAPI WinMain( HINSTANCE hinst, HINSTANCE xxx, LPWSTR lpCmdLine, Ipp32s yyy )
{
   Ipp8s line[WINCE_CMDLINE_SIZE];                     /* to copy command line */
   Ipp8s* argvv[WINCE_NCMD_PARAMS];
   Ipp8s** argv=argvv;

   wchar_t wexename[WINCE_EXENAME_SIZE];
   Ipp8s exename[WINCE_EXENAME_SIZE];
   Ipp8s cmdline[WINCE_CMDLINE_SIZE];

   /* simulate argc and argv parameters */
   Ipp32s argc;
#else /*Other OS*/
Ipp32s main(Ipp32s argc, Ipp8s *argv[])
{
#endif /*_WIN32_WCE*/
   CommandLineParams clParams;
   USC_EC_Params ecParams;
   USC_Status USCStatus;
   MeasureIt measure;
   FILE *fp_rin = NULL;
   FILE *fp_sin = NULL;
   FILE *fp_sout = NULL;
   FILE *f_log = NULL;
   vm_file *f_csv = NULL;        /* csv File    */
   Ipp8u *in1_buff_cur, *in2_buff_cur, *out_buff_cur;
   Ipp8u *in1_buff=NULL, *in2_buff=NULL, *out_buff=NULL;

   Ipp32s flen, in_len, lCallResult;
   Ipp32s i, frameNum, tailNum;
   Ipp32s usage=0, n_repeat=1;
   double speech_sec;
   Ipp32s delay=0;
   Ipp8s* appName=argv[0];
   Ipp8s pString[MAX_LEN_STRING];
   const  IppLibraryVersion *ver = NULL;
#if defined( _WIN32_WCE )

   GetModuleFileName( hinst, wexename, WINCE_EXENAME_SIZE );
   sprintf( exename, "%ls", wexename );
   sprintf( cmdline, "%ls", lpCmdLine );
   argc = parseCmndLine( exename, cmdline, line, WINCE_CMDLINE_SIZE, argv, WINCE_NCMD_PARAMS );

#endif

   ippStaticInit();

   SetCommandLineByDefault(&clParams);
   strcpy(clParams.csvFileName, "ec_speed.csv");

   usage = ReadCommandLine(&clParams, argc, argv);
   if(clParams.puttolog == 1) {
     if((f_log = fopen(clParams.logFileName, "a")) == NULL) return FOPEN_FAIL;
   } else f_log = NULL;
   if(usage) {
      if(clParams.enumerate == 1) {
         EnumerateStaticLinkedEC(f_log);
         if(f_log) fclose(f_log);
         return 0;
      } else {
        PrintUsage((const Ipp8s *)appName, f_log);
        return USAGE;
      }
   }

   lCallResult = LoadECByName((const Ipp8s *)clParams.ECName, &ecParams, f_log);
   if(lCallResult < 0) {
      sprintf(pString, "Cannot find %s echo canceller.\n", clParams.ECName);
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(f_log) fclose(f_log);
      return LOAD_EC_FAIL;
   }
   ecParams.pUSC_EC_Fxns->std.GetInfo((USC_Handle)NULL, &ecParams.pInfo);
   ecParams.objEC = NULL;
   ecParams.pBanks = NULL;
   ecParams.nBanks = 0;

   if((fp_rin = fopen(clParams.rinFileName,"rb")) == NULL)  {
      sprintf(pString, "echo canceller: File %s [r-in] could not be open.\n", clParams.rinFileName);
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(f_log) fclose(f_log);
      return FOPEN_FAIL;
   }
   if((fp_sin = fopen(clParams.sinFileName,"rb")) == NULL) {
      sprintf(pString, "echo canceller: File %s [s-in] could not be open.\n", clParams.sinFileName);
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(f_log) fclose(f_log);
      return FOPEN_FAIL;
   }
   if((fp_sout = fopen(clParams.soutFileName,"wb")) == NULL) {
      sprintf(pString, "echo canceller: File %s [s-out] could not be open.\n", clParams.soutFileName);
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(f_log) fclose(f_log);
      return FOPEN_FAIL;
   }
   if(clParams.puttocsv) { /* open the csv file */
      if((f_csv = vm_file_open(clParams.csvFileName, "a")) == NULL) {
         sprintf(pString, "\nFile %s could not be open.\n", clParams.csvFileName);
         OutputInfoString(1, f_log, (const Ipp8s*)pString);
         if(f_log) fclose(f_log);
         return FOPEN_FAIL;
      }
   }
    if(clParams.printSysInfo){
        OutputInfoString(0, f_log,"The Intel(R) echo canceller conformant to ITU G167 and G168,\n");
        ver = ippscGetLibVersion();
        sprintf(pString, "The Intel(R) IPPSC library used:  %d.%d.%d Build %d, name %s\n",
            ver->major,ver->minor,ver->majorBuild,ver->build,ver->Name);
        OutputInfoString(0, f_log, (const Ipp8s*)pString);
        ver = ippsGetLibVersion();
        sprintf(pString, "The Intel(R) IPPSP library used:  %d.%d.%d Build %d, name %s\n",
            ver->major,ver->minor,ver->majorBuild,ver->build,ver->Name);
        OutputInfoString(0, f_log, (const Ipp8s*)pString);
    }
    sprintf(pString, "Input  rin file: %s\n", clParams.rinFileName);
    OutputInfoString(1, f_log, (const Ipp8s*)pString);
    sprintf(pString, "Input  sin file: %s\n", clParams.sinFileName);
    OutputInfoString(1, f_log, (const Ipp8s*)pString);
    sprintf(pString, "Output sout file: %s\n", clParams.soutFileName);
    OutputInfoString(1, f_log, (const Ipp8s*)pString);
    switch(clParams.nlp) {
     case 0:
         sprintf(pString, "NLP disabled\n");
         break;
     case 1:
         sprintf(pString, "NLP type 1 enabled\n");
         break;
     default:
         sprintf(pString, "NLP  type 2 enabled\n");
    }

    switch(clParams.alg) {
     case EC_FULLBAND:
            ecParams.pInfo.params.algType = EC_FULLBAND;
            sprintf(pString, "mode : fullband \n");
            break;
     case EC_SUBBAND:
            ecParams.pInfo.params.algType = EC_SUBBAND;
            sprintf(pString, "mode : subband \n");
            break;
     case EC_AFFINESUBBAND:
         ecParams.pInfo.params.algType = EC_AFFINESUBBAND;
         sprintf(pString, "mode : subband affine projection \n");
         break;
     case EC_FASTSUBBAND:
            ecParams.pInfo.params.algType = EC_FASTSUBBAND;
            sprintf(pString, "mode : fast subband \n");
            break;
     default: return UNKNOWN_FORMAT;
   }
    OutputInfoString(1, f_log, (const Ipp8s*)pString);
    switch(clParams.adapt) {
        case 0:
            sprintf(pString, "adaptation : disable \n");
            ecParams.pInfo.params.modes.adapt = AD_OFF;
            break;
        case 2:
            sprintf(pString, "adaptation : lite \n");
            ecParams.pInfo.params.modes.adapt = AD_LITEADAPT;
            break;
        default:
            ecParams.pInfo.params.modes.adapt = AD_FULLADAPT;
            sprintf(pString, "adaptation : full \n");
    }
   OutputInfoString(1, f_log, (const Ipp8s*)pString);
   sprintf(pString, "echo tail length : %d\n", clParams.tail);
   OutputInfoString(1, f_log, (const Ipp8s*)pString);
   if(clParams.puttocsv) {
    if(clParams.printSysInfo){
        sysInfoToCSV(f_csv);
    }
   }
   ecParams.pInfo.params.pcmType.sample_frequency = clParams.freq;
   ecParams.pInfo.params.pcmType.bitPerSample = 16;
   ecParams.pInfo.params.echotail = clParams.tail;
   ecParams.pInfo.params.modes.zeroCoeff = 1;///???
   ecParams.pInfo.params.modes.nlp = clParams.nlp;
   ecParams.pInfo.params.modes.cng = clParams.cng;
   ecParams.pInfo.params.modes.td = 1;
   ecParams.pInfo.params.modes.ah = clParams.ah_mode;

   ecParams.pUSC_EC_Fxns->std.NumAlloc((const USC_EC_Option *)&ecParams.pInfo.params, &ecParams.nBanks);
   ecParams.pBanks = (USC_MemBank*)ippsMalloc_8u(sizeof(USC_MemBank)*ecParams.nBanks);
   if(!ecParams.pBanks) {
      sprintf(pString, "\nLow memory: %d bytes not allocated\n", (int)(sizeof(USC_MemBank)*ecParams.nBanks));
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(fp_rin) fclose(fp_rin);
      if(fp_sin) fclose(fp_sin);
      if(fp_sout) fclose(fp_sout);
      if(clParams.puttocsv) { if(f_csv) vm_file_fclose(f_csv); }
      if(f_log) fclose(f_log);
      return MEMORY_FAIL;
   }
   ecParams.pUSC_EC_Fxns->std.MemAlloc((const USC_EC_Option *)&ecParams.pInfo.params, ecParams.pBanks);
   for(i=0;i<ecParams.nBanks;i++) {
     ecParams.pBanks[i].pMem = (Ipp8s *)ippsMalloc_8u(ecParams.pBanks[i].nbytes);//375d60,377420
     if(!ecParams.pBanks[i].pMem) {
       sprintf(pString, "\nLow memory: %d bytes not allocated\n", ecParams.pBanks[i].nbytes);
       OutputInfoString(1, f_log, (const Ipp8s*)pString);
       if(ecParams.pBanks) ippsFree(ecParams.pBanks);
       if(fp_rin) fclose(fp_rin);
       if(fp_sin) fclose(fp_sin);
       if(fp_sout) fclose(fp_sout);
       if(clParams.puttocsv) { if(f_csv) vm_file_fclose(f_csv); }
       if(f_log) fclose(f_log);
       return MEMORY_FAIL;
     }
   }

   flen = PrepareInput(fp_rin, " receive-in input ", &in1_buff, f_log);
   in_len = PrepareInput(fp_sin, " send-in input ", &in2_buff, f_log);

   if(ecParams.pInfo.params.pcmType.sample_frequency == 8000){ /* 8 KHz */
      delay = (Ipp32s) (clParams.fdelay * 8000 * 2/1000);
   }else{ /* 16 KHz */
      delay = (Ipp32s) (clParams.fdelay * 16000 * 2/1000);
   }
   flen -= delay;
   if(flen < 0)  flen = 0;
   if (flen < in_len)
       in_len = flen;

   out_buff=(Ipp8u*)ippsMalloc_8u(in_len);/* allocate output buffer */
   if(!out_buff){ /* allocate output buffer */
      sprintf(pString, "\nNo memory for buffering of %d output bytes", in_len);
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(f_log) fclose(f_log);
      return MEMORY_FAIL;
   }

   /* time stamp prior to threads creation, creation and running time may overlap. */
   measure_start(&measure);

   n_repeat = clParams.nRepeat;
   while(n_repeat--) {
      USCStatus = ecParams.pUSC_EC_Fxns->std.Init((const USC_EC_Option *)&ecParams.pInfo.params, ecParams.pBanks, &ecParams.objEC);
      if(USCStatus!=USC_NoError) {
        OutputInfoString(1, f_log,"\nCan not initialize the EC object!");
        if(ecParams.pBanks) ippsFree(ecParams.pBanks);
        if(fp_rin) fclose(fp_rin);
        if(fp_sin) fclose(fp_sin);
        if(fp_sout) fclose(fp_sout);
        if(clParams.puttocsv) { if(f_csv) vm_file_fclose(f_csv); }
        if(f_log) fclose(f_log);
        return ERROR_INIT;
      }
      ecParams.pUSC_EC_Fxns->std.GetInfo(ecParams.objEC, (USC_EC_Info *)&ecParams.pInfo);
      frameNum = in_len/ecParams.pInfo.params.framesize;
      tailNum = (in_len/sizeof(Ipp16s)) - (ecParams.pInfo.params.framesize/sizeof(Ipp16s))*frameNum;

      out_buff_cur = out_buff;
      in1_buff_cur = in1_buff;
      in2_buff_cur = in2_buff+ delay; /* shift forward the sin at delay */

      for (i = 0; i < frameNum; i++) {
          ecParams.pUSC_EC_Fxns->CancelEcho(ecParams.objEC, (Ipp16s *)in2_buff_cur,
              (Ipp16s *)in1_buff_cur, (Ipp16s *)out_buff_cur);//4,6,9,11,14,19,21,26,29,31,34,36,39,41,44,46,49,51
          in1_buff_cur += ecParams.pInfo.params.framesize;
          in2_buff_cur += ecParams.pInfo.params.framesize;
          out_buff_cur += ecParams.pInfo.params.framesize;
      }
      for (i = 0; i < tailNum; i++) {
          ippsZero_16s((Ipp16s *)out_buff_cur, tailNum);
      }
   }

   measure_end(&measure);

   if (PostProcessPCMstream((Ipp8s *)out_buff, in_len)) {
       sprintf(pString, "No memory for load of %d bytes convert from linear PCM to special pack value.",in_len);
       OutputInfoString(1, f_log, (const Ipp8s*)pString);
       if(f_log) fclose(f_log);
       return MEMORY_FAIL;
   }
   /* Write output PCM to the output file */
   fwrite(out_buff, 1, in_len, fp_sout);

   for(i=0; i<ecParams.nBanks;i++){
     if(ecParams.pBanks[i].pMem) ippsFree(ecParams.pBanks[i].pMem);
     ecParams.pBanks[i].pMem = NULL;
   }
   if(ecParams.pBanks) { ippsFree(ecParams.pBanks); ecParams.pBanks = NULL; }
   ippsFree(out_buff);

   speech_sec = (in_len / 2 * clParams.nRepeat)/(double)ecParams.pInfo.params.pcmType.sample_frequency;
   measure_output(f_log, &measure, speech_sec);
   sprintf(pString, "Done %d samples of %d Hz PCM wave file (%g sec)\n",
       (in_len>>1) * clParams.nRepeat, ecParams.pInfo.params.pcmType.sample_frequency, speech_sec);
   OutputInfoString(1, f_log, (const Ipp8s*)pString);

   if(clParams.puttocsv) {
       Ipp8s* rinFile;
       Ipp8s* sinFile;
       if ((rinFile = strrchr(clParams.rinFileName, '/')) != NULL) {
           rinFile += 1;
       } else if ((rinFile = strrchr(clParams.rinFileName, '\\')) != NULL) {
           rinFile += 1;
       } else
           rinFile = clParams.rinFileName;
       if ((sinFile = strrchr(clParams.sinFileName, '/')) != NULL) {
           sinFile += 1;
       } else if ((sinFile = strrchr(clParams.sinFileName, '\\')) != NULL) {
           sinFile += 1;
       } else
           sinFile = clParams.sinFileName;
       i=sprintf(pString, clParams.ECName);
       i += sprintf(pString + i,",");
       switch(clParams.alg) {
            case EC_FULLBAND:
                i += sprintf(pString + i,"fullband,");
                break;
            case EC_SUBBAND:
                i += sprintf(pString + i,"subband,");
                break;
            case EC_FASTSUBBAND:
                i += sprintf(pString + i,"fast subband,");
                break;
            default:
                i += sprintf(pString + i,"subband,");
       }
       switch(clParams.adapt) {
            case 2:
                i += sprintf(pString + i,"lite,");
                break;
            default:
                i += sprintf(pString + i,"full,");
       }
       i += sprintf(pString + i,"%d,",clParams.tail);
       i += sprintf(pString + i,"%d,%s,%s,%4.2f,%4.2f",
            ecParams.pInfo.params.pcmType.sample_frequency, rinFile, sinFile, speech_sec,
            measure.speed_in_mhz);
       vm_string_fprintf(f_csv,VM_STRING("%s\n"),pString);
       vm_file_fclose(f_csv);
   }

   ippsFree(in1_buff);
   ippsFree(in2_buff);

   fclose(fp_rin);
   fclose(fp_sin);
   fclose(fp_sout);

   OutputInfoString(1, f_log,"Completed !\n");
   if(f_log) fclose(f_log);
   return 0;
}
示例#17
0
void vm_ippsFree(void *lpv)
{
    _vm_deleteMallocItem(lpv);
    ippsFree(lpv);
}
示例#18
0
void CRunDeconvFFT::deleteKernel(Ipp32f* pKernel, CImage* pImg)
{
    if (pKernel == (Ipp32f*)pImg->GetRoiPtr())
        return;
    ippsFree(pKernel);
}
/**
* \brief Default destructor
*/
Worker::~Worker()
{
	ippsFree(imgZ);
}