Why I get greenish and purplish video?

Hi all

I get greenish and purplish video with SDL 1.3.

My code fragments are as follows:

bitmapTex = SDL_CreateTexture(renderer,
SDL_PIXELFORMAT_IYUV,
SDL_TEXTUREACCESS_STREAMING,
dst_w,
dst_h);

dst_pix_fmt = PIX_FMT_YUV420P;

SDL_UpdateTexture(bitmapTex,
NULL,
buffer,
dst_w * SDL_BYTESPERPIXEL(dst_pix_fmt));

SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, bitmapTex, NULL, NULL);
SDL_RenderPresent(renderer);

My buffer is in PIX_FMT_YUV420P. I use ffmpeg to decode.

Any help in this regard is very much appreciated.

Best regards
Unga

SDL_UpdateTexture(bitmapTex,
NULL,
buffer,
dst_w * SDL_BYTESPERPIXEL(dst_pix_fmt));

Is “PIX_FMT_YUV420P” a ffmpeg constant? I’m surprised it works with
SDL_BYTESPERPIXEL.

I get greenish and purplish video with SDL 1.3.
My buffer is in PIX_FMT_YUV420P. I use ffmpeg to decode.

If the video is correct, but miscolored, you probably have the Cb and Cr
channels backwards. I would guess that if you changed
SDL_PIXELFORMAT_IYUV to SDL_PIXELFORMAT_YV12 in your SDL_CreateTexture()
call, it’ll work correctly.

–ryan.

SDL_UpdateTexture(bitmapTex,
? ? ? ? ? ? ? ?
? ? ? ? NULL,
? ? ? ? ? ? ? ?
? ? ? ? buffer,
? ? ? ? ? ? ? ?
? ? ? ? dst_w *
SDL_BYTESPERPIXEL(dst_pix_fmt));

Is “PIX_FMT_YUV420P” a ffmpeg constant? I’m surprised it
works with SDL_BYTESPERPIXEL.

I get greenish and purplish video with SDL 1.3.
My buffer is in PIX_FMT_YUV420P. I use ffmpeg to
decode.

If the video is correct, but miscolored, you probably have
the Cb and Cr channels backwards. I would guess that if you
changed SDL_PIXELFORMAT_IYUV to SDL_PIXELFORMAT_YV12 in your
SDL_CreateTexture() call, it’ll work correctly.

–ryan.

Hi Ryan

It worked with corrections you suggested.

Best regards
Unga— On Wed, 8/17/11, Ryan C. Gordon wrote:

From: Ryan C. Gordon
Subject: Re: [SDL] Why I get greenish and purplish video?
To: “SDL Development List”
Date: Wednesday, August 17, 2011, 3:25 PM