[gst-devel] How can I put the YUV data and its stride into GstrBuffer?

gtxia xia_guangtai at visualon.com
Fri May 18 05:24:22 CEST 2007


Hello All.

DecoderBuffer
{
   guchar* pY;
   guchar* pU;
   guchar* pV;
   guint   stride[3];
} 

When I get a pointer DecoderBuffer from video decoder and its pointer
have been allocation by decoder and put Y plane data, U plane data and V
data seperately. The Y's stride doesn't equal video's width. I have used
the follow functions put the buffers into GstBuffer.

outBuffer = &GST_BUFFER_DATA(XX);

static void copy_from_decoder_into_buffer(DecoderBuffer* inBuffer, guint
inWidth, guint inHeight, guint8** outBuffer)
{
	guint8 *dest, *src;
	guint outsize, line;
	g_assert(*outBuffer != NULL);

	
	/* Copy Y first */
	src = inBuffer->pY;
	dest = *outBuffer;

	
	if(src != NULL)
	{
		for(line = 0; line < inHeight; line++)
		{
			memcpy(dest, src, inWidth);
			dest += inWidth;
			src += inBuffer->stride[0];
		}
	}
	
	
	// U 
	src = inBuffer->pU;
	dest = (*outBuffer) + inWidth * inHeight;

	if(src != NULL)
	{
		for(line = 0; line < inHeight/2 ; line++)
		{
			memcpy(dest, src, inWidth / 2);
			dest += inWidth / 2;
			src += inBuffer->stride[1];
		}
	}
		
	// V 
	src = inBuffer->pV;
	dest = (*outBuffer) + inWidth * inHeight * 4 / 5;
	
	
	if(src != NULL)
	{
		for(line = 0; line < inHeight/2 ; line++)
		{
			memcpy(dest, src, inWidth / 2);
			dest += inWidth / 2;
			src += inBuffer->stride[2];
		}
	}
	
		
}

These buffers can not draw right image on display, I use
ffmpegcolorspace. What's wrong step I have made? Is it necessary for
decoder to tell the colorspace the stides inforamtion if the stride
doesn't equal colorspce? If need, How can do that? Thanks for your kind
help.

Regards

XiaGuangTai
 





More information about the gstreamer-devel mailing list