Module: Mesa Branch: main Commit: 66c75b0ca2321d375ae56fb62f6a7e0a9d067d83 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=66c75b0ca2321d375ae56fb62f6a7e0a9d067d83
Author: Ruijing Dong <ruijing.d...@amd.com> Date: Wed Nov 8 21:30:35 2023 -0500 radeonsi/vcn: preparation for enc intra-refresh This is a prepration for adding intra-refresh in vcn encoders. Intra-refresh is a feature for smoothing out fluctuation in bitrate by replacing a whole intra frame by several intra strips distributed in several continous frames, it is also used in suppressing error propagation situation. Reviewed-by: Leo Liu <leo....@amd.com> Reviewed-by: Boyuan Zhang <boyuan.zh...@amd.com> Signed-off-by: Ruijing Dong <ruijing.d...@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26133> --- src/gallium/include/pipe/p_video_enums.h | 20 ++++++++++++++++++++ src/gallium/include/pipe/p_video_state.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/gallium/include/pipe/p_video_enums.h b/src/gallium/include/pipe/p_video_enums.h index 657fce68381..86e94e0392f 100644 --- a/src/gallium/include/pipe/p_video_enums.h +++ b/src/gallium/include/pipe/p_video_enums.h @@ -213,6 +213,26 @@ enum pipe_video_cap_slice_structure PIPE_VIDEO_CAP_SLICE_STRUCTURE_EQUAL_MULTI_ROWS = 0x00000020, }; +enum pipe_video_enc_intra_refresh_mode +{ + /* no intra-refresh is supported */ + PIPE_VIDEO_ENC_INTRA_REFRESH_NONE = 0x00000, + /* intra-refresh is column based */ + PIPE_VIDEO_ENC_INTRA_REFRESH_COLUMN = 0x00001, + /* intra-refresh is row based */ + PIPE_VIDEO_ENC_INTRA_REFRESH_ROW = 0x00002, + /* intra-refresh could be adaptive, and decided by application */ + PIPE_VIDEO_ENC_INTRA_REFRESH_ADAPTIVE = 0x00010, + /* intra-refresh could be cyclic, decided by application */ + PIPE_VIDEO_ENC_INTRA_REFRESH_CYCLIC = 0x00020, + /* intra-refresh can be on P frame */ + PIPE_VIDEO_ENC_INTRA_REFRESH_P_FRAME = 0x10000, + /* intra-refresh can be on B frame */ + PIPE_VIDEO_ENC_INTRA_REFRESH_B_FRAME = 0x20000, + /* intra-refresh support multiple reference encoder */ + PIPE_VIDEO_ENC_INTRA_REFRESH_MULTI_REF = 0x40000, +}; + enum pipe_video_entrypoint { PIPE_VIDEO_ENTRYPOINT_UNKNOWN, diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h index 9cb34c55aa0..1a4009bbaa5 100644 --- a/src/gallium/include/pipe/p_video_state.h +++ b/src/gallium/include/pipe/p_video_state.h @@ -422,6 +422,31 @@ struct pipe_enc_quality_modes unsigned int vbaq_mode; }; +/* + * intra refresh supports row or column only, it doens't support + * row and column mixed, if mixed it will pick up column mode. + * Also the assumption is the first row/column since the offset + * is zero, and it marks the start of intra-refresh, it will need + * to have headers at this point. + */ +struct pipe_enc_intra_refresh +{ + unsigned int mode; + unsigned int region_size; + unsigned int offset; + unsigned int need_sequence_header; +}; + +/* + * In AVC, unit is MB, HEVC (CTB) and AV1(SB) + */ +enum +{ + INTRA_REFRESH_MODE_NONE, + INTRA_REFRESH_MODE_UNIT_ROWS, + INTRA_REFRESH_MODE_UNIT_COLUMNS, +}; + struct pipe_h264_enc_rate_control { enum pipe_h2645_enc_rate_control_method rate_ctrl_method; @@ -564,6 +589,7 @@ struct pipe_h264_enc_picture_desc bool l1_is_long_term[32]; unsigned gop_size; struct pipe_enc_quality_modes quality_modes; + struct pipe_enc_intra_refresh intra_refresh; bool not_referenced; bool is_ltr; @@ -691,6 +717,7 @@ struct pipe_h265_enc_picture_desc unsigned pic_order_cnt; unsigned pic_order_cnt_type; struct pipe_enc_quality_modes quality_modes; + struct pipe_enc_intra_refresh intra_refresh; unsigned num_ref_idx_l0_active_minus1; unsigned num_ref_idx_l1_active_minus1; unsigned ref_idx_l0_list[PIPE_H265_MAX_REFERENCES]; @@ -827,6 +854,7 @@ struct pipe_av1_enc_picture_desc uint32_t skip_mode_present:1; }; struct pipe_enc_quality_modes quality_modes; + struct pipe_enc_intra_refresh intra_refresh; uint32_t num_tiles_in_pic; /* [1, 32], */ uint32_t tile_rows; uint32_t tile_cols;