YV12和I420的区别

一般来说,直接采集到的视频数据是RGB24的格式,RGB24一帧的大小size=width×heigth×3 Bit,RGB32的size=width×heigth×4,如果是I420(即YUV标准格式4:2:0)的数据量是 size=width×heigth×1.5 Bit。
在采集到RGB24数据后,需要对这个格式的数据进行第一次压缩。即将图像的颜色空间由RGB2YUV。因为,X264在进行编码的时候需要标准的YUV(4:2:0)。但是这里需要注意的是,虽然YV12也是(4:2:0),但是YV12和I420的却是不同的,在存储空间上面有些区别。如下:
YV12 : 亮度(行×列) + V(行×列/4) + U(行×列/4)
I420 : 亮度(行×列) + U(行×列/4) + V(行×列/4)
可以看出,YV12和I420基本上是一样的,就是UV的顺序不同。
继续我们的话题,经过第一次数据压缩后RGB24->YUV(I420)。这样,数据量将减少一半,为什么呢?呵呵,这个就太基础了,我就不多写了。同样,如果是RGB24->YUV(YV12),也是减少一半。但是,虽然都是一半,如果是YV12的话效果就有很大损失。然后,经过X264编码后,数据量将大大减少。将编码后的数据打包,通过RTP实时传送。到达目的地后,将数据取出,进行解码。完成解码后,数据仍然是YUV格式的,所以,还需要一次转换,这样windows的驱动才可以处理,就是YUV2RGB24。

附一个YUV播放器的源代码:http://download.csdn.net/detail/leixiaohua1020/6374065

查看YUV的时候也可以下载使用成熟的YUV播放器 ——YUV Player Deluxe:http://www.yuvplayer.com/

yuv420p就是I420格式,使用极其广泛,它的示意图:

FFMPEG中的swscale提供了视频原始数据(YUV420,YUV422,YUV444,RGB24...)之间的转换,分辨率变换等操作,使用起来十分方便,在这里记录一下它的用法。

swscale主要用于在2个AVFrame之间进行转换。
下面来看一个视频解码的简单例子,这个程序完成了对"北京移动开发者大会茶歇视频2.flv"(其实就是优酷上的一个普通视频)的解码工作,并将解码后的数据保存为原始数据文件(例如YUV420,YUV422,RGB24等等)。其中略去了很多的代码。
注:完整代码在文章:100行代码实现最简单的基于FFMPEG+SDL的视频播放器
[cpp] view plaincopy
  1. //ffmpeg simple player
  2. //
  3. //媒资检索系统子系统
  4. //
  5. //2013 雷霄骅 leixiaohua1020@126.com
  6. //中国传媒大学/数字电视技术
  7. //
  8. #include "stdafx.h"
  9. int _tmain(int argc, _TCHAR* argv[])
  10. {
  11. AVFormatContext *pFormatCtx;
  12. int             i, videoindex;
  13. AVCodecContext  *pCodecCtx;
  14. AVCodec         *pCodec;
  15. char filepath[]="北京移动开发者大会茶歇视频2.flv";
  16. av_register_all();
  17. avformat_network_init();
  18. pFormatCtx = avformat_alloc_context();
  19. if(avformat_open_input(&pFormatCtx,filepath,NULL,NULL)!=0){
  20. printf("无法打开文件\n");
  21. return -1;
  22. }
  23. ......
  24. AVFrame *pFrame,*pFrameYUV;
  25. pFrame=avcodec_alloc_frame();
  26. pFrameYUV=avcodec_alloc_frame();
  27. uint8_t *out_buffer;
  28. out_buffer=new uint8_t[avpicture_get_size(PIX_FMT_RGB24, pCodecCtx->width, pCodecCtx->height)];
  29. avpicture_fill((AVPicture *)pFrameYUV, out_buffer, PIX_FMT_RGB24, pCodecCtx->width, pCodecCtx->height);
  30. /*
  31. out_buffer=new uint8_t[avpicture_get_size(PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height)];
  32. avpicture_fill((AVPicture *)pFrameYUV, out_buffer, PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height);*/
  33. /*
  34. out_buffer=new uint8_t[avpicture_get_size(PIX_FMT_UYVY422, pCodecCtx->width, pCodecCtx->height)];
  35. avpicture_fill((AVPicture *)pFrameYUV, out_buffer, PIX_FMT_UYVY422, pCodecCtx->width, pCodecCtx->height);
  36. out_buffer=new uint8_t[avpicture_get_size(PIX_FMT_YUV422P, pCodecCtx->width, pCodecCtx->height)];
  37. avpicture_fill((AVPicture *)pFrameYUV, out_buffer, PIX_FMT_YUV422P, pCodecCtx->width, pCodecCtx->height);*/
  38. ......
  39. FILE *output=fopen("out.rgb","wb+");
  40. //------------------------------
  41. while(av_read_frame(pFormatCtx, packet)>=0)
  42. {
  43. if(packet->stream_index==videoindex)
  44. {
  45. ret = avcodec_decode_video2(pCodecCtx, pFrame, &got_picture, packet);
  46. if(ret < 0)
  47. {
  48. printf("解码错误\n");
  49. return -1;
  50. }
  51. if(got_picture)
  52. {
  53. /*img_convert_ctx = sws_getContext(pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, PIX_FMT_UYVY422, SWS_BICUBIC, NULL, NULL, NULL);
  54. sws_scale(img_convert_ctx, (const uint8_t* const*)pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameYUV->data, pFrameYUV->linesize);
  55. img_convert_ctx = sws_getContext(pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, PIX_FMT_YUV422P, SWS_BICUBIC, NULL, NULL, NULL);
  56. sws_scale(img_convert_ctx, (const uint8_t* const*)pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameYUV->data, pFrameYUV->linesize);*/
  57. //转换
  58. img_convert_ctx = sws_getContext(pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL);
  59. sws_scale(img_convert_ctx, (const uint8_t* const*)pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameYUV->data, pFrameYUV->linesize);
  60. //RGB
  61. fwrite(pFrameYUV->data[0],(pCodecCtx->width)*(pCodecCtx->height)*3,1,output);
  62. /*
  63. //UYVY
  64. fwrite(pFrameYUV->data[0],(pCodecCtx->width)*(pCodecCtx->height),2,output);
  65. //YUV420P
  66. fwrite(pFrameYUV->data[0],(pCodecCtx->width)*(pCodecCtx->height),1,output);
  67. fwrite(pFrameYUV->data[1],(pCodecCtx->width)*(pCodecCtx->height)/4,1,output);
  68. fwrite(pFrameYUV->data[2],(pCodecCtx->width)*(pCodecCtx->height)/4,1,output);
  69. */
  70. ......
  71. }
  72. }
  73. av_free_packet(packet);
  74. }
  75. fclose(output);
  76. ......
  77. return 0;
  78. }

从代码中可以看出,解码后的视频帧数据保存在pFrame变量中,然后经过swscale函数转换后,将视频帧数据保存在pFrameYUV变量中。最后将pFrameYUV中的数据写入成文件。

在本代码中,将数据保存成了RGB24的格式。如果想保存成其他格式,比如YUV420,YUV422等,需要做2个步骤:

1.初始化pFrameYUV的时候,设定想要转换的格式:

[cpp] view plaincopy
  1. AVFrame *pFrame,*pFrameYUV;
  2. pFrame=avcodec_alloc_frame();
  3. pFrameYUV=avcodec_alloc_frame();
  4. uint8_t *out_buffer;
  5. out_buffer=new uint8_t[avpicture_get_size(PIX_FMT_RGB24, pCodecCtx->width, pCodecCtx->height)];
  6. avpicture_fill((AVPicture *)pFrameYUV, out_buffer, PIX_FMT_RGB24, pCodecCtx->width, pCodecCtx->height);

只需要把PIX_FMT_***改了就可以了

2.在sws_getContext()中更改想要转换的格式:

[cpp] view plaincopy
  1. img_convert_ctx = sws_getContext(pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL);

也是把PIX_FMT_***改了就可以了

最后,如果想将转换后的原始数据存成文件,只需要将pFrameYUV的data指针指向的数据写入文件就可以了。

