Yuv

video cards. (just about them all) have YUVx.x supported in hardware and
in hardware converts to RGB before displaying it to the screen. Is this
feature supported in the x video drivers? Is it only in the 4.x tree?
Or is it in all the trees 3.x(?). If it is, will support for this come
to SLD? If not where should I look to read up on how to access it.
Would I just write directly to the xlib?
Also is there any of the macrovision code checks in the drivers?

-Benjamin Meyer

Question. I took a look at the YUV overlay struct. From what it looks
like it has a RGB pixles inside it? I am given three arrays of data.
They jsut happen to be Y U and V Combined they made an image. :slight_smile: I am
looking to do somthing simpilar to the following code. Any suggestions.

YUVimage yuv
yuv.y = Y;
yuv.u = U;
yuv.v = V;
yuc.show();

-Benjamin

P.S. Anyone working on the documention for this?

Question. I took a look at the YUV overlay struct. From what it looks
like it has a RGB pixles inside it? I am given three arrays of data.
They jsut happen to be Y U and V Combined they made an image. :slight_smile: I am
looking to do somthing simpilar to the following code. Any suggestions.

The overlay struct has generic pixels in it which are defined by the
particular format.

YUVimage yuv
yuv.y = Y;
yuv.u = U;
yuv.v = V;
yuc.show();

Here’s a good example:

struct YUVimage {
SDL_Overlay *overlay;
unsigned char *y;
unsigned char *u;
unsigned char *v;
} yuv;

SDL_Surface *screen;

/* Create a YV12 image (Y + V + U) */
yuv.overlay = SDL_CreateYUVOverlay(w, h, SDL_YV12_OVERLAY, screen);
if ( ! yuv.overlay ) {
    /* error */;
}

for ( ; ; ) {
    if ( SDL_LockYUVOverlay(yuv.overlay) < 0 ) {
        /* error */;
    }
    yuv.y = (unsigned char *)yuv.overlay->pixels;
    yuv.u = (unsigned char *)yuv.overlay->pixels + (w*h) + (w*h)/4;
    yuv.v = (unsigned char *)yuv.overlay->pixels + (w*h);

... decode into yuv.{y,u,v} ...

    SDL_UnlockYUVOverlay(yuv.overlay);

    SDL_DisplayYUVOverlay(yuv.overlay, &dstrect);
}
SDL_FreeYUVOverlay(yuv.overlay);

SMPEG (http://cvs.lokigames.com/) is a good example of this code.

More information on YUV formats can be found online at:
http://www.webartz.com/fourcc/indexyuv.htm

P.S. Anyone working on the documention for this?

Akawaka?

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

    SDL_DisplayYUVOverlay(yuv.overlay, &dstrect);

Also note that the YUV overlays have the special property that the
destination width and height need not be the same as the overlay
width and height. It’s faster if they are, but SDL has special-case
stretching code for YUV overlays. (BTW, 2X is the fastest stretch.)

Oh, SDL doesn’t perform clipping on the destination, so don’t go
sliding the video off the screen. :slight_smile:

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

I’ve to load a stream (a file .raw) and display it. It is in the PLANAR
MODE Y+U+V format.

I’ve got some(!!!) problem to load and display it.

Would you help me, please???

Thanks.

I’ve to load a stream (a file .raw) and display it. It is in the PLANAR
MODE Y+U+V format.

I’ve got some(!!!) problem to load and display it.

What you probably want is to create an SDL_Overlay surface in YV12 format,
and then copy the YUV planes into the surface and then display it. Remember
that YV12 is really Y + V + U, not Y + U + V.

Take a look at the SDL 1.1.6 documentation for the video overlays.

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

I’m in the process of porting the MPEG4IP tools to our embedded Mips
platform. All the file based tools move over with no problem, now I’m faced
with getting some pixels to the screen. MPEG4IP uses SDL, so best to pose my
newbie questions to those that know the answers.

I want to use the MPEG4IP test code, yuvdump tp get started which basically
goes something like this:

SDL_Overlay *m_image = SDL_CreateYUVOverlay(width,
height,
SDL_YV12_OVERLAY,
m_screen);

– setup some yuv buffers

– for all the frames
– read the yuv frame data from a file

SDL_LockYUVOverlay(m_image);
memcpy(m_image->pixels[0], ybuf, ysize);
memcpy(m_image->pixels[1], vbuf, uvsize);
memcpy(m_image->pixels[2], ubuf, uvsize);

SDL_DisplayYUVOverlay(m_image, &m_dstrect);
SDL_UnlockYUVOverlay(m_image);

So my question is this, do you have to have hw yuv acceleration to use these
calls? I don’t believe so, because the FAQ says I can set
SDL_VIDEO_YUV_HWACCEL = 0 to turn it all off and when I do this on a x86 RH7
box the code still works. So where does the actual yuv->rgb conversion
happen? I’ve followed the SDL_DisplayYUVOverlay for X11 down into
SDL_x11yuv.c, X11_DisplayYUVOverlay where it calls XvShmPutImage(). Our
frame buffer controller is very simple with no hw acceleration, can I still
render YUV Overlay to it and have SDL do the conversion?

Thanks-

Casey

So my question is this, do you have to have hw yuv acceleration to use these
calls? I don’t believe so, because the FAQ says I can set
SDL_VIDEO_YUV_HWACCEL = 0 to turn it all off and when I do this on a x86 RH7
box the code still works. So where does the actual yuv->rgb conversion
happen? I’ve followed the SDL_DisplayYUVOverlay for X11 down into
SDL_x11yuv.c, X11_DisplayYUVOverlay where it calls XvShmPutImage(). Our
frame buffer controller is very simple with no hw acceleration, can I still
render YUV Overlay to it and have SDL do the conversion?

It’s much slower since you end up doing the conversion in software, but
SDL will transparently convert the YUV data to RGB for you if it needs to
do so (no hardware acceleration, or you’ve turned it off, etc).

This should be true of all platforms SDL supports.

–ryan.

SDL_LockYUVOverlay(m_image);
memcpy(m_image->pixels[0], ybuf, ysize);
memcpy(m_image->pixels[1], vbuf, uvsize);
memcpy(m_image->pixels[2], ubuf, uvsize);

This can be dangerous, as you cannot be sure that the buffers are contiguous
in memory. It seems that if you are not using hardware acceleration, the
buffers are actually contiguous, but I wouldn’t rely on it…

Use the m_image->pitches array, i.e. for each component (Y, U and V) do:

if (width != m_image->pitches[c]) {
for (i = 0; i < height; i++) {
memcpy(m_image->pixels[c]+i*m_image->pitches[c], buffer, width);
}
}
else {
memcpy(m_image->pixels[c], buffer, size);
}On Wed, 29 Aug 2001, From: Casey King wrote:


Nicolai Dufva - @Nicolai_Dufva_Nielse
``The ships hung in the sky in much the same way that bricks don’t.’’