• Advertisement

Archived

This topic is now archived and is closed to further replies.

How to copy YUV planar formats data(such as YV12,I420 ) to DirectDraw surface

This topic is 5362 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have created a YUV offscreen surface to render a YUV format data buffer. when the YUV format is packed format such as UYVY ,I succeed to render the data using DirectDraw. but when deal with the planar YUV formats such as YV12, I420 etc,I do not know how to copy the data to a DirectDraw YUV format surface. souce snippet as follow: DDPIXELFORMAT ddpYUVScreenPixelFormat[] = { {sizeof (DDPIXELFORMAT),DDPF_FOURCC,MAKEFOURCC(''U'',''Y'',''V'',''Y''),0,0,0,0,0}, {sizeof(DDPIXELFORMAT),DDPF_FOURCC,MAKEFOURCC (''Y'',''V'',''1'',''2''),0,0,0,0,0}}; ZeroMemory(&ddsd, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN ; ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT; ddsd.dwBackBufferCount = 0; ddsd.dwWidth = 640; ddsd.dwHeight = 480; ddsd.ddpfPixelFormat = ddpYUVScreenPixelFormat[1]; hr = lpDDObject->CreateSurface(&ddsd,ppDDS,NULL); // we assume according YUV format OFFSCREEN surface is created successful. when deal with UYVY data,I use following code snippet ,it work well. HRESULT r= suf->Lock(0, &desc, DDLOCK_WAIT|DDLOCK_WRITEONLY, 0); int bytesrequired = (w * 16 ) >> 3; BYTE* surfbits = (BYTE*)desc.lpSurface; BYTE* srcByte = imgbuf; if(r!= DD_OK) { return 0; } for(int i = 0; i < h; i ++) { memcpy(surfbits, srcByte, bytesrequired); surfbits += desc.lPitch; srcByte += bytesrequired; } //w: is image width,h:is image height,imgbuf is image data buffer to rendering. suf->Unlock(0); but as I know the planar format YUV data is store Y data,U data and V data separately,I get some information from www.fourcc.org about YUV format,but I have no idea to deal with YV12 or I420 data at here. any one can help me,how to deal with the Planar format YUV data buffer.

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement