天天看点

FFMPEG的像素格式

<code>#include "libavutil/avconfig.h"</code>

<a target="_blank" href="http://ffmpeg.org/doxygen/trunk/pixfmt_8h_source.html">go to the source code of this file.</a>

#define 

enum  

}

<a target="_blank"></a>

pixel format definitions

#define avpalette_size   1024

#define avpalette_count   256

#define av_pix_fmt_ne

(

be,

)

#define pix_fmt_ne

pixel format.

<dl></dl>

<dt>note</dt>

<dd>av_pix_fmt_rgb32 is handled in an endian-specific manner. an rgba color is put together as: (a &lt;&lt; 24) | (r &lt;&lt; 16) | (g &lt;&lt; 8) | b this is stored as bgra on little-endian cpu architectures and argb on big-endian cpus.</dd>

<dt></dt>

<dd>for all the 8bit per pixel formats, an rgb32 palette is in data[1] like for pal8. this palette is filled in automatically by the function allocating the picture.</dd>

<dd>make sure that all newly added big-endian formats have (pix_fmt &amp; 1) == 1 and that all newly added little-endian formats have (pix_fmt &amp; 1) == 0. this allows simpler detection of big vs little-endian.</dd>

<dt>enumerator:</dt>

<dd></dd>

planar yuv 4:2:0, 12bpp, (1 cr &amp; cb sample per 2x2 y samples)

packed yuv 4:2:2, 16bpp, y0 cb y1 cr

packed rgb 8:8:8, 24bpp, rgbrgb...

packed rgb 8:8:8, 24bpp, bgrbgr...

planar yuv 4:2:2, 16bpp, (1 cr &amp; cb sample per 2x1 y samples)

planar yuv 4:4:4, 24bpp, (1 cr &amp; cb sample per 1x1 y samples)

planar yuv 4:1:0, 9bpp, (1 cr &amp; cb sample per 4x4 y samples)

planar yuv 4:1:1, 12bpp, (1 cr &amp; cb sample per 4x1 y samples)

y , 8bpp.

y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb.

y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb.

8 bit with pix_fmt_rgb32 palette

planar yuv 4:2:0, 12bpp, full scale (jpeg), deprecated in favor of pix_fmt_yuv420p and setting color_range

planar yuv 4:2:2, 16bpp, full scale (jpeg), deprecated in favor of pix_fmt_yuv422p and setting color_range

planar yuv 4:4:4, 24bpp, full scale (jpeg), deprecated in favor of pix_fmt_yuv444p and setting color_range

xvideo motion acceleration via common packet passing.

packed yuv 4:2:2, 16bpp, cb y0 cr y1

packed yuv 4:1:1, 12bpp, cb y0 y1 cr y2 y3

packed rgb 3:3:2, 8bpp, (msb)2b 3g 3r(lsb)

packed rgb 1:2:1 bitstream, 4bpp, (msb)1b 2g 1r(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits

packed rgb 1:2:1, 8bpp, (msb)1b 2g 1r(lsb)

packed rgb 3:3:2, 8bpp, (msb)2r 3g 3b(lsb)

packed rgb 1:2:1 bitstream, 4bpp, (msb)1r 2g 1b(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits

packed rgb 1:2:1, 8bpp, (msb)1r 2g 1b(lsb)

planar yuv 4:2:0, 12bpp, 1 plane for y and 1 plane for the uv components, which are interleaved (first byte u and the following byte v)

as above, but u and v bytes are swapped

packed argb 8:8:8:8, 32bpp, argbargb...

packed rgba 8:8:8:8, 32bpp, rgbargba...

packed abgr 8:8:8:8, 32bpp, abgrabgr...

packed bgra 8:8:8:8, 32bpp, bgrabgra...

y , 16bpp, big-endian.

y , 16bpp, little-endian.

planar yuv 4:4:0 (1 cr &amp; cb sample per 1x2 y samples)

planar yuv 4:4:0 full scale (jpeg), deprecated in favor of pix_fmt_yuv440p and setting color_range

planar yuv 4:2:0, 20bpp, (1 cr &amp; cb sample per 2x2 y &amp; a samples)

packed rgb 16:16:16, 48bpp, 16r, 16g, 16b, the 2-byte value for each r/g/b component is stored as big-endian

packed rgb 16:16:16, 48bpp, 16r, 16g, 16b, the 2-byte value for each r/g/b component is stored as little-endian

packed rgb 5:6:5, 16bpp, (msb) 5r 6g 5b(lsb), big-endian

packed rgb 5:6:5, 16bpp, (msb) 5r 6g 5b(lsb), little-endian

packed rgb 5:5:5, 16bpp, (msb)1a 5r 5g 5b(lsb), big-endian, most significant bit to 0

packed rgb 5:5:5, 16bpp, (msb)1a 5r 5g 5b(lsb), little-endian, most significant bit to 0

packed bgr 5:6:5, 16bpp, (msb) 5b 6g 5r(lsb), big-endian

packed bgr 5:6:5, 16bpp, (msb) 5b 6g 5r(lsb), little-endian

packed bgr 5:5:5, 16bpp, (msb)1a 5b 5g 5r(lsb), big-endian, most significant bit to 1

packed bgr 5:5:5, 16bpp, (msb)1a 5b 5g 5r(lsb), little-endian, most significant bit to 1

hw acceleration through va api at motion compensation entry-point, picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers.

hw acceleration through va api at idct entry-point, picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers.

hw decoding through va api, picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers.

planar yuv 4:2:0, 24bpp, (1 cr &amp; cb sample per 2x2 y samples), little-endian

planar yuv 4:2:0, 24bpp, (1 cr &amp; cb sample per 2x2 y samples), big-endian

planar yuv 4:2:2, 32bpp, (1 cr &amp; cb sample per 2x1 y samples), little-endian

planar yuv 4:2:2, 32bpp, (1 cr &amp; cb sample per 2x1 y samples), big-endian

planar yuv 4:4:4, 48bpp, (1 cr &amp; cb sample per 1x1 y samples), little-endian

planar yuv 4:4:4, 48bpp, (1 cr &amp; cb sample per 1x1 y samples), big-endian

hw decoding through dxva2, picture.data[3] contains a lpdirect3dsurface9 pointer.

packed rgb 4:4:4, 16bpp, (msb)4a 4r 4g 4b(lsb), little-endian, most significant bits to 0

packed rgb 4:4:4, 16bpp, (msb)4a 4r 4g 4b(lsb), big-endian, most significant bits to 0

packed bgr 4:4:4, 16bpp, (msb)4a 4b 4g 4r(lsb), little-endian, most significant bits to 1

packed bgr 4:4:4, 16bpp, (msb)4a 4b 4g 4r(lsb), big-endian, most significant bits to 1

8bit gray, 8bit alpha

alias for av_pix_fmt_ya8

packed rgb 16:16:16, 48bpp, 16b, 16g, 16r, the 2-byte value for each r/g/b component is stored as big-endian

packed rgb 16:16:16, 48bpp, 16b, 16g, 16r, the 2-byte value for each r/g/b component is stored as little-endian

the following 12 formats have the disadvantage of needing 1 format for each bit depth.

notice that each 9/10 bits sample is stored in 16 bits with extra padding. if you want to support multiple bit depths, then using av_pix_fmt_yuv420p16* with the bpp stored separately is better.planar yuv 4:2:0, 13.5bpp, (1 cr &amp; cb sample per 2x2 y samples), big-endian

planar yuv 4:2:0, 13.5bpp, (1 cr &amp; cb sample per 2x2 y samples), little-endian

planar yuv 4:2:0, 15bpp, (1 cr &amp; cb sample per 2x2 y samples), big-endian

planar yuv 4:2:0, 15bpp, (1 cr &amp; cb sample per 2x2 y samples), little-endian

planar yuv 4:2:2, 20bpp, (1 cr &amp; cb sample per 2x1 y samples), big-endian

planar yuv 4:2:2, 20bpp, (1 cr &amp; cb sample per 2x1 y samples), little-endian

planar yuv 4:4:4, 27bpp, (1 cr &amp; cb sample per 1x1 y samples), big-endian

planar yuv 4:4:4, 27bpp, (1 cr &amp; cb sample per 1x1 y samples), little-endian

planar yuv 4:4:4, 30bpp, (1 cr &amp; cb sample per 1x1 y samples), big-endian

planar yuv 4:4:4, 30bpp, (1 cr &amp; cb sample per 1x1 y samples), little-endian

planar yuv 4:2:2, 18bpp, (1 cr &amp; cb sample per 2x1 y samples), big-endian

planar yuv 4:2:2, 18bpp, (1 cr &amp; cb sample per 2x1 y samples), little-endian

hardware decoding through vda

planar gbr 4:4:4 24bpp

planar gbr 4:4:4 27bpp, big-endian

planar gbr 4:4:4 27bpp, little-endian

planar gbr 4:4:4 30bpp, big-endian

planar gbr 4:4:4 30bpp, little-endian

planar gbr 4:4:4 48bpp, big-endian

planar gbr 4:4:4 48bpp, little-endian

duplicated pixel formats for compatibility with libav.

ffmpeg supports these formats since may 8 2012 and jan 28 2012 (commits f9ca1ac7 and 143a5c55) libav added them oct 12 2012 with incompatible values (commit 6d5600e85)planar yuv 4:2:2 24bpp, (1 cr &amp; cb sample per 2x1 y &amp; a samples)

planar yuv 4:4:4 32bpp, (1 cr &amp; cb sample per 1x1 y &amp; a samples)

planar yuv 4:2:0 22.5bpp, (1 cr &amp; cb sample per 2x2 y &amp; a samples), big-endian

planar yuv 4:2:0 22.5bpp, (1 cr &amp; cb sample per 2x2 y &amp; a samples), little-endian

planar yuv 4:2:2 27bpp, (1 cr &amp; cb sample per 2x1 y &amp; a samples), big-endian

planar yuv 4:2:2 27bpp, (1 cr &amp; cb sample per 2x1 y &amp; a samples), little-endian

planar yuv 4:4:4 36bpp, (1 cr &amp; cb sample per 1x1 y &amp; a samples), big-endian

planar yuv 4:4:4 36bpp, (1 cr &amp; cb sample per 1x1 y &amp; a samples), little-endian

planar yuv 4:2:0 25bpp, (1 cr &amp; cb sample per 2x2 y &amp; a samples, big-endian)

planar yuv 4:2:0 25bpp, (1 cr &amp; cb sample per 2x2 y &amp; a samples, little-endian)

planar yuv 4:2:2 30bpp, (1 cr &amp; cb sample per 2x1 y &amp; a samples, big-endian)

planar yuv 4:2:2 30bpp, (1 cr &amp; cb sample per 2x1 y &amp; a samples, little-endian)

planar yuv 4:4:4 40bpp, (1 cr &amp; cb sample per 1x1 y &amp; a samples, big-endian)

planar yuv 4:4:4 40bpp, (1 cr &amp; cb sample per 1x1 y &amp; a samples, little-endian)

planar yuv 4:2:0 40bpp, (1 cr &amp; cb sample per 2x2 y &amp; a samples, big-endian)

planar yuv 4:2:0 40bpp, (1 cr &amp; cb sample per 2x2 y &amp; a samples, little-endian)

planar yuv 4:2:2 48bpp, (1 cr &amp; cb sample per 2x1 y &amp; a samples, big-endian)

planar yuv 4:2:2 48bpp, (1 cr &amp; cb sample per 2x1 y &amp; a samples, little-endian)

planar yuv 4:4:4 64bpp, (1 cr &amp; cb sample per 1x1 y &amp; a samples, big-endian)

planar yuv 4:4:4 64bpp, (1 cr &amp; cb sample per 1x1 y &amp; a samples, little-endian)

hw acceleration through vdpau, picture.data[3] contains a vdpvideosurface.

packed xyz 4:4:4, 36 bpp, (msb) 12x, 12y, 12z (lsb), the 2-byte value for each x/y/z is stored as little-endian, the 4 lower bits are set to 0

packed xyz 4:4:4, 36 bpp, (msb) 12x, 12y, 12z (lsb), the 2-byte value for each x/y/z is stored as big-endian, the 4 lower bits are set to 0

interleaved chroma yuv 4:2:2, 16bpp, (1 cr &amp; cb sample per 2x1 y samples)

interleaved chroma yuv 4:2:2, 20bpp, (1 cr &amp; cb sample per 2x1 y samples), little-endian

interleaved chroma yuv 4:2:2, 20bpp, (1 cr &amp; cb sample per 2x1 y samples), big-endian

ffmpeg supports these formats since sat sep 24 06:01:45 2011 +0200 (commits 9569a3c9f41387a8c7d1ce97d8693520477a66c3) also see fri nov 25 01:38:21 2011 +0100 92afb431621c79155fcb7171d26f137eb1bee028 libav added them sun mar 16 23:05:47 2014 +0100 with incompatible values (commit 1481d24c3a0abf81e1d7a514547bd5305232be30)packed rgba 16:16:16:16, 64bpp, 16r, 16g, 16b, 16a, the 2-byte value for each r/g/b/a component is stored as big-endian

packed rgba 16:16:16:16, 64bpp, 16r, 16g, 16b, 16a, the 2-byte value for each r/g/b/a component is stored as little-endian

packed rgba 16:16:16:16, 64bpp, 16b, 16g, 16r, 16a, the 2-byte value for each r/g/b/a component is stored as big-endian

packed rgba 16:16:16:16, 64bpp, 16b, 16g, 16r, 16a, the 2-byte value for each r/g/b/a component is stored as little-endian

packed yuv 4:2:2, 16bpp, y0 cr y1 cb

hw acceleration through vda, data[3] contains a cvpixelbufferref.

16bit gray, 16bit alpha (big-endian)

16bit gray, 16bit alpha (little-endian)

packed rgba 16:16:16:16, 64bpp, 16r, 16g, 16b, 16a, the 2-byte value for each r/g/b/a component is stored as big-endian

packed rgb 8:8:8, 32bpp, 0rgb0rgb...

packed rgb 8:8:8, 32bpp, rgb0rgb0...

packed bgr 8:8:8, 32bpp, 0bgr0bgr...

packed bgr 8:8:8, 32bpp, bgr0bgr0...

planar yuv 4:2:2 24bpp, (1 cr &amp; cb sample per 2x1 y &amp; a samples)

planar yuv 4:2:0,18bpp, (1 cr &amp; cb sample per 2x2 y samples), big-endian

planar yuv 4:2:0,18bpp, (1 cr &amp; cb sample per 2x2 y samples), little-endian

planar yuv 4:2:0,21bpp, (1 cr &amp; cb sample per 2x2 y samples), big-endian

planar yuv 4:2:0,21bpp, (1 cr &amp; cb sample per 2x2 y samples), little-endian

planar yuv 4:2:2,24bpp, (1 cr &amp; cb sample per 2x1 y samples), big-endian

planar yuv 4:2:2,24bpp, (1 cr &amp; cb sample per 2x1 y samples), little-endian

planar yuv 4:2:2,28bpp, (1 cr &amp; cb sample per 2x1 y samples), big-endian

planar yuv 4:2:2,28bpp, (1 cr &amp; cb sample per 2x1 y samples), little-endian

planar yuv 4:4:4,36bpp, (1 cr &amp; cb sample per 1x1 y samples), big-endian

planar yuv 4:4:4,36bpp, (1 cr &amp; cb sample per 1x1 y samples), little-endian

planar yuv 4:4:4,42bpp, (1 cr &amp; cb sample per 1x1 y samples), big-endian

planar yuv 4:4:4,42bpp, (1 cr &amp; cb sample per 1x1 y samples), little-endian

planar gbr 4:4:4 36bpp, big-endian

planar gbr 4:4:4 36bpp, little-endian

planar gbr 4:4:4 42bpp, big-endian

planar gbr 4:4:4 42bpp, little-endian

planar gbra 4:4:4:4 32bpp

planar gbra 4:4:4:4 64bpp, big-endian

planar gbra 4:4:4:4 64bpp, little-endian

planar yuv 4:1:1, 12bpp, (1 cr &amp; cb sample per 4x1 y samples) full scale (jpeg), deprecated in favor of pix_fmt_yuv411p and setting color_range

bayer, bgbg..(odd line), grgr..(even line), 8-bit samples */

bayer, rgrg..(odd line), gbgb..(even line), 8-bit samples */

bayer, gbgb..(odd line), rgrg..(even line), 8-bit samples */

bayer, grgr..(odd line), bgbg..(even line), 8-bit samples */

bayer, bgbg..(odd line), grgr..(even line), 16-bit samples, little-endian */

bayer, bgbg..(odd line), grgr..(even line), 16-bit samples, big-endian */

bayer, rgrg..(odd line), gbgb..(even line), 16-bit samples, little-endian */

bayer, rgrg..(odd line), gbgb..(even line), 16-bit samples, big-endian */

bayer, gbgb..(odd line), rgrg..(even line), 16-bit samples, little-endian */

bayer, gbgb..(odd line), rgrg..(even line), 16-bit samples, big-endian */

bayer, grgr..(odd line), bgbg..(even line), 16-bit samples, little-endian */

bayer, grgr..(odd line), bgbg..(even line), 16-bit samples, big-endian */

number of pixel formats, do not use this if you want to link with shared libav* because the number of formats might differ between versions

planar yuv 4:2:0, 13.5bpp, (1 cr &amp; cb sample per 2x2 y samples), big-endian

planar gbr 4:4:4 27bpp, big endian

planar gbr 4:4:4 27bpp, little endian

planar gbr 4:4:4 30bpp, big endian

planar gbr 4:4:4 30bpp, little endian

planar gbr 4:4:4 48bpp, big endian

planar gbr 4:4:4 48bpp, little endian

planar gbr 4:4:4 36bpp, big endian

planar gbr 4:4:4 36bpp, little endian

planar gbr 4:4:4 42bpp, big endian

planar gbr 4:4:4 42bpp, little endian

chromaticity coordinates of the source primaries.

also itu-r bt1361 / iec 61966-2-4 / smpte rp177 annex b

also itu-r bt601-6 625 / itu-r bt1358 625 / itu-r bt1700 625 pal &amp; secam

also itu-r bt601-6 525 / itu-r bt1358 525 / itu-r bt1700 ntsc

functionally identical to above

colour filters using illuminant c

itu-r bt2020.

not part of abi.

color transfer characteristic.

also itu-r bt1361

also itu-r bt470m / itu-r bt1700 625 pal &amp; secam

also itu-r bt470bg

also itu-r bt601-6 525 or 625 / itu-r bt1358 525 or 625 / itu-r bt1700 ntsc

"linear transfer characteristics"

"logarithmic transfer characteristic (100:1 range)"

"logarithmic transfer characteristic (100 * sqrt(10) : 1 range)"

iec 61966-2-4.

itu-r bt1361 extended colour gamut.

iec 61966-2-1 (srgb or sycc)

itu-r bt2020 for 10 bit system.

itu-r bt2020 for 12 bit system.

yuv colorspace type.

order of coefficients is actually gbr, also iec 61966-2-1 (srgb)

also itu-r bt1361 / iec 61966-2-4 xvycc709 / smpte rp177 annex b

also itu-r bt601-6 625 / itu-r bt1358 625 / itu-r bt1700 625 pal &amp; secam / iec 61966-2-4 xvycc601

also itu-r bt601-6 525 / itu-r bt1358 525 / itu-r bt1700 ntsc / functionally identical to above

used by dirac / vc-2 and h.264 frext, see itu-t sg16.

itu-r bt2020 non-constant luminance system.

itu-r bt2020 constant luminance system.

mpeg vs jpeg yuv range.

the normal 219*2^(n-8) "mpeg" yuv ranges

the normal 2^n-1 "jpeg" yuv ranges

location of chroma samples.

x x 3 4 x x are luma samples, 1 2 1-6 are possible chroma positions x x 5 6 x 0 is undefined/unknown position

mpeg2/4, h264 default

mpeg1, jpeg, h263

dv.

继续阅读