Permalink
Browse files

xvba: add cropping, fix picture jumping (non shared surfaces)

  • Loading branch information...
1 parent 993ed81 commit 662d569e7d610668a8af5e1e692bd95d9a7bcbca @FernetMenta committed Dec 18, 2011
@@ -2574,6 +2574,11 @@ void CLinuxRendererGL::DeleteXVBAyv12Texture(int index)
YUVFIELDS &fields = m_buffers[index].fields;
GLuint *pbo = m_buffers[index].pbo;
+ if (m_buffers[index].xvba)
+ m_buffers[index].xvba->FinishGL();
+
+ SAFE_RELEASE(m_buffers[index].xvba);
+
if( fields[FIELD_FULL][0].id == 0 ) return;
/* finish up all textures, and delete them */
@@ -2766,11 +2771,12 @@ bool CLinuxRendererGL::CreateXVBAyv12Texture(int index)
void CLinuxRendererGL::UploadXVBAyv12Texture(int source)
{
- YUVBUFFER& buf = m_buffers[source];
- YV12Image* im = &buf.image;
- YUVFIELDS& fields = buf.fields;
+ YUVBUFFER& buf = m_buffers[source];
+ YV12Image* im = &buf.image;
+ YUVFIELDS& fields = buf.fields;
+ XVBA::CDecoder *xvba = m_buffers[source].xvba;
- if (!(im->flags&IMAGE_FLAG_READY))
+ if (!(im->flags&IMAGE_FLAG_READY) || !xvba)
{
m_eventTexturesDone[source]->Set();
return;
@@ -2839,6 +2845,12 @@ void CLinuxRendererGL::UploadXVBAyv12Texture(int source)
VerifyGLState();
+ // crop texture
+ CRect crop = xvba->GetCropRect();
+ m_sourceRect.x1 += crop.x1;
+ m_sourceRect.x2 -= m_sourceWidth - crop.x2;
+ m_sourceRect.y1 += crop.y1;
+ m_sourceRect.y2 -= m_sourceHeight - crop.y2;
CalculateTextureSourceRects(source, 3);
glDisable(m_textureTarget);
@@ -816,7 +816,9 @@ int CXBMCRenderManager::AddVideoPicture(DVDVideoPicture& pic)
{
if (pic.xvba)
{
- pic.xvba->CopyYV12(image.plane[0]);
+ m_pRenderer->AddProcessor(pic.xvba);
+ pic.xvba->Present(index);
+ pic.xvba->CopyYV12(index, image.plane[0]);
}
}
#endif
@@ -1174,7 +1174,7 @@ void CDecoder::Present(int index)
m_presentPicture = NULL;
}
-void CDecoder::CopyYV12(uint8_t *dest)
+void CDecoder::CopyYV12(int index, uint8_t *dest)
{
CSharedLock lock(m_decoderSection);
@@ -1183,7 +1183,7 @@ void CDecoder::CopyYV12(uint8_t *dest)
return;
}
- if (!m_presentPicture)
+ if (!m_flipBuffer[index].outPic)
{
CLog::Log(LOGWARNING, "XVBA::Present: present picture is NULL");
return;
@@ -1197,7 +1197,7 @@ void CDecoder::CopyYV12(uint8_t *dest)
XVBA_Get_Surface_Input input;
input.size = sizeof(input);
input.session = m_xvbaSession;
- input.src_surface = m_presentPicture->render->surface;
+ input.src_surface = m_flipBuffer[index].outPic->render->surface;
input.target_buffer = dest;
input.target_pitch = m_surfaceWidth;
input.target_width = m_surfaceWidth;
@@ -1209,18 +1209,6 @@ void CDecoder::CopyYV12(uint8_t *dest)
CLog::Log(LOGERROR,"(XVBA::CopyYV12) failed to get surface");
}
}
-
- if (m_presentPicture->render)
- {
- CSingleLock lock(m_videoSurfaceSec);
- m_presentPicture->render->state &= ~FF_XVBA_STATE_USED_FOR_RENDER;
- m_presentPicture->render = NULL;
- }
- {
- CSingleLock lock(m_outPicSec);
- m_freeOutPic.push_back(m_presentPicture);
- m_presentPicture = NULL;
- }
}
void CDecoder::Reset()
@@ -89,7 +89,7 @@ class CDecoder : public CDVDVideoCodecFFmpeg::IHardwareDecoder,
virtual const std::string Name() { return "xvba"; }
void Present(int index);
- void CopyYV12(uint8_t *dest);
+ void CopyYV12(int index, uint8_t *dest);
int UploadTexture(int index, XVBA_SURFACE_FLAG field, GLenum textureTarget);
GLuint GetTexture(int index, XVBA_SURFACE_FLAG field);
CRect GetCropRect();

0 comments on commit 662d569

Please sign in to comment.