[SDL 1.3] Greenish video when video size smaller than textur

Unga,

The third parameter to SDL_UpdateTexture is a pointer to the raw pixel data.

From the code I can only guess what data[0] is but I’m assuming its data from the video frame. If there is only 1366x582 pixels worth of data in the frame to update, the rest of the texture that needs to get updated will be garbage. Just a guess but seems to make sense.

I frequently have gotten green video when I used SDL_UpdateTexture using the wrong YUV formats. I don’t think green video is an uncommon thing to get if the pitch / planes and resolutions of your videos and texture don’t line up.

Could you perhaps set the size of your texture to be whatever you video size is and then use another texture / drawing functions to draw black rectangles above and below the video?

Mark J


From: mjohnson@baytekgames.com (mjohnson)
To: sdl at lists.libsdl.org
Sent: Thursday, October 6, 2011 8:24 PM
Subject: Re: [SDL] [SDL 1.3] Greenish video when video size smaller than textur

Unga,

The third parameter to SDL_UpdateTexture is a pointer to the raw pixel data.

From the code I can only guess what data[0] is but I’m assuming its data from the video frame. If there is only 1366x582 pixels worth of data in the frame to update, the rest of the texture that needs to get updated will be garbage. Just a guess but seems to make sense.

Hi Mark

Thanks for the reply.

I only copy the relevant no garbage portion to the renderer for display:
SDL_RenderCopy(renderer, bitmapTex, &srcrect, &dstrect);

The renderer is already set to black at time of its creation.

I get fine black borders on top and bottom of the video. Its only the video is green.

Without any change to the code if I run a video fitting the display size, its plays fine without any green.

I’m beginning to feel SDL_UpdateTexture(), SDL_RenderCopy or SDL_RenderPresent is buggy.

Any ideas?

Regards
Unga

I’m beginning to feel SDL_UpdateTexture(), SDL_RenderCopy or SDL_RenderPresent is buggy.

Can somebody please check GL_UpdateTexture() of src/render/opengl/SDL_render_gl.c?

Looks not right when a rect (SDL_Rect) involves.

Many thanks in advance.

Regards
Unga

Cc:

I’m beginning to feel SDL_UpdateTexture(), SDL_RenderCopy or
SDL_RenderPresent is buggy.

Hi all

I have attached a sample video player to test this greenish issue.

Appreciate very much if the SDL community could help to solve this issue. I had a look, but I’m not a openGL guy.

Try a 1080p or 720p video. It should play with correct colours.

