Problem displaying YUV format

Hi all. I need help after 3 night of work and no result.
I have for v4l cam (fedora 4 core) and i’m trying to build a GTK
interface to show all cam’s frames in the same winwows. I chose to
display YUV2 format. I i try one cam all seem to work correctly. The
code i’m using is the follow:

SDL_Overlay *cam4Overlay;
int flags 	=  SDL_HWSURFACE|SDL_DOUBLEBUF; //SDL_SWSURFACE

| SDL_FULLSCREEN;
int nWidth = XWINDOWSIZE / cam4Struct->nRedim;
int nHeigth = YWINDOWSIZE / cam4Struct->nRedim;
int i = 0;

SDL_Rect rect4;
rect4.x = cam4Struct->nTopX;
rect4.y = cam4Struct->nTopY;
rect4.w = nWidth;
rect4.h = nHeigth;

cam4Overlay = SDL_CreateYUVOverlay(nWidth, nHeigth,

SDL_YUY2_OVERLAY, mainscreen);

while( !quit )
{
	....
	.....	
	
	SDL_LockYUVOverlay(cam4Overlay);

memcpy(cam4Overlay->pixels[0],buffer.data,buffer.buffer_size);

	cam4Overlay->pitches[0] = 320;
	
		SDL_UnlockYUVOverlay(cam4Overlay);
		SDL_DisplayYUVOverlay(cam4Overlay,&rect4);
}
....

I need to show the 4 cams in 4 SDL_Rect on the main screen.
I use thread to assolve this job.
The problems is:

My frame are showed correctly but each time i update one cam i can see
on the other a rect filled of blue color.

What i’m doing wrong? Anynone know where is my problem? I’m really nes
on the SDl lib. Please help me.

Thank’s in advance.

Carmelo Gallucci

int NumOverlay = 1;
SDL_Overlay *cam4Overlay[ NumOverlay ];
int flags = SDL_HWSURFACE|SDL_DOUBLEBUF; //SDL_SWSURFACE
| SDL_FULLSCREEN;
int nWidth = XWINDOWSIZE / cam4Struct->nRedim;
int nHeigth = YWINDOWSIZE / cam4Struct->nRedim;
int i = 0;

    SDL_Rect rect4;
    rect4.x = cam4Struct->nTopX;
    rect4.y = cam4Struct->nTopY;
    rect4.w = nWidth;
    rect4.h = nHeigth;

/* You may want to edit the nWidth and nHeight to fit every camra */
for( int yuv = 0; yuv < NumOverlay; yuv++ )
cam4Overlay[yuv] = SDL_CreateYUVOverlay(nWidth, nHeigth, SDL_YUY2_OVERLAY,
mainscreen);

while( !quit )
{
// …
for( int yuv = 0; yuv < NumOverlay; yuv++ )
{
SDL_LockYUVOverlay( cam4Overlay[ yuv ] );

memcpy(cam4Overlay->pixels[0],buffer.data,buffer.buffer_size);

SDL_UnLockYUVOverlay( cam4Overlay[ yuv ] );

SDL_Delay( 10 );

cam4Overlay->pitches[0] = 320;

SDL_DisplayYUVOverlay( cam4Overlay[ yuv ], rect4 ); // Obviously change the
rect4 to whereever
}

SDL_Flip( mainscreen );
SDL_Delay( 1 ); // Mmmmm…CPU conservation
}

I haven’t tested this code, but I think it should work.

Alex~ (not the other techie one…just a loser Alex)On 1/29/06, carmelo gallucci wrote:

Hi all. I need help after 3 night of work and no result.
I have for v4l cam (fedora 4 core) and i’m trying to build a GTK
interface to show all cam’s frames in the same winwows. I chose to
display YUV2 format. I i try one cam all seem to work correctly. The
code i’m using is the follow:

    SDL_Overlay *cam4Overlay;
    int flags       =  SDL_HWSURFACE|SDL_DOUBLEBUF; //SDL_SWSURFACE

| SDL_FULLSCREEN;
int nWidth = XWINDOWSIZE / cam4Struct->nRedim;
int nHeigth = YWINDOWSIZE / cam4Struct->nRedim;
int i = 0;

    SDL_Rect rect4;
    rect4.x = cam4Struct->nTopX;
    rect4.y = cam4Struct->nTopY;
    rect4.w = nWidth;
    rect4.h = nHeigth;

    cam4Overlay = SDL_CreateYUVOverlay(nWidth, nHeigth,

SDL_YUY2_OVERLAY, mainscreen);

    while( !quit )
    {
            ....
            .....

            SDL_LockYUVOverlay(cam4Overlay);

memcpy(cam4Overlay->pixels[0],buffer.data,buffer.buffer_size);

            cam4Overlay->pitches[0] = 320;

                    SDL_UnlockYUVOverlay(cam4Overlay);
                    SDL_DisplayYUVOverlay(cam4Overlay,&rect4);
    }
    ....

I need to show the 4 cams in 4 SDL_Rect on the main screen.
I use thread to assolve this job.
The problems is:

My frame are showed correctly but each time i update one cam i can see
on the other a rect filled of blue color.

What i’m doing wrong? Anynone know where is my problem? I’m really nes
on the SDl lib. Please help me.

Thank’s in advance.

Carmelo Gallucci


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


Smith: "…Why, Mr Anderson, Why - Do - You - Persist?"
Neo: “Because I choose to.”
-Matrix Revolutions