xref: /rockchip-linux_mpp/mpp/codec/enc/h265/h265e_header_gen.h (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /*
2  * Copyright 2015 Rockchip Electronics Co. LTD
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __H265E_HEADER_GEN_H__
18 #define __H265E_HEADER_GEN_H__
19 
20 #include "h265e_stream.h"
21 #define H265E_UUID_LENGTH 16
22 
23 typedef enum H265eNalIdx_t {
24     H265E_NAL_IDX_VPS,
25     H265E_NAL_IDX_SPS,
26     H265E_NAL_IDX_PPS,
27     H265E_NAL_IDX_SEI,
28     H265E_NAL_IDX_BUTT,
29 } H265eNalIdx;
30 
31 typedef enum H265SeiType_e {
32     H265_SEI_BUFFERING_PERIOD                       = 0,
33     H265_SEI_PICTURE_TIMING                         = 1,
34     H265_SEI_PAN_SCAN_RECT                          = 2,
35     H265_SEI_FILLER_PAYLOAD                         = 3,
36     H265_SEI_USER_DATA_REGISTERED_ITU_T_T35         = 4,
37     H265_SEI_USER_DATA_UNREGISTERED                 = 5,
38     H265_SEI_RECOVERY_POINT                         = 6,
39     H265_SEI_SCENE_INFO                             = 9,
40     H265_SEI_FULL_FRAME_SNAPSHOT                    = 15,
41     H265_SEI_PROGRESSIVE_REFINEMENT_SEGMENT_START   = 16,
42     H265_SEI_PROGRESSIVE_REFINEMENT_SEGMENT_END     = 17,
43     H265_SEI_FILM_GRAIN_CHARACTERISTICS             = 19,
44     H265_SEI_POST_FILTER_HINT                       = 22,
45     H265_SEI_TONE_MAPPING_INFO                      = 23,
46     H265_SEI_FRAME_PACKING                          = 45,
47     H265_SEI_DISPLAY_ORIENTATION                    = 47,
48     H265_SEI_SOP_DESCRIPTION                        = 128,
49     H265_SEI_ACTIVE_PARAMETER_SETS                  = 129,
50     H265_SEI_DECODING_UNIT_INFO                     = 130,
51     H265_SEI_TEMPORAL_LEVEL0_INDEX                  = 131,
52     H265_SEI_DECODED_PICTURE_HASH                   = 132,
53     H265_SEI_SCALABLE_NESTING                       = 133,
54     H265_SEI_REGION_REFRESH_INFO                    = 134,
55     H265_SEI_MAX_ELEMENTS = 255, //!< number of maximum syntax elements
56 } H265SeiType;
57 
58 typedef struct  H265eNal_t {
59     RK_S32 i_ref_idc;  /* nal_priority_e */
60     RK_S32 i_type;     /* nal_unit_type_e */
61     RK_S32 b_long_startcode;
62     RK_S32 i_first_mb; /* If this NAL is a slice, the index of the first MB in the slice. */
63     RK_S32 i_last_mb;  /* If this NAL is a slice, the index of the last MB in the slice. */
64 
65     /* Size of payload (including any padding) in bytes. */
66     RK_S32     i_payload;
67     /* If param->b_annexb is set, Annex-B bytestream with startcode.
68      * Otherwise, startcode is replaced with a 4-byte size.
69      * This size is the size used in mp4/similar muxing; it is equal to i_payload-4 */
70     RK_U8 *p_payload;
71 
72     /* Size of padding in bytes. */
73     RK_S32 i_padding;
74     RK_S32 sh_head_len;
75     RK_S32 temporal_id;
76 } H265eNal;
77 
78 typedef struct H265eExtraInfo_t {
79     RK_S32          nal_num;
80     H265eNal        nal[H265E_NAL_IDX_BUTT];
81     RK_U8           *nal_buf;
82     RK_U8           *sei_buf;
83     RK_U32          sei_change_flg;
84     H265eStream     stream;
85 //    H265eSei        sei;
86     RK_S32          temporal_id;
87 } H265eExtraInfo;
88 
89 #ifdef __cplusplus
90 extern "C" {
91 #endif
92 
93 MPP_RET h265e_init_extra_info(void *extra_info);
94 MPP_RET h265e_deinit_extra_info(void *extra_info);
95 void h265e_rkv_nal_start(H265eExtraInfo *out, RK_S32 i_type,
96                          RK_S32 i_ref_idc);
97 
98 void h265e_nal_end(H265eExtraInfo *out);
99 
100 RK_U32 h265e_data_to_sei(void *dst, RK_U8 uuid[16], const void *payload, RK_S32 size);
101 MPP_RET h265e_sei_recovery_point(void *dst, RK_U8 uuid[16], const void *payload,
102                                  RK_S32 size);
103 
104 MPP_RET h265e_set_extra_info(H265eCtx *ctx);
105 MPP_RET h265e_get_extra_info(H265eCtx *ctx, MppPacket pkt_out);
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif /*__H265E_HEADER_GEN_H__ */
112