예제 #1
0
파일: mdi_net_fs.c 프로젝트: BarryChen/RDA
avinfostr* avstream_srv_testinit(int filehandle)
{
	avinfostr* avinfohdl;
	avfillstr * fillhdl;
	int res;
	avfilehdl=filehandle;
	dwldbuf= mmc_MemMalloc(80*1024);
	avinfohdl= mmc_MemMalloc(sizeof(avinfostr));
	avinfohdl->avstreamhdl_a=avstream_srv_create(0);
	avinfohdl->avstreamhdl_v=avstream_srv_create(1);

	avinfohdl->totaltime=115000;//ms
	//audio info
	avinfohdl->fmt_a=3;//audio format
	avinfohdl->samplerate_a=8000;
	avinfohdl->bits_a=16;
	avinfohdl->channels_a=1;
	avinfohdl->totalfrm_a=0;//total frame count or time/data length
	//video info
	avinfohdl->fmt_v=9;//video format
	avinfohdl->width_v=176;
	avinfohdl->height_v=144;
	avinfohdl->fps_v=25;
	avinfohdl->totalfrm_v=0;//total frame count or time/data length

	vfileoffset=0;
	afileoffset=2945324;
	
	avstream_srv_filltest(avinfohdl);
	avstream_srv_filltest(avinfohdl);

	return avinfohdl;
}
예제 #2
0
void *
xvid_malloc(unsigned int size,
			uint8_t alignment)
{
	uint8_t *mem_ptr;
#if 1
	if ((mem_ptr = (uint8_t *) mmc_MemMalloc(size )) != NULL)
	{
		return ((void *)mem_ptr);
	}
#else
	if (!alignment) {

		/* We have not to satisfy any alignment */
		//if ((mem_ptr = (uint8_t *) my_malloc(size + 1)) != NULL) {
		if(size + 1>mmc_MemGetFree()-32)return NULL;
		if ((mem_ptr = (uint8_t *) mmc_MemMalloc(size + 1)) != NULL) {
			/* Store (mem_ptr - "real allocated memory") in *(mem_ptr-1) */
			*mem_ptr = (uint8_t)1;

			/* Return the mem_ptr pointer */
			return ((void *)(mem_ptr+1));
		}
	} else {
		uint8_t *tmp;

		/* Allocate the required size memory + alignment so we
		 * can realign the data if necessary */
		//if ((tmp = (uint8_t *) my_malloc(size + alignment)) != NULL) {
		if(size + alignment>mmc_MemGetFree()-32)return NULL;
		if ((tmp = (uint8_t *) mmc_MemMalloc(size + alignment)) != NULL) {
			/* Align the tmp pointer */
			mem_ptr =
				(uint8_t *) ((ptr_t) (tmp + alignment - 1) &
							 (~(ptr_t) (alignment - 1)));

			/* Special case where malloc have already satisfied the alignment
			 * We must add alignment to mem_ptr because we must store
			 * (mem_ptr - tmp) in *(mem_ptr-1)
			 * If we do not add alignment to mem_ptr then *(mem_ptr-1) points
			 * to a forbidden memory space */
			if (mem_ptr == tmp)
				mem_ptr += alignment;

			/* (mem_ptr - tmp) is stored in *(mem_ptr-1) so we are able to retrieve
			 * the real malloc block allocated and free it in xvid_free */
			*(mem_ptr - 1) = (uint8_t) (mem_ptr - tmp);

			/* Return the aligned pointer */
			return ((void *)mem_ptr);
		}
	}
#endif

	return(NULL);
}
예제 #3
0
파일: mdi_net_fs.c 프로젝트: BarryChen/RDA
/*
audio/video ringbuf system create.
avmode=0, create audio ringbuf with mirror area at head and tail, 
avmode=1, create video ringbuf.
must be call before video player open, and fill the buf after create.
sheen
20120425
*/
avstreamstr *avstream_srv_create(INT32 avmode)
{
	avstreamstr *avstreamhdl=0;

	avstreamhdl=(avstreamstr*)mmc_MemMalloc(sizeof(avstreamstr));

	if(avstreamhdl)
	{
		if(avmode==0)//with mirror area
		{
			avstreamhdl->ringbufptr=(unsigned char*)mmc_MemMalloc(AVSTREAM_A_RINGBUF_SIZE+AVSTREAM_MIRROR_SIZE*2);
			avstreamhdl->avstreamhdl_agent=(avagentstr*)mmc_MemMalloc(sizeof(avagentstr));
			if(avstreamhdl->ringbufptr && avstreamhdl->avstreamhdl_agent)
			{
				avstreamhdl->ringbuflen=AVSTREAM_A_RINGBUF_SIZE;
				avstreamhdl->rdptr=avstreamhdl->wtptr=avstreamhdl->ringbufptr+AVSTREAM_MIRROR_SIZE;
				avstreamhdl->mirrorlen=AVSTREAM_MIRROR_SIZE;
				//set frame header info flag
				avstreamhdl->frminfoflag=0;//not need before audio frame

				//set agent for first fill after create
				avstreamhdl->avstreamhdl_agent->ringbufptr=avstreamhdl->ringbufptr;
				avstreamhdl->avstreamhdl_agent->rdptr=avstreamhdl->rdptr;
				avstreamhdl->avstreamhdl_agent->wtptr=avstreamhdl->wtptr;
				avstreamhdl->avstreamhdl_agent->ringbuflen=avstreamhdl->ringbuflen;
				avstreamhdl->avstreamhdl_agent->mirrorlen=avstreamhdl->mirrorlen;
				avstreamhdl->avstreamhdl_agent->avid=0;//audio id
				avstreamhdl->avstreamhdl_agent->bytesneed=AVSTREAM_A_RINGBUF_SIZE+AVSTREAM_MIRROR_SIZE-AVSTREAM_SPACE;
				avstreamhdl->avstreamhdl_agent->bufupdate=1;
				avstreamhdl->avstreamhdl_agent->frminfoflag=avstreamhdl->frminfoflag;
			}
			else
			{
				//free(avstreamhdl);
				avstreamhdl=0;
				avstreamhdl->avstreamhdl_agent=0;
			}
		}
		else//no mirror
		{
			avstreamhdl->ringbufptr=(unsigned char*)mmc_MemMalloc(AVSTREAM_V_RINGBUF_SIZE);
			avstreamhdl->avstreamhdl_agent=(avagentstr*)mmc_MemMalloc(sizeof(avagentstr));
			if(avstreamhdl->ringbufptr && avstreamhdl->avstreamhdl_agent)
			{
				avstreamhdl->ringbuflen=AVSTREAM_V_RINGBUF_SIZE;
				avstreamhdl->rdptr=avstreamhdl->wtptr=avstreamhdl->ringbufptr;
				avstreamhdl->mirrorlen=0;
				//set frame header info flag.
				avstreamhdl->frminfoflag=1;//need frame header info before video frame data.

				//set agent for first fill after create
				avstreamhdl->avstreamhdl_agent->ringbufptr=avstreamhdl->ringbufptr;
				avstreamhdl->avstreamhdl_agent->rdptr=avstreamhdl->rdptr;
				avstreamhdl->avstreamhdl_agent->wtptr=avstreamhdl->wtptr;
				avstreamhdl->avstreamhdl_agent->ringbuflen=avstreamhdl->ringbuflen;
				avstreamhdl->avstreamhdl_agent->mirrorlen=avstreamhdl->mirrorlen;
				avstreamhdl->avstreamhdl_agent->avid=1;//video id
				avstreamhdl->avstreamhdl_agent->bytesneed=AVSTREAM_V_RINGBUF_SIZE -AVSTREAM_SPACE;
				avstreamhdl->avstreamhdl_agent->bufupdate=1;
				avstreamhdl->avstreamhdl_agent->frminfoflag=avstreamhdl->frminfoflag;
			}
			else
			{
				//free(avstreamhdl);
				avstreamhdl=0;
				avstreamhdl->avstreamhdl_agent=0;
			}
		}
	}

	return avstreamhdl;
}
예제 #4
0
//=============================================================================
// vpp_AudioJpegDecOpen function
//-----------------------------------------------------------------------------
HAL_ERR_T vpp_AudioJpegDecOpen(HAL_VOC_IRQ_HANDLER_T vocIrqHandler) 
{
    HAL_VOC_CFG_T cfg;
    vpp_AudioJpeg_DEC_IN_T * pDecIn;
    vpp_AudioJpeg_DEC_OUT_T *pDecStatus;
    INT32 * *pDMA;
    INT16 *pFilter;

    CALIB_BUFFER_T* calibPtr = tgt_GetCalibConfig();
	
   diag_printf("[vpp_AudioJpeg_DEC]Opening VPP AUDIO_DEC\n"); 

    if(calibPtr->aud.vocItfMap[audioItf]>=0)
        pFilter = &(calibPtr->aud.vocFilters[calibPtr->aud.vocItfMap[audioItf]].sdfFilter[0]);
    else
    {
        pFilter = mmc_MemMalloc(sizeof(CALIB_AUDIO_VOC_FILTERS_T));
        memset(pFilter, 0, sizeof(CALIB_AUDIO_VOC_FILTERS_T));
    }  
    cfg.vocCode              = G_VppCommonDecCode;
    cfg.vocCodeSize        = vpp_AudioJpeg_DEC_CODE_SIZE;
    cfg.pcVal                   = vpp_AudioJpeg_DEC_CODE_ENTRY;
    cfg.pcValCriticalSecMin  = vpp_AudioJpeg_DEC_CRITICAL_SECTION_MIN;
    cfg.pcValCriticalSecMax  = vpp_AudioJpeg_DEC_CRITICAL_SECTION_MAX;
    cfg.needOpenDoneIrq      = FALSE;
    cfg.irqMask.voc          = (vocIrqHandler) ? 1 : 0;
    cfg.irqMask.dmaVoc       = 0;
    cfg.vocIrqHandler        = vocIrqHandler;
    
    cfg.eventMask.wakeupIfc0 = 0;
    cfg.eventMask.wakeupIfc1 = 0;
    cfg.eventMask.wakeupDmae = 0;
    cfg.eventMask.wakeupDmai = 0;
    cfg.eventMask.wakeupSof0 = 0;
    cfg.eventMask.wakeupSof1 = 0;
    
    // load the VPP AUDIO_DEC  code and configure the VoC resource        
    switch (hal_VocOpen(&cfg))
    {
        // error opening the resource
        case HAL_ERR_RESOURCE_BUSY:                 
            diag_printf("[vpp_AudioJpeg_DEC]##WARNING##Error opening VoC resource\n"); 
            return HAL_ERR_RESOURCE_BUSY;
                                        
        // first open, load the constant tables                            
        case HAL_ERR_RESOURCE_RESET:              
            diag_printf("[vpp_AudioJpeg_DEC]First open.\n");			
            break;

        default:           
            diag_printf("[vpp_AudioJpeg_DEC]No first open.\n"); 
            break;
    }                          

   diag_printf("[vpp_AudioJpeg_DEC]Initializing the DMA addr.\n");
      //mp3
   	pDMA = hal_VocGetPointer(VPP_MP3_Code_ExternalAddr_addr);
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppMp3DecCode,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppMp3DecConstX,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppMp3DecConstY,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
   *((INT32*)hal_VocGetPointer(VPP_AUDIO_MIXING_MP3_ADDR))=FALSE;
	//aac
	pDMA = hal_VocGetPointer(VPP_AAC_Code_ExternalAddr_addr);

	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecCode,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppMp3Layer12Dec_DMA_ConstY,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);	
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecConstY,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);

	//amr
	pDMA = hal_VocGetPointer(VPP_AMR_Code_ExternalAddr_addr);

	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAmrDecCode,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppMp3Dec_EQ_DMA_ConstY,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAmrDecConstY,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);

