Yuv to rgb

hello there,

does anybody know if and how one can make yuv to rgb colorspace
transformation by using
the local graphic card?
i was told that it’s possible with yuv-overlay. since i’ve never worked with
sdl before the short
description @ http://sdldoc.csn.ul.ie/sdlcreateyuvoverlay.php doesn’t mean a
lot to me.
i’m glad to have further hints, suggestions, tutorials to get me further.

cheers,
kien hung_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail

Typically, you create overlay (read: a bitmap in YUV format) with a given
size and a specific YUV subtype (planar, packed, 420, 421 …) that usually
is dictated by the source of data (most webcams spit out planar 420).

overlay = SDL_CreateYUVOverlay( video_width, video_height,
SDL_IYUV_OVERLAY, screen );

Everytime you want to display a new image, you must lock the overlay and
fill the data in the overlay from your source.

SDL_LockYUVOverlay( overlay );
memcpy( overlay->pixels[0], Yplane, video_width*video_height );
memcpy( overlay->pixels[1], Uplane, video_width*video_height/4 );
memcpy( overlay->pixels[2], Vplane, video_width*video_height/4 );

Finally you unlock and display the overlay (or part of it depending on given
rectangle):

SDL_UnlockYUVOverlay( overlay );
SDL_DisplayYUVOverlay( overlay, &rect );

If you want I can send you codesnippets for playing mpeg frames (via
libmpeg3 on Linux) or capturing from v4l device.
Regards,
Jacek
BTW Of course you know, the conversion really happens in the video card and
therefore you cannot access the resulting RGB values, don’t you? So it isn’t
srictly speaking ‘transformation’, rather ‘displaying’. In other case I have
also snippets for software YUV->RGB conversion (and the SDL source probably
contains better ones if you know where to look for).On Wed, Nov 20, 2002 at 01:27:54PM +0100, kien hung ong wrote:

hello there,

does anybody know if and how one can make yuv to rgb colorspace
transformation by using
the local graphic card?
i was told that it’s possible with yuv-overlay. since i’ve never worked
with sdl before the short
description @ http://sdldoc.csn.ul.ie/sdlcreateyuvoverlay.php doesn’t mean
a lot to me.
i’m glad to have further hints, suggestions, tutorials to get me further.


±------------------------------------+
|from: J.C.Wojdel |
| J.C.Wojdel at cs.tudelft.nl |
±------------------------------------+

Hello,

— Jacek Wojdel wrote:

[snip]

If you want I can send you codesnippets for playing mpeg frames (via
libmpeg3 on Linux) or capturing from v4l device.
Regards,
Jacek

I’m not the original poster of the question, but I’d be very
interested in seeing the v4l code. I’ve had a TV tuner for a while now
and it works fine with xawtv but I’ve been dying to write some of my
own code for it :slight_smile:

Thanks!=====

Roger Ostrander, TraderMissions maintainer
http://tradermissions.sf.net


Do you Yahoo!?
Yahoo! Mail Plus ? Powerful. Affordable. Sign up now.

Yes send the code snippets. Especially the frame playback.
Thank you,
RobertOn Thu, 2002-11-21 at 08:28, Jacek Wojdel wrote:

On Wed, Nov 20, 2002 at 01:27:54PM +0100, kien hung ong wrote:

hello there,

does anybody know if and how one can make yuv to rgb colorspace
transformation by using
the local graphic card?
i was told that it’s possible with yuv-overlay. since i’ve never worked
with sdl before the short
description @ http://sdldoc.csn.ul.ie/sdlcreateyuvoverlay.php doesn’t mean
a lot to me.
i’m glad to have further hints, suggestions, tutorials to get me further.

Typically, you create overlay (read: a bitmap in YUV format) with a given
size and a specific YUV subtype (planar, packed, 420, 421 …) that usually
is dictated by the source of data (most webcams spit out planar 420).

overlay = SDL_CreateYUVOverlay( video_width, video_height,
SDL_IYUV_OVERLAY, screen );

Everytime you want to display a new image, you must lock the overlay and
fill the data in the overlay from your source.

