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_ENC_H__ 18 #define __MPP_ENC_H__ 19 20 #include "rk_type.h" 21 #include "mpp_err.h" 22 #include "rk_mpi_cmd.h" 23 24 /* 25 * Configure of encoder is separated into four parts. 26 * 27 * 1. Rate control parameter 28 * This is quality and bitrate request from user. 29 * For controller only 30 * 31 * 2. Data source MppFrame parameter 32 * This is data source buffer information. 33 * For both controller and hal 34 * 35 * 3. Video codec infomation 36 * This is user custormized stream information. 37 * For hal only 38 * 39 * 4. Extra parameter 40 * including: 41 * PreP : encoder Preprocess configuration 42 * ROI : Region Of Interest 43 * OSD : On Screen Display 44 * MD : Motion Detection 45 * extra : SEI for h.264 / Exif for mjpeg 46 * For hal only 47 * 48 * The module transcation flow is as follows: 49 * 50 * + + 51 * User | Mpi/Mpp | EncImpl 52 * | | Hal 53 * | | 54 * +----------+ | +---------+ | +------------+ 55 * | | | | +-----RcCfg-----> | 56 * | RcCfg +---------> | | | EncImpl | 57 * | | | | | +-Frame-----> | 58 * +----------+ | | | | | +---+-----^--+ 59 * | | | | | | | 60 * | | | | | | | 61 * +----------+ | | | | | syntax | 62 * | | | | | | | | | 63 * | MppFrame +---------> MppEnc +---+ | | result 64 * | | | | | | | | | 65 * +----------+ | | | | | | | 66 * | | | | | +---v-----+--+ 67 * | | | +-Frame-----> | 68 * +----------+ | | | | | | 69 * | | | | +---CodecCfg----> Hal | 70 * | CodecCfg +---------> | | | | 71 * | | | | <-----Extra-----> | 72 * +----------+ | +---------+ | +------------+ 73 * | | 74 * | | 75 * + + 76 * 77 * The function call flow is shown below: 78 * 79 * mpi mpp_enc controller hal 80 * + + + + 81 * | | | | 82 * | | | | 83 * +----------init------------> | | 84 * | | | | 85 * | | | | 86 * | PrepCfg | | | 87 * +---------control----------> PrepCfg | | 88 * | +-----control-----> | 89 * | | | PrepCfg | 90 * | +--------------------------control--------> 91 * | | | allocate 92 * | | | buffer 93 * | | | | 94 * | RcCfg | | | 95 * +---------control----------> RcCfg | | 96 * | +-----control-----> | 97 * | | rc_init | 98 * | | | | 99 * | | | | 100 * | CodecCfg | | | 101 * +---------control----------> | CodecCfg | 102 * | +--------------------------control--------> 103 * | | | generate 104 * | | | sps/pps 105 * | | | Get extra info | 106 * | +--------------------------control--------> 107 * | Get extra info | | | 108 * +---------control----------> | | 109 * | | | | 110 * | | | | 111 * | ROICfg | | | 112 * +---------control----------> | ROICfg | 113 * | +--------------------------control--------> 114 * | | | | 115 * | OSDCfg | | | 116 * +---------control----------> | OSDCfg | 117 * | +--------------------------control--------> 118 * | | | | 119 * | MDCfg | | | 120 * +---------control----------> | MDCfg | 121 * | +--------------------------control--------> 122 * | | | | 123 * | Set extra info | | | 124 * +---------control----------> | Set extra info | 125 * | +--------------------------control--------> 126 * | | | | 127 * | task | | | 128 * +----------encode----------> task | | 129 * | +-----encode------> | 130 * | | encode | 131 * | | | syntax | 132 * | +--------------------------gen_reg--------> 133 * | | | | 134 * | | | | 135 * | +---------------------------start---------> 136 * | | | | 137 * | | | | 138 * | +---------------------------wait----------> 139 * | | | | 140 * | | callback | | 141 * | +-----------------> | 142 * +--OSD-MD--encode----------> | | 143 * | . | | | 144 * | . | | | 145 * | . | | | 146 * +--OSD-MD--encode----------> | | 147 * | | | | 148 * +----------deinit----------> | | 149 * + + + + 150 */ 151 152 typedef void* MppEnc; 153 154 typedef struct MppEncInitCfg_t { 155 MppCodingType coding; 156 RK_S32 task_cnt; 157 void *mpp; 158 } MppEncInitCfg; 159 160 #ifdef __cplusplus 161 extern "C" { 162 #endif 163 164 MPP_RET mpp_enc_init_v2(MppEnc *ctx, MppEncInitCfg *cfg); 165 MPP_RET mpp_enc_deinit_v2(MppEnc ctx); 166 167 MPP_RET mpp_enc_start_v2(MppEnc ctx); 168 MPP_RET mpp_enc_start_async(MppEnc ctx); 169 MPP_RET mpp_enc_stop_v2(MppEnc ctx); 170 171 MPP_RET mpp_enc_control_v2(MppEnc ctx, MpiCmd cmd, void *param); 172 MPP_RET mpp_enc_notify_v2(MppEnc ctx, RK_U32 flag); 173 MPP_RET mpp_enc_reset_v2(MppEnc ctx); 174 175 #ifdef __cplusplus 176 } 177 #endif 178 179 #endif /*__MPP_ENC_H__*/ 180