Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

xvba: add cropping for shared surfaces

  • Loading branch information...
commit 77fdd44ef7184b47a031cc65a83ed74020e5212f 1 parent 628f490
@FernetMenta authored
View
22 xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
@@ -1681,10 +1681,10 @@ void CLinuxRendererGL::RenderXVBA(int index, int field)
glBegin(GL_QUADS);
if (m_textureTarget==GL_TEXTURE_2D)
{
- glTexCoord2f(0.0, 0.0); glVertex2f(m_destRect.x1, m_destRect.y1);
- glTexCoord2f(1.0, 0.0); glVertex2f(m_destRect.x2, m_destRect.y1);
- glTexCoord2f(1.0, 1.0); glVertex2f(m_destRect.x2, m_destRect.y2);
- glTexCoord2f(0.0, 1.0); glVertex2f(m_destRect.x1, m_destRect.y2);
+ glTexCoord2f(plane.rect.x1, plane.rect.y1); glVertex2f(m_destRect.x1, m_destRect.y1);
+ glTexCoord2f(plane.rect.x2, plane.rect.y1); glVertex2f(m_destRect.x2, m_destRect.y1);
+ glTexCoord2f(plane.rect.x2, plane.rect.y2); glVertex2f(m_destRect.x2, m_destRect.y2);
+ glTexCoord2f(plane.rect.x1, plane.rect.y2); glVertex2f(m_destRect.x1, m_destRect.y2);
}
else
{
@@ -2483,7 +2483,8 @@ bool CLinuxRendererGL::CreateXVBATexture(int index)
#ifdef HAVE_LIBXVBA
YV12Image &im = m_buffers[index].image;
YUVFIELDS &fields = m_buffers[index].fields;
- YUVPLANE &plane = fields[0][1];
+ YUVPLANE &plane = fields[0][0];
+ YUVPLANE &planeFallback = fields[0][1];
DeleteXVBATexture(index);
@@ -2498,8 +2499,8 @@ bool CLinuxRendererGL::CreateXVBATexture(int index)
plane.pixpertex_x = 1;
plane.pixpertex_y = 1;
- glGenTextures(1, &plane.id);
- fields[0][0].id = plane.id;
+ glGenTextures(1, &planeFallback.id);
+ plane.id = planeFallback.id;
m_eventTexturesDone[index]->Set();
#endif
@@ -2535,6 +2536,13 @@ void CLinuxRendererGL::UploadXVBATexture(int index)
if (xvba->UploadTexture(index, field, m_textureTarget) == 1)
fields[m_currentField][0].id = xvba->GetTexture(index, field);
+ 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(index, 1);
+
glDisable(m_textureTarget);
m_eventTexturesDone[index]->Set();
View
13 xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp
@@ -551,6 +551,9 @@ bool CDecoder::CreateSession(AVCodecContext* avctx)
m_surfaceWidth = (avctx->coded_width+15) & ~15;
m_surfaceHeight = (avctx->coded_height+15) & ~15;
+ m_vidWidth = avctx->width;
+ m_vidHeight = avctx->height;
+
XVBA_Create_Decode_Session_Input sessionInput;
XVBA_Create_Decode_Session_Output sessionOutput;
@@ -1287,6 +1290,16 @@ GLuint CDecoder::GetTexture(int index, XVBA_SURFACE_FLAG field)
return m_flipBuffer[index].glTexture[field];
}
+CRect CDecoder::GetCropRect()
+{
+ CRect crop;
+ crop.x1 = 0;
+ crop.y1 = 0;
+ crop.x2 = m_vidWidth;
+ crop.y2 = m_vidHeight;
+ return crop;
+}
+
void CDecoder::FinishGL()
{
CLog::Log(LOGNOTICE, "XVBA::FinishGL - clearing down gl resources");
View
3  xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h
@@ -28,6 +28,7 @@
#include "threads/SharedSection.h"
#include "threads/Event.h"
#include "guilib/DispResource.h"
+#include "guilib/Geometry.h"
#include "libavcodec/xvba.h"
#include <vector>
#include <deque>
@@ -91,6 +92,7 @@ class CDecoder : public CDVDVideoCodecFFmpeg::IHardwareDecoder,
void CopyYV12(uint8_t *dest);
int UploadTexture(int index, XVBA_SURFACE_FLAG field, GLenum textureTarget);
GLuint GetTexture(int index, XVBA_SURFACE_FLAG field);
+ CRect GetCropRect();
void FinishGL();
protected:
@@ -115,6 +117,7 @@ class CDecoder : public CDVDVideoCodecFFmpeg::IHardwareDecoder,
EDisplayState m_displayState;
unsigned int m_surfaceWidth, m_surfaceHeight;
+ unsigned int m_vidWidth, m_vidHeight;
unsigned int m_numRenderBuffers;
XVBADecodeCap m_decoderCap;
Please sign in to comment.
Something went wrong with that request. Please try again.