例如,保存YUV420P格式的数据,用以下代码:

[cpp] view plaincopy
  1. fwrite(pFrameYUV->data[0],(pCodecCtx->width)*(pCodecCtx->height),1,output);
  2. fwrite(pFrameYUV->data[1],(pCodecCtx->width)*(pCodecCtx->height)/4,1,output);
  3. fwrite(pFrameYUV->data[2],(pCodecCtx->width)*(pCodecCtx->height)/4,1,output);

保存RGB24格式的数据,用以下代码:

[cpp] view plaincopy
  1. fwrite(pFrameYUV->data[0],(pCodecCtx->width)*(pCodecCtx->height)*3,1,output);

保存UYVY格式的数据,用以下代码:

[cpp] view plaincopy
  1. fwrite(pFrameYUV->data[0],(pCodecCtx->width)*(pCodecCtx->height),2,output);

在这里又有一个问题,YUV420P格式需要写入data[0],data[1],data[2];而RGB24,UYVY格式却仅仅是写入data[0],他们的区别到底是什么呢?经过研究发现,在FFMPEG中,图像原始数据包括两种:planar和packed。planar就是将几个分量分开存,比如YUV420中,data[0]专门存Y,data[1]专门存U,data[2]专门存V。而packed则是打包存,所有数据都存在data[0]中。

具体哪个格式是planar,哪个格式是packed,可以查看pixfmt.h文件。注:有些格式名称后面是LE或BE,分别对应little-endian或big-endian。另外名字后面有P的是planar格式。

[cpp] view plaincopy
  1. /* 雷霄骅
  2. * 中国传媒大学/数字电视技术
  3. * leixiaohua1020@126.com
  4. *
  5. */
  6. /*
  7. * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
  8. *
  9. * This file is part of FFmpeg.
  10. *
  11. * FFmpeg is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation; either
  14. * version 2.1 of the License, or (at your option) any later version.
  15. *
  16. * FFmpeg is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with FFmpeg; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. */
  25. #ifndef AVUTIL_PIXFMT_H
  26. #define AVUTIL_PIXFMT_H
  27. /**
  28. * @file
  29. * pixel format definitions
  30. *
  31. */
  32. #include "libavutil/avconfig.h"
  33. /**
  34. * Pixel format.
  35. *
  36. * @note
  37. * PIX_FMT_RGB32 is handled in an endian-specific manner. An RGBA
  38. * color is put together as:
  39. *  (A << 24) | (R << 16) | (G << 8) | B
  40. * This is stored as BGRA on little-endian CPU architectures and ARGB on
  41. * big-endian CPUs.
  42. *
  43. * @par
  44. * When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized
  45. * image data is stored in AVFrame.data[0]. The palette is transported in
  46. * AVFrame.data[1], is 1024 bytes long (256 4-byte entries) and is
  47. * formatted the same as in PIX_FMT_RGB32 described above (i.e., it is
  48. * also endian-specific). Note also that the individual RGB palette
  49. * components stored in AVFrame.data[1] should be in the range 0..255.
  50. * This is important as many custom PAL8 video codecs that were designed
  51. * to run on the IBM VGA graphics adapter use 6-bit palette components.
  52. *
  53. * @par
  54. * For all the 8bit per pixel formats, an RGB32 palette is in data[1] like
  55. * for pal8. This palette is filled in automatically by the function
  56. * allocating the picture.
  57. *
  58. * @note
  59. * make sure that all newly added big endian formats have pix_fmt&1==1
  60. * and that all newly added little endian formats have pix_fmt&1==0
  61. * this allows simpler detection of big vs little endian.
  62. */
  63. enum PixelFormat {
  64. PIX_FMT_NONE= -1,
  65. PIX_FMT_YUV420P,   ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
  66. PIX_FMT_YUYV422,   ///< packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
  67. PIX_FMT_RGB24,     ///< packed RGB 8:8:8, 24bpp, RGBRGB...
  68. PIX_FMT_BGR24,     ///< packed RGB 8:8:8, 24bpp, BGRBGR...
  69. PIX_FMT_YUV422P,   ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
  70. PIX_FMT_YUV444P,   ///< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
  71. PIX_FMT_YUV410P,   ///< planar YUV 4:1:0,  9bpp, (1 Cr & Cb sample per 4x4 Y samples)
  72. PIX_FMT_YUV411P,   ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
  73. PIX_FMT_GRAY8,     ///<        Y        ,  8bpp
  74. PIX_FMT_MONOWHITE, ///<        Y        ,  1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb
  75. PIX_FMT_MONOBLACK, ///<        Y        ,  1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb
  76. PIX_FMT_PAL8,      ///< 8 bit with PIX_FMT_RGB32 palette
  77. PIX_FMT_YUVJ420P,  ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_range
  78. PIX_FMT_YUVJ422P,  ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_range
  79. PIX_FMT_YUVJ444P,  ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_range
  80. PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing
  81. PIX_FMT_XVMC_MPEG2_IDCT,
  82. PIX_FMT_UYVY422,   ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
  83. PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
  84. PIX_FMT_BGR8,      ///< packed RGB 3:3:2,  8bpp, (msb)2B 3G 3R(lsb)
  85. PIX_FMT_BGR4,      ///< 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
  86. PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1,  8bpp, (msb)1B 2G 1R(lsb)
  87. PIX_FMT_RGB8,      ///< packed RGB 3:3:2,  8bpp, (msb)2R 3G 3B(lsb)
  88. PIX_FMT_RGB4,      ///< 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
  89. PIX_FMT_RGB4_BYTE, ///< packed RGB 1:2:1,  8bpp, (msb)1R 2G 1B(lsb)
  90. PIX_FMT_NV12,      ///< 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)
  91. PIX_FMT_NV21,      ///< as above, but U and V bytes are swapped
  92. PIX_FMT_ARGB,      ///< packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
  93. PIX_FMT_RGBA,      ///< packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
  94. PIX_FMT_ABGR,      ///< packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
  95. PIX_FMT_BGRA,      ///< packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
  96. PIX_FMT_GRAY16BE,  ///<        Y        , 16bpp, big-endian
  97. PIX_FMT_GRAY16LE,  ///<        Y        , 16bpp, little-endian
  98. PIX_FMT_YUV440P,   ///< planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
  99. PIX_FMT_YUVJ440P,  ///< planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range
  100. PIX_FMT_YUVA420P,  ///< planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
  101. PIX_FMT_VDPAU_H264,///< H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
  102. PIX_FMT_VDPAU_MPEG1,///< MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
  103. PIX_FMT_VDPAU_MPEG2,///< MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
  104. PIX_FMT_VDPAU_WMV3,///< WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
  105. PIX_FMT_VDPAU_VC1, ///< VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
  106. PIX_FMT_RGB48BE,   ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian
  107. PIX_FMT_RGB48LE,   ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian
  108. PIX_FMT_RGB565BE,  ///< packed RGB 5:6:5, 16bpp, (msb)   5R 6G 5B(lsb), big-endian
  109. PIX_FMT_RGB565LE,  ///< packed RGB 5:6:5, 16bpp, (msb)   5R 6G 5B(lsb), little-endian
  110. PIX_FMT_RGB555BE,  ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0
  111. PIX_FMT_RGB555LE,  ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0
  112. PIX_FMT_BGR565BE,  ///< packed BGR 5:6:5, 16bpp, (msb)   5B 6G 5R(lsb), big-endian
  113. PIX_FMT_BGR565LE,  ///< packed BGR 5:6:5, 16bpp, (msb)   5B 6G 5R(lsb), little-endian
  114. PIX_FMT_BGR555BE,  ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1
  115. PIX_FMT_BGR555LE,  ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1
  116. PIX_FMT_VAAPI_MOCO, ///< 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
  117. PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers
  118. PIX_FMT_VAAPI_VLD,  ///< 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
  119. PIX_FMT_YUV420P16LE,  ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
  120. PIX_FMT_YUV420P16BE,  ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
  121. PIX_FMT_YUV422P16LE,  ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
  122. PIX_FMT_YUV422P16BE,  ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
  123. PIX_FMT_YUV444P16LE,  ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
  124. PIX_FMT_YUV444P16BE,  ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
  125. PIX_FMT_VDPAU_MPEG4,  ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
  126. PIX_FMT_DXVA2_VLD,    ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer
  127. PIX_FMT_RGB444LE,  ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0
  128. PIX_FMT_RGB444BE,  ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0
  129. PIX_FMT_BGR444LE,  ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1
  130. PIX_FMT_BGR444BE,  ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1
  131. PIX_FMT_GRAY8A,    ///< 8bit gray, 8bit alpha
  132. PIX_FMT_BGR48BE,   ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian
  133. PIX_FMT_BGR48LE,   ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian
  134. //the following 10 formats have the disadvantage of needing 1 format for each bit depth, thus
  135. //If you want to support multiple bit depths, then using PIX_FMT_YUV420P16* with the bpp stored seperately
  136. //is better
  137. PIX_FMT_YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
  138. PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
  139. PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
  140. PIX_FMT_YUV420P10LE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
  141. PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
  142. PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
  143. PIX_FMT_YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
  144. PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
  145. PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
  146. PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
  147. PIX_FMT_YUV422P9BE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
  148. PIX_FMT_YUV422P9LE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
  149. PIX_FMT_VDA_VLD,    ///< hardware decoding through VDA
  150. #ifdef AV_PIX_FMT_ABI_GIT_MASTER
  151. PIX_FMT_RGBA64BE,  ///< 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
  152. PIX_FMT_RGBA64LE,  ///< 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
  153. PIX_FMT_BGRA64BE,  ///< 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
  154. PIX_FMT_BGRA64LE,  ///< 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
  155. #endif
  156. PIX_FMT_GBRP,      ///< planar GBR 4:4:4 24bpp
  157. PIX_FMT_GBRP9BE,   ///< planar GBR 4:4:4 27bpp, big endian
  158. PIX_FMT_GBRP9LE,   ///< planar GBR 4:4:4 27bpp, little endian
  159. PIX_FMT_GBRP10BE,  ///< planar GBR 4:4:4 30bpp, big endian
  160. PIX_FMT_GBRP10LE,  ///< planar GBR 4:4:4 30bpp, little endian
  161. PIX_FMT_GBRP16BE,  ///< planar GBR 4:4:4 48bpp, big endian
  162. PIX_FMT_GBRP16LE,  ///< planar GBR 4:4:4 48bpp, little endian
  163. #ifndef AV_PIX_FMT_ABI_GIT_MASTER
  164. PIX_FMT_RGBA64BE=0x123,  ///< 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
  165. PIX_FMT_RGBA64LE,  ///< 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
  166. PIX_FMT_BGRA64BE,  ///< 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
  167. PIX_FMT_BGRA64LE,  ///< 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
  168. #endif
  169. PIX_FMT_0RGB=0x123+4,      ///< packed RGB 8:8:8, 32bpp, 0RGB0RGB...
  170. PIX_FMT_RGB0,      ///< packed RGB 8:8:8, 32bpp, RGB0RGB0...
  171. PIX_FMT_0BGR,      ///< packed BGR 8:8:8, 32bpp, 0BGR0BGR...
  172. PIX_FMT_BGR0,      ///< packed BGR 8:8:8, 32bpp, BGR0BGR0...
  173. PIX_FMT_YUVA444P,  ///< planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
  174. PIX_FMT_NB,        ///< 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
  175. };
  176. #define PIX_FMT_Y400A PIX_FMT_GRAY8A
  177. #define PIX_FMT_GBR24P PIX_FMT_GBRP
  178. #if AV_HAVE_BIGENDIAN
  179. #   define PIX_FMT_NE(be, le) PIX_FMT_##be
  180. #else
  181. #   define PIX_FMT_NE(be, le) PIX_FMT_##le
  182. #endif
  183. #define PIX_FMT_RGB32   PIX_FMT_NE(ARGB, BGRA)
  184. #define PIX_FMT_RGB32_1 PIX_FMT_NE(RGBA, ABGR)
  185. #define PIX_FMT_BGR32   PIX_FMT_NE(ABGR, RGBA)
  186. #define PIX_FMT_BGR32_1 PIX_FMT_NE(BGRA, ARGB)
  187. #define PIX_FMT_0RGB32  PIX_FMT_NE(0RGB, BGR0)
  188. #define PIX_FMT_0BGR32  PIX_FMT_NE(0BGR, RGB0)
  189. #define PIX_FMT_GRAY16 PIX_FMT_NE(GRAY16BE, GRAY16LE)
  190. #define PIX_FMT_RGB48  PIX_FMT_NE(RGB48BE,  RGB48LE)
  191. #define PIX_FMT_RGB565 PIX_FMT_NE(RGB565BE, RGB565LE)
  192. #define PIX_FMT_RGB555 PIX_FMT_NE(RGB555BE, RGB555LE)
  193. #define PIX_FMT_RGB444 PIX_FMT_NE(RGB444BE, RGB444LE)
  194. #define PIX_FMT_BGR48  PIX_FMT_NE(BGR48BE,  BGR48LE)
  195. #define PIX_FMT_BGR565 PIX_FMT_NE(BGR565BE, BGR565LE)
  196. #define PIX_FMT_BGR555 PIX_FMT_NE(BGR555BE, BGR555LE)
  197. #define PIX_FMT_BGR444 PIX_FMT_NE(BGR444BE, BGR444LE)
  198. #define PIX_FMT_YUV420P9  PIX_FMT_NE(YUV420P9BE , YUV420P9LE)
  199. #define PIX_FMT_YUV422P9  PIX_FMT_NE(YUV422P9BE , YUV422P9LE)
  200. #define PIX_FMT_YUV444P9  PIX_FMT_NE(YUV444P9BE , YUV444P9LE)
  201. #define PIX_FMT_YUV420P10 PIX_FMT_NE(YUV420P10BE, YUV420P10LE)
  202. #define PIX_FMT_YUV422P10 PIX_FMT_NE(YUV422P10BE, YUV422P10LE)
  203. #define PIX_FMT_YUV444P10 PIX_FMT_NE(YUV444P10BE, YUV444P10LE)
  204. #define PIX_FMT_YUV420P16 PIX_FMT_NE(YUV420P16BE, YUV420P16LE)
  205. #define PIX_FMT_YUV422P16 PIX_FMT_NE(YUV422P16BE, YUV422P16LE)
  206. #define PIX_FMT_YUV444P16 PIX_FMT_NE(YUV444P16BE, YUV444P16LE)
  207. #define PIX_FMT_RGBA64 PIX_FMT_NE(RGBA64BE, RGBA64LE)
  208. #define PIX_FMT_BGRA64 PIX_FMT_NE(BGRA64BE, BGRA64LE)
  209. #define PIX_FMT_GBRP9     PIX_FMT_NE(GBRP9BE ,    GBRP9LE)
  210. #define PIX_FMT_GBRP10    PIX_FMT_NE(GBRP10BE,    GBRP10LE)
  211. #define PIX_FMT_GBRP16    PIX_FMT_NE(GBRP16BE,    GBRP16LE)
  212. #endif /* AVUTIL_PIXFMT_H */
转载:http://blog.csdn.net/leixiaohua1020/article/details/12234821

YV12,I420,YUV420P的区别与格式转换相关推荐

  1. 使用ffmpeg工具进行YUV420P到RGB32的格式转换问题总结

    最近学习ffmpeg相关知识,参照雷神的博客,完成YUV420P到RGB32格式的转换,具体的步骤就不说了,可以自行百度大神们的教程,但是在整个工程的配置以及运行过程中遇到了很多问题,下面一一总结: ...

  2. fasta与fastaq的区别以及格式转换

    1)测序质量值 首先在了解fastq,fasta之前,了解一下什么是质量值.Phred 功能是处理测序仪直接生成的色谱图,给出相应的碱基和质量值.不同的测序仪会给出不同的色谱文件,Phred 能够识别 ...

  3. YV12和I420的区别 yuv420和yuv420p的区别

    YV12和I420的区别   YV12和I420的区别        一般来说,直接采集到的视频数据是RGB24的格式,RGB24一帧的大小size=width×heigth×3 Bit,RGB32的 ...

  4. YV12,I420,YUV420P的区别

    YV12和I420的区别 一般来说,直接采集到的视频数据是RGB24的格式,RGB24一帧的大小size=width×heigth×3 Byte,RGB32的size=width×heigth×4,如 ...

  5. 【Android】直播必备之YUV使用总结 —— 常用的几种格式:NV21/NV12/YV12/YUV420P的区别

    转载自 gitzzp 的博客 [Android]直播必备之YUV使用总结 -- 常用的几种格式:NV21/NV12/YV12/YUV420P的区别 转自:http://www.cnblogs.com/ ...

  6. flac格式转换mp3格式_MP3,FLAC和其他音频格式之间有什么区别?

    flac格式转换mp3格式 Digital audio has been around a very long time so there's bound to be a plethora of au ...

  7. [SSL证书].pfx格式和.Cer格式的区别以及格式互相转换

    现在很多网站都是用了ssl加密的https访问,而且现在网站不使用cdn的话简直是裸奔,但是目前用户最多的360网站卫士和腾讯云提供的免费配置ssl证书支持https访问功能都采取不一样格式的ssl证 ...

  8. base64转cer_[SSL证书].pfx格式和.Cer格式的区别以及格式互相转换

    现在很多网站都是用了ssl加密的https访问,而且现在网站不使用cdn的话简直是裸奔,但是目前用户最多的360网站卫士和腾讯云提供的免费配置ssl证书支持https访问功能都采取不一样格式的ssl证 ...

  9. YUV视频格式到RGB32格式转换的速度优化 上篇(转)

    YUV视频格式到RGB32格式转换的速度优化 上篇                     HouSisong@GMail.com    2007.10.30   tag: YUV,YCbCr,YUV ...

最新文章

  1. java ssm常用注解_SSM框架中常用的注解
  2. 中国移动 全球通、 动感地带、神州行 的区别
  3. Windows平台下安装证书文件cer的步骤
  4. -xdebug java8_多种高级debug方法,帮你更快定位问题
  5. Spring 中的重试机制,简单、实用!
  6. 论Acmer的自我修养 (算法学习目标和推荐题目)
  7. Jenkins--下载安装及简单配置
  8. 云计算,大数据,人工智能本质和概念
  9. 百度指数 数据分析(介绍)
  10. reg型变量怎么赋值_FPGA的wire和reg类型变量
  11. 【Java爬虫】爬取南通大学教务处成绩
  12. 服务器显示拥挤进不去怎么办,《拥挤城市》游戏进不去怎么办 玩不了解决方法...
  13. 二级管/三极管门电路原理
  14. 微信 8.0 的状态原来这么炸裂,无情地爱了爱了,做程序员的你还不赶紧设置一把?
  15. 让SpringBoot不需要Controller、Service、DAO、Mapper,卧槽!这款工具
  16. WKWebView使用及注意点(keng)
  17. 两位数求和(xhh)
  18. CopyOnWriteArraySet
  19. 文本分类(text classification)
  20. linux内核栈与用户栈及调用栈观察方法

热门文章

  1. 应急照明市电检测_A型0.5KVA应急照明集中电源ty-d市电检测 市电监测
  2. 3D游戏编程与设计——游戏的本质章节作业与练习
  3. XDOJ 1202: The Offer - Lunatic
  4. 什么叫水平,不是看懂了叫水平,也不是会用了就叫水平,更不是懂得更多才叫有水平,而是知道如何做才能做得更好才叫真正有水平?...
  5. 麦克风产品 麦克风元器件 市场调研
  6. 【035】中国地震台网–及时了解官方报道地震信息
  7. SWUST OJ 77: 计算员工周工资
  8. java 帕斯卡,帕斯卡三角 有多少种可能,java编程 帕斯卡三角形 立刻求高手!! 给满分...
  9. php文件直链源码,蓝奏网盘文件夹直链解析源码
  10. coreldraw凸起字符_CorelDRAW X7制作凹凸字效果