• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __MPP_META_H__
17 #define __MPP_META_H__
18 
19 #include <stdint.h>
20 #include "rk_type.h"
21 
22 #define FOURCC_META(a, b, c, d)                                                                                        \
23     (((unsigned int)(a) << 24) | ((unsigned int)(b) << 16) | ((unsigned int)(c) << 8) | ((unsigned int)(d) << 0))
24 
25 /*
26  * Mpp Metadata definition
27  *
28  * Metadata is for information transmision in mpp.
29  * Mpp task will contain two meta data:
30  *
31  * 1. Data flow metadata
32  *    This metadata contains information of input / output data flow. For example
33  *    A. decoder input side task the input packet must be defined and output frame
34  *    may not be defined. Then decoder will try malloc or use committed buffer to
35  *    complete decoding.
36  *    B. decoder output side task
37  *
38  *
39  * 2. Flow control metadata
40  *
41  */
42 typedef enum MppMetaDataType_e {
43     /*
44      * mpp meta data of data flow
45      * reference counter will be used for these meta data type
46      */
47     TYPE_FRAME = FOURCC_META('m', 'f', 'r', 'm'),
48     TYPE_PACKET = FOURCC_META('m', 'p', 'k', 't'),
49     TYPE_BUFFER = FOURCC_META('m', 'b', 'u', 'f'),
50 
51     /* mpp meta data of normal data type */
52     TYPE_S32 = FOURCC_META('s', '3', '2', ' '),
53     TYPE_S64 = FOURCC_META('s', '6', '4', ' '),
54     TYPE_PTR = FOURCC_META('p', 't', 'r', ' '),
55 } MppMetaType;
56 
57 typedef enum MppMetaKey_e {
58     /* data flow key */
59     KEY_INPUT_FRAME = FOURCC_META('i', 'f', 'r', 'm'),
60     KEY_INPUT_PACKET = FOURCC_META('i', 'p', 'k', 't'),
61     KEY_OUTPUT_FRAME = FOURCC_META('o', 'f', 'r', 'm'),
62     KEY_OUTPUT_PACKET = FOURCC_META('o', 'p', 'k', 't'),
63     /* output motion information for motion detection */
64     KEY_MOTION_INFO = FOURCC_META('m', 'v', 'i', 'f'),
65     KEY_HDR_INFO = FOURCC_META('h', 'd', 'r', ' '),
66 
67     /* flow control key */
68     KEY_INPUT_BLOCK = FOURCC_META('i', 'b', 'l', 'k'),
69     KEY_OUTPUT_BLOCK = FOURCC_META('o', 'b', 'l', 'k'),
70     KEY_INPUT_IDR_REQ = FOURCC_META('i', 'i', 'd', 'r'), /* input idr frame request flag */
71     KEY_OUTPUT_INTRA = FOURCC_META('o', 'i', 'd', 'r'),  /* output intra frame indicator */
72 
73     /* mpp_frame / mpp_packet meta data info key */
74     KEY_TEMPORAL_ID = FOURCC_META('t', 'l', 'i', 'd'),
75     KEY_LONG_REF_IDX = FOURCC_META('l', 't', 'i', 'd'),
76     KEY_ENC_AVERAGE_QP = FOURCC_META('a', 'v', 'g', 'q'),
77     KEY_ROI_DATA = FOURCC_META('r', 'o', 'i', ' '),
78     KEY_OSD_DATA = FOURCC_META('o', 's', 'd', ' '),
79     KEY_OSD_DATA2 = FOURCC_META('o', 's', 'd', '2'),
80     KEY_USER_DATA = FOURCC_META('u', 's', 'r', 'd'),
81     KEY_USER_DATAS = FOURCC_META('u', 'r', 'd', 's'),
82 
83     /* input motion list for smart p rate control */
84     KEY_MV_LIST = FOURCC_META('m', 'v', 'l', 't'),
85 
86     /* frame long-term reference frame operation */
87     KEY_ENC_MARK_LTR = FOURCC_META('m', 'l', 't', 'r'),
88     KEY_ENC_USE_LTR = FOURCC_META('u', 'l', 't', 'r'),
89 
90     /* MLVEC specified encoder feature  */
91     KEY_ENC_FRAME_QP = FOURCC_META('f', 'r', 'm', 'q'),
92     KEY_ENC_BASE_LAYER_PID = FOURCC_META('b', 'p', 'i', 'd'),
93 } MppMetaKey;
94 
95 #define mpp_meta_get(meta) mpp_meta_get_with_tag(meta, MODULE_TAG, __FUNCTION__)
96 
97 #include "mpp_frame.h"
98 
99 #ifdef __cplusplus
100 extern "C" {
101 #endif
102 
103 MPP_RET mpp_meta_get_with_tag(MppMeta *meta, const char *tag, const char *caller);
104 MPP_RET mpp_meta_put(MppMeta meta);
105 signed int mpp_meta_size(MppMeta meta);
106 
107 MPP_RET mpp_meta_set_s32(MppMeta meta, MppMetaKey key, signed int val);
108 MPP_RET mpp_meta_set_s64(MppMeta meta, MppMetaKey key, RK_S64 val);
109 MPP_RET mpp_meta_set_ptr(MppMeta meta, MppMetaKey key, void *val);
110 MPP_RET mpp_meta_get_s32(MppMeta meta, MppMetaKey key, signed int *val);
111 MPP_RET mpp_meta_get_s64(MppMeta meta, MppMetaKey key, RK_S64 *val);
112 MPP_RET mpp_meta_get_ptr(MppMeta meta, MppMetaKey key, void **val);
113 
114 MPP_RET mpp_meta_set_frame(MppMeta meta, MppMetaKey key, MppFrame frame);
115 MPP_RET mpp_meta_set_packet(MppMeta meta, MppMetaKey key, MppPacket packet);
116 MPP_RET mpp_meta_set_buffer(MppMeta meta, MppMetaKey key, MppBuffer buffer);
117 MPP_RET mpp_meta_get_frame(MppMeta meta, MppMetaKey key, MppFrame *frame);
118 MPP_RET mpp_meta_get_packet(MppMeta meta, MppMetaKey key, MppPacket *packet);
119 MPP_RET mpp_meta_get_buffer(MppMeta meta, MppMetaKey key, MppBuffer *buffer);
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif /* __MPP_META_H__ */
126