[vlc-commits] opengl: implement manual unpacking for OpenGL ES

Ilkka Ollakka git at videolan.org
Fri Feb 8 22:45:24 CET 2013


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Fri Feb  8 22:29:39 2013 +0100| [3422455f7e844bfc301ade6b5371bc29e62ecdd1] | committer: Felix Paul Kühne

opengl: implement manual unpacking for OpenGL ES

Signed-off-by: Felix Paul Kühne <fkuehne at videolan.org>

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

 modules/video_output/opengl.c |   33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/modules/video_output/opengl.c b/modules/video_output/opengl.c
index 33a5a43..9079e5b 100644
--- a/modules/video_output/opengl.c
+++ b/modules/video_output/opengl.c
@@ -659,11 +659,34 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
         }
         glBindTexture(vgl->tex_target, vgl->texture[0][j]);
         glPixelStorei(GL_UNPACK_ROW_LENGTH, picture->p[j].i_pitch / picture->p[j].i_pixel_pitch);
-        glTexSubImage2D(vgl->tex_target, 0,
-                        0, 0,
-                        vgl->fmt.i_width  * vgl->chroma->p[j].w.num / vgl->chroma->p[j].w.den,
-                        vgl->fmt.i_height * vgl->chroma->p[j].h.num / vgl->chroma->p[j].h.den,
-                        vgl->tex_format, vgl->tex_type, picture->p[j].p_pixels);
+
+#if USE_OPENGL_ES
+        if ( (picture->p[j].i_pitch / picture->p[j].i_pixel_pitch) != (vgl->fmt.i_width  * vgl->chroma->p[j].w.num / vgl->chroma->p[j].w.den) ) {
+            uint8_t *new_plane = malloc(picture->p[j].i_pitch*picture->p[j].i_pixel_pitch *vgl->fmt.i_height * vgl->chroma->p[j].h.num / vgl->chroma->p[j].h.den);
+            uint8_t *destination = new_plane;
+            const uint8_t *source = picture->p[j].p_pixels;
+            for( unsigned height = 0; height < vgl->fmt.i_height * vgl->chroma->p[j].h.num / vgl->chroma->p[j].h.den; height++ )
+            {
+                memcpy( destination, source, vgl->fmt.i_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 += vgl->fmt.i_width  * vgl->chroma->p[j].w.num / vgl->chroma->p[j].w.den;
+            }
+            glTexSubImage2D( vgl->tex_target, 0,
+                             0, 0,
+                             vgl->fmt.i_width  * vgl->chroma->p[j].w.num / vgl->chroma->p[j].w.den,
+                             vgl->fmt.i_height * vgl->chroma->p[j].h.num / vgl->chroma->p[j].h.den,
+                             vgl->tex_format, vgl->tex_type, new_plane );
+            free( new_plane );
+        } else {
+#endif
+            glTexSubImage2D(vgl->tex_target, 0,
+                            0, 0,
+                            vgl->fmt.i_width  * vgl->chroma->p[j].w.num / vgl->chroma->p[j].w.den,
+                            vgl->fmt.i_height * vgl->chroma->p[j].h.num / vgl->chroma->p[j].h.den,
+                            vgl->tex_format, vgl->tex_type, picture->p[j].p_pixels);
+#if USE_OPENGL_ES
+        }
+#endif
     }
 
     int         last_count = vgl->region_count;



More information about the vlc-commits mailing list