[vlc-devel] [PATCH 1/3] opengl: Handle pixel pitch properly when repacking textures for upload
Martin Storsjö
martin at martin.st
Thu Mar 14 11:25:41 CET 2013
This makes repacking of textures with multiple bytes per pixel (RGBA)
work properly.
---
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 2dc1e9c..c1b8c05 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,
--
1.7.9.5
More information about the vlc-devel
mailing list