Permalink
Browse files

fixed: stride given to LoadPlane should be in bytes not pixels

  • Loading branch information...
elupus committed Mar 22, 2012
1 parent 43bc023 commit c7aad3ea455092beae9737d246e5924d75bbeede
Showing with 19 additions and 18 deletions.
  1. +12 −12 xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
  2. +7 −6 xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
@@ -439,12 +439,12 @@ void CLinuxRendererGL::LoadPlane( YUVPLANE& plane, int type, unsigned flipindex
if(currPbo)
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, currPbo);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, stride);
+ int bps = glFormatElementByteCount(type);
+
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, stride / bps);
glBindTexture(m_textureTarget, plane.id);
glTexSubImage2D(m_textureTarget, 0, 0, 0, width, height, type, GL_UNSIGNED_BYTE, data);
- int bps = glFormatElementByteCount(type);
-
/* check if we need to load any border pixels */
if(height < plane.texheight)
glTexSubImage2D( m_textureTarget, 0
@@ -1919,12 +1919,12 @@ void CLinuxRendererGL::UploadNV12Texture(int source)
// Load Odd UV Fields
LoadPlane( fields[FIELD_TOP][1], GL_LUMINANCE_ALPHA, buf.flipindex
, im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
- , im->stride[1], im->plane[1] );
+ , im->stride[1]*2, im->plane[1] );
// Load Even UV Fields
LoadPlane( fields[FIELD_BOT][1], GL_LUMINANCE_ALPHA, buf.flipindex
, im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
- , im->stride[1], im->plane[1] + im->stride[1] );
+ , im->stride[1]*2, im->plane[1] + im->stride[1] );
}
else
@@ -1937,7 +1937,7 @@ void CLinuxRendererGL::UploadNV12Texture(int source)
// Load UV plane
LoadPlane( fields[FIELD_FULL][1], GL_LUMINANCE_ALPHA, buf.flipindex
, im->width >> im->cshift_x, im->height >> im->cshift_y
- , im->stride[1]/2, im->plane[1] );
+ , im->stride[1], im->plane[1] );
}
m_eventTexturesDone[source]->Set();
@@ -2382,18 +2382,18 @@ void CLinuxRendererGL::UploadYUV422PackedTexture(int source)
// Load YUYV fields
LoadPlane( fields[FIELD_TOP][0], GL_BGRA, buf.flipindex
, im->width / 2, im->height >> 1
- , im->stride[0] / 2, im->plane[0] );
+ , im->stride[0] * 2, im->plane[0] );
LoadPlane( fields[FIELD_BOT][0], GL_BGRA, buf.flipindex
, im->width / 2, im->height >> 1
- , im->stride[0] / 2, im->plane[0] + im->stride[0]) ;
+ , im->stride[0] * 2, im->plane[0] + im->stride[0]) ;
}
else
{
// Load YUYV plane
LoadPlane( fields[FIELD_FULL][0], GL_BGRA, buf.flipindex
, im->width / 2, im->height
- , im->stride[0] / 4, im->plane[0] );
+ , im->stride[0], im->plane[0] );
}
m_eventTexturesDone[source]->Set();
@@ -2864,17 +2864,17 @@ void CLinuxRendererGL::UploadRGBTexture(int source)
{
LoadPlane( fields[FIELD_TOP][0] , GL_BGRA, buf.flipindex
, im->width, im->height >> 1
- , m_sourceWidth, m_rgbBuffer, &m_rgbPbo );
+ , m_sourceWidth*4, m_rgbBuffer, &m_rgbPbo );
LoadPlane( fields[FIELD_BOT][0], GL_BGRA, buf.flipindex
, im->width, im->height >> 1
- , m_sourceWidth, m_rgbBuffer + m_sourceWidth*m_sourceHeight*2, &m_rgbPbo );
+ , m_sourceWidth*4, m_rgbBuffer + m_sourceWidth*m_sourceHeight*2, &m_rgbPbo );
}
else
{
LoadPlane( fields[FIELD_FULL][0], GL_BGRA, buf.flipindex
, im->width, im->height
- , m_sourceWidth, m_rgbBuffer, &m_rgbPbo );
+ , m_sourceWidth*4, m_rgbBuffer, &m_rgbPbo );
}
//after using the pbo to upload, allocate a new buffer so we don't have to wait
@@ -328,27 +328,28 @@ void CLinuxRendererGLES::LoadPlane( YUVPLANE& plane, int type, unsigned flipinde
const GLvoid *pixelData = data;
char *pixelVector = NULL;
+ int bps = glFormatElementByteCount(type);
+
// OpenGL ES does not support strided texture input. Make a copy without stride
- if(stride != width)
+ if(stride != width * bps)
{
- pixelVector = (char *)malloc(width * height * width);
+ pixelVector = (char *)malloc(width * height * bps);
const char *src = (const char *)data;
char *dst = pixelVector;
for (int y = 0;y < height;++y)
{
- fast_memcpy(dst, src, width);
+ fast_memcpy(dst, src, width * bps);
src += stride;
- dst += width;
+ dst += width * bps;
}
pixelData = pixelVector;
- stride = width;
+ stride = width * bps;
}
glBindTexture(m_textureTarget, plane.id);
glTexSubImage2D(m_textureTarget, 0, 0, 0, width, height, type, GL_UNSIGNED_BYTE, pixelData);
- int bps = glFormatElementByteCount(type);
/* check if we need to load any border pixels */
if(height < plane.texheight)

0 comments on commit c7aad3e

Please sign in to comment.