[vlc-devel] [PATCH] opengl: use the visible dimensions when uploading a picture to a texture.

Felix Abecassis felix.abecassis at gmail.com
Tue Dec 31 15:40:48 CET 2013


Removes a green line bug at the bottom of some videos.
---
 modules/video_output/opengl.c | 49 ++++++++++++++-----------------------------
 1 file changed, 16 insertions(+), 33 deletions(-)

diff --git a/modules/video_output/opengl.c b/modules/video_output/opengl.c
index 030183d..a24d0ca 100644
--- a/modules/video_output/opengl.c
+++ b/modules/video_output/opengl.c
@@ -565,8 +565,8 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
 
     /* Texture size */
     for (unsigned j = 0; j < vgl->chroma->plane_count; j++) {
-        int w = vgl->fmt.i_width  * vgl->chroma->p[j].w.num / vgl->chroma->p[j].w.den;
-        int h = vgl->fmt.i_height * vgl->chroma->p[j].h.num / vgl->chroma->p[j].h.den;
+        int w = vgl->fmt.i_visible_width  * vgl->chroma->p[j].w.num / vgl->chroma->p[j].w.den;
+        int h = vgl->fmt.i_visible_height * vgl->chroma->p[j].h.num / vgl->chroma->p[j].h.den;
         if (vgl->supports_npot) {
             vgl->tex_width[j]  = w;
             vgl->tex_height[j] = h;
@@ -770,24 +770,20 @@ error:
 
 #define ALIGN(x, y) (((x) + ((y) - 1)) & ~((y) - 1))
 static void Upload(vout_display_opengl_t *vgl, int in_width, int in_height,
-                   int in_full_width, int in_full_height,
                    int w_num, int w_den, int h_num, int h_den,
-                   int pitch, int pixel_pitch,
-                   int full_upload, const uint8_t *pixels,
+                   int pitch, int pixel_pitch, const uint8_t *pixels,
                    int tex_target, int tex_format, int tex_type)
 {
     int width       =       in_width * w_num / w_den;
-    int full_width  =  in_full_width * w_num / w_den;
     int height      =      in_height * h_num / h_den;
-    int full_height = in_full_height * h_num / h_den;
     // This unpack alignment is the default, but setting it just in case.
     glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
 #ifndef GL_UNPACK_ROW_LENGTH
-    int dst_width = full_upload ? full_width : width;
+    int dst_width = width;
     int dst_pitch = ALIGN(dst_width * pixel_pitch, 4);
     if ( pitch != dst_pitch )
     {
-        int buf_size = dst_pitch * full_height * pixel_pitch;
+        int buf_size = dst_pitch * height * pixel_pitch;
         const uint8_t *source = pixels;
         uint8_t *destination;
         if( !vgl->texture_temp_buf || vgl->texture_temp_buf_size < buf_size )
@@ -804,15 +800,9 @@ static void Upload(vout_display_opengl_t *vgl, int in_width, int in_height,
             source += pitch;
             destination += dst_pitch;
         }
-        if (full_upload)
-            glTexImage2D( tex_target, 0, tex_format,
-                          full_width, full_height,
-                          0, tex_format, tex_type, vgl->texture_temp_buf );
-        else
-            glTexSubImage2D( tex_target, 0,
-                             0, 0,
-                             width, height,
-                             tex_format, tex_type, vgl->texture_temp_buf );
+        glTexImage2D( tex_target, 0, tex_format,
+                      width, height,
+                      0, tex_format, tex_type, vgl->texture_temp_buf );
     } else {
 #else
     (void) width;
@@ -821,15 +811,9 @@ static void Upload(vout_display_opengl_t *vgl, int in_width, int in_height,
     {
         glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / pixel_pitch);
 #endif
-        if (full_upload)
-            glTexImage2D(tex_target, 0, tex_format,
-                         full_width, full_height,
-                         0, tex_format, tex_type, pixels);
-        else
-            glTexSubImage2D(tex_target, 0,
-                            0, 0,
-                            width, height,
-                            tex_format, tex_type, pixels);
+        glTexImage2D(tex_target, 0, tex_format,
+                     width, height,
+                     0, tex_format, tex_type, pixels);
     }
 }
 
@@ -848,9 +832,8 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
         glBindTexture(vgl->tex_target, vgl->texture[0][j]);
 
         Upload(vgl, picture->format.i_visible_width, vgl->fmt.i_visible_height,
-               vgl->fmt.i_width, vgl->fmt.i_height,
                vgl->chroma->p[j].w.num, vgl->chroma->p[j].w.den, vgl->chroma->p[j].h.num, vgl->chroma->p[j].h.den,
-               picture->p[j].i_pitch, picture->p[j].i_pixel_pitch, 0, picture->p[j].p_pixels, vgl->tex_target, vgl->tex_format, vgl->tex_type);
+               picture->p[j].i_pitch, picture->p[j].i_pixel_pitch, picture->p[j].p_pixels, vgl->tex_target, vgl->tex_format, vgl->tex_type);
     }
 
     int         last_count = vgl->region_count;
@@ -912,8 +895,8 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
                                       r->fmt.i_x_offset * r->p_picture->p->i_pixel_pitch;
             if (glr->texture) {
                 glBindTexture(GL_TEXTURE_2D, glr->texture);
-                Upload(vgl, r->fmt.i_visible_width, r->fmt.i_visible_height, glr->width, glr->height, 1, 1, 1, 1,
-                       r->p_picture->p->i_pitch, r->p_picture->p->i_pixel_pitch, 0,
+                Upload(vgl, r->fmt.i_visible_width, r->fmt.i_visible_height, 1, 1, 1, 1,
+                       r->p_picture->p->i_pitch, r->p_picture->p->i_pixel_pitch,
                        &r->p_picture->p->p_pixels[pixels_offset], GL_TEXTURE_2D, glr->format, glr->type);
             } else {
                 glGenTextures(1, &glr->texture);
@@ -926,8 +909,8 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
                 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
                 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-                Upload(vgl, r->fmt.i_visible_width, r->fmt.i_visible_height, glr->width, glr->height, 1, 1, 1, 1,
-                       r->p_picture->p->i_pitch, r->p_picture->p->i_pixel_pitch, 1,
+                Upload(vgl, r->fmt.i_visible_width, r->fmt.i_visible_height, 1, 1, 1, 1,
+                       r->p_picture->p->i_pitch, r->p_picture->p->i_pixel_pitch,
                        &r->p_picture->p->p_pixels[pixels_offset], GL_TEXTURE_2D, glr->format, glr->type);
             }
         }
-- 
1.8.3.2




More information about the vlc-devel mailing list