summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorsten Jager <t.jager@gmx.de>2012-10-07 21:47:03 +0300
committerTorsten Jager <t.jager@gmx.de>2012-10-07 21:47:03 +0300
commitdf87ae129b29a82f52641bf81003dd831bb2a791 (patch)
tree68441ff2cbe97fbbb0726f09113b34717a692559
parent6d3333041cdbeb59443d0eae2c02469a3556d229 (diff)
downloadxine-lib-df87ae129b29a82f52641bf81003dd831bb2a791.tar.gz
xine-lib-df87ae129b29a82f52641bf81003dd831bb2a791.tar.bz2
vo_opengl2: fixed distortion and segfaults for non-16 video width
-rw-r--r--src/video_out/video_out_opengl2.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/video_out/video_out_opengl2.c b/src/video_out/video_out_opengl2.c
index 23dabc726..e2fdd1f7c 100644
--- a/src/video_out/video_out_opengl2.c
+++ b/src/video_out/video_out_opengl2.c
@@ -416,7 +416,8 @@ static int opengl2_check_textures_size( opengl2_driver_t *this_gen, int w, int h
{
opengl2_driver_t *this = this_gen;
opengl2_yuvtex_t *ytex = &this->yuvtex;
-
+
+ w = (w + 15) & ~15;
if ( (w == ytex->width) && (h == ytex->height) )
return 1;
@@ -717,14 +718,14 @@ static void opengl2_update_frame_format( vo_driver_t *this_gen, vo_frame_t *fram
av_freep (&frame->vo_frame.base[2]);
if (format == XINE_IMGFMT_YV12) {
- frame->vo_frame.pitches[0] = 8*((width + 7) / 8);
- frame->vo_frame.pitches[1] = 8*((width + 15) / 16);
- frame->vo_frame.pitches[2] = 8*((width + 15) / 16);
+ frame->vo_frame.pitches[0] = (width + 15) & ~15;
+ frame->vo_frame.pitches[1] = ((width + 15) & ~15) >> 1;
+ frame->vo_frame.pitches[2] = ((width + 15) & ~15) >> 1;
frame->vo_frame.base[0] = av_mallocz (frame->vo_frame.pitches[0] * height);
frame->vo_frame.base[1] = av_mallocz (frame->vo_frame.pitches[1] * ((height+1)/2));
frame->vo_frame.base[2] = av_mallocz (frame->vo_frame.pitches[2] * ((height+1)/2));
} else if (format == XINE_IMGFMT_YUY2){
- frame->vo_frame.pitches[0] = 8*((width + 3) / 4);
+ frame->vo_frame.pitches[0] = ((width + 15) & ~15) << 1;
frame->vo_frame.base[0] = av_mallocz (frame->vo_frame.pitches[0] * height);
}
@@ -1107,21 +1108,21 @@ static void opengl2_draw( opengl2_driver_t *that, opengl2_frame_t *frame )
glBindTexture( GL_TEXTURE_RECTANGLE_ARB, that->yuvtex.y );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, that->videoPBO );
void *mem = glMapBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY );
- memcpy( mem, frame->vo_frame.base[0], frame->vo_frame.pitches[0] * frame->height );
+ xine_fast_memcpy (mem, frame->vo_frame.base[0], frame->vo_frame.pitches[0] * frame->height);
glUnmapBuffer( GL_PIXEL_UNPACK_BUFFER_ARB );
- glTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, frame->width, frame->height, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0 );
+ glTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, frame->vo_frame.pitches[0], frame->height, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0 );
glActiveTexture( GL_TEXTURE1 );
glBindTexture( GL_TEXTURE_RECTANGLE_ARB, that->yuvtex.u );
mem = glMapBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY );
- memcpy( mem, frame->vo_frame.base[1], frame->vo_frame.pitches[1] * ((frame->height+1)/2) );
+ xine_fast_memcpy (mem, frame->vo_frame.base[1], frame->vo_frame.pitches[1] * frame->height / 2);
glUnmapBuffer( GL_PIXEL_UNPACK_BUFFER_ARB );
- glTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, frame->width/2, frame->height/2, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0 );
+ glTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, frame->vo_frame.pitches[1], frame->height/2, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0 );
glActiveTexture( GL_TEXTURE2 );
glBindTexture( GL_TEXTURE_RECTANGLE_ARB, that->yuvtex.v );
mem = glMapBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY );
- memcpy( mem, frame->vo_frame.base[2], frame->vo_frame.pitches[2] * ((frame->height+1)/2) );
+ xine_fast_memcpy (mem, frame->vo_frame.base[2], frame->vo_frame.pitches[2] * frame->height / 2);
glUnmapBuffer( GL_PIXEL_UNPACK_BUFFER_ARB );
- glTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, frame->width/2, frame->height/2, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0 );
+ glTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, frame->vo_frame.pitches[2], frame->height/2, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0 );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, 0 );
glUseProgram( that->yuv420_program.program );
@@ -1135,9 +1136,9 @@ static void opengl2_draw( opengl2_driver_t *that, opengl2_frame_t *frame )
glBindTexture( GL_TEXTURE_RECTANGLE_ARB, that->yuvtex.yuv );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, that->videoPBO );
void *mem = glMapBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY );
- memcpy( mem, frame->vo_frame.base[0], frame->vo_frame.pitches[0] * frame->height );
+ xine_fast_memcpy (mem, frame->vo_frame.base[0], frame->vo_frame.pitches[0] * frame->height);
glUnmapBuffer( GL_PIXEL_UNPACK_BUFFER_ARB );
- glTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, frame->width, frame->height, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 0 );
+ glTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, frame->vo_frame.pitches[0] / 2, frame->height, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 0 );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, 0 );
glUseProgram( that->yuv422_program.program );