对x264_param_t 的注释

本文详细介绍了x264编码器的参数配置结构,包括CPU标志位、视频属性、Vui参数集、流参数等。此外还深入探讨了熵编码、量化、去块滤波器等设置,并解析了日志记录、分析参数、码率控制等多个方面的配置选项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

typedef struct x264_param_t
{
    /* CPU 标志位 */
    unsigned int cpu;
    int         i_threads;       /* 并行编码多帧 */
    int         b_deterministic; /*是否允许非确定性时线程优化*/
    int         i_sync_lookahead; /* 线程超前缓冲 */

    /* 视频属性 */
    int         i_width; /* 宽度*/
    int         i_height; /* 高度*/
    int         i_csp;  /* 编码比特流的CSP,仅支持i420,色彩空间设置 */
    int         i_level_idc; /* level值的设置*/
    int         i_frame_total; /* 编码帧的总数, 默认 0 */
/*Vui参数集视频可用性信息视频标准化选项 */
    struct
    {
        /* they will be reduced to be 0 < x <= 65535 and prime */
        int         i_sar_height;
        int         i_sar_width; /* 设置长宽比 */

        int         i_overscan;    /* 0=undef, 1=no overscan, 2=overscan 过扫描线,默认"undef"(不设置),可选项:show(观看)/crop(去除)*/

        /*见以下的值h264附件E */
        Int       i_vidformat;/* 视频格式,默认"undef",component/pal/ntsc/secam/mac/undef*/
        int       b_fullrange; /*Specify full range samples setting,默认"off",可选项:off/on*/
        int       i_colorprim; /*原始色度格式,默认"undef",可选项:undef/bt709/bt470m/bt470bg,smpte170m/smpte240m/film*/
        int   i_transfer; /*转换方式,默认"undef",可选项:undef/bt709/bt470m/bt470bg/linear,log100/log316/smpte170m/smpte240m*/
        int  i_colmatrix; /*色度矩阵设置,默认"undef",undef/bt709/fcc/bt470bg,smpte170m/smpte240m/GBR/YCgCo*/
        int         i_chroma_loc;    /* both top & bottom色度样本指定,范围0~5,默认0 */
    } vui;

    int         i_fps_num;
    int         i_fps_den;
/*这两个参数是由fps帧率确定的,赋值的过程见下:
{        float fps;       
if( sscanf( value, "%d/%d", &p->i_fps_num, &p->i_fps_den ) == 2 )
            ;
        else if( sscanf( value, "%f", &fps ) )
        {
            p->i_fps_num = (int)(fps * 1000 + .5);
            p->i_fps_den = 1000;
        }
        else
            b_error = 1;
    }
Value的值就是fps。*/

    /*流参数 */
    int         i_frame_reference;  /* 参考帧最大数目 */
    int         i_keyint_max;       /* 在此间隔设置IDR关键帧 */
    int         i_keyint_min;       /* 场景切换少于次值编码位I, 而不是 IDR. */
    int         i_scenecut_threshold; /*如何积极地插入额外的I帧 */
    int         i_bframe;   /*两个相关图像间P帧的数目 */
    int         i_bframe_adaptive; /*自适应B帧判定*/
    int         i_bframe_bias; /*控制插入B帧判定,范围-100~+100,越高越容易插入B帧,默认0*/
    int         b_bframe_pyramid;   /*允许部分B为参考帧 */
/*去块滤波器需要的参数*/
    int         b_deblocking_filter;
    int         i_deblocking_filter_alphac0;    /* [-6, 6] -6 light filter, 6 strong */
    int         i_deblocking_filter_beta;       /* [-6, 6]  idem */
   /*熵编码 */
    int         b_cabac;
    int         i_cabac_init_idc;

    int         b_interlaced; /* 隔行扫描 */
    /*量化 */
    int         i_cqm_preset;         /*自定义量化矩阵(CQM),初始化量化模式为flat*/
    char        *psz_cqm_file;      /* JM format读取JM格式的外部量化矩阵文件,自动忽略其他—cqm 选项*/
    uint8_t     cqm_4iy[16];        /* used only if i_cqm_preset == X264_CQM_CUSTOM */
    uint8_t     cqm_4ic[16];
    uint8_t     cqm_4py[16];
    uint8_t     cqm_4pc[16];
    uint8_t     cqm_8iy[64];
    uint8_t     cqm_8py[64];

    /* 日志 */
    void        (*pf_log)( void *, int i_level, const char *psz, va_list );
    void        *p_log_private;
    int         i_log_level;
    int         b_visualize;
    char        *psz_dump_yuv;  /* 重建帧的名字 */

    /* 编码分析参数*/
    struct
    {
        unsigned int intra;     /* 帧间分区*/
        unsigned int inter;     /* 帧内分区 */

        int          b_transform_8x8; /* 帧间分区*/
        int          b_weighted_bipred; /*为b帧隐式加权 */
        int          i_direct_mv_pred; /*时间空间队运动预测 */
        int          i_chroma_qp_offset; /*色度量化步长偏移量 */

        int          i_me_method; /* 运动估计算法 (X264_ME_*) */
        int          i_me_range; /* 整像素运动估计搜索范围 (from predicted mv) */
        int          i_mv_range; /* 运动矢量最大长度(in pixels). -1 = auto, based on level */
        int          i_mv_range_thread; /* 线程之间的最小空间. -1 = auto, based on number of threads. */
        int          i_subpel_refine; /* 亚像素运动估计质量 */
        int          b_chroma_me; /* 亚像素色度运动估计和P帧的模式选择 */
        int          b_mixed_references; /*允许每个宏块的分区在P帧有它自己的参考号*/
        int          i_trellis;  /* Trellis量化,对每个8x8的块寻找合适的量化值,需要CABAC,默认0 0:关闭1:只在最后编码时使用2:一直使用*/
        int          b_fast_pskip; /*快速P帧跳过检测*/
        int          b_dct_decimate; /* 在P-frames转换参数域 */
        int          i_noise_reduction; /*自适应伪盲区 */
        float        f_psy_rd; /* Psy RD strength */
        float        f_psy_trellis; /* Psy trellis strength */
        int          b_psy; /* Toggle all psy optimizations */

        /*,亮度量化中使用的无效区大小*/
        int          i_luma_deadzone[2]; /* {帧间, 帧内} */

        int          b_psnr;    /* 计算和打印PSNR信息 */
        int          b_ssim;    /*计算和打印SSIM信息*/
    } analyse;

    /* 码率控制参数 */
    struct
    {
        int         i_rc_method;    /* X264_RC_* */

        int         i_qp_constant;  /* 0-51 */
        int         i_qp_min;       /*允许的最小量化值 */
        int         i_qp_max;       /*允许的最大量化值*/
        int         i_qp_step;      /*帧间最大量化步长 */

        int         i_bitrate;  /*设置平均码率 */
        float       f_rf_constant;  /* 1pass VBR, nominal QP */
        float       f_rate_tolerance;
        int         i_vbv_max_bitrate; /*平均码率模式下,最大瞬时码率,默认0(与-B设置相同) */
        int         i_vbv_buffer_size; /*码率控制缓冲区的大小,单位kbit,默认0 */
        float       f_vbv_buffer_init; /* <=1: fraction of buffer_size. >1: kbit码率控制缓冲区数据保留的最大数据量与缓冲区大小之比,范围0~1.0,默认0.9*/
        float       f_ip_factor;
        float       f_pb_factor;

        int         i_aq_mode;      /* psy adaptive QP. (X264_AQ_*) */
        float       f_aq_strength;
        int         b_mb_tree;      /* Macroblock-tree ratecontrol. */
        int         i_lookahead;

        /* 2pass 多次压缩码率控制 */
        int         b_stat_write;   /* Enable stat writing in psz_stat_out */
        char        *psz_stat_out;
        int         b_stat_read;    /* Read stat from psz_stat_in and use it */
        char        *psz_stat_in;

        /* 2pass params (same as ffmpeg ones) */
        float       f_qcompress;    /* 0.0 => cbr, 1.0 => constant qp */
        float       f_qblur;        /*时间上模糊量化 */
        float       f_complexity_blur; /* 时间上模糊复杂性 */
        x264_zone_t *zones;         /* 码率控制覆盖 */
        int         i_zones;        /* number of zone_t's */
        char        *psz_zones;     /*指定区的另一种方法*/
    } rc;

    /* Muxing parameters */
    int b_aud;                  /*生成访问单元分隔符*/
    int b_repeat_headers;       /* 在每个关键帧前放置SPS/PPS*/
    int i_sps_id;               /* SPS 和 PPS id 号 */

    /*切片(像条)参数 */
    int i_slice_max_size;    /* 每片字节的最大数,包括预计的NAL开销. */
    int i_slice_max_mbs;     /* 每片宏块的最大数,重写 i_slice_count */
    int i_slice_count;       /* 每帧的像条数目: 设置矩形像条. */

    /* Optional callback for freeing this x264_param_t when it is done being used.
     * Only used when the x264_param_t sits in memory for an indefinite period of time,
     * i.e. when an x264_param_t is passed to x264_t in an x264_picture_t or in zones.
     * Not used when x264_encoder_reconfig is called directly. */
    void (*param_free)( void* );
} x264_param_t;

转载自:http://wmnmtm.blog.163.com/blog/static/3824571420115106013979/
<think>好的,我现在需要解决用户在STM32项目中遇到的链接错误L6218E,具体问题是“未定义符号assert_param”。用户提到了stm32f10x_rcc.o这个文件,所以问题可能和RCC相关的配置或库文件有关。 首先,我应该回忆一下assert_param的作用。在STM32的标准外设库中,assert_param通常用于参数检查,属于断言机制的一部分。如果某个函数的参数不符合要求,就会调用这个宏来触发错误。比如在RCC配置函数中,如果传入的时钟源或分频系数不正确,assert_param会检测到并报错。 接下来,用户遇到的链接错误是未定义的符号,说明编译器在链接阶段找不到assert_param的实现。这可能是因为相关的宏或函数没有被正确启用或定义。根据之前的经验,标准库中的断言功能默认可能是关闭的,需要通过预定义宏来开启,比如USE_FULL_ASSERT。如果用户没有定义这个宏,那么assert_param可能被定义为空,导致链接时找不到具体的实现。 然后,我需要检查用户可能没有正确配置的地方。首先,用户是否在工程中包含了stm32f10x_conf.h文件,并且在该文件中启用了对应的外设头文件?比如,如果使用了RCC相关的函数,需要确保stm32f10x_rcc.h被包含,而stm32f10x_conf.h中的相关注释是否被正确取消。例如,用户提到的引用[2]中,stm32f10x_conf.h需要包含所需的头文件,如果被注释掉了,可能导致相关函数或宏未定义。 另外,用户是否在预处理器选项中定义了USE_STDPERIPH_DRIVER和USE_FULL_ASSERT?这两个宏的定义对于标准外设库的正确使用至关重要。USE_STDPERIPH_DRIVER告诉编译器使用标准外设库,而USE_FULL_ASSERT启用断言功能,这样assert_param才会被正确展开为具体的代码,否则可能被定义为空,导致链接错误。 还有一个可能的原因是启动文件是否正确配置。根据引用[4],启动文件中的某些函数可能有弱定义,如果用户没有自定义,就会使用默认的。但assert_param的问题更可能和库配置有关,而不是启动文件。 接下来,解决方案可能包括以下几个步骤: 1. 在stm32f10x_conf.h中确保包含了stm32f10x_rcc.h,并且其他必要的外设头文件未被注释。 2. 在项目的预处理器设置中添加USE_FULL_ASSERT和USE_STDPERIPH_DRIVER的定义。 3. 检查是否有自定义的assert_failed函数,并确保其被正确实现,比如在main.c或其他地方添加该函数的定义,用于处理断言失败的情况。 4. 确认标准外设库的文件是否被正确添加到工程中,比如stm32f10x_rcc.c是否被编译。 在用户提供的引用中,引用[1]给出了assert_param的宏定义,其中调用了assert_failed函数。如果用户没有实现这个函数,链接时就会找不到符号,导致错误。因此,用户需要自己提供assert_failed的实现,比如输出错误信息或进入死循环。 总结可能的问题点:未定义USE_FULL_ASSERT导致断言未被启用,或者启用了但未实现assert_failed函数,或者相关库文件未正确包含。</think>要解决STM32项目中的链接错误`L6218E: undefined symbol assert_param`,需检查以下关键点: ### 问题原因 1. **断言未启用或未定义** STM32标准外设库默认关闭断言功能,若未启用`USE_FULL_ASSERT`宏,`assert_param`会被定义为空,导致链接时找不到符号[^1][^2]。 2. **缺少`assert_failed`函数实现** `assert_param`宏依赖`assert_failed`函数处理错误,若未定义该函数,会触发未定义符号错误。 3. **标准库配置错误** 未正确包含外设头文件(如`stm32f10x_rcc.h`)或未编译相关源文件(如`stm32f10x_rcc.c`)。 --- ### 逐步解决方案 #### 1. 启用断言功能 - **在预处理器中定义宏**: 在IDE(如Keil、IAR)的预处理器设置中添加: ```c USE_FULL_ASSERT USE_STDPERIPH_DRIVER ``` *说明*:`USE_STDPERIPH_DRIVER`启用标准外设库,`USE_FULL_ASSERT`激活断言[^2]。 #### 2. 实现`assert_failed`函数 - **在`main.c`中添加以下代码**: ```c void assert_failed(uint8_t* file, uint32_t line) { while (1) { /* 阻塞并触发调试(如断点) */ } } ``` *说明*:此函数会在断言失败时被调用,需用户自行实现。 #### 3. 检查库文件配置 - **确认`stm32f10x_conf.h`配置**: 确保该文件包含所需外设头文件(如`#include "stm32f10x_rcc.h"`),并移除不必要的注释。 - **验证源文件编译**: 检查`stm32f10x_rcc.c`是否已加入工程并参与编译。 #### 4. 重新编译项目 完成上述修改后,清理并重新编译整个工程。 --- ### 代码示例 ```c // main.c中实现assert_failed #include "stm32f10x.h" void assert_failed(uint8_t* file, uint32_t line) { printf("Assert failed in %s, line %lu\n", file, line); while (1); } ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值