Commit 5ba9bf7b authored by Martin Storsjö's avatar 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: default avatarMartin Storsjö <martin@martin.st>
parent 3d64617d
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment