Sign in

username:

password:



Not a member?

Search code-comp



Search tips

Subscribe to code-comp



code-comp by Keywords

ARM7 | BIOS | Bug | EVM | JTAG | Linker | LOG_printf | McBSP | Profiling | Relocation | RTDX | Simulator | Target | Watch

Ads

Discussion Groups

Discussion Groups | Code-Composer | Problem in convert .yuv to .dat that ccs probe can use.

Technical discussions about Code Composer Studio.

  

Post a new Thread

Problem in convert .yuv to .dat that ccs probe can use. - ahra...@yahoo.com.cn - Nov 8 6:03:48 2007



Hey~I wrote a simple program to convert yuv to dat in which ccs probe can use.
However there is something wrong with it, the generated .dat is alway 0kb, it seems that the
data were not wrote into .dat.
Anyone help ?

#include <stdio.h>
#include <string.h>
#include <conio.h>
#define WIDTH 352
#define HEIGHT 288
typedef unsigned char	uint8_t;
main()
{

	FILE *fp;
	FILE *fd;
	uint8_t *plane[4];
	plane[0] = NULL;
	plane[1] = NULL;
	plane[2] = NULL;
	plane[3] = NULL;
	if ((fp = fopen(\"foreman.yuv\",\"rb\")) == 0) 
	{
		printf(\"Error when open input file\\n\");
	}

	if (fread( plane[0], 1, WIDTH * HEIGHT, fp ) < 0 
		|| fread( plane[1], 1, WIDTH * HEIGHT / 4, fp ) <0 
		|| fread( plane[2], 1, WIDTH * HEIGHT / 4, fp ) < 0)
	{
		printf(\"Error when read yuv file\\n\");
	}

	if ( (fd = fopen(\"f.dat\", \"wb\")) == 0)
	{
		printf(\"Error when open output file\\n\");
	}

	if (fwrite( plane[0], 1, WIDTH * HEIGHT,  fd ) < 0
		|| fwrite( plane[1], 1, WIDTH * HEIGHT / 4, fd ) < 0
		|| fwrite( plane[2], 1, WIDTH * HEIGHT / 4, fd ) < 0)
	{
		printf(\"Error when write dat file\\n\");
	}

	fclose(fp);
	fclose(fd);
	getche();
}



(You need to be a member of code-comp -- send a blank email to code-comp-subscribe@yahoogroups.com )