SDL_LockYUVOverlay( overlay );
memcpy( overlay->pixels[0], Yplane, video_width*video_height );
memcpy( overlay->pixels[1], Uplane, video_width*video_height/4 );
memcpy( overlay->pixels[2], Vplane, video_width*video_height/4 );

Finally you unlock and display the overlay (or part of it depending on given
rectangle):

SDL_UnlockYUVOverlay( overlay );
SDL_DisplayYUVOverlay( overlay, &rect );

If you want I can send you codesnippets for playing mpeg frames (via
libmpeg3 on Linux) or capturing from v4l device.
Regards,
Jacek
BTW Of course you know, the conversion really happens in the video card and
therefore you cannot access the resulting RGB values, don’t you? So it isn’t
srictly speaking ‘transformation’, rather ‘displaying’. In other case I have
also snippets for software YUV->RGB conversion (and the SDL source probably
contains better ones if you know where to look for).

±------------------------------------+
|from: J.C.Wojdel |
| J.C.Wojdel at cs.tudelft.nl |
±------------------------------------+


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

BTW Of course you know, the conversion really happens in the video card and
therefore you cannot access the resulting RGB values, don’t you? So it
isn’t
srictly speaking ‘transformation’, rather ‘displaying’. In other case I
have
also snippets for software YUV->RGB conversion (and the SDL source probably
contains better ones if you know where to look for).

±------------------------------------+
|from: J.C.Wojdel |
| J.C.Wojdel at cs.tudelft.nl |
±------------------------------------+

how about display the image in rgb and capture (part of) the image into
memory?
would that be possible? are there functions to do that?

kien hung_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*
http://join.msn.com/?page=features/virus

No way. If you yse an HW YUV overlay, it gets displayed directly through
your card’s ramdac. There is no trace of it in the display memory (on X the
video memory is usually filled with nice blue color, which you can clearly
see when taking snapshot of the application). There are some cards that
allow for using YUV in textures in 3D. That means, I guess, that there is a
HW circuit that does the conversion when rendering (I don’t think it’s
feasible to implement this feature as overlay). I haven’t seen any (semi)
official OpenGL extension to use that so I guess it remains a D3D only thing.
Due to the apparent interest for my code I’ll put it up on the web RSN.
Greets,
JacekOn Fri, Nov 22, 2002 at 12:27:37PM +0100, kien hung ong wrote:

how about display the image in rgb and capture (part of) the image into
memory?
would that be possible? are there functions to do that?


±------------------------------------+
|from: J.C.Wojdel |
| J.C.Wojdel at cs.tudelft.nl |
±------------------------------------+

So here it is:

http://www.kbs.twi.tudelft.nl/People/Staff/J.C.Wojdel/SDL_overlay/sdl_yuv_examples.tar.gz

Two C files, one Makefile (remember to edit the CFLAGS and LDFLAGS
appropriately to your setup). They’re simple (I hope), probably almost
bug-free (my hope here is rather faint) and they surely compile on my
machine.
Get it, compile it, read it and ask anything you want to know more (not that
I’ll be able to answer all the questions though).
Regards,
JacekOn Fri, Nov 22, 2002 at 12:57:34PM +0100, Jacek Wojdel wrote:

Due to the apparent interest for my code I’ll put it up on the web RSN.


±------------------------------------+
|from: J.C.Wojdel |
| J.C.Wojdel at cs.tudelft.nl |
±------------------------------------+

Try mpeg4ip (www.mpeg4ip.net). We have a live capture and
encoding to mpeg4. We use SDL to display the raw video.

Bill May

Roger Ostrander wrote:> Hello,

— Jacek Wojdel wrote:

[snip]

If you want I can send you codesnippets for playing mpeg frames (via
libmpeg3 on Linux) or capturing from v4l device.
Regards,
Jacek

I’m not the original poster of the question, but I’d be very
interested in seeing the v4l code. I’ve had a TV tuner for a while now
and it works fine with xawtv but I’ve been dying to write some of my
own code for it :slight_smile:

Thanks!

=====

Roger Ostrander, TraderMissions maintainer
http://tradermissions.sf.net


Do you Yahoo!?
Yahoo! Mail Plus ? Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com