ffmpeg中的像素格式
pixdesc.c文件中定义的av_pix_fmt_descriptors列表定义了一帧图片在小于等于4个平面上存储方式
https://blog.csdn.net/qq_24868923/article/details/108165101
/** * Descriptor that unambiguously describes how the bits of a pixel are * stored in the up to 4 data planes of an image. It also stores the * subsampling factors and number of components. * * @note This is separate of the colorspace (RGB, YCbCr, YPbPr, JPEG-style YUV * and all the YUV variants) AVPixFmtDescriptor just stores how values * are stored not what these values represent. */ typedef struct AVPixFmtDescriptor { const char *name; uint8_t nb_components; ///< The number of components each pixel has, (1-4) /** * Amount to shift the luma width right to find the chroma width. * For YV12 this is 1 for example. * chroma_width = AV_CEIL_RSHIFT(luma_width, log2_chroma_w) * The note above is needed to ensure rounding up. * This value only refers to the chroma components. */ uint8_t log2_chroma_w; /** * Amount to shift the luma height right to find the chroma height. * For YV12 this is 1 for example. * chroma_height= AV_CEIL_RSHIFT(luma_height, log2_chroma_h) * The note above is needed to ensure rounding up. * This value only refers to the chroma components. */ uint8_t log2_chroma_h; /** * Combination of AV_PIX_FMT_FLAG_... flags. */ uint64_t flags; /** * Parameters that describe how pixels are packed. * If the format has 1 or 2 components, then luma is 0. * If the format has 3 or 4 components: * if the RGB flag is set then 0 is red, 1 is green and 2 is blue; * otherwise 0 is luma, 1 is chroma-U and 2 is chroma-V. * * If present, the Alpha channel is always the last component. */ AVComponentDescriptor comp[4]; /** * Alternative comma-separated names. */ const char *alias; } AVPixFmtDescriptor; typedef struct AVComponentDescriptor { /** * Which of the 4 planes contains the component. */ int plane; /** * Number of elements between 2 horizontally consecutive pixels. * Elements are bits for bitstream formats, bytes otherwise. */ int step; /** * Number of elements before the component of the first pixel. * Elements are bits for bitstream formats, bytes otherwise. */ int offset; /** * Number of least significant bits that must be shifted away * to get the value. */ int shift; /** * Number of bits in the component. */ int depth; #if FF_API_PLUS1_MINUS1 /** deprecated, use step instead */ attribute_deprecated int step_minus1; /** deprecated, use depth instead */ attribute_deprecated int depth_minus1; /** deprecated, use offset instead */ attribute_deprecated int offset_plus1; #endif } AVComponentDescriptor;
// 像素名 name : yuv420p // comp成员所有的像素个数, (1-4) nb_components : 3 // 仅对有亮度的像素组成的像素格式有效,表示右移多少位 亮度的宽 来得到 色度的宽 | 如 yuv420 1920x1080 : Y 宽 :1920 则 UV 色度的宽 : 1920 >> 1 : 960 log2_chroma_w : 1 // 同上 表示右移多少位 亮度的高来得到 色度的高. log2_chroma_h : 1 // AV_PIX_FMT_FLAG_ 标志的组合 flags : 16 // 以逗号分隔的替代像素名,大部分为空. alias : (null) // comp[4] 描述像素如何包装的参数, 大小 nb_components 指定. // 如果该像素格式包含1或2个分量,则luma(亮度分量)为0平面。 // 如果该像素格式包含3或4个分量组成: // 如果设置了RGB标志,则0为红色,1为绿色,2为蓝色; // 否则0为亮度,1为色度U,2为色度V。 // 如果存在Alpha(透明通道),则Alpha通道始终是最后一个分量(4), 如 YUVA420 // plane :四个平面中的第几平面, 对应存储在frame->data[plane]中. // step :2个水平连续像素之间的元素数,或者可理解为步长,偏移。step和offset 可以对比下 nv12 和 yuyv 422 的存储理解下, 下面有栗子 // offset :第一个像素分量之前的元素数。 // shift :必须移走的最低有效位数。 // depth :常见的位深, bit/pix comp[0] : plane : 0, step : 1, offset : 0, shift : 0, depth : 8 comp[1] : plane : 1, step : 1, offset : 0, shift : 0, depth : 8 comp[2] : plane : 2, step : 1, offset : 0, shift : 0, depth : 8
来源:https://blog.csdn.net/qq_17308321/article/details/106843595
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App