Overlay Surface: HELP ME, PLEASE

Hi all.
I have a big problem. I hope someone could give me an hint.
I have a GTK application to play 4 Cam stream. The only way i can see
may 4 cam is playing in 4 different only if in a packet format(YUVY 16
bpp).
If i try to grab a planar format (Y2YV 32 bpp) i can:

  1. Display correctly only one overlay surface.
  2. if i put 4 overlay surface on the screen i can see the 4 cam but
    with a blue rectangle flikering over each overlay surface.
    Attached my code i use tu display.

m_mainscreen = SDL_SetVideoMode(DEFAULT_WIDTH, DEFAULT_HEIGHT, m_nBpp,
SDL_HWSURFACE | SDL_RESIZABLE);

int MainPlay(void *data)
{
CYuvMainWin *pMainWin = (CYuvMainWin *) data;
int yuv= 0;
int index = 0;

while( !pMainWin->m_nQuit )
{
	
	for(yuv = 0; yuv < pMainWin->getNumOverlay() ; yuv++ )
	{
		CBufferData *pBuffer = NULL;
		
		if (!pMainWin->m_FullScreenStatus)
			pBuffer = pMainWin->getData(yuv);
		else
			pBuffer =

pMainWin->getData(pMainWin->m_nFullScreenCam);

		Uint32 format = pBuffer->getOverlayFormat();
			
		if ((pBuffer->getCamStatus() == NOTHING) ||

(pBuffer->getImage()->Buffer()[0] == ‘\0’))
{
// Display static Image
switch(format)
{
case SDL_YV12_OVERLAY:

pMainWin->ConvertRGBtoYV12(pMainWin->getStaticImage(),pBuffer->getCamOve
rlay(),0,100);
break;
case SDL_IYUV_OVERLAY:

pMainWin->ConvertRGBtoIYUV(pMainWin->getStaticImage(),pBuffer->getCamOve
rlay(),0,100);
break;
case SDL_YUY2_OVERLAY:

pMainWin->ConvertRGBtoYUY2(pMainWin->getStaticImage(),pBuffer->getCamOve
rlay(),0,100);
break;
case SDL_UYVY_OVERLAY:

pMainWin->ConvertRGBtoUYVY(pMainWin->getStaticImage(),pBuffer->getCamOve
rlay(),0,100);
break;
case SDL_YVYU_OVERLAY:

pMainWin->ConvertRGBtoYVYU(pMainWin->getStaticImage(),pBuffer->getCamOve
rlay(),0,100);
break;
default:

pMainWin->ConvertRGBtoYUY2(pMainWin->getStaticImage(),pBuffer->getCamOve
rlay(),0,100);
}

		}
		else
		{
			assert(pBuffer != NULL);
			
			SDL_LockMutex(pBuffer->getLockMutex());

SDL_LockSurface(pMainWin->getMainScreen());

SDL_LockYUVOverlay(pBuffer->getCamOverlay());

			if (format == SDL_YV12_OVERLAY) 
			{
				guint8 *y,*u,*v;
				Uint32 fourcc = TP_MAKE_FOURCC

(‘I’, ‘4’, ‘2’, ‘0’);
if(fourcc == TP_MAKE_FOURCC
(‘Y’, ‘V’, ‘1’, ‘2’)) // GST_MAKE_FOURCC (‘Y’, ‘V’, ‘1’, ‘2’):
{
y =
pBuffer->getImage()->Buffer();
u = y +
pBuffer->getRect()->w * pBuffer->getRect()->h;
v = y +
pBuffer->getRect()->w * pBuffer->getRect()->h * 5 / 4;

				}
				else if (fourcc ==

TP_MAKE_FOURCC (‘I’, ‘4’, ‘2’, ‘0’)) // GST_MAKE_FOURCC (‘I’, ‘4’, ‘2’,
‘0’):
{
// y =
pBuffer->getData();
y =
pBuffer->getImage()->Buffer();
/* I420 is YV12 with
switched colour planes and different offsets */
v = y + I420_U_OFFSET
(pBuffer->getRect()->w, pBuffer->getRect()->h);
u = y + I420_V_OFFSET
(pBuffer->getRect()->w, pBuffer->getRect()->h);

				}	

memcpy((pBuffer->getCamOverlay())->pixels[0],y,pBuffer->getRect()->w *
pBuffer->getRect()->h);

memcpy((pBuffer->getCamOverlay())->pixels[1],u,pBuffer->getRect()->w *
pBuffer->getRect()->h/4);

memcpy((pBuffer->getCamOverlay())->pixels[2],v,pBuffer->getRect()->w *
pBuffer->getRect()->h/4);

			}
			else

memcpy((pBuffer->getCamOverlay())->pixels[0],pBuffer->getImage()->Buffer
(),pBuffer->getBufferSize());

		}


		SDL_UnlockYUVOverlay(pBuffer->getCamOverlay());
					
		SDL_UnlockSurface(pMainWin->getMainScreen());

		SDL_UnlockMutex(pBuffer->getLockMutex());
		
		if (!pMainWin->m_FullScreenStatus)

SDL_DisplayYUVOverlay(pBuffer->getCamOverlay(),
pBuffer->getRectOverlay());
else

SDL_DisplayYUVOverlay(pBuffer->getCamOverlay(),
pMainWin->getLayoutClass()->getRectOverlay(0));

	}
	
	SDL_Delay(10); 
}


return 0;

}

Could you please help me?

Thanks.

Carmelo Gallucci

You can only display one HW Overlay at a time. The blue image is
actually the key used by the HW Overlay for knowing where to display.
So it’s “under” the overlay. when you display another overlay somewhere
else you are left with this key color where the previous overlay was.

Your best option, IMHO, would be to combine all 4 sources into one
large overlay image with one common YUV format before displaying that
one overlay image, otherwise perhaps force SW Overlay display which
would be slower, but may not leave the blue mask behind.

do something like this before SDL_Init (to be sure)
check the SDL source to see when it gets this envvar if you want to fine
tune when you set it…or if you want to set it over and over…

putenv(“SDL_VIDEO_YUV_HWACCEL=0”);

-LIM-

carmelo gallucci wrote:

Hi all.
I have a big problem. I hope someone could give me an hint.
I have a GTK application to play 4 Cam stream. The only way i can see
may 4 cam is playing in 4 different only if in a packet format(YUVY 16
bpp).
If i try to grab a planar format (Y2YV 32 bpp) i can:

  1. Display correctly only one overlay surface.
  2. if i put 4 overlay surface on the screen i can see the 4 cam but
    with a blue rectangle flikering over each overlay surface.
    – snip –