#ifndef TARGET_AAC_SUPPORT_OFF
    pDMA= hal_VocGetPointer(VPP_AAC_Tab_huffTabSpec_START_addr);
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecHuffTabSpec,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecCos4sin4tab,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecTwidTabOdd,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecSinWindow,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
#endif

 *((INT16*)hal_VocGetPointer( VPP_GLOBAL_NON_CLIP_BUFFER_MP3_CLEAR_FLAG))=1;

#ifdef VIDEO_PLAYER_SUPPORT
	//jpeg
	pDMA = hal_VocGetPointer(VPP_JPEG_Code_ExternalAddr_addr);

	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppJpegDecCode,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppJpegDecConstY,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);


	
	pDMA = hal_VocGetPointer(VPP_AAC_Tab_huffTabSpec_START_addr);
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecHuffTabSpec,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecCos4sin4tab,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecTwidTabOdd,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecSinWindow,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);

      //h263 zoom
	pDMA = hal_VocGetPointer(VPP_H263_Zoom_Code_ExternalAddr_addr);
     *pDMA=hal_VocGetDmaiPointer((INT32*)G_VppH263ZoomCode,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	 pDMA=pDMA+1;
     *pDMA=hal_VocGetDmaiPointer((INT32*)G_VppH263ZoomConstX,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
#endif

#ifdef bt_support
       //sbc encode
	pDMA = hal_VocGetPointer(VPP_SBC_ENC_Code_ExternalAddr_addr);
     *pDMA=hal_VocGetDmaiPointer((INT32*)G_VppSBCCode,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
#endif

	pDMA = hal_VocGetPointer(VPP_Speak_AntiDistortion_Filter_Coef_addr);
   //  *pDMA=hal_VocGetDmaiPointer((INT32*)(&(calibPtr->bb->audio[4].vocFilters.sdfFilter[0])),  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
    *pDMA=hal_VocGetDmaiPointer((INT32*)pFilter,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
     
	pDMA = hal_VocGetPointer(VPP_GLOBAL_NON_CLIP_HISTORYDATA_L_MP3_ADDR);

#ifdef SMALL_BSS_RAM_SIZE

	G_Mp3NonCliPLBuf_alloc                     = (UINT8*)mmc_MemMalloc_BssRam(G_Mp3NonCliPLBuf_Len+3);
	//G_Mp3NonCliPRBuf_alloc                     = (UINT8*)mmc_MemMalloc_BssRam(G_Mp3NonCliPRBuf_Len+3);
	G_Mp3NonCliPLBuf =(UINT32*) ((UINT32)(G_Mp3NonCliPLBuf_alloc +3) & ~0x3);
	//G_Mp3NonCliPRBuf =(UINT32*) ((UINT32)(G_Mp3NonCliPRBuf_alloc+3) & ~0x3);

	hal_HstSendEvent(SYS_EVENT,0xaccccccc);
	hal_HstSendEvent(SYS_EVENT,G_Mp3NonCliPLBuf_alloc);
	hal_HstSendEvent(SYS_EVENT,G_Mp3NonCliPLBuf);
	//hal_HstSendEvent(SYS_EVENT,G_Mp3NonCliPRBuf_alloc);
	//hal_HstSendEvent(SYS_EVENT,G_Mp3NonCliPRBuf);

#endif


     *pDMA=hal_VocGetDmaiPointer((INT32*)G_Mp3NonCliPLBuf,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
     
	//pDMA = hal_VocGetPointer(VPP_GLOBAL_NON_CLIP_HISTORYDATA_R_MP3_ADDR);
    // *pDMA=hal_VocGetDmaiPointer((INT32*)G_Mp3NonCliPRBuf,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
     
	pDMA = hal_VocGetPointer(VPP_GLOBAL_DIGITAL_GAIN_MP3_ADDR);

     *pDMA=(INT32 *)(((32767)<<16)|(0x10));

     for(INT32 i=0;i<30;i++)
     {
        //calibPtr->bb->audio[4].vocFilters.sdfFilter[32+i]=f_sbc_persition[i];
        pFilter[32+i]=f_sbc_persition[i];
     }

     for(INT32 i=0;i<288;i++)
     {
        G_Mp3NonCliPLBuf[i]=0;
           
     }

	pDecIn = hal_VocGetPointer(vpp_AudioJpeg_DEC_IN_STRUCT);
	pDecIn->reset=1;
	pDecIn->EQ_Type = -1;  	


    
	 pDecStatus = (vpp_AudioJpeg_DEC_OUT_T *)hal_VocGetPointer(vpp_AudioJpeg_DEC_OUT_STRUCT);
	 pDecStatus->ErrorStatus=0;
	 pDecStatus->mode=-1;//not 0~9;
 

    // move to STALL location (VoC irq generated)

      vpp_AudioJpegDecVocOpen_status=TRUE;

    return  hal_VocWakeup(HAL_VOC_START);
            
}