File: INPUT.FORMAT

package info (click to toggle)
ucbmpeg 1r2-6
  • links: PTS
  • area: non-free
  • in suites: hamm, potato, slink
  • size: 9,504 kB
  • ctags: 7,643
  • sloc: ansic: 79,920; tcl: 2,985; perl: 313; asm: 284; makefile: 269; csh: 13
file content (105 lines) | stat: -rw-r--r-- 2,599 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
			----------------
			| FILE FORMATS |
			----------------

PPM FORMAT
----------

To give you an idea of what a PPM file is, the following code will write
one out:

    int **red, **green, **blue;

    void	WritePPM(char *fileName, int width, int height, int maxVal)
    {
	register int x, y;
	unsigned char   r, g, b;

	fprintf(stdout, "P6\n");
	fprintf(stdout, "%d %d\n", width, height);
	fprintf(stdout, "%d\n", maxVal);

	for ( y = 0; y < height; y++ )
	    for ( x = 0; x < width; x++ )
	    {
		r = red[x][y];  g = green[x][y];    b = blue[x][y];

		fwrite(&r, 1, 1, stdout);
		fwrite(&g, 1, 1, stdout);
		fwrite(&b, 1, 1, stdout);
	    }
    }

maxVal is the maximum color value.  It must be between 0 and 255 inclusive.
Generally speaking, it should be 255 always.


UCB YUV FORMAT
--------------

You should be aware that the YUV format used in the MPEG encoder is DIFFERENT
than the Abekas YUV format.  The reason for this is that in MPEG, the U and
V components are subsampled 4:1.

To give you an idea of what format the YUV file must be in, the following
code will read in a YUV file:

    unsigned char **y_data, **cr_data, **cb_data;

    void	ReadYUV(char *fileName, int width, int height)
    {
	FILE *fpointer;
	register int y;

	/* should allocate memory for y_data, cr_data, cb_data here */

	fpointer = fopen(fileName, "r");

	for (y = 0; y < height; y++)			/* Y */
	    fread(y_data[y], 1, width, fpointer);

	for (y = 0; y < height / 2; y++)			/* U */
	    fread(cb_data[y], 1, width / 2, fpointer);

	for (y = 0; y < height / 2; y++)			/* V */
	    fread(cr_data[y], 1, width / 2, fpointer);

	fclose(fpointer);
    }

There are two reasons why you'd want to use YUV files rather than PPM files:
	1)  The YUV files are 50% the size of the corresponding PPM files
	2)  The ENCODER will run slightly faster, since it doesn't have to
	    do the RGB to YUV conversion itself.


ABEKAS YUV FORMAT 
-----------------

The Abekas YUV Format interlaces the Y, U, and V values in a 4:2:2 format.
The interlacing pattern is

UYVY

for each group of 4 bytes in the file.


PHILLIPS YUV FORMAT 
-------------------

The Phillips YUV Format interlaces the Y, U, and V values in a 4:2:2 format.
The interlacing pattern is

YVYU

for each group of 4 bytes in the file.


You may specify either ABEKAS, PHILLIPS, or UCB as the YUV_FORMAT when
encoding ; the encoder defaults to UCB YUV_FORMAT if not specified.
In addition, if you've got a weird interlacing format, you can also
try and de-interlace it by giving the YUV pattern in the YUV_FORMAT.
So a YUV 4:4:4 format would be

YUVYUV