<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multimedia.cx/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Artoria2e5</id>
	<title>MultimediaWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multimedia.cx/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Artoria2e5"/>
	<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php/Special:Contributions/Artoria2e5"/>
	<updated>2026-07-07T15:38:30Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15759</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15759"/>
		<updated>2023-12-31T08:10:50Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares: everyone just adapts y4m to whatever needs arise for testing their codec. There is also no widely-recognized extension field for indicating which matrix is in use &amp;amp;ndash; good luck!&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes (&amp;quot;center&amp;quot;: 0.5 right, 0.5 down)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with coincident R and vertically-displaced B (down 1 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420mpeg2&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (MPEG-2: B and R have same displacement of down 0.5 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt;  = 4:2:0. Not found in original spec, so interpretations differ:&lt;br /&gt;
:** with coincident chroma planes, according to rav1e (arguably the more useful interpretation)&lt;br /&gt;
:** with JPEG displacement, [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegdec.c according to ffmpeg] and aom.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2 coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4 coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444alpha&amp;lt;/code&amp;gt; = 4:4:4 plus a alpha channel of the same size (not supported by libwebm)&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace], [https://aomedia.googlesource.com/aom/+/refs/heads/av1-normative/common/y4menc.c aom-av1 y4menc.c], and [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegenc.c ffmpeg yuv4mpegenc.c]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420, C420jpeg, C420paldv, and C420mpeg2 this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* FFmpeg yuv4mpegdec's interpretation of &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt; sample locations surprisingly differ from the original. Instead of noting &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; as coincidental, the decoder only reads &amp;quot;unknown&amp;quot;.&lt;br /&gt;
* FFmpeg's yuv4mpegenc taxonomy uses &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; for &amp;quot;top-left&amp;quot;, i.e. coincidental. This is obviously wrong, but nothing can be done without sacrificing the real PAL-DV: ffmpeg uses one &amp;lt;code&amp;gt;AvChromaLocation&amp;lt;/code&amp;gt; to describe where ''both'' chroma samples are taken.&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15758</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15758"/>
		<updated>2023-11-22T08:44:38Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: /* Notes */ ~&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares: everyone just adapts y4m to whatever needs arise for testing their codec. There is also no widely-recognized extension field for indicating which matrix is in use &amp;amp;ndash; good luck!&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes (&amp;quot;center&amp;quot;: 0.5 right, 0.5 down)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with coincident R and vertically-displaced B (down 1 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420mpeg2&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (MPEG-2: B and R have same displacement of down 0.5 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt;  = 4:2:0. Not found in original spec, so interpretations differ:&lt;br /&gt;
:** with coincident chroma planes, according to AV1 (arguably the more useful interpretation)&lt;br /&gt;
:** with JPEG displacement, [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegdec.c according to ffmpeg]&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2 coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4 coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444alpha&amp;lt;/code&amp;gt; = 4:4:4 plus a alpha channel of the same size (not supported by libwebm)&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace], [https://aomedia.googlesource.com/aom/+/refs/heads/av1-normative/common/y4menc.c aom-av1 y4menc.c], and [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegenc.c ffmpeg yuv4mpegenc.c]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420, C420jpeg, C420paldv, and C420mpeg2 this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* FFmpeg yuv4mpegdec's interpretation of &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt; sample locations surprisingly differ from the original. Instead of noting &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; as coincidental, the decoder only reads &amp;quot;unknown&amp;quot;.&lt;br /&gt;
* FFmpeg's yuv4mpegenc taxonomy uses &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; for &amp;quot;top-left&amp;quot;, i.e. coincidental. This is obviously wrong, but nothing can be done without sacrificing the real PAL-DV: ffmpeg uses one &amp;lt;code&amp;gt;AvChromaLocation&amp;lt;/code&amp;gt; to describe where ''both'' chroma samples are taken.&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15757</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15757"/>
		<updated>2023-11-22T08:40:47Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: /* Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares: everyone just adapts y4m to whatever needs arise for testing their codec. There is also no widely-recognized extension field for indicating which matrix is in use &amp;amp;ndash; good luck!&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes (&amp;quot;center&amp;quot;: 0.5 right, 0.5 down)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with coincident R and vertically-displaced B (down 1 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420mpeg2&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (MPEG-2: B and R have same displacement of down 0.5 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt;  = 4:2:0. Not found in original spec, so interpretations differ:&lt;br /&gt;
:** with coincident chroma planes, according to AV1 (arguably the more useful interpretation)&lt;br /&gt;
:** with JPEG displacement, [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegdec.c according to ffmpeg]&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2 coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4 coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444alpha&amp;lt;/code&amp;gt; = 4:4:4 plus a alpha channel of the same size (not supported by libwebm)&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace], [https://aomedia.googlesource.com/aom/+/refs/heads/av1-normative/common/y4menc.c aom-av1 y4menc.c], and [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegenc.c ffmpeg yuv4mpegenc.c]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420, C420jpeg, C420paldv, and C420mpeg2 this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* FFmpeg yuv4mpegdec's interpretation of &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt; sample locations surprisingly differ from the original. Instead of noting &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; as coincidental, the decoder only reads &amp;quot;unknown&amp;quot;.&lt;br /&gt;
* FFmpeg's yuv4mpegenc taxonomy uses &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; for &amp;quot;top-left&amp;quot;, i.e. coincidental. This is obviously wrong. This is partially because ffmpeg uses one &amp;lt;code&amp;gt;AvChromaLocation&amp;lt;/code&amp;gt; to describe where ''both'' chroma samples are taken.&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15756</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15756"/>
		<updated>2023-11-22T08:26:30Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: aaa&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares: everyone just adapts y4m to whatever needs arise for testing their codec. There is also no widely-recognized extension field for indicating which matrix is in use &amp;amp;ndash; good luck!&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes (&amp;quot;center&amp;quot;: 0.5 right, 0.5 down)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with coincident R and vertically-displaced B (down 1 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420mpeg2&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (MPEG-2: B and R have same displacement of down 0.5 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt;  = 4:2:0. Not found in original spec, so interpretations differ:&lt;br /&gt;
:** with coincident chroma planes, according to AV1 (arguably the more useful interpretation)&lt;br /&gt;
:** with JPEG displacement, [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegdec.c according to ffmpeg]&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2 coincident (&amp;quot;unknown&amp;quot; according to ffmpeg... see the problem here?)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4 coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444alpha&amp;lt;/code&amp;gt; = 4:4:4 plus a alpha channel of the same size (not supported by libwebm)&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace], [https://aomedia.googlesource.com/aom/+/refs/heads/av1-normative/common/y4menc.c aom-av1 y4menc.c], and [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegenc.c ffmpeg yuv4mpegenc.c]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420, C420jpeg, C420paldv, and C420mpeg2 this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15755</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15755"/>
		<updated>2023-11-22T08:09:36Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: /* File header */ ~&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares: everyone just adapts y4m to whatever needs arise for testing their codec. There is also no widely-recognized extension field for indicating which matrix is in use &amp;amp;ndash; good luck!&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes (&amp;quot;center&amp;quot;: 0.5 right, 0.5 down)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with coincident R and vertically-displaced B (down 1 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420mpeg2&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (MPEG-2: B and R have same displacement of down 0.5 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt;  = 4:2:0. Not found in original spec, so interpretations differ:&lt;br /&gt;
:** with coincident chroma planes, according to AV1 (arguably the more useful interpretation)&lt;br /&gt;
:** with JPEG displacement, [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegdec.c according to ffmpeg]&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2 coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4 coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444alpha&amp;lt;/code&amp;gt; = 4:4:4 plus a alpha channel of the same size (not supported by libwebm)&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace], [https://aomedia.googlesource.com/aom/+/refs/heads/av1-normative/common/y4menc.c aom-av1 y4menc.c], and [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegenc.c ffmpeg yuv4mpegenc.c]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420, C420jpeg, C420paldv, and C420mpeg2 this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15754</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15754"/>
		<updated>2023-11-22T08:06:52Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: /* File header */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares: everyone just adapts y4m to whatever needs arise for testing their codec. There is also no widely-recognized extension field for indicating which matrix is in use &amp;amp;ndash; good luck!&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes (&amp;quot;center&amp;quot;: 0.5 right, 0.5 down)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with coincident R and vertically-displaced B (down 1 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420mpeg2&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (MPEG-2: B and R have same displacement of down 0.5 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt;  = 4:2:0. Not found in original spec, so interpretations differ:&lt;br /&gt;
:** with coincident chroma planes, according to AV1&lt;br /&gt;
:** with JPEG displacement, [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegdec.c according to ffmpeg]&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2 coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4 coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444alpha&amp;lt;/code&amp;gt; = 4:4:4 plus a alpha channel of the same size (not supported by libwebm)&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace], [https://aomedia.googlesource.com/aom/+/refs/heads/av1-normative/common/y4menc.c aom-av1 y4menc.c], and [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegenc.c ffmpeg yuv4mpegenc.c]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420, C420jpeg, C420paldv, and C420mpeg2 this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15753</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15753"/>
		<updated>2023-11-22T08:01:43Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: /* File header */ ~&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares: everyone just adapts y4m to whatever needs arise for testing their codec. There is also no widely-recognized extension field for indicating which matrix is in use &amp;amp;ndash; good luck!&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes (&amp;quot;center&amp;quot;: 0.5 right, 0.5 down)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with coincident R and vertically-displaced B (down 1 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420mpeg2&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (MPEG-2: B and R have same displacement of down 0.5 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt;  = 4:2:0 with coincident chroma planes (not part of the original spec, but made necessary by newer codec behavior)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2 coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4 coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444alpha&amp;lt;/code&amp;gt; = 4:4:4 plus a alpha channel of the same size (not supported by libwebm)&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace], [https://aomedia.googlesource.com/aom/+/refs/heads/av1-normative/common/y4menc.c aom-av1 y4menc.c], and [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegenc.c ffmpeg yuv4mpegenc.c]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420, C420jpeg, C420paldv, and C420mpeg2 this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15752</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15752"/>
		<updated>2023-11-22T08:00:42Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: /* File header */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares: everyone just adapts y4m to whatever needs arise for testing their codec. There is also no widely-recognized extension field for indicating which matrix is in use &amp;amp;ndash; good luck!&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with coincident R and vertically-displaced B&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420mpeg2&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (MPEG-2: B and R have same displacement of down 0.5 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt;  = 4:2:0 with coincident chroma planes (not part of the original spec, but made necessary by newer codec behavior)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2 coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4 coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444alpha&amp;lt;/code&amp;gt; = 4:4:4 plus a alpha channel of the same size (not supported by libwebm)&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace], [https://aomedia.googlesource.com/aom/+/refs/heads/av1-normative/common/y4menc.c aom-av1 y4menc.c], and [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegenc.c ffmpeg yuv4mpegenc.c]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420, C420jpeg, C420paldv, and C420mpeg2 this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15751</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15751"/>
		<updated>2023-11-22T07:30:09Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: ~&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares: everyone just adapts y4m to whatever needs arise for testing their codec. There is also no widely-recognized extension field for indicating which matrix is in use &amp;amp;ndash; good luck!&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (PAL-DV: R coincident, B displaced down 1 pixel)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420mpeg2&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (MPEG-2: B and R have same displacement of down 0.5 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt;  = 4:2:0 with coincident chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444alpha&amp;lt;/code&amp;gt; = 4:4:4 plus a alpha channel of the same size (not supported by libwebm)&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace], [https://aomedia.googlesource.com/aom/+/refs/heads/av1-normative/common/y4menc.c aom-av1 y4menc.c], and [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegenc.c ffmpeg yuv4mpegenc.c]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420, C420jpeg, C420paldv, and C420mpeg2 this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15750</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15750"/>
		<updated>2023-11-22T07:28:56Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: /* File header */ ~&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares: everyone just adapts y4m to whatever needs arise for testing their codec. There is also no widely-recognized extension field for indicating which matrix is in use &amp;amp;ndash; good luck!&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (PAL-DV: R coincident, B displaced down 1 pixel)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420mpeg2&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (MPEG-2: B and R have same displacement of down 0.5 px)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt;  = 4:2:0 with coincident chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2, coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444alpha&amp;lt;/code&amp;gt; = 4:4:4 plus a alpha channel of the same size (not supported by libwebm)&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace], [https://aomedia.googlesource.com/aom/+/refs/heads/av1-normative/common/y4menc.c aom-av1 y4menc.c], and [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegenc.c ffmpeg yuv4mpegenc.c]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420, C420jpeg, C420paldv, and C420mpeg2 this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15749</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15749"/>
		<updated>2023-11-22T07:26:33Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: /* File header */ y4menc.c&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares: everyone just adapts y4m to whatever needs arise for testing their codec. There is also no widely-recognized extension field for indicating which matrix is in use &amp;amp;ndash; good luck!&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (PAL-DV: B and R have different, alternate displacement)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420mpeg2&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (MPEG-2: B and R have same displacement)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt;  = 4:2:0 with coincident chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2, coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444alpha&amp;lt;/code&amp;gt; = 4:4:4 plus a alpha channel of the same size (not supported by libwebm)&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace], [https://aomedia.googlesource.com/aom/+/refs/heads/av1-normative/common/y4menc.c aom-av1 y4menc.c], and [https://github.com/FFmpeg/FFmpeg/blob/e9c93009fc34ca9dfcf0c6f2ed90ef1df298abf7/libavformat/yuv4mpegenc.c ffmpeg yuv4mpegenc.c]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420, C420jpeg, C420paldv, and C420mpeg2 this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15748</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15748"/>
		<updated>2023-11-22T07:21:38Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: /* File header */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares: everyone just adapts y4m to whatever needs arise for testing their codec. There is also no widely-recognized extension field for indicating which matrix is in use &amp;amp;ndash; good luck!&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (PAL-DV: B and R have different, alternate displacement)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420mpeg2&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (MPEG-2: B and R have same displacement)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt;  = 4:2:0 with coincident chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2, coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444alpha&amp;lt;/code&amp;gt; = 4:4:4 plus a alpha channel of the same size (not supported by libwebm)&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420, C420jpeg, C420paldv, and C420mpeg2 this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15747</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15747"/>
		<updated>2023-11-22T07:20:17Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: C444alpha for anyone who cares&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares: everyone just adapts y4m to whatever needs arise for testing their codec. There is also no widely-recognized extension field for indicating which matrix is in use &amp;amp;ndash; good luck!&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (PAL-DV: B and R have different, alternate displacement)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420mpeg2&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (MPEG-2: B and R have same displacement)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt;  = 4:2:0 with coincident chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2, coincident&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444alpha&amp;lt;/code&amp;gt; = 4:4:4 plus a alpha channel of the same size (rarely implemented)&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420, C420jpeg, C420paldv, and C420mpeg2 this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15746</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15746"/>
		<updated>2023-11-22T07:09:53Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: /* File header */ C420mpeg2&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares: everyone just adapts y4m to whatever needs arise for testing their codec. There is also no widely-recognized extension field for indicating which matrix is in use &amp;amp;ndash; good luck!&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (PAL-DV: B and R have different, alternate displacement)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420mpeg2&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes (MPEG-2: B and R have same displacement)&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt;  = 4:2:0 with coincident chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420, C420jpeg, C420paldv, and C420mpeg2 this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15745</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15745"/>
		<updated>2023-11-21T10:35:04Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: ~&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares: everyone just adapts y4m to whatever needs arise for testing their codec. There is also no widely-recognized extension field for indicating which matrix is in use &amp;amp;ndash; good luck!&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt; = 4:2:0 with coincident chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420jpeg and C420paldv, this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15744</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15744"/>
		<updated>2023-11-21T10:31:30Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: well.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares. There is also no widely-recognized extension field for indicating which matrix is in use &amp;amp;ndash; good luck!&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt; = 4:2:0 with coincident chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420jpeg and C420paldv, this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15743</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15743"/>
		<updated>2023-11-21T10:30:16Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: well...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but nobody actually cares.&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt; = 4:2:0 with coincident chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420jpeg and C420paldv, this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15742</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15742"/>
		<updated>2023-11-21T10:27:47Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: ah sike, no &amp;lt;ref&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the [https://manned.org/yuv4mpeg.5 original MJPEGTools documentation], it is always supposed to be BT.601, but this is not quite always respected.&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt; = 4:2:0 with coincident chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420jpeg and C420paldv, this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The [https://manned.org/yuv4mpeg.5 original specification] defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments. However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15741</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15741"/>
		<updated>2023-11-21T10:27:06Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2.&lt;br /&gt;
&lt;br /&gt;
The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).&lt;br /&gt;
&lt;br /&gt;
The file format does not specify what color matrix is used. According to the original MJPEGTools documentation, it is always supposed to be BT.601,&amp;lt;ref name=manpage&amp;gt;https://manned.org/yuv4mpeg.5&amp;lt;/ref&amp;gt; but this is not quite always respected.&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt; = 4:2:0 with coincident chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420jpeg and C420paldv, this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A. The original specification defines an &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; parameter for describing the interlace (in a format much more complex than the file-header &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;) and an &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; parameter for comments.&amp;lt;ref name=manpage/&amp;gt; However, tools rarely go through the trouble of trying to understand frame headers.&lt;br /&gt;
&lt;br /&gt;
This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15740</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15740"/>
		<updated>2023-11-21T10:23:32Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: /* Data format */ bit better, right?&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2. The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes). Since the original MPEG-2 specification supports more than one type of color matrix (BT.601, BT.709, ...), there is no way to know, without extensions in this format, the color matrix used for conversion to YCbCr from RGB.&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
&lt;br /&gt;
=== File header ===&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}}, interlacing&lt;br /&gt;
: &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
: &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
: &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
; &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, pixel aspect ratio&lt;br /&gt;
: Note that this is not the ratio of the picture as a whole, just the pixels. Any integer ratio is acceptable. Examples:&lt;br /&gt;
:* &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
:* &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
:* &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
; &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, Colour space&lt;br /&gt;
: Called &amp;quot;colorspace&amp;quot;, actually defines pixel format and color model.&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt; = 4:2:0 with coincident chroma planes&lt;br /&gt;
:* &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2&lt;br /&gt;
:* &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4&lt;br /&gt;
:* &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
:For a much more exhaustive list, check out documentation for [https://docs.rs/y4m/0.8.0/y4m/enum.Colorspace.html y4m::Colorspace]. Yes, there are higher bit-depth options. If you tell ffmpeg to be less strict, there are even wackier possibilities.&lt;br /&gt;
:If you have trouble figuring out the difference between C420jpeg and C420paldv, this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
; &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, Comment or extension.&lt;br /&gt;
: Ignored, but preserved and passed down, by a YUV4MPEG2 processor.&lt;br /&gt;
: FFMPEG defines, among others, the following extensions:&lt;br /&gt;
:*&amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt;, defines the color range.&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
:**&amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
:*&amp;lt;code&amp;gt;XYSCSS&amp;lt;/code&amp;gt;, indicates non-standard pixel formats not quite described by &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame data ===&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A.  This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15739</id>
		<title>YUV4MPEG2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YUV4MPEG2&amp;diff=15739"/>
		<updated>2023-11-21T10:12:56Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: Let's get ya to use the HTML code tag first&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: .y4m&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/yuv4mpeg2/&lt;br /&gt;
&lt;br /&gt;
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of [[YCbCr]] video formatted as [[YCbCr 4:2:0]], [[YCbCr 4:2:2]] or [[YCbCr 4:4:4]] data for the purpose of encoding, likely to [[MPEG]]-2. The part &amp;quot;YUV&amp;quot; in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes). Since the original MPEG-2 specification supports more than one type of color matrix (BT.601, BT.709, ...), there is no way to know, without extensions in this format, the color matrix used for conversion to YCbCr from RGB.&lt;br /&gt;
&lt;br /&gt;
== Data format ==&lt;br /&gt;
A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of &amp;lt;code&amp;gt;YUV4MPEG2 &amp;lt;/code&amp;gt; (last character is a space, ASCII 0x20).  Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:&lt;br /&gt;
* frame width: &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;W720&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame height: &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt; followed by a plaintext integer; example: &amp;lt;code&amp;gt;H480&amp;lt;/code&amp;gt;&lt;br /&gt;
* frame rate: &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; followed by the number of frames per second, expressed as a fraction in the form numerator:denominator.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;F30:1&amp;lt;/code&amp;gt; = 30 FPS&lt;br /&gt;
** &amp;lt;code&amp;gt;F25:1&amp;lt;/code&amp;gt; = 25 FPS (PAL/SECAM standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24:1&amp;lt;/code&amp;gt; = 24 FPS (Film)&lt;br /&gt;
** &amp;lt;code&amp;gt;F30000:1001&amp;lt;/code&amp;gt; = 29.97 FPS (NTSC standard)&lt;br /&gt;
** &amp;lt;code&amp;gt;F24000:1001&amp;lt;/code&amp;gt; = 23.976 FPS (Film transferred to NTSC)&lt;br /&gt;
&lt;br /&gt;
The following parameters are optional:&lt;br /&gt;
; {{#tag:code|I}} (interlacing)&lt;br /&gt;
&lt;br /&gt;
* interlacing: &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; followed by a single letter to indicate interlacing mode:&lt;br /&gt;
** &amp;lt;code&amp;gt;Ip&amp;lt;/code&amp;gt; = Progressive&lt;br /&gt;
** &amp;lt;code&amp;gt;It&amp;lt;/code&amp;gt; = Top field first&lt;br /&gt;
** &amp;lt;code&amp;gt;Ib&amp;lt;/code&amp;gt; = Bottom field first&lt;br /&gt;
** &amp;lt;code&amp;gt;Im&amp;lt;/code&amp;gt; = Mixed modes (detailed in FRAME headers)&lt;br /&gt;
* Parameter &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;: Pixel aspect ratio.  Note that this is not the ratio of the picture as a whole, just the pixels.  Examples: &lt;br /&gt;
** &amp;lt;code&amp;gt;A0:0&amp;lt;/code&amp;gt; = unknown&lt;br /&gt;
** &amp;lt;code&amp;gt;A1:1&amp;lt;/code&amp;gt; = square pixels&lt;br /&gt;
** &amp;lt;code&amp;gt;A4:3&amp;lt;/code&amp;gt; = NTSC-SVCD (480x480 stretched to 4:3 screen)&lt;br /&gt;
** &amp;lt;code&amp;gt;A4:5&amp;lt;/code&amp;gt; = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)&lt;br /&gt;
** &amp;lt;code&amp;gt;A32:27&amp;lt;/code&amp;gt; = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)&lt;br /&gt;
* Parameter &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;: Colour space&lt;br /&gt;
** &amp;lt;code&amp;gt;C420jpeg&amp;lt;/code&amp;gt; = 4:2:0 with biaxially-displaced chroma planes&lt;br /&gt;
** &amp;lt;code&amp;gt;C420paldv&amp;lt;/code&amp;gt; = 4:2:0 with vertically-displaced chroma planes&lt;br /&gt;
** &amp;lt;code&amp;gt;C420&amp;lt;/code&amp;gt; = 4:2:0 with coincident chroma planes&lt;br /&gt;
** &amp;lt;code&amp;gt;C422&amp;lt;/code&amp;gt; = 4:2:2&lt;br /&gt;
** &amp;lt;code&amp;gt;C444&amp;lt;/code&amp;gt; = 4:4:4&lt;br /&gt;
** &amp;lt;code&amp;gt;Cmono&amp;lt;/code&amp;gt; = YCbCr plane only&lt;br /&gt;
* Parameter &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;: Comment or extension.  Ignored, but passed, by a YUV4MPEG2 processor.&lt;br /&gt;
** FFMPEG defines, among others, the following extensions:&lt;br /&gt;
*** &amp;lt;code&amp;gt;XCOLORRANGE&amp;lt;/code&amp;gt; providing information on the color space&lt;br /&gt;
**** &amp;lt;code&amp;gt;XCOLORRANGE=FULL&amp;lt;/code&amp;gt; JPEG / Full swing / ITU T.871 range&lt;br /&gt;
**** &amp;lt;code&amp;gt;XCOLORRANGE=LIMITED&amp;lt;/code&amp;gt; MPEG / Studio swing / TV range&lt;br /&gt;
&lt;br /&gt;
If you have trouble figuring out the difference between C420jpeg and C420paldv, this might help: https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/y4minput.c&lt;br /&gt;
&lt;br /&gt;
Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes &amp;lt;code&amp;gt;FRAME&amp;lt;/code&amp;gt; followed by zero or more parameters each preceded by 0x20, ending with 0x0A.  This is then followed by the raw bytes from each plane.&lt;br /&gt;
&lt;br /&gt;
The length of each frame (excluding its header) can be computed as:&lt;br /&gt;
&lt;br /&gt;
* frame length = width * height * 3 / 2 (4:2:0)&lt;br /&gt;
* frame length = width * height * 2 (4:2:2)&lt;br /&gt;
* frame length = width * height * 3 (4:4:4)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YCoCg&amp;diff=15710</id>
		<title>YCoCg</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YCoCg&amp;diff=15710"/>
		<updated>2023-07-17T04:32:33Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: /* YCoCg-R */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some modern video codecs (e.g. [[Dirac]], [[H.264|H.264 FRExt]]) support the YCoCg colorspace. The correct written expression for this colorspace is YC&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;g&amp;lt;/sub&amp;gt;, with the 'o' and 'g' characters as subscripts. It is also called YC&amp;lt;sub&amp;gt;g&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, following the component order found in [[YCbCr]].&lt;br /&gt;
&lt;br /&gt;
== Technical Details ==&lt;br /&gt;
The various components of the name represent:&lt;br /&gt;
&lt;br /&gt;
* Y  = pseudo luma&lt;br /&gt;
* C&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = &amp;quot;orange chrominance&amp;quot;&lt;br /&gt;
* C&amp;lt;sub&amp;gt;g&amp;lt;/sub&amp;gt; = &amp;quot;green chrominance&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Unlike [[YCbCr]], this colorspace is defined using whole binary fractions, so it is possible to losslessly transform from [[RGB]] to YCoCg when using 2 more bits for YCoCg representation than for RGB. E.g., it is possible to losslessly transform a pixel from a 30-bit RGB frame into a pixel in a 32-bit YCoCg 4:4:4 frame and back. This assumes that each R, G, and B component will have 10 bits of information which Y will have 10 bits and Co and Cg will each have 11 bits.&lt;br /&gt;
&lt;br /&gt;
The use of whole binary fractions is a departure from the human vision model, but do remember that YCbCr &amp;quot;luma&amp;quot; was already a departure from the correct luminance formula. This departure does not make YCoCg worse at separating colors into unrelated components: it actually makes more coding gain [https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/2008_ColorTransforms_MalvarSullivanSrinivasan.pdf on the Kodak image set].&lt;br /&gt;
&lt;br /&gt;
In contrast to [[YCbCr]], this colorspace isn't based on the human vision model. This colorspace was invented to use similar encoding techniques as [[YCbCr|YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt;]] but with frames in [[RGB]] colorspace.&lt;br /&gt;
&lt;br /&gt;
=== YCoCg-R ===&lt;br /&gt;
&lt;br /&gt;
YCoCg-R is the version that takes fewer (2 extra) bits to be losslessly reversible, as opposed to the original version that took 5 extra bits. In modern encoding standards, only YCoCg-R is ever used, so even if you see &amp;quot;ycgco&amp;quot;, it's probably the new one.&lt;br /&gt;
&lt;br /&gt;
It is possible to squeeze a bit harder and use ''no'' extra bits, as wraparounds from modulo arithmetic is unambiguous in YCoCg. However, the wraparound causes a discontinuity in the generated components, potentially confusing a codec's predictors and making compression worse. (Remember, YCC pixels is only an intermediate format; making them smaller does not guarantee smaller final sizes!) As a result, no video codec uses this variant.&lt;br /&gt;
&lt;br /&gt;
== Possible Formats ==&lt;br /&gt;
&lt;br /&gt;
Like with [[:Category:YCbCr Formats|YCbCr]] it is also possible to use different plane sizes (chroma subsampling) for each component. Thus, every pixel in an image of a YCoCg encoded frame is associated with one Y sample, but possibly groups of pixels share C&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; and C&amp;lt;sub&amp;gt;g&amp;lt;/sub&amp;gt; samples.&lt;br /&gt;
&lt;br /&gt;
Possible encodings include:&lt;br /&gt;
* YCoCg 4:4:4, analogous to [[YCbCr 4:4:4]]&lt;br /&gt;
* YCoCg 4:2:2, analogous to [[YCbCr 4:2:2]]&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
== Algorithm ==&lt;br /&gt;
&lt;br /&gt;
The algorithm is described in this paper: [http://escher.elis.ugent.be/publ/Edocs/DOC/P105_213.pdf YCoCg(-R) Color Space Conversion on the GPU].&lt;br /&gt;
&lt;br /&gt;
And in the [http://diracvideo.org/download/specification/dirac-spec-latest.pdf dirac spec] in section F.1.5.2.&lt;br /&gt;
&lt;br /&gt;
From RGB to YCoCg:&lt;br /&gt;
 Co = R - B&lt;br /&gt;
  t = B + (Co &amp;gt;&amp;gt; 1)&lt;br /&gt;
 Cg = G - t&lt;br /&gt;
  Y = t + (Cg &amp;gt;&amp;gt; 1)&lt;br /&gt;
&lt;br /&gt;
and back from YCoCg to RGB:&lt;br /&gt;
  t = Y  - (Cg &amp;gt;&amp;gt; 1)&lt;br /&gt;
  G = Cg + t&lt;br /&gt;
  B = t  - (Co &amp;gt;&amp;gt; 1)&lt;br /&gt;
  R = Co + B&lt;br /&gt;
&lt;br /&gt;
The three-byte variant is described by [https://stackoverflow.com/a/12146329 David Cary].&lt;br /&gt;
&lt;br /&gt;
[[Category:Compression Theory]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YCoCg&amp;diff=15709</id>
		<title>YCoCg</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YCoCg&amp;diff=15709"/>
		<updated>2023-07-17T04:17:51Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some modern video codecs (e.g. [[Dirac]], [[H.264|H.264 FRExt]]) support the YCoCg colorspace. The correct written expression for this colorspace is YC&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;g&amp;lt;/sub&amp;gt;, with the 'o' and 'g' characters as subscripts. It is also called YC&amp;lt;sub&amp;gt;g&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, following the component order found in [[YCbCr]].&lt;br /&gt;
&lt;br /&gt;
== Technical Details ==&lt;br /&gt;
The various components of the name represent:&lt;br /&gt;
&lt;br /&gt;
* Y  = pseudo luma&lt;br /&gt;
* C&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = &amp;quot;orange chrominance&amp;quot;&lt;br /&gt;
* C&amp;lt;sub&amp;gt;g&amp;lt;/sub&amp;gt; = &amp;quot;green chrominance&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Unlike [[YCbCr]], this colorspace is defined using whole binary fractions, so it is possible to losslessly transform from [[RGB]] to YCoCg when using 2 more bits for YCoCg representation than for RGB. E.g., it is possible to losslessly transform a pixel from a 30-bit RGB frame into a pixel in a 32-bit YCoCg 4:4:4 frame and back. This assumes that each R, G, and B component will have 10 bits of information which Y will have 10 bits and Co and Cg will each have 11 bits.&lt;br /&gt;
&lt;br /&gt;
The use of whole binary fractions is a departure from the human vision model, but do remember that YCbCr &amp;quot;luma&amp;quot; was already a departure from the correct luminance formula. This departure does not make YCoCg worse at separating colors into unrelated components: it actually makes more coding gain [https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/2008_ColorTransforms_MalvarSullivanSrinivasan.pdf on the Kodak image set].&lt;br /&gt;
&lt;br /&gt;
In contrast to [[YCbCr]], this colorspace isn't based on the human vision model. This colorspace was invented to use similar encoding techniques as [[YCbCr|YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt;]] but with frames in [[RGB]] colorspace.&lt;br /&gt;
&lt;br /&gt;
=== YCoCg-R ===&lt;br /&gt;
&lt;br /&gt;
YCoCg-R is the version that takes fewer (2 extra) bits to be losslessly reversible, as opposed to the original version that took 5 extra bits. In modern encoding standards, only YCoCg-R is ever used, so even if you see &amp;quot;ycgco&amp;quot;, it's probably the reversible one.&lt;br /&gt;
&lt;br /&gt;
It is possible to squeeze a bit harder and use ''no'' extra bits, as wraparounds from modulo arithmetic is unambiguous in YCoCg. However, the wraparound causes a discontinuity in the generated components, potentially confusing a codec's predictors and making compression worse. (Remember, YCC pixels is only an intermediate format; making them smaller does not guarantee smaller final sizes!) As a result, no video codec uses this variant. &lt;br /&gt;
&lt;br /&gt;
== Possible Formats ==&lt;br /&gt;
&lt;br /&gt;
Like with [[:Category:YCbCr Formats|YCbCr]] it is also possible to use different plane sizes (chroma subsampling) for each component. Thus, every pixel in an image of a YCoCg encoded frame is associated with one Y sample, but possibly groups of pixels share C&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; and C&amp;lt;sub&amp;gt;g&amp;lt;/sub&amp;gt; samples.&lt;br /&gt;
&lt;br /&gt;
Possible encodings include:&lt;br /&gt;
* YCoCg 4:4:4, analogous to [[YCbCr 4:4:4]]&lt;br /&gt;
* YCoCg 4:2:2, analogous to [[YCbCr 4:2:2]]&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
== Algorithm ==&lt;br /&gt;
&lt;br /&gt;
The algorithm is described in this paper: [http://escher.elis.ugent.be/publ/Edocs/DOC/P105_213.pdf YCoCg(-R) Color Space Conversion on the GPU].&lt;br /&gt;
&lt;br /&gt;
And in the [http://diracvideo.org/download/specification/dirac-spec-latest.pdf dirac spec] in section F.1.5.2.&lt;br /&gt;
&lt;br /&gt;
From RGB to YCoCg:&lt;br /&gt;
 Co = R - B&lt;br /&gt;
  t = B + (Co &amp;gt;&amp;gt; 1)&lt;br /&gt;
 Cg = G - t&lt;br /&gt;
  Y = t + (Cg &amp;gt;&amp;gt; 1)&lt;br /&gt;
&lt;br /&gt;
and back from YCoCg to RGB:&lt;br /&gt;
  t = Y  - (Cg &amp;gt;&amp;gt; 1)&lt;br /&gt;
  G = Cg + t&lt;br /&gt;
  B = t  - (Co &amp;gt;&amp;gt; 1)&lt;br /&gt;
  R = Co + B&lt;br /&gt;
&lt;br /&gt;
The three-byte variant is described by [https://stackoverflow.com/a/12146329 David Cary].&lt;br /&gt;
&lt;br /&gt;
[[Category:Compression Theory]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YCbCr&amp;diff=15708</id>
		<title>YCbCr</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YCbCr&amp;diff=15708"/>
		<updated>2023-07-17T04:05:43Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many modern video codecs rely on a YCbCr colorspace. The correct written expression for this colorspace is YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt;, with the 'b' and 'r' characters as subscripts. This is what the components represent:&lt;br /&gt;
&lt;br /&gt;
* Y = luma, an approximate version of luminance / intensity (See [https://en.wikipedia.org/wiki/Luma_(video) Wikipedia] for how it differs from true luminance)&lt;br /&gt;
* C&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt; = &amp;quot;blue chrominance&amp;quot;, or more precisely the color deviation from gray on a blue-yellow axis&lt;br /&gt;
* C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; = &amp;quot;red chrominance&amp;quot;, or more precisely the color deviation from gray on a red-cyan axis&lt;br /&gt;
&lt;br /&gt;
Green can be calculated based on these three values.&lt;br /&gt;
&lt;br /&gt;
'''YUV''': YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; is often falsely mixed up with YUV. Properly speaking, YUV is the analogue PAL color encoding, where the color components U and V differ from C&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt; and C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt;, found in PAL TV transmission and analogue video tapes. Nevertheless, it's very common for software to call YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; &amp;quot;YUV&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
'''Chroma subsampling:''' Note that with most digital [[RGB]] color encodings, every single pixel has a different R, G and B sample. The same is not true with many YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; (including [[YCoCg|YC&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;g&amp;lt;/sub&amp;gt;]]) color encodings. These YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; variants operate on the empirical evidence that the human eye is more sensitive to variations in the intensity of a pixel rather than variations in color. Thus, every pixel in an image of such a YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; variant has an associated Y sample, but groups of pixels share C&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt; and C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; samples.&lt;br /&gt;
&lt;br /&gt;
There are different matrix coefficients defined to convert encodings in the RGB color space to YCbCr. Among the more important ones are:&lt;br /&gt;
&lt;br /&gt;
* ITU BT.601 Used for Standard Definition television signals&lt;br /&gt;
* ITU T.871 JPEG File Interchange Format (JFIF)&lt;br /&gt;
* ITU BT.709 Used for High definition television (HDTV)&lt;br /&gt;
* ITU BT.2020 Used for Ultra high definition television&lt;br /&gt;
* [[YCoCg]]&lt;br /&gt;
&lt;br /&gt;
Others are proprietary or less widely used, such as those defined in [[Cinepak]] and SMPTE 240M.&lt;br /&gt;
&lt;br /&gt;
For information on specific YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; formats, see the [[:Category:YCbCr Formats|YCbCr formats category page]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Compression Theory]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YCbCr&amp;diff=15707</id>
		<title>YCbCr</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YCbCr&amp;diff=15707"/>
		<updated>2023-07-17T03:47:30Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: eh, not that much&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many modern video codecs rely on a YCbCr colorspace. The correct written expression for this colorspace is YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt;, with the 'b' and 'r' characters as subscripts. This is what the components represent:&lt;br /&gt;
&lt;br /&gt;
* Y = luma, an approximate version of luminance / intensity (See [[Wikipedia:luma]] for difference from true luminance)&lt;br /&gt;
* C&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt; = &amp;quot;blue chrominance&amp;quot;, or more precisely the color deviation from gray on a blue-yellow axis&lt;br /&gt;
* C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; = &amp;quot;red chrominance&amp;quot;, or more precisely the color deviation from gray on a red-cyan axis&lt;br /&gt;
&lt;br /&gt;
Green can be calculated based on these three values.&lt;br /&gt;
&lt;br /&gt;
'''YUV''': YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; is often falsely mixed up with YUV. Properly speaking, YUV is the analogue PAL color encoding, where the color components U and V differ from C&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt; and C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt;, found in PAL TV transmission and analogue video tapes. Nevertheless, it's very common for software to call YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; &amp;quot;YUV&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
'''Chroma subsampling:''' Note that with most digital [[RGB]] color encodings, every single pixel has a different R, G and B sample. The same is not true with many YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; (including [[YCoCg|YC&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;g&amp;lt;/sub&amp;gt;]]) color encodings. These YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; variants operate on the empirical evidence that the human eye is more sensitive to variations in the intensity of a pixel rather than variations in color. Thus, every pixel in an image of such a YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; variant has an associated Y sample, but groups of pixels share C&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt; and C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; samples.&lt;br /&gt;
&lt;br /&gt;
There are different matrix coefficients defined to convert encodings in the RGB color space to YCbCr. Among the more important ones are:&lt;br /&gt;
&lt;br /&gt;
* ITU BT.601 Used for Standard Definition television signals&lt;br /&gt;
* ITU T.871 JPEG File Interchange Format (JFIF)&lt;br /&gt;
* ITU BT.709 Used for High definition television (HDTV)&lt;br /&gt;
* ITU BT.2020 Used for Ultra high definition television&lt;br /&gt;
* [[YCoCg]]&lt;br /&gt;
&lt;br /&gt;
Others are proprietary or less widely used, such as those defined in [[Cinepak]] and SMPTE 240M.&lt;br /&gt;
&lt;br /&gt;
For information on specific YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; formats, see the [[:Category:YCbCr Formats|YCbCr formats category page]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Compression Theory]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YCbCr&amp;diff=15706</id>
		<title>YCbCr</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YCbCr&amp;diff=15706"/>
		<updated>2023-07-17T03:24:23Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: This will do.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many modern video codecs rely on a YCbCr colorspace. The correct written expression for this colorspace is YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt;, with the 'b' and 'r' characters as subscripts. This is what the components represent:&lt;br /&gt;
&lt;br /&gt;
* Y = luma, an approximate version of luminance / intensity (See [[Wikipedia:luma]] for difference from true luminance)&lt;br /&gt;
* C&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt; = &amp;quot;blue chrominance&amp;quot;, or more precisely the color deviation from gray on a blue-yellow axis&lt;br /&gt;
* C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; = &amp;quot;red chrominance&amp;quot;, or more precisely the color deviation from gray on a red-cyan axis&lt;br /&gt;
&lt;br /&gt;
Green can be calculated based on these three values.&lt;br /&gt;
&lt;br /&gt;
'''YUV''': YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; is often falsely mixed up with YUV. Properly speaking, YUV is the analogue PAL color encoding, where the color components U and V differ quite a lot from C&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt; and C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt;, found in PAL TV transmission and analogue video tapes. Nevertheless, it's very common for software to call YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; &amp;quot;YUV&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
'''Chroma subsampling:''' Note that with most digital [[RGB]] color encodings, every single pixel has a different R, G and B sample. The same is not true with many YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; (including [[YCoCg|YC&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;g&amp;lt;/sub&amp;gt;]]) color encodings. These YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; variants operate on the empirical evidence that the human eye is more sensitive to variations in the intensity of a pixel rather than variations in color. Thus, every pixel in an image of such a YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; variant has an associated Y sample, but groups of pixels share C&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt; and C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; samples.&lt;br /&gt;
&lt;br /&gt;
There are different matrix coefficients defined to convert encodings in the RGB color space to YCbCr. Among the more important ones are:&lt;br /&gt;
&lt;br /&gt;
* ITU BT.601 Used for Standard Definition television signals&lt;br /&gt;
* ITU T.871 JPEG File Interchange Format (JFIF)&lt;br /&gt;
* ITU BT.709 Used for High definition television (HDTV)&lt;br /&gt;
* ITU BT.2020 Used for Ultra high definition television&lt;br /&gt;
* [[YCoCg]]&lt;br /&gt;
&lt;br /&gt;
Others are proprietary or less widely used, such as those defined in [[Cinepak]] and SMPTE 240M.&lt;br /&gt;
&lt;br /&gt;
For information on specific YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; formats, see the [[:Category:YCbCr Formats|YCbCr formats category page]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Compression Theory]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YCbCr&amp;diff=15705</id>
		<title>YCbCr</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YCbCr&amp;diff=15705"/>
		<updated>2023-07-17T03:14:59Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many modern video codecs rely on a YCbCr colorspace. The correct written expression for this colorspace is YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt;, with the 'b' and 'r' characters as subscripts. This is what the components represent:&lt;br /&gt;
&lt;br /&gt;
* Y = luma, an approximate version of luminance / intensity&lt;br /&gt;
* C&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt; = &amp;quot;blue chrominance&amp;quot;, or more precisely the color deviation from gray on a blue-yellow axis&lt;br /&gt;
* C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; = &amp;quot;red chrominance&amp;quot;, or more precisely the color deviation from gray on a red-cyan axis&lt;br /&gt;
&lt;br /&gt;
Green can be calculated based on these three values.&lt;br /&gt;
&lt;br /&gt;
YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; is often falsely mixed up with YUV, which is a different colorspace that is not used in digital media but in analog PAL-based stuff as analog TV transmission or analog video tapes.&lt;br /&gt;
&lt;br /&gt;
Note that with most digital [[RGB]] color encodings, every single pixel has a different R, G and B sample. The same is not true with many YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; and also not necessarily true for [[YCoCg|YC&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;g&amp;lt;/sub&amp;gt;]] color encodings. These YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; variants operate on the empirical evidence that the human eye is more sensitive to variations in the intensity of a pixel rather than variations in color. Thus, every pixel in an image of such a YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; variant has an associated Y sample, but groups of pixels share C&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt; and C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; samples.&lt;br /&gt;
&lt;br /&gt;
There are different matrix coefficients defined to convert encodings in the RGB color space to YCbCr. Among the more important ones are:&lt;br /&gt;
&lt;br /&gt;
* ITU BT.601 Used for Standard Definition television signals&lt;br /&gt;
* ITU T.871 JPEG File Interchange Format (JFIF)&lt;br /&gt;
* ITU BT.709 Used for High definition television (HDTV)&lt;br /&gt;
* ITU BT.2020 Used for Ultra high definition television&lt;br /&gt;
* [[YCoCg]]&lt;br /&gt;
&lt;br /&gt;
Others are proprietary or less widely used, such as those defined in [[Cinepak]] and SMPTE 240M.&lt;br /&gt;
&lt;br /&gt;
For information on specific YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; formats, see the [[:Category:YCbCr Formats|YCbCr formats category page]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Compression Theory]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=YCbCr&amp;diff=15704</id>
		<title>YCbCr</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=YCbCr&amp;diff=15704"/>
		<updated>2023-07-17T03:14:44Z</updated>

		<summary type="html">&lt;p&gt;Artoria2e5: not luminance, luma&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many modern video codecs rely on a YCbCr colorspace. The correct written expression for this colorspace is YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt;, with the 'b' and 'r' characters as subscripts. This is what the components represent:&lt;br /&gt;
&lt;br /&gt;
* Y = luma, an approximate version of luminance / intensity&lt;br /&gt;
* C&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt; = &amp;quot;blue chrominance&amp;quot;, or more precisely the color deviation from gray on a blue-yellow axis&lt;br /&gt;
* C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; = &amp;quot;red chrominance&amp;quot;, or more precisely the color deviation from gray on a red-cyan axis&lt;br /&gt;
&lt;br /&gt;
Green can be calculated based on these three values.&lt;br /&gt;
&lt;br /&gt;
YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; is often falsely mixed up with YUV, which is a different colorspace that is not used in digital media but in analog PAL-based stuff as analog TV transmission or analog video tapes.&lt;br /&gt;
&lt;br /&gt;
Note that with most digital [[RGB]] color encodings, every single pixel has a different R, G and B sample. The same is not true with many YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; and also not necessarily true for [[YCoCg|YC&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;g&amp;lt;/sub&amp;gt;]] color encodings. These YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; variants operate on the empirical evidence that the human eye is more sensitive to variations in the intensity of a pixel rather than variations in color. Thus, every pixel in an image of such a YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; variant has an associated Y sample, but groups of pixels share C&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt; and C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; samples.&lt;br /&gt;
&lt;br /&gt;
There are different matrix coefficients defined to convert encodings in the RGB color space to YCbCr. Among the more important ones are:&lt;br /&gt;
&lt;br /&gt;
* ITU BT.601 Used for Standard Definition television signals&lt;br /&gt;
* ITU T.871 JPEG File Interchange Format (JFIF)&lt;br /&gt;
* ITU BT.709 Used for High definition television (HDTV)&lt;br /&gt;
* ITU BT.2020 Used for Ultra high definition television&lt;br /&gt;
&lt;br /&gt;
Others are proprietary or less widely used, such as those defined in [[Cinepak]] and SMPTE 240M.&lt;br /&gt;
&lt;br /&gt;
For information on specific YC&amp;lt;sub&amp;gt;b&amp;lt;/sub&amp;gt;C&amp;lt;sub&amp;gt;r&amp;lt;/sub&amp;gt; formats, see the [[:Category:YCbCr Formats|YCbCr formats category page]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Compression Theory]]&lt;/div&gt;</summary>
		<author><name>Artoria2e5</name></author>
	</entry>
</feed>