Hi
I want to read an YUV422psemi picture and display it, but I can't get the picture but some orderless bars, and I don't know why? and the yuv422psemi picture display well through Rawplayer, but the play Format is YV12. the picture size is 320*240
The following is my codes, who can help me? thank you!
Int main(Int argc, String argv[])
{
Buffer_Handle hSrcBuf,hDstBuf;//hIntBuf;
Loader_Attrs lAttrs = Loader_Attrs_DEFAULT;
Loader_Handle hLoader;
BufferGfx_Dimensions dstDim;
BufferGfx_Attrs gfxAttrs = BufferGfx_Attrs_DEFAULT;
Display_Handle hDisplay = NULL;
BufTab_Handle hBufTab = NULL;
Display_Attrs dAttrs = Display_Attrs_DM6467_VID_DEFAULT;
VideoStd_Type videoStd;
Int32 bufSize;
Dmai_init();
videoStd = VideoStd_D1_PAL;
gfxAttrs.colorSpace = ColorSpace_YUV422PSEMI;
gfxAttrs.dim.width = VideoStd_D1_WIDTH ;
gfxAttrs.dim.height = VideoStd_D1_PAL_HEIGHT;
gfxAttrs.dim.lineLength = BufferGfx_calcLineLength(VideoStd_D1_WIDTH,
ColorSpace_YUV422PSEMI);
bufSize = BufferGfx_calcSize(videoStd, ColorSpace_YUV422PSEMI);
if (bufSize < 0) {
ERR("Failed to calculate buffer size for buffer\n");
exit(1);
}
hBufTab = BufTab_create(1, bufSize,
BufferGfx_getBufferAttrs(&gfxAttrs));
if (hBufTab == NULL) {
printf("Failed to allocate contiguous buffers\n");
exit(1);
}
lAttrs.readBufSize = 720*576*2;
lAttrs.readSize = 320*240*2;
hLoader=Loader_create("a_YUV422Sep.yuv",&lAttrs);
if(hLoader==NULL)
{
printf("hLoader created failure,please check!\n");
}
Loader_prime(hLoader,&hSrcBuf);
if (hSrcBuf == NULL)
{
printf("Loader_prime failure !\n");
}
// BufferGfx_getDimensions(hSrcBuf, &srcDim);
dAttrs.videoStd = videoStd;
dAttrs.videoOutput = Display_Output_COMPOSITE;
hDisplay = Display_create(NULL, &dAttrs);
if (hDisplay == NULL)
{
printf("Failed to create display\n");
exit(1);
}
/* Get a buffer from the display device driver */
while(1)
{
if (Display_get(hDisplay, &hDstBuf) < 0) {
ERR("Failed to get display buffer\n");
exit(1);
}
/* Get the dimensions of the destination buffer */
BufferGfx_getDimensions(hDstBuf, &dstDim);
printf("Display size %dx%d pitch %d dim.x=%d dim.y=%d\n", (Int) dstDim.width,
(Int) dstDim.height, (Int)dstDim.lineLength,(Int)dstDim.x,(Int)dstDim.y);
Display_put(hDisplay, hSrcBuf); //把写有数据的Buffer填如驱动的内存中
}
Loader_delete(hLoader);
Display_delete(hDisplay); //销毁display对象
return 0;
}
PS: the bufTab is defined but not used, because it is used in the Display_create() function, and the hDisplay is NULL, I don't know why?
thanks
Dingguo Peng