Commit 98615b55 authored by Sam Lantinga's avatar Sam Lantinga

Fixed bug 1315 - Greenish video when video size smaller than texture

The incoming pixels are contiguous for the update rectangle.
parent b7323989
...@@ -569,15 +569,10 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, ...@@ -569,15 +569,10 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
rect->h, data->format, data->formattype, rect->h, data->format, data->formattype,
pixels); pixels);
if (data->yuv) { if (data->yuv) {
const void *top;
renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, (pitch / 2)); renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, (pitch / 2));
/* Skip to the top of the next texture */
top = (const void*)((const Uint8*)pixels + (texture->h-rect->y) * pitch - rect->x);
/* Skip to the correct offset into the next texture */ /* Skip to the correct offset into the next texture */
pixels = (const void*)((const Uint8*)top + (rect->y / 2) * pitch + rect->x / 2); pixels = (const void*)((const Uint8*)pixels + rect->h * pitch);
if (texture->format == SDL_PIXELFORMAT_YV12) { if (texture->format == SDL_PIXELFORMAT_YV12) {
renderdata->glBindTexture(data->type, data->vtexture); renderdata->glBindTexture(data->type, data->vtexture);
} else { } else {
...@@ -587,11 +582,8 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, ...@@ -587,11 +582,8 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
rect->w/2, rect->h/2, rect->w/2, rect->h/2,
data->format, data->formattype, pixels); data->format, data->formattype, pixels);
/* Skip to the top of the next texture */
top = (const void*)((const Uint8*)top + (texture->h * pitch)/4);
/* Skip to the correct offset into the next texture */ /* Skip to the correct offset into the next texture */
pixels = (const void*)((const Uint8*)top + (rect->y / 2) * pitch + rect->x / 2); pixels = (const void*)((const Uint8*)pixels + (rect->h * pitch)/4);
if (texture->format == SDL_PIXELFORMAT_YV12) { if (texture->format == SDL_PIXELFORMAT_YV12) {
renderdata->glBindTexture(data->type, data->utexture); renderdata->glBindTexture(data->type, data->utexture);
} else { } else {
......
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