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

📄 em85xx.cpp

📁 EM8511s中使用的mp3录制源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		RUA_DECODER_SET_PROPERTY (m_handle, VIDEO_SET, evValidWindow, sizeof (Wnd), &Wnd);		RUA_DECODER_SET_PROPERTY (m_handle, VIDEO_SET, evTvOutputFormat, sizeof(TvOutputFormat), &TvOutputFormat);		RUA_DECODER_SET_PROPERTY (m_handle, VIDEO_SET, evTvStandard, sizeof(TvStandard), &TvStandard);		RUA_DECODER_SET_PROPERTY (m_handle, VIDEO_SET, evOutputDevice, sizeof(OutputDevice), &OutputDevice);		Wnd.x = 0;		Wnd.y = 0;		Wnd.w = 720;		Wnd.h = 480;		RUA_DECODER_SET_PROPERTY (m_handle, OSD_SET, eOsdDestinationWindow,			sizeof(Wnd), &Wnd);		Wnd.x = 0;		Wnd.y = 0;		Wnd.w = 720;		Wnd.h = 480;		m_screenWidth = 720;		m_screenHeight = 480;		RUA_DECODER_SET_PROPERTY (m_handle, VIDEO_SET, evDestinationWindow, sizeof(Wnd), &Wnd);	}	return MPEG_DECODER_ERROR_NO_ERROR;}MPEG_DECODER_ERROR MpegDecoder::GetScreenDimensions (RMint32 *w, RMint32 *h, RMint32 *n, RMint32 *d){	ASSERT (w);	ASSERT (h);	*w = m_screenWidth;	*h = m_screenHeight;	*n = m_numeratorPixelAspectRatio;	*d = m_denominatorPixelAspectRatio;	return MPEG_DECODER_ERROR_NO_ERROR;	}MPEG_DECODER_ERROR MpegDecoder::DisplayYUV420 (RMuint8 *pY, RMuint8 *pUV, RMint32 x, RMint32 y, RMint32 w, RMint32 h, RMint32 w_screen, RMint32 h_screen){	RMint32 i, Yaddr, UVaddr, isMPEG4;	YUVframe F;	RMuint8 *Y = (RMuint8 *)pY;	RMuint8 *UV = (RMuint8 *)pUV;	if ((pY == 0) && (pUV == 0))	{					int retval;		decoderproperty Dp;		evYUVWriteParams_type yuv; 		ASSERT (m_yuvWidth);		ASSERT (m_yuvHeight);		isMPEG4 = 0;		RUA_DECODER_SET_PROPERTY (m_handle, DECODER_SET, edecVideoStd, sizeof (isMPEG4), &isMPEG4);		yuv.wWidth = m_yuvWidth;		yuv.wHeight = m_yuvHeight;		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)		{			DEBUGMSG (1, ("ERROR: could not set yuv display parameters\n"));			return (MPEG_DECODER_ERROR)retval;		}		isMPEG4 = m_isMPEG4;		RUA_DECODER_SET_PROPERTY (m_handle, DECODER_SET, edecVideoStd, sizeof (isMPEG4), &isMPEG4);		return MPEG_DECODER_ERROR_NO_ERROR;	}	if ((w_screen != m_yuvWidth) || (h_screen != m_yuvHeight))	{		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::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);*/	FeedPacketQueuesInit (FeedPacketsArray, MAX_FEEDPACKETS);	ioctl (m_handle, REALMAGICHWL_IOCTL_DECODER_STOP, 0);	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 < 2048)			{				// 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);	DEBUGMSG (1, ("STC = %d, time to stop = %d\n", (RMint32)foo.dwlTime, (RMint32)time));	if (foo.dwlTime >= 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;

⌨️ 快捷键说明

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