After that, try a different aspect video such as Sintel (http://www.sintel.org/download).

Best regards
Unga
-------------- next part --------------
A non-text attachment was scrubbed…
Name: tutorial03a.c
Type: application/octet-stream
Size: 14801 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20111018/a01dccfb/attachment.obj

----- Original Message -----
From: Unga <@Unga>
To: Unga <@Unga>; SDL Development List
Sent: Saturday, October 8, 2011 9:44 AM
Subject: Re: [SDL] [SDL 1.3] Greenish video when video size smaller than textur

Cc:

> Cc: textur > >> >> I'm beginning to feel SDL_UpdateTexture(), SDL_RenderCopy or > SDL_RenderPresent is buggy. >> >

Hi all

I have attached a sample video player to test this greenish issue.

Appreciate very much if the SDL community could help to solve this issue. I had
a look, but I’m not a openGL guy.

Try a 1080p or 720p video. It should play with correct colours.

After that, try a different aspect video such as Sintel
(http://www.sintel.org/download).

Best regards
Unga

Submitted as a bug:? http://bugzilla.libsdl.org/show_bug.cgi?id=1315

Best regards
Unga

----- Original Message -----
From: Unga <@Unga>
To: “sdl at lists.libsdl.org
Sent: Tuesday, October 18, 2011 7:16 AM
Subject: Re: [SDL] [SDL 1.3] Greenish video when video size smaller than textur
----- Original Message -----

From: Unga <@Unga>
To: Unga <@Unga>; SDL Development List
Sent: Saturday, October 8, 2011 9:44 AM
Subject: Re: [SDL] [SDL 1.3] Greenish video when video size smaller than

Usually when there is discolouration, it’s because the pixel format is
wrong. It may be that it’s wrong when it’s full-size, but less evident, so
when you scale it down, it looks really greenish.

Also, I noticed for SDL_CreateWindow, you’re passing SDL_OPENGL, but that’s
only if you are making an OpenGL context, afaik, and you are using the SDL
Renderer back-end (so the flag is probably unnecessary and ignored).

You’re also picking your texture to be SDL_PIXELFORMAT_YV12 - have you tried
using SDL_PIXELFORMAT_IYUV ?
MPEG videos are typically YCbCr ( see:
http://en.wikipedia.org/wiki/MPEG-2#Video ,
http://en.wikipedia.org/wiki/H.262 ), which is closely related, but not
exactly YUV, so you might be finding your issue there, and it may be that
SDL needs to implement a YCbCr pixel format, I don’t know.

Hopefully, that points you in the right direction. Bottom line, though, is
that I don’t think this is an SDL bug.
-AlexOn Tue, Oct 18, 2011 at 10:52 PM, Unga wrote:

----- Original Message -----

From: Unga
To: “sdl at lists.libsdl.org
Cc:
Sent: Tuesday, October 18, 2011 7:16 AM
Subject: Re: [SDL] [SDL 1.3] Greenish video when video size smaller than
textur

----- Original Message -----

From: Unga
To: Unga ; SDL Development List

Cc:
Sent: Saturday, October 8, 2011 9:44 AM
Subject: Re: [SDL] [SDL 1.3] Greenish video when video size smaller
than
textur

I’m beginning to feel SDL_UpdateTexture(), SDL_RenderCopy or
SDL_RenderPresent is buggy.

Hi all

I have attached a sample video player to test this greenish issue.

Appreciate very much if the SDL community could help to solve this issue.
I had
a look, but I’m not a openGL guy.

Try a 1080p or 720p video. It should play with correct colours.

After that, try a different aspect video such as Sintel
(http://www.sintel.org/download).

Best regards
Unga

Submitted as a bug: http://bugzilla.libsdl.org/show_bug.cgi?id=1315

Best regards
Unga


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Usually when there is?discolouration, it’s because the pixel format is wrong. ?It may be that it’s wrong when it’s full-size, but less evident, so when you scale it down, it looks really greenish.

Also, I noticed for SDL_CreateWindow, you’re passing SDL_OPENGL, but that’s only if you are making an OpenGL context, afaik, and you are using the SDL Renderer back-end (so the flag is probably unnecessary and ignored).

You’re also picking your texture to be SDL_PIXELFORMAT_YV12 - have you tried using?SDL_PIXELFORMAT_IYUV ?

Yes, I have. Does not make a difference:

? if ((bitmapTex = SDL_CreateTexture(renderer,
??? SDL_PIXELFORMAT_IYUV,
??? SDL_TEXTUREACCESS_STREAMING,
??? mode.w,
??? mode.h)) == NULL)
??? {
??? fprintf(stderr, “SDL_CreateTexture FAILED: %s\n”, SDL_GetError());
??? return -1;
??? }

??? pict.data[0] = pFrameYUV420P->data[0];
??? pict.data[1] = pFrameYUV420P->data[1];
??? pict.data[2] = pFrameYUV420P->data[2];

??? pict.linesize[0] = pFrameYUV420P->linesize[0];
??? pict.linesize[1] = pFrameYUV420P->linesize[1];
??? pict.linesize[2] = pFrameYUV420P->linesize[2];

MPEG videos are typically YCbCr ( see:?http://en.wikipedia.org/wiki/MPEG-2#Video?,?http://en.wikipedia.org/wiki/H.262?), which is closely related, but not exactly YUV, so you might be finding your issue there, and it may be that SDL needs to implement a YCbCr pixel format, I don’t know.

Hopefully, that points you in the right direction. ?Bottom line, though, is that I don’t think this is an SDL bug.

But no issues with MPEG/H.264/webm where the the rect size is as same as? the texture (bitmapTex), issue comes when there are different.

If you are good in openGL, could you please check GL_UpdateTexture() of src/render/opengl/SDL_render_gl.c?

I don’t understand the logic there, the pitch is divided by 2 instead of 3, etc.

Regards
UngaFrom: alex.barry@gmail.com (Alex Barry)

To: Unga <@Unga>; SDL Development List
Sent: Wednesday, October 19, 2011 1:20 PM
Subject: Re: [SDL] [SDL 1.3] Greenish video when video size smaller than textur

I’m not a pixel format guy, so I don’t know if division by 2 is correct or
not, but you might find this interesting:
http://lurkertech.com/lg/ogl.video.html

-AlexOn Wed, Oct 19, 2011 at 10:40 AM, Unga wrote:

From: Alex Barry <@Alex_Barry>

To: Unga ; SDL Development List
Sent: Wednesday, October 19, 2011 1:20 PM
Subject: Re: [SDL] [SDL 1.3] Greenish video when video size smaller than
textur

Usually when there is discolouration, it’s because the pixel format is
wrong. It may be that it’s wrong when it’s full-size, but less evident, so
when you scale it down, it looks really greenish.

Also, I noticed for SDL_CreateWindow, you’re passing SDL_OPENGL, but
that’s only if you are making an OpenGL context, afaik, and you are using
the SDL Renderer back-end (so the flag is probably unnecessary and ignored).

You’re also picking your texture to be SDL_PIXELFORMAT_YV12 - have you
tried using SDL_PIXELFORMAT_IYUV ?

Yes, I have. Does not make a difference:

if ((bitmapTex = SDL_CreateTexture(renderer,
SDL_PIXELFORMAT_IYUV,
SDL_TEXTUREACCESS_STREAMING,
mode.w,
mode.h)) == NULL)
{
fprintf(stderr, “SDL_CreateTexture FAILED: %s\n”, SDL_GetError());
return -1;
}

pict.data[0] = pFrameYUV420P->data[0];
pict.data[1] = pFrameYUV420P->data[1];
pict.data[2] = pFrameYUV420P->data[2];

pict.linesize[0] = pFrameYUV420P->linesize[0];
pict.linesize[1] = pFrameYUV420P->linesize[1];
pict.linesize[2] = pFrameYUV420P->linesize[2];

MPEG videos are typically YCbCr ( see:
http://en.wikipedia.org/wiki/MPEG-2#Video ,
http://en.wikipedia.org/wiki/H.262 ), which is closely related, but not
exactly YUV, so you might be finding your issue there, and it may be that
SDL needs to implement a YCbCr pixel format, I don’t know.

Hopefully, that points you in the right direction. Bottom line, though,
is that I don’t think this is an SDL bug.

But no issues with MPEG/H.264/webm where the the rect size is as same as
the texture (bitmapTex), issue comes when there are different.

If you are good in openGL, could you please check GL_UpdateTexture() of
src/render/opengl/SDL_render_gl.c?

I don’t understand the logic there, the pitch is divided by 2 instead of 3,
etc.

Regards
Unga


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org