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) (((RK_U32)(a) << 24) | \ 23 ((RK_U32)(b) << 16) | \ 24 ((RK_U32)(c) << 8) | \ 25 ((RK_U32)(d) << 0)) 26 27 /* 28 * Mpp Metadata definition 29 * 30 * Metadata is for information transmision in mpp. 31 * Mpp task will contain two meta data: 32 * 33 * 1. Data flow metadata 34 * This metadata contains information of input / output data flow. For example 35 * A. decoder input side task the input packet must be defined and output frame 36 * may not be defined. Then decoder will try malloc or use committed buffer to 37 * complete decoding. 38 * B. decoder output side task 39 * 40 * 41 * 2. Flow control metadata 42 * 43 */ 44 typedef enum MppMetaDataType_e { 45 /* 46 * mpp meta data of data flow 47 * reference counter will be used for these meta data type 48 */ 49 TYPE_FRAME = FOURCC_META('m', 'f', 'r', 'm'), 50 TYPE_PACKET = FOURCC_META('m', 'p', 'k', 't'), 51 TYPE_BUFFER = FOURCC_META('m', 'b', 'u', 'f'), 52 53 /* mpp meta data of normal data type */ 54 TYPE_S32 = FOURCC_META('s', '3', '2', ' '), 55 TYPE_S64 = FOURCC_META('s', '6', '4', ' '), 56 TYPE_PTR = FOURCC_META('p', 't', 'r', ' '), 57 } MppMetaType; 58 59 typedef enum MppMetaKey_e { 60 /* data flow key */ 61 KEY_INPUT_FRAME = FOURCC_META('i', 'f', 'r', 'm'), 62 KEY_INPUT_PACKET = FOURCC_META('i', 'p', 'k', 't'), 63 KEY_OUTPUT_FRAME = FOURCC_META('o', 'f', 'r', 'm'), 64 KEY_OUTPUT_PACKET = FOURCC_META('o', 'p', 'k', 't'), 65 /* output motion information for motion detection */ 66 KEY_MOTION_INFO = FOURCC_META('m', 'v', 'i', 'f'), 67 KEY_HDR_INFO = FOURCC_META('h', 'd', 'r', ' '), 68 69 /* flow control key */ 70 KEY_INPUT_BLOCK = FOURCC_META('i', 'b', 'l', 'k'), 71 KEY_OUTPUT_BLOCK = FOURCC_META('o', 'b', 'l', 'k'), 72 KEY_INPUT_IDR_REQ = FOURCC_META('i', 'i', 'd', 'r'), /* input idr frame request flag */ 73 KEY_OUTPUT_INTRA = FOURCC_META('o', 'i', 'd', 'r'), /* output intra frame indicator */ 74 75 /* mpp_frame / mpp_packet meta data info key */ 76 KEY_TEMPORAL_ID = FOURCC_META('t', 'l', 'i', 'd'), 77 KEY_LONG_REF_IDX = FOURCC_META('l', 't', 'i', 'd'), 78 KEY_ENC_AVERAGE_QP = FOURCC_META('a', 'v', 'g', 'q'), 79 KEY_ROI_DATA = FOURCC_META('r', 'o', 'i', ' '), 80 KEY_OSD_DATA = FOURCC_META('o', 's', 'd', ' '), 81 KEY_OSD_DATA2 = FOURCC_META('o', 's', 'd', '2'), 82 KEY_USER_DATA = FOURCC_META('u', 's', 'r', 'd'), 83 KEY_USER_DATAS = FOURCC_META('u', 'r', 'd', 's'), 84 85 /* input motion list for smart p rate control */ 86 KEY_MV_LIST = FOURCC_META('m', 'v', 'l', 't'), 87 88 /* frame long-term reference frame operation */ 89 KEY_ENC_MARK_LTR = FOURCC_META('m', 'l', 't', 'r'), 90 KEY_ENC_USE_LTR = FOURCC_META('u', 'l', 't', 'r'), 91 92 /* MLVEC specified encoder feature */ 93 KEY_ENC_FRAME_QP = FOURCC_META('f', 'r', 'm', 'q'), 94 KEY_ENC_BASE_LAYER_PID = FOURCC_META('b', 'p', 'i', 'd'), 95 } MppMetaKey; 96 97 #define mpp_meta_get(meta) mpp_meta_get_with_tag(meta, MODULE_TAG, __FUNCTION__) 98 99 #include "mpp_frame.h" 100 101 #ifdef __cplusplus 102 extern "C" { 103 #endif 104 105 MPP_RET mpp_meta_get_with_tag(MppMeta *meta, const char *tag, const char *caller); 106 MPP_RET mpp_meta_put(MppMeta meta); 107 RK_S32 mpp_meta_size(MppMeta meta); 108 109 MPP_RET mpp_meta_set_s32(MppMeta meta, MppMetaKey key, RK_S32 val); 110 MPP_RET mpp_meta_set_s64(MppMeta meta, MppMetaKey key, RK_S64 val); 111 MPP_RET mpp_meta_set_ptr(MppMeta meta, MppMetaKey key, void *val); 112 MPP_RET mpp_meta_get_s32(MppMeta meta, MppMetaKey key, RK_S32 *val); 113 MPP_RET mpp_meta_get_s64(MppMeta meta, MppMetaKey key, RK_S64 *val); 114 MPP_RET mpp_meta_get_ptr(MppMeta meta, MppMetaKey key, void **val); 115 116 MPP_RET mpp_meta_set_frame (MppMeta meta, MppMetaKey key, MppFrame frame); 117 MPP_RET mpp_meta_set_packet(MppMeta meta, MppMetaKey key, MppPacket packet); 118 MPP_RET mpp_meta_set_buffer(MppMeta meta, MppMetaKey key, MppBuffer buffer); 119 MPP_RET mpp_meta_get_frame (MppMeta meta, MppMetaKey key, MppFrame *frame); 120 MPP_RET mpp_meta_get_packet(MppMeta meta, MppMetaKey key, MppPacket *packet); 121 MPP_RET mpp_meta_get_buffer(MppMeta meta, MppMetaKey key, MppBuffer *buffer); 122 123 #ifdef __cplusplus 124 } 125 #endif 126 127 #endif /* __MPP_META_H__ */ 128