summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEddie Goodall <eddie.goodall@googlemail.com>2010-01-21 00:06:48 +0000
committerEddie Goodall <eddie.goodall@googlemail.com>2010-01-21 00:06:48 +0000
commita9ab2429f5b734f832349f4c3d32a23faebd2343 (patch)
tree1ff06bc60229569a48d6aa04a81d999fcfcad0a6
parent64a1c261e9dbbe32372cd2d8970186e4b62a5d80 (diff)
downloadxine-lib-a9ab2429f5b734f832349f4c3d32a23faebd2343.tar.gz
xine-lib-a9ab2429f5b734f832349f4c3d32a23faebd2343.tar.bz2
Fix width and padding bugs in opengl fragprog renderer
There's a rendering bug when using the opengl fragment program if the width of the video is not a multiple of 16. U and V channels will have padding on each row because they always have pitches which are a multiple of 8, glTexSubImage2D will copy the padding data to the texture and the U & V channels will be skewed. The same also applies to the Y channel when width is not a multiple of 8. Fixed by passing pitch to glTexSubImage2D instead of width. The U & V channels also have to be outlined in grey on the texture and if there's padding then we need to add the line on the right to every frame before calling glTexSubImage. It also looks like the location of the V channel in the texture was off by one pixel in the call to glProgramEnvParameter4fARB. --HG-- extra : rebase_source : 1984e493f77e80081e55b7c3b816d3baea965e4e
-rw-r--r--src/video_out/video_out_opengl.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/video_out/video_out_opengl.c b/src/video_out/video_out_opengl.c
index 1904fe6af..648cd38c5 100644
--- a/src/video_out/video_out_opengl.c
+++ b/src/video_out/video_out_opengl.c
@@ -606,7 +606,7 @@ static int render_image_fp_yuv (opengl_driver_t *this, opengl_frame_t *frame) {
return 0;
}
- ret = render_help_image_tex (this, frame->width+3, frame->height + h2 + 3,
+ ret = render_help_image_tex (this, w2 + frame->vo_frame.pitches[2] + 3, frame->height + h2 + 3,
GL_LUMINANCE, GL_LUMINANCE);
if (! ret)
return 0;
@@ -628,16 +628,21 @@ static int render_image_fp_yuv (opengl_driver_t *this, opengl_frame_t *frame) {
this->glProgramEnvParameter4fARB (MYGL_FRAGMENT_PROGRAM_ARB, 0,
1.0 /this->tex_width,
(float)(frame->height+2)/this->tex_height,
- (float)(w2+1) /this->tex_width,
+ (float)(w2+2) /this->tex_width,
0);
}
+ if (w2 & 7)
+ for (i = 0; i < h2; i++) {
+ frame->vo_frame.base[1][i*frame->vo_frame.pitches[1]+w2] = 128;
+ frame->vo_frame.base[2][i*frame->vo_frame.pitches[2]+w2] = 128;
+ }
/* Load texture */
CHECKERR ("pre-texsubimage");
- glTexSubImage2D (GL_TEXTURE_2D, 0, 1, 0, frame->width, frame->height,
+ glTexSubImage2D (GL_TEXTURE_2D, 0, 1, 0, frame->vo_frame.pitches[0], frame->height,
GL_LUMINANCE, GL_UNSIGNED_BYTE, frame->vo_frame.base[0]);
- glTexSubImage2D (GL_TEXTURE_2D, 0, 1, frame->height+2, w2, h2,
+ glTexSubImage2D (GL_TEXTURE_2D, 0, 1, frame->height+2, frame->vo_frame.pitches[1], h2,
GL_LUMINANCE, GL_UNSIGNED_BYTE, frame->vo_frame.base[1]);
- glTexSubImage2D (GL_TEXTURE_2D, 0, w2+2, frame->height+2, w2, h2,
+ glTexSubImage2D (GL_TEXTURE_2D, 0, w2+2, frame->height+2, frame->vo_frame.pitches[2], h2,
GL_LUMINANCE, GL_UNSIGNED_BYTE, frame->vo_frame.base[2]);
CHECKERR ("texsubimage");
return 1;