int CWinRenderer::GetImage(YV12Image *image, int source, bool readonly) { /* take next available buffer */ if( source == AUTOSOURCE ) source = NextYV12Texture(); if( source < 0 ) return -1; YUVBuffer *buf = (YUVBuffer*)m_VideoBuffers[source]; image->cshift_x = 1; image->cshift_y = 1; image->height = m_sourceHeight; image->width = m_sourceWidth; image->flags = 0; for(int i=0;i<3;i++) { image->stride[i] = buf->planes[i].rect.Pitch; image->plane[i] = (BYTE*)buf->planes[i].rect.pBits; } return source; }
int CWinRenderer::GetImage(YV12Image *image, int source, bool readonly) { /* take next available buffer */ if( source == AUTOSOURCE ) source = NextYV12Texture(); if( source < 0 ) return -1; YUVPLANES &planes = m_YUVTexture[source]; image->cshift_x = 1; image->cshift_y = 1; image->height = m_iSourceHeight; image->width = m_iSourceWidth; image->flags = 0; D3DLOCKED_RECT rect; for(int i=0;i<3;i++) { planes[i]->LockRect(0, &rect, NULL, 0); image->stride[i] = rect.Pitch; image->plane[i] = (BYTE*)rect.pBits; } return source; }
void CWinRenderer::AddProcessor(DXVA::CProcessor* processor, int64_t id) { int source = NextYV12Texture(); if(source < 0) return; DXVABuffer *buf = (DXVABuffer*)m_VideoBuffers[source]; SAFE_RELEASE(buf->proc); buf->proc = processor->Acquire(); buf->id = id; }
void CWinRenderer::ReleaseImage(int source, bool preserve) { if( source == AUTOSOURCE ) source = NextYV12Texture(); if( source < 0 ) return; YUVPLANES &planes = m_YUVTexture[source]; for(int i=0;i<3;i++) planes[i]->UnlockRect(0); }
void CWinRenderer::FlipPage(int source) { if(source == AUTOSOURCE) source = NextYV12Texture(); if (m_VideoBuffers[m_iYV12RenderBuffer] != NULL) m_VideoBuffers[m_iYV12RenderBuffer]->StartDecode(); if( source >= 0 && source < m_NumYV12Buffers ) m_iYV12RenderBuffer = source; else m_iYV12RenderBuffer = 0; if (m_VideoBuffers[m_iYV12RenderBuffer] != NULL) m_VideoBuffers[m_iYV12RenderBuffer]->StartRender(); #ifdef MP_DIRECTRENDERING __asm wbinvd #endif return; }
void CWinRenderer::FlipPage(int source) { if( source >= 0 && source < m_NumYV12Buffers ) m_iYV12RenderBuffer = source; else m_iYV12RenderBuffer = NextYV12Texture(); /* we always decode into to the next buffer */ ++m_iOSDRenderBuffer %= m_NumOSDBuffers; /* if osd wasn't rendered this time around, previuse should not be */ /* displayed on next frame */ if( !m_OSDRendered ) m_OSDWidth = m_OSDHeight = 0; m_OSDRendered = false; #ifdef MP_DIRECTRENDERING __asm wbinvd #endif return; }
unsigned int CWinRenderer::DrawSlice(unsigned char *src[], int stride[], int w, int h, int x, int y) { BYTE *s; BYTE *d; int i, p; int index = NextYV12Texture(); if( index < 0 ) return -1; D3DLOCKED_RECT rect; RECT target; target.left = x; target.right = x+w; target.top = y; target.bottom = y+h; YUVPLANES &planes = m_YUVTexture[index]; // copy Y p = 0; planes[p]->LockRect(0, &rect, &target, D3DLOCK_DISCARD); d = (BYTE*)rect.pBits; s = src[p]; for (i = 0;i < h;i++) { memcpy(d, s, w); s += stride[p]; d += rect.Pitch; } planes[p]->UnlockRect(0); w >>= 1; h >>= 1; x >>= 1; y >>= 1; target.top>>=1; target.bottom>>=1; target.left>>=1; target.right>>=1; // copy U p = 1; planes[p]->LockRect(0, &rect, &target, D3DLOCK_DISCARD); d = (BYTE*)rect.pBits; s = src[p]; for (i = 0;i < h;i++) { memcpy(d, s, w); s += stride[p]; d += rect.Pitch; } planes[p]->UnlockRect(0); // copy V p = 2; planes[p]->LockRect(0, &rect, &target, D3DLOCK_DISCARD); d = (BYTE*)rect.pBits; s = src[p]; for (i = 0;i < h;i++) { memcpy(d, s, w); s += stride[p]; d += rect.Pitch; } planes[p]->UnlockRect(0); return 0; }