[vlc-commits] opengl: Handle pixel pitch properly when repacking textures for upload

Martin Storsjö git at videolan.org
Tue Mar 19 09:08:47 CET 2013


vlc | branch: master | Martin Storsjö <martin at martin.st> | Thu Mar 14 11:40:26 2013 +0200| [5ba9bf7ba159a865bb3a4ab77cc1f4098feb7935] | committer: Martin Storsjö

opengl: Handle pixel pitch properly when repacking textures for upload

This makes repacking of textures with multiple bytes per pixel (RGBA)
work properly.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5ba9bf7ba159a865bb3a4ab77cc1f4098feb7935
---

 modules/video_output/opengl.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/modules/video_output/opengl.c b/modules/video_output/opengl.c
index ea514e8..763e909 100644
--- a/modules/video_output/opengl.c
+++ b/modules/video_output/opengl.c
@@ -710,15 +710,15 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
         if ( (picture->p[j].i_pitch / picture->p[j].i_pixel_pitch) != (unsigned int)
              ( picture->format.i_visible_width * vgl->chroma->p[j].w.num / vgl->chroma->p[j].w.den ) )
         {
-            uint8_t *new_plane = malloc( picture->format.i_visible_width * vgl->fmt.i_visible_height * vgl->chroma->p[j].w.num * vgl->chroma->p[j].h.num / (vgl->chroma->p[j].h.den * vgl->chroma->p[j].w.den ) );
+            uint8_t *new_plane = malloc( picture->format.i_visible_width * vgl->fmt.i_visible_height * vgl->chroma->p[j].w.num * vgl->chroma->p[j].h.num / (vgl->chroma->p[j].h.den * vgl->chroma->p[j].w.den ) * picture->p[j].i_pixel_pitch );
             uint8_t *destination = new_plane;
             const uint8_t *source = picture->p[j].p_pixels;
 
             for( unsigned height = 0; height < (vgl->fmt.i_visible_height * vgl->chroma->p[j].h.num / vgl->chroma->p[j].h.den) ; height++ )
             {
-                memcpy( destination, source, picture->format.i_visible_width * vgl->chroma->p[j].w.num / vgl->chroma->p[j].w.den );
-                source += picture->p[j].i_pitch / picture->p[j].i_pixel_pitch;
-                destination += picture->format.i_visible_width * vgl->chroma->p[j].w.num / vgl->chroma->p[j].w.den;
+                memcpy( destination, source, picture->format.i_visible_width * vgl->chroma->p[j].w.num / vgl->chroma->p[j].w.den * picture->p[j].i_pixel_pitch );
+                source += picture->p[j].i_pitch;
+                destination += picture->format.i_visible_width * vgl->chroma->p[j].w.num / vgl->chroma->p[j].w.den * picture->p[j].i_pixel_pitch;
             }
             glTexSubImage2D( vgl->tex_target, 0,
                              0, 0,



More information about the vlc-commits mailing list