⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 em85xx.cpp

📁 EM8511s中使用的mp3播放器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		int retval;		decoderproperty Dp;			evYUVWriteParams_type yuv; 		isMPEG4 = m_isMPEG4 = 0;		RUA_DECODER_SET_PROPERTY (m_handle, DECODER_SET, edecVideoStd, sizeof (isMPEG4), &isMPEG4);		yuv.wWidth = w_screen;		yuv.wHeight = h_screen;		yuv.YUVFormat = YUV_420_UNPACKED;		Dp.PropSet = VIDEO_SET;		Dp.PropId = evYUVWriteParams;		Dp.PropTypeLength = sizeof (evYUVWriteParams_type);		Dp.pValue = &yuv;		retval = ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_SET_PROPERTY, &Dp);		if (retval == 0)		{			m_yuvWidth = w_screen;			m_yuvHeight = h_screen;			}		else		{			DEBUGMSG (1, ("ERROR: could not set yuv display parameters\n"));			return (MPEG_DECODER_ERROR)retval;		}	}	DEBUGMSG (1, ("MpegDecoder::DisplayYUV420 (0x%08lx,0x%08lx,%3d,%3d,%3d,%3d)\n", (RMuint32)pY, (RMuint32)pUV, x, y, w, h));	ASSERT (m_yuvHeight >= h);	ASSERT (m_yuvWidth >= w);	Yaddr = (y * m_yuvWidth) + x;	UVaddr = (y * m_yuvWidth / 2) + x;	for (i=0; i<h; i++)	{		ASSERT (Yaddr < (m_yuvHeight*m_yuvWidth));		F.pY = (RMuint32 *)Y;				F.pUV = (RMuint32 *)UV;		F.nYbytes = w;		F.Yaddr = Yaddr;		F.UVaddr = UVaddr;		if (i & 1)			F.nUVbytes = 0;		else			F.nUVbytes = w;		ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_DISPLAY_YUV, &F);		Y += w;		Yaddr += m_yuvWidth;		if ((i & 1) == 0)		{			UV += w;			UVaddr += m_yuvWidth;		}	}	return MPEG_DECODER_ERROR_NO_ERROR;	} MPEG_DECODER_ERROR MpegDecoder::RenderText (RMint8 *text, RMuint32 colour, RMint32 x, RMint32 y, RMint32 w, RMint32 h){	RMuint8 *p = (RMuint8 *)m_OsdBuffer.framebuffer;	if (text == 0)	{		RMint32 i;		RMuint8 *pbits = (RMuint8 *)m_OsdBuffer.framebuffer + 8 + 1024;		pbits += (y * m_osdWidth);		pbits += x;		for (i=0; i<h; i++)		{			memset (pbits, 0, w);			pbits += m_osdWidth;		}		asm ("mcr p15, 0, r0, c7, c10, 0\n");			ioctl (m_handle, REALMAGICHWL_IOCTL_OSDFB_REFRESH, 0);		return MPEG_DECODER_ERROR_NO_ERROR;	}	switch (colour)	{	case 0xffff00:		pixel_value = 2;		break;	case 0x0000ff:		pixel_value = 3;		break;	default:		pixel_value = 1;		break;	}	sdPOINT pt;	pt.x = x;	pt.y = y;	pt.x2 = x+w;	pt.y2 = y+h;	DrawText (&font_myfont, text, &pt, 1, p+8+1024, m_osdWidth, m_osdHeight);	asm ("mcr p15, 0, r0, c7, c10, 0\n");		ioctl (m_handle, REALMAGICHWL_IOCTL_OSDFB_REFRESH, 0);	return MPEG_DECODER_ERROR_NO_ERROR;}MPEG_DECODER_ERROR MpegDecoder::RenderOsdPalette (RMuint8 *palette){	RMint32 i;	RMuint8 *ppalette = (RMuint8 *)m_OsdBuffer.framebuffer + 8;	ppalette += 16;	palette += 16;	for (i=4; i<256; i++)	{		ppalette[0] = palette[0];		ppalette[1] = palette[1];		ppalette[2] = palette[2];		ppalette[3] = palette[3];		ppalette += 4;		palette += 4;	}	return MPEG_DECODER_ERROR_NO_ERROR;}MPEG_DECODER_ERROR MpegDecoder::RenderOsdBits (RMuint8 *osd, RMint32 x, RMint32 y, RMint32 w, RMint32 h){		RMint32 i;	RMuint8 *pbits = (RMuint8 *)m_OsdBuffer.framebuffer + 8 + 1024;	pbits += (y * m_osdWidth);	pbits += x;	for (i=0; i<h; i++)	{		if (osd)			memcpy (pbits, osd, w);		else			memset (pbits, 1, w);		pbits += m_osdWidth;		if (osd)			osd += w;	}	asm ("mcr p15, 0, r0, c7, c10, 0\n");		ioctl (m_handle, REALMAGICHWL_IOCTL_OSDFB_REFRESH, 0);	return MPEG_DECODER_ERROR_NO_ERROR;}MPEG_DECODER_ERROR MpegDecoder::SaveOsdBits (RMuint8 *osd, RMint32 x, RMint32 y, RMint32 w, RMint32 h){	RMint32 i;	RMuint8 *pbits = (RMuint8 *)m_OsdBuffer.framebuffer + 8 + 1024;	pbits += (y * m_osdWidth);	pbits += x;	for (i=0; i<h; i++)	{		memcpy (osd, pbits, w);		pbits += m_osdWidth;		osd += w;	}	return MPEG_DECODER_ERROR_NO_ERROR;}MPEG_DECODER_ERROR MpegDecoder::SetVideoDestination (RMint32 x, RMint32 y, RMint32 w, RMint32 h){	decoderproperty Dp;	Wnd_type Wnd; 	if ((w == 0) && (h == 0))	{		w = m_screenWidth;		h = m_screenHeight;	}	Wnd.x = x;	Wnd.y = y;	Wnd.w = w;	Wnd.h = h;	Dp.PropSet = VIDEO_SET;	Dp.PropId = evDestinationWindow;	Dp.PropTypeLength = sizeof (Wnd_type);	Dp.pValue = &Wnd;	ASSERT (Wnd.x >= 0);	ASSERT (Wnd.y >= 0);	ASSERT (Wnd.w >= 0);	ASSERT (Wnd.w <= 1920);	ASSERT (Wnd.h <= 1080);	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_SET_PROPERTY, &Dp);	return MPEG_DECODER_ERROR_NO_ERROR;}MPEG_DECODER_ERROR MpegDecoder::Play (){	RMuint32 mode = VideoHwPlayNormal;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_PLAY, &mode);	return MPEG_DECODER_ERROR_NO_ERROR;}MPEG_DECODER_ERROR MpegDecoder::PlayIFrame (){	RMuint32 mode = VideoHwPlayIFrame;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_PLAY, &mode);	return MPEG_DECODER_ERROR_NO_ERROR;}MPEG_DECODER_ERROR MpegDecoder::PlayIFrame (RMint32 speed){	if (speed < 0)	{		speed = -speed;		RUA_DECODER_STOP (m_handle);		RUA_DECODER_SET_PROPERTY (m_handle, VIDEO_SET, evVOBUReverseSpeed, sizeof(speed), &speed);		RUA_DECODER_PLAY (m_handle, VideoHwPlayIFrameReverse);	}	else if (speed > 0)	{		RUA_DECODER_STOP (m_handle);		RUA_DECODER_SET_PROPERTY (m_handle, VIDEO_SET, evSpeed, sizeof(speed), &speed);		RUA_DECODER_PLAY (m_handle, VideoHwPlayIFrame);		}	else	{		speed = 256;		RUA_DECODER_STOP (m_handle);		RUA_DECODER_SET_PROPERTY (m_handle, VIDEO_SET, evSpeed, sizeof(speed), &speed);		RUA_DECODER_PLAY (m_handle, VideoHwPlayNormal);	}	return MPEG_DECODER_ERROR_NO_ERROR;}MPEG_DECODER_ERROR MpegDecoder::Pause (){	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_PAUSE, 0);	return MPEG_DECODER_ERROR_NO_ERROR;}MPEG_DECODER_ERROR MpegDecoder::Stop (){	// just for testing/*	RMuint32 n = 0;    RUA_DECODER_GET_PROPERTY (m_handle, VIDEO_SET, evSkippedFramesCounter, sizeof(n), &n);	printf ("%d frames skipped.\n", n);	fflush (stdout);*/	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_STOP, 0);	FeedPacketQueuesInit (FeedPacketsArray, MAX_FEEDPACKETS);	return MPEG_DECODER_ERROR_NO_ERROR;}MPEG_DECODER_ERROR MpegDecoder::GetSTC (RMint64 *pSTC, RMuint32 Resolution){    etimSystemTimeClock_type foo;    foo.dwTimeResolution_Hz = Resolution;    RUA_DECODER_GET_PROPERTY (m_handle, TIME_SET, etimSystemTimeClock,		sizeof(etimSystemTimeClock_type),&foo);	*pSTC = foo.dwlTime;	return MPEG_DECODER_ERROR_NO_ERROR;}MPEG_DECODER_ERROR MpegDecoder::EndOfStream (RMint64 time, RMuint32 Resolution){	if (time == -1)	{		edecDataFifo_type datafifo;		datafifo.Type = AUDIO;		RUA_DECODER_GET_PROPERTY (m_handle, DECODER_SET, edecDataFifo,			sizeof(datafifo), &datafifo);		DEBUGMSG (1, ("audio datafifo fullness: %d\n", (RMint32)datafifo.Info.Fullness));		if (datafifo.Info.Fullness < 1024)		{			datafifo.Type = VIDEO;			RUA_DECODER_GET_PROPERTY (m_handle, DECODER_SET, edecDataFifo,				sizeof(datafifo), &datafifo);			DEBUGMSG (1, ("video datafifo fullness: %d\n", (RMint32)datafifo.Info.Fullness));			if (datafifo.Info.Fullness < 8192)			{				// data fifos are empty				return MPEG_DECODER_ERROR_EOF;			}		}		return MPEG_DECODER_ERROR_NO_ERROR;	}    etimSystemTimeClock_type foo;    foo.dwTimeResolution_Hz = Resolution;    RUA_DECODER_GET_PROPERTY (m_handle, TIME_SET, etimSystemTimeClock,		sizeof(etimSystemTimeClock_type),&foo);	if ((RMint64)foo.dwlTime >= (RMint64)time) {		// STC is greater than or equal to the specified time		return MPEG_DECODER_ERROR_EOF;	}	return MPEG_DECODER_ERROR_NO_ERROR;	}MPEG_DECODER_ERROR MpegDecoder::SetPCMParameters (PCM_PARAMETERS *pPcmParameters){	decoderproperty Dp;	RMint32 activate = 0;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_AUDIO_SWITCH, &activate);	RMuint32 sr = pPcmParameters->SamplesPerSecond;	Dp.PropSet = AUDIO_SET;	Dp.PropId = eAudioSampleRate;	Dp.PropTypeLength = sizeof (RMuint32);	Dp.pValue = &sr;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_SET_PROPERTY, &Dp);	eAudioDigitalOutput_type outputType = eAudioDigitalOutput_Pcm;	Dp.PropSet = AUDIO_SET;	Dp.PropId = eAudioDigitalOutput;	Dp.PropTypeLength = sizeof (outputType);	Dp.pValue = &outputType;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_SET_PROPERTY, &Dp);	RMuint32 bps = pPcmParameters->NumberOfBitsPerSample;	Dp.PropSet = AUDIO_SET;	Dp.PropId = eAudioNumberOfBitsPerSample;	Dp.PropTypeLength = sizeof (bps);	Dp.pValue = &bps;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_SET_PROPERTY, &Dp);	RMuint32 nac = pPcmParameters->NumberOfChannels;	Dp.PropSet = AUDIO_SET;	Dp.PropId = eAudioNumberOfChannels;	Dp.PropTypeLength = sizeof (nac);	Dp.pValue = &nac;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_SET_PROPERTY, &Dp);	eAudioFormat_type formatType = eAudioFormat_PCM;	Dp.PropSet = AUDIO_SET;	Dp.PropId = eAudioFormat;	Dp.PropTypeLength = sizeof (formatType);	Dp.pValue = &formatType;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_SET_PROPERTY, &Dp);	activate = 1;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_AUDIO_SWITCH, &activate);	activate = 0;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_AUDIO_SWITCH, &activate);	activate = 1;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_AUDIO_SWITCH, &activate);			sr = pPcmParameters->SamplesPerSecond;	Dp.PropSet = AUDIO_SET;	Dp.PropId = eAudioSampleRate;	Dp.PropTypeLength = sizeof (RMuint32);	Dp.pValue = &sr;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_SET_PROPERTY, &Dp);	outputType = eAudioDigitalOutput_Pcm;	Dp.PropSet = AUDIO_SET;	Dp.PropId = eAudioDigitalOutput;	Dp.PropTypeLength = sizeof (outputType);	Dp.pValue = &outputType;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_SET_PROPERTY, &Dp);	bps = pPcmParameters->NumberOfBitsPerSample;	Dp.PropSet = AUDIO_SET;	Dp.PropId = eAudioNumberOfBitsPerSample;	Dp.PropTypeLength = sizeof (bps);	Dp.pValue = &bps;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_SET_PROPERTY, &Dp);	nac = pPcmParameters->NumberOfChannels;	Dp.PropSet = AUDIO_SET;	Dp.PropId = eAudioNumberOfChannels;	Dp.PropTypeLength = sizeof (nac);	Dp.pValue = &nac;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_SET_PROPERTY, &Dp);	formatType = eAudioFormat_PCM;	Dp.PropSet = AUDIO_SET;	Dp.PropId = eAudioFormat;	Dp.PropTypeLength = sizeof (formatType);	Dp.pValue = &formatType;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_SET_PROPERTY, &Dp);	return MPEG_DECODER_ERROR_NO_ERROR;}MPEG_DECODER_ERROR MpegDecoder::SetAC3Parameters (AC3_PARAMETERS *pAc3Parameters){	decoderproperty Dp;	RMint32 activate = 0;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_AUDIO_SWITCH, &activate);	RMuint32 sr = pAc3Parameters->SamplesPerSecond;	Dp.PropSet = AUDIO_SET;	Dp.PropId = eAudioSampleRate;	Dp.PropTypeLength = sizeof (RMuint32);	Dp.pValue = &sr;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_SET_PROPERTY, &Dp);	eAudioDigitalOutput_type outputType = eAudioDigitalOutput_Pcm;	if (pAc3Parameters->rawOutput)		outputType = eAudioDigitalOutput_Compressed;	Dp.PropSet = AUDIO_SET;	Dp.PropId = eAudioDigitalOutput;	Dp.PropTypeLength = sizeof (outputType);	Dp.pValue = &outputType;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_SET_PROPERTY, &Dp);	eAudioFormat_type formatType = eAudioFormat_AC3;	Dp.PropSet = AUDIO_SET;	Dp.PropId = eAudioFormat;	Dp.PropTypeLength = sizeof (formatType);	Dp.pValue = &formatType;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_SET_PROPERTY, &Dp);	activate = 1;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_AUDIO_SWITCH, &activate);	return MPEG_DECODER_ERROR_NO_ERROR;}MPEG_DECODER_ERROR MpegDecoder::SetAACParameters (AAC_PARAMETERS *pAacParameters){	DEBUGMSG (1, ("SetAACParameters:\n"));	decoderproperty Dp;	RMint32 activate = 0;	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_AUDIO_SWITCH, &activate);	eaAacConf_type AacConf;		switch (pAacParameters->AACType) 	{	    case AAC_TYPE_ADTS: 			AacConf.AacFormat = eaAacFormat_ADTS; 			break;	    case AAC_TYPE_ADIF: 			AacConf.AacFormat = eaAacFormat_ADIF; 			break;	    case AAC_TYPE_DSI: 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -