首页 > 其他分享 >ffmpeg中的像素格式

ffmpeg中的像素格式

时间:2022-10-20 08:11:24浏览次数:60  
标签:ffmpeg int chroma 像素 step components offset 格式

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

标签:ffmpeg,int,chroma,像素,step,components,offset,格式
From: https://www.cnblogs.com/8335IT/p/16807195.html

相关文章