void CVideoPlayerPropPage::PlayMediaYuvData( ST_YUV_VIDEO_DATA &stYuvData )
{
STRY;
#ifdef _SDL_H
m_nWidth = stYuvData.nWidth;
m_nHeight = stYuvData.nHeight;
//SDL Show YUV data
if(m_nMagnification == 0) //正常播放 没有缩放
{
m_sdlSrcRect.h = stYuvData.nHeight;
m_sdlSrcRect.w = stYuvData.nWidth;
m_sdlSrcRect.x = 0;
m_sdlSrcRect.y = 0;
}
SDL_Rect srcRT;
srcRT.h = stYuvData.nHeight;
srcRT.w = stYuvData.nWidth;
srcRT.x = 0;
srcRT.y = 0;
SDL_Rect dstRT;
dstRT.h = stYuvData.nHeight;
dstRT.w = stYuvData.nWidth;
dstRT.x = 0;
dstRT.y = 0;
int iW = stYuvData.nWidth;
int iH = stYuvData.nHeight;
char szPrint[256] = {0};
//计算yuv一行数据占的字节数
int iPitch = iW*SDL_BYTESPERPIXEL(SDL_PIXELFORMAT_YV12);
int iWidth = 0;
int iHeight = 0;
SDL_GetWindowSize( m_pSDLWindow, &iWidth, &iHeight );
dstRT.h = iHeight;
dstRT.w = iWidth;
if(m_pSDLRender == NULL)
{
int nDriversCount = SDL_GetNumRenderDrivers();
//创建渲染器,第二个参数为选用的画图驱动,0代表d3d
m_pSDLRender = SDL_CreateRenderer( m_pSDLWindow, 0, SDL_RENDERER_ACCELERATED );
if(m_pSDLRender == NULL)
{
TTRACE("%s SDL_GetError() =%s ",__FUNCTION__,SDL_GetError());
}
SDL_RendererInfo info;
SDL_GetRendererInfo(m_pSDLRender, &info);
}
//创建纹理
if(m_pSDLTexture == NULL)
{
m_pSDLTexture = SDL_CreateTexture( m_pSDLRender,SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING, iW, iH );
}
int nRet = FALSE;
nRet = SDL_UpdateYUVTexture(m_pSDLTexture,&srcRT,stYuvData.pData[0],stYuvData.nLineSize[0],\
stYuvData.pData[1],stYuvData.nLineSize[1],stYuvData.pData[2],stYuvData.nLineSize[2]);
//nRet = SDL_UpdateTexture( m_pSDLTexture, &srcRT, stYuvData.pYuvbuf, iPitch );
nRet = SDL_RenderClear( m_pSDLRender );
//if( !m_bIsSpecilReToShow )//不是指定区域显示
{
if(m_bIsZoom)
{
m_bIsZoom = FALSE;
if(m_nMagnification > m_nOldMagnification)
{
if(m_nMagnification < stYuvData.nWidth)
{
m_sdlSrcRect.x += m_nMagnification;
}
if(m_nMagnification < stYuvData.nHeight )
{
m_sdlSrcRect.y += m_nMagnification;
}
if( (m_nMagnification*2 + m_sdlSrcRect.x ) < m_sdlSrcRect.w )
{
m_sdlSrcRect.w -= m_nMagnification;
m_sdlSrcRect.w -= m_nMagnification;
}
if( (m_nMagnification*2 + m_sdlSrcRect.y ) < m_sdlSrcRect.h )
{
m_sdlSrcRect.h -= m_nMagnification;
m_sdlSrcRect.h -= m_nMagnification;
}
//SetBrightness(stYuvData.pYuvbuf,m_nWidth,m_nHeight,g_nBrightness);
}
else
{
if(m_nMagnification < stYuvData.nWidth)
{
m_sdlSrcRect.x -= m_nMagnification;
}
if(m_nMagnification < stYuvData.nHeight )
{
m_sdlSrcRect.y -= m_nMagnification;
}
// if( (m_nMagnification + m_sdlSrcRect.x + 100) < m_sdlSrcRect.w )
{
m_sdlSrcRect.w += m_nMagnification;
m_sdlSrcRect.w += m_nMagnification;
}
// if( (m_nMagnification + m_sdlSrcRect.y + 100) < m_sdlSrcRect.h )
{
m_sdlSrcRect.h += m_nMagnification;
m_sdlSrcRect.h += m_nMagnification;
}
}
m_nOldMagnification = m_nMagnification;
/*
// if( (m_nMagnification + m_sdlSrcRect.x + 100) < m_sdlSrcRect.w )
{
srcRT.w -= m_nMagnification;
srcRT.w -= m_nMagnification;
m_sdlSrcRect.w = srcRT.w;
}
// if( (m_nMagnification + m_sdlSrcRect.y + 100) < m_sdlSrcRect.h )
{
srcRT.h -= m_nMagnification;
srcRT.h -= m_nMagnification;
m_sdlSrcRect.h = srcRT.h;
}
*/
m_rectCurZoom.left = m_sdlSrcRect.x;
m_rectCurZoom.top = m_sdlSrcRect.y;
m_rectCurZoom.right = m_rectCurZoom.left + m_sdlSrcRect.w;
m_rectCurZoom.bottom = m_rectCurZoom.top + m_sdlSrcRect.h;
}
}
//else //指定区域显示
{
/*
m_sdlSrcRect.x = m_rectCurZoom.left;
m_sdlSrcRect.y = m_rectCurZoom.right;
m_sdlSrcRect.w = m_rectCurZoom.Width();
m_sdlSrcRect.h = m_rectCurZoom.Height();
*/
}
SDL_RenderCopy( m_pSDLRender, m_pSDLTexture, &m_sdlSrcRect, &dstRT );
// SDL_RenderCopy( m_pSDLRender, m_pSDLTexture, &sdlRT, &dstRT );
SDL_RenderPresent( m_pSDLRender );
#endif
return;
SCATCH;
return;
}