[h264e_syntax]: Simplify h264e_syntax

1. Move sps / pps / slice / dpb definition to there own header.
2. Prepare to add new h264e syntax struct for hal.

Change-Id: I95e884afcf08fa51bdeb6f1e6571c264d9a609ec
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
Herman Chen
2020-09-28 09:52:13 +08:00
parent 04137732ac
commit f8b77d6aa2
12 changed files with 262 additions and 253 deletions

View File

@@ -17,6 +17,7 @@
#ifndef __H264E_DPB_H__
#define __H264E_DPB_H__
#include "h264e_syntax.h"
#include "h264e_sps.h"
#include "mpp_enc_ref.h"

View File

@@ -20,7 +20,40 @@
#include "mpp_packet.h"
#include "mpp_enc_cfg.h"
#include "h264e_syntax.h"
#include "h264_syntax.h"
typedef struct H264ePps_t {
RK_S32 pps_id;
RK_S32 sps_id;
// 0 - CAVLC 1 - CABAC
RK_S32 entropy_coding_mode;
RK_S32 bottom_field_pic_order_in_frame_present;
RK_S32 num_slice_groups;
RK_S32 num_ref_idx_l0_default_active;
RK_S32 num_ref_idx_l1_default_active;
RK_S32 weighted_pred;
RK_S32 weighted_bipred_idc;
RK_S32 pic_init_qp;
RK_S32 pic_init_qs;
RK_S32 chroma_qp_index_offset;
RK_S32 second_chroma_qp_index_offset;
RK_S32 deblocking_filter_control;
RK_S32 constrained_intra_pred;
RK_S32 redundant_pic_cnt;
RK_S32 transform_8x8_mode;
// Only support flat and default scaling list
RK_S32 pic_scaling_matrix_present;
RK_S32 use_default_scaling_matrix[H264_SCALING_MATRIX_TYPE_BUTT];
} H264ePps;
#ifdef __cplusplus
extern "C" {

View File

@@ -24,6 +24,7 @@
#include "h264e_debug.h"
#include "h264e_slice.h"
#include "h264e_dpb.h"
#define FP_FIFO_IS_FULL

View File

@@ -20,7 +20,116 @@
#include "mpp_enc_cfg.h"
#include "h264e_syntax.h"
#include "h264e_dpb.h"
#include "h264e_sps.h"
/*
* For H.264 encoder slice header process.
* Remove some syntax that encoder not supported.
* Field, mbaff, B slice are not supported yet.
*
* The reorder and mmco syntax will be create by dpb and attach to slice.
* Then slice syntax will be passed to hal to config hardware or modify the
* hardware stream.
*/
/* reference picture list modification operation */
typedef struct H264eRplmo_t {
RK_S32 modification_of_pic_nums_idc;
RK_S32 abs_diff_pic_num_minus1;
RK_S32 long_term_pic_idx;
RK_S32 abs_diff_view_idx_minus1;
} H264eRplmo;
typedef struct H264eReorderInfo_t {
RK_S32 rd_cnt;
RK_S32 wr_cnt;
RK_S32 size;
H264eRplmo ops[H264E_MAX_REFS_CNT];
} H264eReorderInfo;
/*
* mmco (Memory management control operation) value
* 0 - End memory_management_control_operation syntax element loop
* 1 - Mark a short-term reference picture as "unused for reference"
* 2 - Mark a long-term reference picture as "unused for reference"
* 3 - Mark a short-term reference picture as "used for long-term
* reference" and assign a long-term frame index to it
* 4 - Specify the maximum long-term frame index and mark all long-term
* reference pictures having long-term frame indices greater than
* the maximum value as "unused for reference"
* 5 - Mark all reference pictures as "unused for reference" and set the
* MaxLongTermFrameIdx variable to "no long-term frame indices"
* 6 - Mark the current picture as "used for long-term reference" and
* assign a long-term frame index to it
*/
typedef struct H264eMmco_t {
RK_S32 mmco;
RK_S32 difference_of_pic_nums_minus1; // for MMCO 1 & 3
RK_S32 long_term_pic_num; // for MMCO 2
RK_S32 long_term_frame_idx; // for MMCO 3 & 6
RK_S32 max_long_term_frame_idx_plus1; // for MMCO 4
} H264eMmco;
#define MAX_H264E_MMCO_CNT 8
typedef struct H264eMarkingInfo_t {
RK_S32 idr_flag;
/* idr marking flag */
RK_S32 no_output_of_prior_pics;
RK_S32 long_term_reference_flag;
/* non-idr marking flag */
RK_S32 adaptive_ref_pic_buffering;
RK_S32 rd_cnt;
RK_S32 wr_cnt;
RK_S32 size;
H264eMmco ops[MAX_H264E_MMCO_CNT];
} H264eMarkingInfo;
typedef struct H264eSlice_t {
/* Copy of sps/pps parameter */
RK_U32 max_num_ref_frames;
RK_U32 entropy_coding_mode;
RK_S32 log2_max_frame_num;
RK_S32 log2_max_poc_lsb;
RK_S32 pic_order_cnt_type;
/* Nal parameters */
RK_S32 nal_reference_idc;
RK_S32 nalu_type;
/* Unchanged parameters */
RK_U32 first_mb_in_slice;
RK_U32 slice_type;
RK_U32 pic_parameter_set_id;
RK_S32 frame_num;
RK_S32 num_ref_idx_override;
RK_S32 qp_delta;
RK_U32 cabac_init_idc;
RK_U32 disable_deblocking_filter_idc;
RK_S32 slice_alpha_c0_offset_div2;
RK_S32 slice_beta_offset_div2;
/* reorder parameter */
RK_S32 ref_pic_list_modification_flag;
H264eReorderInfo *reorder;
H264eMarkingInfo *marking;
RK_S32 idr_flag;
RK_U32 idr_pic_id;
RK_U32 next_idr_pic_id;
/* for poc mode 0 */
RK_U32 pic_order_cnt_lsb;
RK_S32 num_ref_idx_active;
/* idr mmco flag */
RK_S32 no_output_of_prior_pics;
RK_S32 long_term_reference_flag;
/* Changable parameters */
RK_S32 adaptive_ref_pic_buffering;
/* for multi-slice writing */
RK_S32 is_multi_slice;
} H264eSlice;
#ifdef __cplusplus
extern "C" {

View File

@@ -20,7 +20,106 @@
#include "mpp_packet.h"
#include "mpp_enc_cfg.h"
#include "h264e_syntax.h"
#include "h264_syntax.h"
typedef struct H264eVui_t {
RK_U32 vui_present;
RK_S32 aspect_ratio_info_present;
RK_S32 aspect_ratio_idc;
RK_S32 sar_width;
RK_S32 sar_height;
RK_S32 overscan_info_present;
RK_S32 overscan_appropriate_flag;
RK_S32 signal_type_present;
RK_S32 vidformat;
RK_S32 fullrange;
RK_S32 color_description_present;
RK_S32 colorprim;
RK_S32 colortrc;
RK_S32 colmatrix;
RK_S32 chroma_loc_info_present;
RK_S32 chroma_loc_top;
RK_S32 chroma_loc_bottom;
RK_S32 timing_info_present;
RK_U32 num_units_in_tick;
RK_U32 time_scale;
RK_S32 fixed_frame_rate;
RK_S32 nal_hrd_parameters_present;
RK_S32 vcl_hrd_parameters_present;
struct {
RK_S32 cpb_cnt;
RK_S32 bit_rate_scale;
RK_S32 cpb_size_scale;
RK_S32 bit_rate_value;
RK_S32 cpb_size_value;
RK_S32 bit_rate_unscaled;
RK_S32 cpb_size_unscaled;
RK_S32 cbr_hrd;
RK_S32 initial_cpb_removal_delay_length;
RK_S32 cpb_removal_delay_length;
RK_S32 dpb_output_delay_length;
RK_S32 time_offset_length;
} hrd;
RK_S32 pic_struct_present;
RK_S32 bitstream_restriction;
RK_S32 motion_vectors_over_pic_boundaries;
RK_S32 max_bytes_per_pic_denom;
RK_S32 max_bits_per_mb_denom;
RK_S32 log2_max_mv_length_horizontal;
RK_S32 log2_max_mv_length_vertical;
RK_S32 num_reorder_frames;
RK_S32 max_dec_frame_buffering;
} H264eVui;
typedef struct H264eSps_t {
RK_S32 profile_idc;
RK_S32 constraint_set0;
RK_S32 constraint_set1;
RK_S32 constraint_set2;
RK_S32 constraint_set3;
RK_S32 constraint_set4;
RK_S32 constraint_set5;
RK_S32 level_idc;
RK_S32 sps_id;
RK_S32 chroma_format_idc;
/* scaling list is in pps */
RK_S32 log2_max_frame_num_minus4;
RK_S32 pic_order_cnt_type;
/* poc type 0 */
RK_S32 log2_max_poc_lsb_minus4;
RK_S32 num_ref_frames;
RK_S32 gaps_in_frame_num_value_allowed;
RK_S32 pic_width_in_mbs;
RK_S32 pic_height_in_mbs;
// alway frame encoding
RK_S32 frame_mbs_only;
RK_S32 direct8x8_inference;
RK_S32 cropping;
struct {
RK_S32 left;
RK_S32 right;
RK_S32 top;
RK_S32 bottom;
} crop;
H264eVui vui;
} H264eSps;
#ifdef __cplusplus
extern "C" {

View File

@@ -177,4 +177,6 @@ typedef enum H264ScalingListType_e {
H264_SCALING_MATRIX_TYPE_BUTT,
} H264ScalingMatrixType;
#define H264E_MAX_REFS_CNT 16
#endif /*__H264_SYNTAX_H__*/

View File

@@ -40,138 +40,6 @@ typedef struct H264eSyntaxDesc_t {
void *p;
} H264eSyntaxDesc;
typedef struct H264eVui_t {
RK_U32 vui_present;
RK_S32 aspect_ratio_info_present;
RK_S32 aspect_ratio_idc;
RK_S32 sar_width;
RK_S32 sar_height;
RK_S32 overscan_info_present;
RK_S32 overscan_appropriate_flag;
RK_S32 signal_type_present;
RK_S32 vidformat;
RK_S32 fullrange;
RK_S32 color_description_present;
RK_S32 colorprim;
RK_S32 colortrc;
RK_S32 colmatrix;
RK_S32 chroma_loc_info_present;
RK_S32 chroma_loc_top;
RK_S32 chroma_loc_bottom;
RK_S32 timing_info_present;
RK_U32 num_units_in_tick;
RK_U32 time_scale;
RK_S32 fixed_frame_rate;
RK_S32 nal_hrd_parameters_present;
RK_S32 vcl_hrd_parameters_present;
struct {
RK_S32 cpb_cnt;
RK_S32 bit_rate_scale;
RK_S32 cpb_size_scale;
RK_S32 bit_rate_value;
RK_S32 cpb_size_value;
RK_S32 bit_rate_unscaled;
RK_S32 cpb_size_unscaled;
RK_S32 cbr_hrd;
RK_S32 initial_cpb_removal_delay_length;
RK_S32 cpb_removal_delay_length;
RK_S32 dpb_output_delay_length;
RK_S32 time_offset_length;
} hrd;
RK_S32 pic_struct_present;
RK_S32 bitstream_restriction;
RK_S32 motion_vectors_over_pic_boundaries;
RK_S32 max_bytes_per_pic_denom;
RK_S32 max_bits_per_mb_denom;
RK_S32 log2_max_mv_length_horizontal;
RK_S32 log2_max_mv_length_vertical;
RK_S32 num_reorder_frames;
RK_S32 max_dec_frame_buffering;
} H264eVui;
typedef struct H264eSps_t {
RK_S32 profile_idc;
RK_S32 constraint_set0;
RK_S32 constraint_set1;
RK_S32 constraint_set2;
RK_S32 constraint_set3;
RK_S32 constraint_set4;
RK_S32 constraint_set5;
RK_S32 level_idc;
RK_S32 sps_id;
RK_S32 chroma_format_idc;
/* scaling list is in pps */
RK_S32 log2_max_frame_num_minus4;
RK_S32 pic_order_cnt_type;
/* poc type 0 */
RK_S32 log2_max_poc_lsb_minus4;
RK_S32 num_ref_frames;
RK_S32 gaps_in_frame_num_value_allowed;
RK_S32 pic_width_in_mbs;
RK_S32 pic_height_in_mbs;
// alway frame encoding
RK_S32 frame_mbs_only;
RK_S32 direct8x8_inference;
RK_S32 cropping;
struct {
RK_S32 left;
RK_S32 right;
RK_S32 top;
RK_S32 bottom;
} crop;
H264eVui vui;
} H264eSps;
typedef struct H264ePps_t {
RK_S32 pps_id;
RK_S32 sps_id;
// 0 - CAVLC 1 - CABAC
RK_S32 entropy_coding_mode;
RK_S32 bottom_field_pic_order_in_frame_present;
RK_S32 num_slice_groups;
RK_S32 num_ref_idx_l0_default_active;
RK_S32 num_ref_idx_l1_default_active;
RK_S32 weighted_pred;
RK_S32 weighted_bipred_idc;
RK_S32 pic_init_qp;
RK_S32 pic_init_qs;
RK_S32 chroma_qp_index_offset;
RK_S32 second_chroma_qp_index_offset;
RK_S32 deblocking_filter_control;
RK_S32 constrained_intra_pred;
RK_S32 redundant_pic_cnt;
RK_S32 transform_8x8_mode;
// Only support flat and default scaling list
RK_S32 pic_scaling_matrix_present;
RK_S32 use_default_scaling_matrix[H264_SCALING_MATRIX_TYPE_BUTT];
} H264ePps;
typedef struct H264ePrefixNal_t {
RK_S32 nal_ref_idc;
@@ -187,116 +55,9 @@ typedef struct H264ePrefixNal_t {
RK_S32 output_flag;
} H264ePrefixNal;
/*
* For H.264 encoder slice header process.
* Remove some syntax that encoder not supported.
* Field, mbaff, B slice are not supported yet.
*
* The reorder and mmco syntax will be create by dpb and attach to slice.
* Then slice syntax will be passed to hal to config hardware or modify the
* hardware stream.
*/
#define H264E_MAX_REFS_CNT 16
/* reference picture list modification operation */
typedef struct H264eRplmo_t {
RK_S32 modification_of_pic_nums_idc;
RK_S32 abs_diff_pic_num_minus1;
RK_S32 long_term_pic_idx;
RK_S32 abs_diff_view_idx_minus1;
} H264eRplmo;
typedef struct H264eReorderInfo_t {
RK_S32 rd_cnt;
RK_S32 wr_cnt;
RK_S32 size;
H264eRplmo ops[H264E_MAX_REFS_CNT];
} H264eReorderInfo;
/*
* mmco (Memory management control operation) value
* 0 - End memory_management_control_operation syntax element loop
* 1 - Mark a short-term reference picture as "unused for reference"
* 2 - Mark a long-term reference picture as "unused for reference"
* 3 - Mark a short-term reference picture as "used for long-term
* reference" and assign a long-term frame index to it
* 4 - Specify the maximum long-term frame index and mark all long-term
* reference pictures having long-term frame indices greater than
* the maximum value as "unused for reference"
* 5 - Mark all reference pictures as "unused for reference" and set the
* MaxLongTermFrameIdx variable to "no long-term frame indices"
* 6 - Mark the current picture as "used for long-term reference" and
* assign a long-term frame index to it
*/
typedef struct H264eMmco_t {
RK_S32 mmco;
RK_S32 difference_of_pic_nums_minus1; // for MMCO 1 & 3
RK_S32 long_term_pic_num; // for MMCO 2
RK_S32 long_term_frame_idx; // for MMCO 3 & 6
RK_S32 max_long_term_frame_idx_plus1; // for MMCO 4
} H264eMmco;
#define MAX_H264E_MMCO_CNT 8
typedef struct H264eMarkingInfo_t {
RK_S32 idr_flag;
/* idr marking flag */
RK_S32 no_output_of_prior_pics;
RK_S32 long_term_reference_flag;
/* non-idr marking flag */
RK_S32 adaptive_ref_pic_buffering;
RK_S32 rd_cnt;
RK_S32 wr_cnt;
RK_S32 size;
H264eMmco ops[MAX_H264E_MMCO_CNT];
} H264eMarkingInfo;
typedef struct H264eSlice_t {
/* Copy of sps/pps parameter */
RK_U32 max_num_ref_frames;
RK_U32 entropy_coding_mode;
RK_S32 log2_max_frame_num;
RK_S32 log2_max_poc_lsb;
RK_S32 pic_order_cnt_type;
/* Nal parameters */
RK_S32 nal_reference_idc;
RK_S32 nalu_type;
/* Unchanged parameters */
RK_U32 first_mb_in_slice;
RK_U32 slice_type;
RK_U32 pic_parameter_set_id;
RK_S32 frame_num;
RK_S32 num_ref_idx_override;
RK_S32 qp_delta;
RK_U32 cabac_init_idc;
RK_U32 disable_deblocking_filter_idc;
RK_S32 slice_alpha_c0_offset_div2;
RK_S32 slice_beta_offset_div2;
/* reorder parameter */
RK_S32 ref_pic_list_modification_flag;
H264eReorderInfo *reorder;
H264eMarkingInfo *marking;
RK_S32 idr_flag;
RK_U32 idr_pic_id;
RK_U32 next_idr_pic_id;
/* for poc mode 0 */
RK_U32 pic_order_cnt_lsb;
RK_S32 num_ref_idx_active;
/* idr mmco flag */
RK_S32 no_output_of_prior_pics;
RK_S32 long_term_reference_flag;
/* Changable parameters */
RK_S32 adaptive_ref_pic_buffering;
/* for multi-slice writing */
RK_S32 is_multi_slice;
} H264eSlice;
typedef struct H264eReorderInfo_t H264eReorderInfo;
typedef struct H264eMarkingInfo_t H264eMarkingInfo;
typedef struct H264eDpbFrm_t H264eDpbFrm;
/*
* Split reference frame configure to two parts

View File

@@ -29,7 +29,8 @@
#include "mpp_rc.h"
#include "hal_h264e_debug.h"
#include "h264e_syntax.h"
#include "h264e_sps.h"
#include "h264e_pps.h"
#include "h264e_slice.h"
#include "hal_bufs.h"

View File

@@ -27,7 +27,8 @@
#include "mpp_enc_hal.h"
#include "h264e_debug.h"
#include "h264e_syntax.h"
#include "h264e_sps.h"
#include "h264e_pps.h"
#include "h264e_slice.h"
#include "hal_h264e_debug.h"

View File

@@ -27,7 +27,8 @@
#include "mpp_enc_hal.h"
#include "h264e_debug.h"
#include "h264e_syntax.h"
#include "h264e_sps.h"
#include "h264e_pps.h"
#include "h264e_slice.h"
#include "hal_h264e_debug.h"

View File

@@ -20,6 +20,7 @@
#include "mpp_mem.h"
#include "mpp_common.h"
#include "mpp_buffer.h"
#include "mpp_enc_ref.h"
#include "vepu_common.h"

View File

@@ -18,7 +18,6 @@
#define __HAL_H264E_VEPU_V2_H__
#include "mpp_enc_cfg.h"
#include "h264e_syntax.h"
#include "mpp_rc.h"
#define H264E_HAL_SET_REG(reg, addr, val) \