YUV player

I am trying to play decoded YUV components using SDL
interface, but i am getting green color only and
segentation fault error, i think the problem is with
managing the buffer, here is the code

.
.
screen = SDL_SetVideoMode(w,h, 16, SDL_DOUBLEBUF |
SDL_RESIZABLE );
.
.
YUV_overlay =
SDL_CreateYUVOverlay(w,h,SDL_YV12_OVERLAY,screen);
.
.
avcodec_decode_video(videoCodec,frame,&gotpics,pkt.data,pkt.size);
.
.
if ( SDL_MUSTLOCK(screen) ) {
if ( SDL_LockSurface(screen) < 0 ) return;
}
SDL_LockYUVOverlay(YUV_overlay) ;

		fprintf(stdout,"sdl start to lock the overlay\n");

					YUV_overlay->pixels[0] = pkt.data;

		YUV_overlay->pixels[2] = YUV_overlay->pixels[0] +

w*h;

		YUV_overlay->pixels[1] = YUV_overlay->pixels[2] +

(w*h)/4;
.
.
.

		if ( SDL_MUSTLOCK(screen) ) {
			SDL_UnlockSurface(screen);
			}
		SDL_UnlockYUVOverlay(YUV_overlay);

SDL_DisplayYUVOverlay(YUV_overlay,&rect);___________________________________________________________
New Yahoo! Mail is the ultimate force in competitive emailing. Find out more at the Yahoo! Mail Championships. Plus: play games and win prizes.
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk