• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 __MPP_META_H__
18 #define __MPP_META_H__
19 
20 #include <stdint.h>
21 #include "rk_type.h"
22 
23 #define FOURCC_META(a, b, c, d) ((RK_U32)(a) << 24  | \
24                                 ((RK_U32)(b) << 16) | \
25                                 ((RK_U32)(c) << 8)  | \
26                                 ((RK_U32)(d) << 0))
27 
28 /*
29  * Mpp Metadata definition
30  *
31  * Metadata is for information transmision in mpp.
32  * Mpp task will contain two meta data:
33  *
34  * 1. Data flow metadata
35  *    This metadata contains information of input / output data flow. For example
36  *    A. decoder input side task the input packet must be defined and output frame
37  *    may not be defined. Then decoder will try malloc or use committed buffer to
38  *    complete decoding.
39  *    B. decoder output side task
40  *
41  *
42  * 2. Flow control metadata
43  *
44  */
45 typedef enum MppMetaDataType_e {
46     /*
47      * mpp meta data of data flow
48      * reference counter will be used for these meta data type
49      */
50     TYPE_FRAME                  = FOURCC_META('m', 'f', 'r', 'm'),
51     TYPE_PACKET                 = FOURCC_META('m', 'p', 'k', 't'),
52     TYPE_BUFFER                 = FOURCC_META('m', 'b', 'u', 'f'),
53 
54     /* mpp meta data of normal data type */
55     TYPE_S32                    = FOURCC_META('s', '3', '2', ' '),
56     TYPE_S64                    = FOURCC_META('s', '6', '4', ' '),
57     TYPE_PTR                    = FOURCC_META('p', 't', 'r', ' '),
58 } MppMetaType;
59 
60 typedef enum MppMetaKey_e {
61     /* data flow key */
62     KEY_INPUT_FRAME             = FOURCC_META('i', 'f', 'r', 'm'),
63     KEY_INPUT_PACKET            = FOURCC_META('i', 'p', 'k', 't'),
64     KEY_OUTPUT_FRAME            = FOURCC_META('o', 'f', 'r', 'm'),
65     KEY_OUTPUT_PACKET           = FOURCC_META('o', 'p', 'k', 't'),
66     /* output motion information for motion detection */
67     KEY_MOTION_INFO             = FOURCC_META('m', 'v', 'i', 'f'),
68     KEY_HDR_INFO                = FOURCC_META('h', 'd', 'r', ' '),
69 
70     /* flow control key */
71     KEY_INPUT_BLOCK             = FOURCC_META('i', 'b', 'l', 'k'),
72     KEY_OUTPUT_BLOCK            = FOURCC_META('o', 'b', 'l', 'k'),
73     KEY_INPUT_IDR_REQ           = FOURCC_META('i', 'i', 'd', 'r'),   /* input idr frame request flag */
74     KEY_OUTPUT_INTRA            = FOURCC_META('o', 'i', 'd', 'r'),   /* output intra frame indicator */
75 
76     /* mpp_frame / mpp_packet meta data info key */
77     KEY_TEMPORAL_ID             = FOURCC_META('t', 'l', 'i', 'd'),
78     KEY_LONG_REF_IDX            = FOURCC_META('l', 't', 'i', 'd'),
79     KEY_ENC_AVERAGE_QP          = FOURCC_META('a', 'v', 'g', 'q'),
80     KEY_ROI_DATA                = FOURCC_META('r', 'o', 'i', ' '),
81     KEY_OSD_DATA                = FOURCC_META('o', 's', 'd', ' '),
82     KEY_OSD_DATA2               = FOURCC_META('o', 's', 'd', '2'),
83     KEY_USER_DATA               = FOURCC_META('u', 's', 'r', 'd'),
84     KEY_USER_DATAS              = FOURCC_META('u', 'r', 'd', 's'),
85 
86     /*
87      * For vepu580 roi buffer config mode
88      * The encoder roi structure is so complex that we should provide a buffer
89      * tunnel for externl user to config encoder hardware by direct sending
90      * roi data buffer.
91      * This way can reduce the config parsing and roi buffer data generating
92      * overhead in mpp.
93      */
94     KEY_ROI_DATA2               = FOURCC_META('r', 'o', 'i', '2'),
95 
96     /*
97      * qpmap for rv1109/1126 encoder qpmap config
98      * Input data is a MppBuffer which contains an array of 16bit Vepu541RoiCfg.
99      * And each 16bit represents a 16x16 block qp info.
100      *
101      * H.264 - 16x16 block qp is arranged in raster order:
102      * each value is a 16bit data
103      * 00 01 02 03 04 05 06 07 -> 00 01 02 03 04 05 06 07
104      * 10 11 12 13 14 15 16 17    10 11 12 13 14 15 16 17
105      * 20 21 22 23 24 25 26 27    20 21 22 23 24 25 26 27
106      * 30 31 32 33 34 35 36 37    30 31 32 33 34 35 36 37
107      *
108      * H.265 - 16x16 block qp is reorder to 64x64/32x32 ctu order then 64x64 / 32x32 ctu raster order
109      * 64x64 ctu
110      * 00 01 02 03 04 05 06 07 -> 00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33 04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37
111      * 10 11 12 13 14 15 16 17
112      * 20 21 22 23 24 25 26 27
113      * 30 31 32 33 34 35 36 37
114      * 32x32 ctu
115      * 00 01 02 03 04 05 06 07 -> 00 01 10 11 02 03 12 13 04 05 14 15 06 07 16 17
116      * 10 11 12 13 14 15 16 17    20 21 30 31 22 23 32 33 24 25 34 35 26 27 36 37
117      * 20 21 22 23 24 25 26 27
118      * 30 31 32 33 34 35 36 37
119      */
120     KEY_QPMAP0                  = FOURCC_META('e', 'q', 'm', '0'),
121 
122     /* input motion list for smart p rate control */
123     KEY_MV_LIST                 = FOURCC_META('m', 'v', 'l', 't'),
124 
125     /* frame long-term reference frame operation */
126     KEY_ENC_MARK_LTR            = FOURCC_META('m', 'l', 't', 'r'),
127     KEY_ENC_USE_LTR             = FOURCC_META('u', 'l', 't', 'r'),
128 
129     /* MLVEC specified encoder feature  */
130     KEY_ENC_FRAME_QP            = FOURCC_META('f', 'r', 'm', 'q'),
131     KEY_ENC_BASE_LAYER_PID      = FOURCC_META('b', 'p', 'i', 'd'),
132 } MppMetaKey;
133 
134 #define mpp_meta_get(meta) mpp_meta_get_with_tag(meta, MODULE_TAG, __FUNCTION__)
135 
136 #include "mpp_frame.h"
137 #include "mpp_packet.h"
138 
139 #ifdef __cplusplus
140 extern "C" {
141 #endif
142 
143 MPP_RET mpp_meta_get_with_tag(MppMeta *meta, const char *tag, const char *caller);
144 MPP_RET mpp_meta_put(MppMeta meta);
145 RK_S32  mpp_meta_size(MppMeta meta);
146 
147 MPP_RET mpp_meta_set_s32(MppMeta meta, MppMetaKey key, RK_S32 val);
148 MPP_RET mpp_meta_set_s64(MppMeta meta, MppMetaKey key, RK_S64 val);
149 MPP_RET mpp_meta_set_ptr(MppMeta meta, MppMetaKey key, void  *val);
150 MPP_RET mpp_meta_get_s32(MppMeta meta, MppMetaKey key, RK_S32 *val);
151 MPP_RET mpp_meta_get_s64(MppMeta meta, MppMetaKey key, RK_S64 *val);
152 MPP_RET mpp_meta_get_ptr(MppMeta meta, MppMetaKey key, void  **val);
153 
154 MPP_RET mpp_meta_set_frame (MppMeta meta, MppMetaKey key, MppFrame  frame);
155 MPP_RET mpp_meta_set_packet(MppMeta meta, MppMetaKey key, MppPacket packet);
156 MPP_RET mpp_meta_set_buffer(MppMeta meta, MppMetaKey key, MppBuffer buffer);
157 MPP_RET mpp_meta_get_frame (MppMeta meta, MppMetaKey key, MppFrame  *frame);
158 MPP_RET mpp_meta_get_packet(MppMeta meta, MppMetaKey key, MppPacket *packet);
159 MPP_RET mpp_meta_get_buffer(MppMeta meta, MppMetaKey key, MppBuffer *buffer);
160 
161 MPP_RET mpp_meta_get_s32_d(MppMeta meta, MppMetaKey key, RK_S32 *val, RK_S32 def);
162 MPP_RET mpp_meta_get_s64_d(MppMeta meta, MppMetaKey key, RK_S64 *val, RK_S64 def);
163 MPP_RET mpp_meta_get_ptr_d(MppMeta meta, MppMetaKey key, void  **val, void *def);
164 MPP_RET mpp_meta_get_frame_d(MppMeta meta, MppMetaKey key, MppFrame *frame, MppFrame def);
165 MPP_RET mpp_meta_get_packet_d(MppMeta meta, MppMetaKey key, MppPacket *packet, MppPacket def);
166 MPP_RET mpp_meta_get_buffer_d(MppMeta meta, MppMetaKey key, MppBuffer *buffer, MppBuffer def);
167 
168 #ifdef __cplusplus
169 }
170 #endif
171 
172 #endif /*__MPP_META_H__*/
173