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