AV1学习笔记一
最新webrtc版本已經支持AV1編解碼功能,實測性能和質量真有很大的進步空間,另外potplay、VLC也支持AV1解碼播放功能。
一、接口函數
根據webrtc代碼總結AV1函數調用框架如下:
?
- aom_codec_enc_config_default(aom_codec_iface_t *iface,aom_codec_enc_cfg_t *cfg, unsigned int usage)
? ? ? ? 注冊編碼器,獲取注冊的編碼器的默認編碼參數集。
? ? ? ??aom_codec_iface_t *iface:要使用的編碼器句柄指針。里面包含編碼器使用的接口函數,默認配置參數。
? ? ? ??aom_codec_enc_cfg_t *cfg:編碼器實際使用參數指針。這里是出參,需要根據usage在iface里面找到一組默認參數。
? ? ? ??usage:默認參數組序號。在webrtc代碼里面,可以參考encoder_usage_cfg定義。
- aom_img_alloc
? ? ? ? 申請輸入編碼數據緩存buf
- aom_codec_enc_init
? ? ? ?根據aom_codec_iface_t、aom_codec_enc_cfg_t初始化aom_codec_ctx_t句柄。并調用aom_codec_iface_t.encoder_init函數初始化編碼器。
- aom_codec_control
? ? ? 根據需要,動態調整編碼參數。可以參考aom_codec_av1_cx_algo.encoder_ctrl_maps定義。可調整的參數列表參考encoder_ctrl_maps定義。可修改的參數列表在aom_com_control_id、aome_enc_control_id里面定義。??
- aom_codec_encode
? ? ? ?輸入編碼器待編碼參數,進行編碼。
- aom_codec_get_cx_data
? ? ? 獲取編碼后數據
- aom_codec_enc_config_set
? ? ? 動態調整編碼參數。可通過調整aom_codec_enc_cfg_t參數,生效編碼器。
- aom_img_free
? ? ?釋放編碼數據緩存buf
- aom_codec_destroy
? ? ?釋放編碼器申請資源
?
二、接口參數
aom_codec_enc_cfg結構體定義
| 參數名稱 | 參數類型 | 參數含義 | 參數配置 |
| g_usage | unsigned int | 自定義參數組編號 | webrtc里面自定義編碼: AOM_USAGE_GOOD_QUALITY (0) AOM_USAGE_REALTIME (1) |
| g_threads | unsigned int | 最大可使用線程數 | ? |
| g_profile | unsigned int | 編碼器可支持的格式集合 | PROFILE_0:8-bit 4:2:0 only PROFILE_1:8-bit 4:4:4, 4:2:2, and 4:4:0 PROFILE_2:10-bit and 12-bit color only, with 4:2:0 sampling. PROFILE_3:10-bit and 12-bit color only, with 4:2:2/4:4:4/4:4:0 sampling. |
| g_w | unsigned int | 寬 | ? |
| g_h | unsigned int | 高 | ? |
| g_bit_depth | aom_bit_depth_t | 編碼器支持的位深 | AOM_BITS_8 AOM_BITS_10 AOM_BITS_12 |
| g_input_bit_depth | unsigned int | 輸入編碼器數據位深 | ? |
| g_timebase | aom_rational | 視頻采樣率 | ? |
| g_error_resilient | aom_codec_er_flags_t | Enable error resiliency features | AOM_ERROR_RESILIENT_DEFAULT AOM_ERROR_RESILIENT_PARTITIONS |
| g_pass | aom_enc_pass | pass參數 | AOM_RC_ONE_PASS AOM_RC_FIRST_PASS AOM_RC_LAST_PASS |
| g_lag_in_frames | unsigned int | 預編碼幀數 | ? |
| rc_dropframe_thresh | unsigned int | 時間重采樣閾值 | ? |
| rc_resize_mode | unsigned int | 下采樣模式調整 | RESIZE_NONE:不調整分辨率. RESIZE_FIXED:所有幀都按照指定參數調整分辨率,關鍵幀按照rc_resize_kf_numerator調整,非關鍵幀按照rc_resize_numerator調整 RESIZE_DYNAMIC:動態調整每一幀的分辨率 |
| rc_resize_numerator | unsigned int | 非關鍵幀調整系數 | ? |
| rc_resize_kf_numerator | unsigned int | 關鍵幀調整系數 | ? |
| rc_superres_mode | unsigned int | 上采樣模式調整 | SUPERRES_NONE:不調整分辨率. SUPERRES_FIXED:所有幀都按照指定參數調整分辨率,關鍵幀按照rc_superres_kf_numerator調整,非關鍵幀按照rc_superres_numerator調整 SUPERRES_DYNAMIC:動態調整每一幀的分辨率 |
| rc_superres_numerator | unsigned int | 非關鍵幀調整系數 | ? |
| rc_superres_kf_numerator | unsigned int | 關鍵幀調整系數 | ? |
| rc_end_usage | aom_rc_mode | 碼控模式 | AOM_VBR:Variable Bit Rate mode AOM_CBR:Constant Bit Rate mode AOM_CQ:Constrained Quality mode AOM_Q:Constant Quality mode |
| rc_twopass_stats_in | aom_fixed_buf_t | 2pass統計 | ? |
| rc_firstpass_mb_stats_in | aom_fixed_buf_t | 1pass統計 | ? |
| rc_target_bitrate | unsigned int | 目標碼率 | ? |
| rc_min_quantizer | unsigned int | 最小QP | ? |
| rc_max_quantizer | unsigned int | 最大QP | ? |
| rc_undershoot_pct | unsigned int | 可上浮目標碼率比例 | ? |
| rc_overshoot_pct | unsigned int | 可下浮目標碼率比例 | ? |
| rc_buf_sz | unsigned int | 解碼端需分配的緩存buf | ? |
| rc_buf_initial_sz | unsigned int | 開始解碼時,解碼端需分配的緩存buf | ? |
| rc_buf_optimal_sz | unsigned int | 解碼端需分配的最優緩存buf | ? |
| rc_2pass_vbr_bias_pct | unsigned int | CBR/VBR bias (0=CBR, 100=VBR) | ? |
| rc_2pass_vbr_minsection_pct | unsigned int | GOP min bitrate (% of target) | ? |
| rc_2pass_vbr_maxsection_pct | unsigned int | GOP max bitrate (% of target) | ? |
| kf_mode | aom_kf_mode | 配置I幀間隔 | AOM_KF_AUTO:自適應I幀間隔 AOM_KF_DISABLED:固定I幀間隔 |
| kf_min_dist | unsigned int | 最小I幀間隔 | ? |
| kf_max_dist | unsigned int | 最大I幀間隔 | ? |
?
總結
- 上一篇: Python 处理dat文件并画图
- 下一篇: STM32F051——USART