xref: /OK3568_Linux_fs/external/mpp/mpp/codec/dec/h265/h265d_codec.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  *
3  * Copyright 2015 Rockchip Electronics Co. LTD
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /*
19  * @file       h265d_codec.h
20  * @brief
21  * @author      csy(csy@rock-chips.com)
22 
23  * @version     1.0.0
24  * @history
25  *   2015.7.15 : Create
26  */
27 
28 #ifndef __H265D_CODEC_H__
29 #define __H265D_CODEC_H__
30 
31 #include "mpp_frame.h"
32 #include "mpp_soc.h"
33 #include "mpp_dec_cfg.h"
34 
35 typedef struct MppRational {
36     RK_S32 num; ///< numerator
37     RK_S32 den; ///< denominator
38 } MppRational_t;
39 
40 enum MppPictureStructure {
41     MPP_PICTURE_STRUCTURE_UNKNOWN,      //< unknown
42     MPP_PICTURE_STRUCTURE_TOP_FIELD,    //< coded as top field
43     MPP_PICTURE_STRUCTURE_BOTTOM_FIELD, //< coded as bottom field
44     MPP_PICTURE_STRUCTURE_FRAME,        //< coded as frame
45 };
46 
47 #define END_NOT_FOUND (-100)
48 #define MPP_PARSER_PTS_NB 4
49 
50 typedef struct SplitContext {
51     RK_U8 *buffer;
52     RK_U32 buffer_size;
53     RK_S32 index;
54     RK_S32 last_index;
55     RK_U32 state;             ///< contains the last few bytes in MSB order
56     RK_S32 frame_start_found;
57     RK_S32 overread;               ///< the number of bytes which where irreversibly read from the next frame
58     RK_S32 overread_index;         ///< the index into ParseContext.buffer of the overread bytes
59     RK_U64 state64;           ///< contains the last 8 bytes in MSB order
60     RK_S64 pts;     /* pts of the current frame */
61     RK_S64 dts;     /* dts of the current frame */
62     RK_S64 frame_offset; /* offset of the current frame */
63     RK_S64 cur_offset; /* current offset
64                            (incremented by each av_parser_parse()) */
65     RK_S64 next_frame_offset; /* offset of the next frame */
66     /* private data */
67     RK_S64 last_pts;
68     RK_S64 last_dts;
69     RK_S32 fetch_timestamp;
70 
71     RK_S32 cur_frame_start_index;
72     RK_S64 cur_frame_offset[MPP_PARSER_PTS_NB];
73     RK_S64 cur_frame_pts[MPP_PARSER_PTS_NB];
74     RK_S64 cur_frame_dts[MPP_PARSER_PTS_NB];
75 
76     RK_S64 offset;      ///< byte offset from starting packet start
77     RK_S64 cur_frame_end[MPP_PARSER_PTS_NB];
78     /**
79      * Set by parser to 1 for key frames and 0 for non-key frames.
80      * It is initialized to -1, so if the parser doesn't set this flag,
81      * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames
82      * will be used.
83      */
84     RK_S32 key_frame;
85     RK_S32 eos;
86 } SplitContext_t;
87 
88 typedef struct H265dContext {
89 
90     void *priv_data;
91 
92     void *split_cxt;
93 
94     /**
95     * for rk log printf
96     **/
97     // RK_LOG_CONTEX_t *log_ctx;
98     /**
99      * display width & height
100     **/
101     RK_S32 width, height;
102 
103     /**
104      *codec decoder width & height
105     **/
106     RK_S32 coded_width, coded_height;
107 
108     RK_U8 *extradata;
109 
110     RK_U32 extradata_size;
111 
112     /**
113      * Pixel format
114     **/
115     RK_U32 pix_fmt;
116 
117     RK_U32 nBitDepth;
118     RK_U32 err_recognition;
119 
120     /**
121          * sample aspect ratio (0 if unknown)
122          * That is the width of a pixel divided by the height of the pixel.
123          * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
124          * - decoding: Set by rkcodec.
125         */
126     MppRational_t sample_aspect_ratio;
127 
128     /**
129      * YUV colorspace type.
130      * - decoding: Set by rkcodec
131      */
132     MppFrameColorSpace colorspace;
133 
134     /**
135      * MPEG vs JPEG YUV range.
136      * - decoding: Set by rkcodec
137      */
138     MppFrameColorRange color_range;
139 
140     void *compare_info;
141 
142     MppDecCfgSet *cfg;
143 
144     const MppDecHwCap *hw_info;
145 } H265dContext_t;
146 #ifdef  __cplusplus
147 extern "C" {
148 #endif
149 
150 RK_S32 h265d_parser2_syntax(void *ctx);
151 RK_S32 h265d_syntax_fill_slice(void *ctx, RK_S32 input_index);
152 
153 #ifdef  __cplusplus
154 }
155 #endif
156 
157 #endif /* __H265D_CODEC_H__ */
158