mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-13 04:43:42 +08:00

1. Interface change: Separate normal config into three basic config and several runtime config: Three basic config - a. rate control config b. preprocess config c. video codec protocol config More flexible rate control interfaces are provided. More codec configure interfaces are provided. Change flag with bitmap is provided for further optimization. 2. Remove old codec config from controller and left rate control module only Encoder controller only handle user rate control requirement and bit allocation. Hal hardware encoder only handle qp calculation according given target bit. Remove all old codec code. 3. Move codec process to hal Different hardware will share same codec process function in common protocol directory. And different hardware api will register to same api set. Codec header generation is moved to separate hal directory. 4. Encoder will return length by task Encoder will NOT get stream information feedback from controller. All information required by encoder will be all stored in Task. 5. Add mpp_rc for rate control Move some common rate control utils to mpp_base. 6. Update mpi_enc_test and mpi_rc_test with new interface Change-Id: Iebb5e276a48f547167e1bed4673f21cc2f0c8ad5 Signed-off-by: Herman Chen <herman.chen@rock-chips.com> Signed-off-by: Lin Kesheng <lks@rock-chips.com>
210 lines
9.6 KiB
C
210 lines
9.6 KiB
C
/*
|
|
* Copyright 2015 Rockchip Electronics Co. LTD
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#ifndef __MPP_ENC_H__
|
|
#define __MPP_ENC_H__
|
|
|
|
#include "rk_mpi.h"
|
|
|
|
#include "mpp_thread.h"
|
|
#include "mpp_controller.h"
|
|
#include "mpp_hal.h"
|
|
|
|
/*
|
|
* Configure of encoder is separated into four parts.
|
|
*
|
|
* 1. Rate control parameter
|
|
* This is quality and bitrate request from user.
|
|
* For controller only
|
|
*
|
|
* 2. Data source MppFrame parameter
|
|
* This is data source buffer information.
|
|
* For both controller and hal
|
|
*
|
|
* 3. Video codec infomation
|
|
* This is user custormized stream information.
|
|
* For hal only
|
|
*
|
|
* 4. Extra parameter
|
|
* including:
|
|
* PreP : encoder Preprocess configuration
|
|
* ROI : Region Of Interest
|
|
* OSD : On Screen Display
|
|
* MD : Motion Detection
|
|
* extra : SEI for h.264 / Exif for mjpeg
|
|
* For hal only
|
|
*
|
|
* The module transcation flow is as follows:
|
|
*
|
|
* + +
|
|
* User | Mpi/Mpp | Controller
|
|
* | | Hal
|
|
* | |
|
|
* +----------+ | +---------+ | +------------+
|
|
* | | | | +-----RcCfg-----> |
|
|
* | RcCfg +---------> | | | Controller |
|
|
* | | | | | +-Frame-----> |
|
|
* +----------+ | | | | | +---+-----^--+
|
|
* | | | | | | |
|
|
* | | | | | | |
|
|
* +----------+ | | | | | syntax |
|
|
* | | | | | | | | |
|
|
* | MppFrame +---------> MppEnc +---+ | | result
|
|
* | | | | | | | | |
|
|
* +----------+ | | | | | | |
|
|
* | | | | | +---v-----+--+
|
|
* | | | +-Frame-----> |
|
|
* +----------+ | | | | | |
|
|
* | | | | +---CodecCfg----> Hal |
|
|
* | CodecCfg +---------> | | | |
|
|
* | | | | <-----Extra-----> |
|
|
* +----------+ | +---------+ | +------------+
|
|
* | |
|
|
* | |
|
|
* + +
|
|
*
|
|
* The function call flow is shown below:
|
|
*
|
|
* mpi mpp_enc controller hal
|
|
* + + + +
|
|
* | | | |
|
|
* | | | |
|
|
* +----------init------------> | |
|
|
* | | | |
|
|
* | | | |
|
|
* | PrepCfg | | |
|
|
* +---------control----------> PrepCfg | |
|
|
* | +-----control-----> |
|
|
* | | | PrepCfg |
|
|
* | +--------------------------control-------->
|
|
* | | | allocate
|
|
* | | | buffer
|
|
* | | | |
|
|
* | RcCfg | | |
|
|
* +---------control----------> RcCfg | |
|
|
* | +-----control-----> |
|
|
* | | rc_init |
|
|
* | | | |
|
|
* | | | |
|
|
* | CodecCfg | | |
|
|
* +---------control----------> | CodecCfg |
|
|
* | +--------------------------control-------->
|
|
* | | | generate
|
|
* | | | sps/pps
|
|
* | | | Get extra info |
|
|
* | +--------------------------control-------->
|
|
* | Get extra info | | |
|
|
* +---------control----------> | |
|
|
* | | | |
|
|
* | | | |
|
|
* | ROICfg | | |
|
|
* +---------control----------> | ROICfg |
|
|
* | +--------------------------control-------->
|
|
* | | | |
|
|
* | OSDCfg | | |
|
|
* +---------control----------> | OSDCfg |
|
|
* | +--------------------------control-------->
|
|
* | | | |
|
|
* | MDCfg | | |
|
|
* +---------control----------> | MDCfg |
|
|
* | +--------------------------control-------->
|
|
* | | | |
|
|
* | Set extra info | | |
|
|
* +---------control----------> | Set extra info |
|
|
* | +--------------------------control-------->
|
|
* | | | |
|
|
* | task | | |
|
|
* +----------encode----------> task | |
|
|
* | +-----encode------> |
|
|
* | | encode |
|
|
* | | | syntax |
|
|
* | +--------------------------gen_reg-------->
|
|
* | | | |
|
|
* | | | |
|
|
* | +---------------------------start--------->
|
|
* | | | |
|
|
* | | | |
|
|
* | +---------------------------wait---------->
|
|
* | | | |
|
|
* | | callback | |
|
|
* | +-----------------> |
|
|
* +--OSD-MD--encode----------> | |
|
|
* | . | | |
|
|
* | . | | |
|
|
* | . | | |
|
|
* +--OSD-MD--encode----------> | |
|
|
* | | | |
|
|
* +----------deinit----------> | |
|
|
* + + + +
|
|
*/
|
|
|
|
typedef struct MppEnc_t MppEnc;
|
|
|
|
struct MppEnc_t {
|
|
MppCodingType coding;
|
|
Controller controller;
|
|
MppHal hal;
|
|
|
|
// common resource
|
|
MppBufSlots frame_slots;
|
|
MppBufSlots packet_slots;
|
|
HalTaskGroup tasks;
|
|
|
|
// internal status and protection
|
|
Mutex lock;
|
|
RK_U32 reset_flag;
|
|
|
|
/* Encoder configure set */
|
|
MppEncCfgSet cfg;
|
|
MppEncCfgSet set;
|
|
|
|
/*
|
|
* configuration parameter to controller and hal
|
|
*/
|
|
MppEncConfig mpp_cfg;
|
|
};
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
* main thread for all encoder. This thread will connect encoder / hal / mpp
|
|
*/
|
|
void *mpp_enc_control_thread(void *data);
|
|
void *mpp_enc_hal_thread(void *data);
|
|
|
|
MPP_RET mpp_enc_init(MppEnc **enc, MppCodingType coding);
|
|
MPP_RET mpp_enc_deinit(MppEnc *enc);
|
|
MPP_RET mpp_enc_control(MppEnc *enc, MpiCmd cmd, void *param);
|
|
MPP_RET mpp_enc_notify(void *ctx, void *info);
|
|
MPP_RET mpp_enc_reset(MppEnc *enc);
|
|
|
|
/*
|
|
* preprocess config and rate-control config is common config then they will
|
|
* be done in mpp_enc layer
|
|
*
|
|
* codec related config will be set in each hal component
|
|
*/
|
|
void mpp_enc_update_prep_cfg(MppEncPrepCfg *dst, MppEncPrepCfg *src);
|
|
void mpp_enc_update_rc_cfg(MppEncRcCfg *dst, MppEncRcCfg *src);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /*__MPP_ENC_H__*/
|