mirror of
https://github.com/nyanmisaka/mpp.git
synced 2026-01-24 05:10:39 +01:00
[mpp_dec]: Add MppDecImpl layer
Add MppDecImpl layer for separate encoder and decoder. Change-Id: I02e04acddf617ae5188572af89312ab20fbf21b6 Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
parent
9ee20c594a
commit
14076644ea
6 changed files with 159 additions and 115 deletions
|
|
@ -17,83 +17,11 @@
|
|||
#ifndef __MPP_DEC_H__
|
||||
#define __MPP_DEC_H__
|
||||
|
||||
#include "mpp_time.h"
|
||||
#include "mpp_list.h"
|
||||
#include "rk_type.h"
|
||||
#include "mpp_err.h"
|
||||
#include "rk_mpi_cmd.h"
|
||||
|
||||
#include "mpp_parser.h"
|
||||
#include "mpp_hal.h"
|
||||
|
||||
typedef struct MppDec_t MppDec;
|
||||
|
||||
// for timing record
|
||||
typedef enum MppDecTimingType_e {
|
||||
DEC_PRS_TOTAL,
|
||||
DEC_PRS_WAIT,
|
||||
DEC_PRS_PROC,
|
||||
DEC_PRS_PREPARE,
|
||||
DEC_PRS_PARSE,
|
||||
DEC_HAL_GEN_REG,
|
||||
DEC_HW_START,
|
||||
|
||||
DEC_HAL_TOTAL,
|
||||
DEC_HAL_WAIT,
|
||||
DEC_HAL_PROC,
|
||||
DEC_HW_WAIT,
|
||||
DEC_TIMING_BUTT,
|
||||
} MppDecTimingType;
|
||||
|
||||
struct MppDec_t {
|
||||
MppCodingType coding;
|
||||
|
||||
Parser parser;
|
||||
MppHal hal;
|
||||
|
||||
// common resource
|
||||
MppBufSlots frame_slots;
|
||||
MppBufSlots packet_slots;
|
||||
HalTaskGroup tasks;
|
||||
HalTaskGroup vproc_tasks;
|
||||
|
||||
// status flags
|
||||
RK_U32 parser_work_count;
|
||||
RK_U32 parser_wait_count;
|
||||
RK_U32 parser_status_flag;
|
||||
RK_U32 parser_notify_flag;
|
||||
RK_U32 hal_notify_flag;
|
||||
|
||||
// reset process:
|
||||
// 1. mpp_dec set reset flag and signal parser
|
||||
// 2. mpp_dec wait on parser_reset sem
|
||||
// 3. parser wait hal reset done
|
||||
// 4. hal wait vproc reset done
|
||||
// 5. vproc do reset and signal hal
|
||||
// 6. hal do reset and signal parser
|
||||
// 7. parser do reset and signal mpp_dec
|
||||
// 8. mpp_dec reset done
|
||||
RK_U32 reset_flag;
|
||||
|
||||
RK_U32 hal_reset_post;
|
||||
RK_U32 hal_reset_done;
|
||||
sem_t parser_reset;
|
||||
sem_t hal_reset;
|
||||
|
||||
// work mode flags
|
||||
RK_U32 parser_need_split;
|
||||
RK_U32 parser_fast_mode;
|
||||
RK_U32 parser_internal_pts;
|
||||
RK_U32 disable_error;
|
||||
RK_U32 use_preset_time_order;
|
||||
RK_U32 enable_deinterlace;
|
||||
|
||||
// dec parser thread runtime resource context
|
||||
MppPacket mpp_pkt_in;
|
||||
void *mpp;
|
||||
void *vproc;
|
||||
|
||||
// statistics data
|
||||
RK_U32 statistics_en;
|
||||
MppTimer timers[DEC_TIMING_BUTT];
|
||||
};
|
||||
typedef void* MppDec;
|
||||
|
||||
typedef struct {
|
||||
MppCodingType coding;
|
||||
|
|
@ -107,24 +35,21 @@ typedef struct {
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* main thread for all decoder. This thread will connect parser / hal / mpp
|
||||
*/
|
||||
MPP_RET mpp_dec_init(MppDec *ctx, MppDecCfg *cfg);
|
||||
MPP_RET mpp_dec_deinit(MppDec ctx);
|
||||
|
||||
MPP_RET mpp_dec_start(MppDec ctx);
|
||||
MPP_RET mpp_dec_stop(MppDec ctx);
|
||||
|
||||
MPP_RET mpp_dec_reset(MppDec ctx);
|
||||
MPP_RET mpp_dec_flush(MppDec ctx);
|
||||
MPP_RET mpp_dec_control(MppDec ctx, MpiCmd cmd, void *param);
|
||||
MPP_RET mpp_dec_notify(MppDec ctx, RK_U32 flag);
|
||||
|
||||
void *mpp_dec_parser_thread(void *data);
|
||||
void *mpp_dec_hal_thread(void *data);
|
||||
void *mpp_dec_advanced_thread(void *data);
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
MPP_RET mpp_dec_init(MppDec **dec, MppDecCfg *cfg);
|
||||
MPP_RET mpp_dec_deinit(MppDec *dec);
|
||||
|
||||
MPP_RET mpp_dec_reset(MppDec *dec);
|
||||
MPP_RET mpp_dec_flush(MppDec *dec);
|
||||
MPP_RET mpp_dec_control(MppDec *dec, MpiCmd cmd, void *param);
|
||||
MPP_RET mpp_dec_notify(MppDec *dec, RK_U32 flag);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
105
mpp/codec/inc/mpp_dec_impl.h
Normal file
105
mpp/codec/inc/mpp_dec_impl.h
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* 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_DEC_IMPL_H__
|
||||
#define __MPP_DEC_IMPL_H__
|
||||
|
||||
#include "mpp_time.h"
|
||||
|
||||
#include "mpp.h"
|
||||
#include "mpp_parser.h"
|
||||
#include "mpp_hal.h"
|
||||
|
||||
// for timing record
|
||||
typedef enum MppDecTimingType_e {
|
||||
DEC_PRS_TOTAL,
|
||||
DEC_PRS_WAIT,
|
||||
DEC_PRS_PROC,
|
||||
DEC_PRS_PREPARE,
|
||||
DEC_PRS_PARSE,
|
||||
DEC_HAL_GEN_REG,
|
||||
DEC_HW_START,
|
||||
|
||||
DEC_HAL_TOTAL,
|
||||
DEC_HAL_WAIT,
|
||||
DEC_HAL_PROC,
|
||||
DEC_HW_WAIT,
|
||||
DEC_TIMING_BUTT,
|
||||
} MppDecTimingType;
|
||||
|
||||
typedef struct MppDecImpl_t {
|
||||
MppCodingType coding;
|
||||
|
||||
Parser parser;
|
||||
MppHal hal;
|
||||
|
||||
// common resource
|
||||
MppBufSlots frame_slots;
|
||||
MppBufSlots packet_slots;
|
||||
HalTaskGroup tasks;
|
||||
HalTaskGroup vproc_tasks;
|
||||
|
||||
// status flags
|
||||
RK_U32 parser_work_count;
|
||||
RK_U32 parser_wait_count;
|
||||
RK_U32 parser_status_flag;
|
||||
RK_U32 parser_notify_flag;
|
||||
RK_U32 hal_notify_flag;
|
||||
|
||||
// reset process:
|
||||
// 1. mpp_dec set reset flag and signal parser
|
||||
// 2. mpp_dec wait on parser_reset sem
|
||||
// 3. parser wait hal reset done
|
||||
// 4. hal wait vproc reset done
|
||||
// 5. vproc do reset and signal hal
|
||||
// 6. hal do reset and signal parser
|
||||
// 7. parser do reset and signal mpp_dec
|
||||
// 8. mpp_dec reset done
|
||||
RK_U32 reset_flag;
|
||||
|
||||
RK_U32 hal_reset_post;
|
||||
RK_U32 hal_reset_done;
|
||||
sem_t parser_reset;
|
||||
sem_t hal_reset;
|
||||
|
||||
// work mode flags
|
||||
RK_U32 parser_need_split;
|
||||
RK_U32 parser_fast_mode;
|
||||
RK_U32 parser_internal_pts;
|
||||
RK_U32 disable_error;
|
||||
RK_U32 use_preset_time_order;
|
||||
RK_U32 enable_deinterlace;
|
||||
|
||||
// dec parser thread runtime resource context
|
||||
MppPacket mpp_pkt_in;
|
||||
void *mpp;
|
||||
void *vproc;
|
||||
|
||||
// statistics data
|
||||
RK_U32 statistics_en;
|
||||
MppTimer timers[DEC_TIMING_BUTT];
|
||||
} MppDecImpl;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__MPP_DEC_IMPL_H__*/
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
#include "mpp_time.h"
|
||||
|
||||
#include "mpp.h"
|
||||
#include "mpp_dec_impl.h"
|
||||
#include "mpp_buffer_impl.h"
|
||||
#include "mpp_packet_impl.h"
|
||||
#include "mpp_frame_impl.h"
|
||||
|
|
@ -123,7 +124,7 @@ static void dec_task_init(DecTask *task)
|
|||
* return MPP_OK for not wait
|
||||
* return MPP_NOK for wait
|
||||
*/
|
||||
static MPP_RET check_task_wait(MppDec *dec, DecTask *task)
|
||||
static MPP_RET check_task_wait(MppDecImpl *dec, DecTask *task)
|
||||
{
|
||||
MPP_RET ret = MPP_OK;
|
||||
RK_U32 notify = dec->parser_notify_flag;
|
||||
|
|
@ -160,7 +161,7 @@ static MPP_RET check_task_wait(MppDec *dec, DecTask *task)
|
|||
|
||||
static RK_U32 reset_parser_thread(Mpp *mpp, DecTask *task)
|
||||
{
|
||||
MppDec *dec = mpp->mDec;
|
||||
MppDecImpl *dec = (MppDecImpl *)mpp->mDec;
|
||||
MppThread *hal = mpp->mThreadHal;
|
||||
HalTaskGroup tasks = dec->tasks;
|
||||
MppBufSlots frame_slots = dec->frame_slots;
|
||||
|
|
@ -256,7 +257,7 @@ static RK_U32 reset_parser_thread(Mpp *mpp, DecTask *task)
|
|||
/* Overall mpp_dec output frame function */
|
||||
static void mpp_dec_put_frame(Mpp *mpp, RK_S32 index, HalDecTaskFlag flags)
|
||||
{
|
||||
MppDec *dec = mpp->mDec;
|
||||
MppDecImpl *dec = (MppDecImpl *)mpp->mDec;
|
||||
MppBufSlots slots = dec->frame_slots;
|
||||
MppFrame frame = NULL;
|
||||
RK_U32 eos = flags.eos;
|
||||
|
|
@ -318,7 +319,7 @@ static void mpp_dec_put_frame(Mpp *mpp, RK_S32 index, HalDecTaskFlag flags)
|
|||
mpp_assert(index >= 0);
|
||||
mpp_assert(frame);
|
||||
|
||||
if (mpp->mDec->disable_error) {
|
||||
if (dec->disable_error) {
|
||||
mpp_frame_set_errinfo(frame, 0);
|
||||
mpp_frame_set_discard(frame, 0);
|
||||
}
|
||||
|
|
@ -402,7 +403,7 @@ static void mpp_dec_put_frame(Mpp *mpp, RK_S32 index, HalDecTaskFlag flags)
|
|||
static void mpp_dec_push_display(Mpp *mpp, HalDecTaskFlag flags)
|
||||
{
|
||||
RK_S32 index = -1;
|
||||
MppDec *dec = mpp->mDec;
|
||||
MppDecImpl *dec = (MppDecImpl *)mpp->mDec;
|
||||
MppBufSlots frame_slots = dec->frame_slots;
|
||||
RK_U32 eos = flags.eos;
|
||||
HalDecTaskFlag tmp = flags;
|
||||
|
|
@ -443,7 +444,7 @@ static void mpp_dec_put_task(Mpp *mpp, DecTask *task)
|
|||
|
||||
static void reset_hal_thread(Mpp *mpp)
|
||||
{
|
||||
MppDec *dec = mpp->mDec;
|
||||
MppDecImpl *dec = (MppDecImpl *)mpp->mDec;
|
||||
HalTaskGroup tasks = dec->tasks;
|
||||
MppBufSlots frame_slots = dec->frame_slots;
|
||||
HalDecTaskFlag flag;
|
||||
|
|
@ -473,7 +474,7 @@ static void reset_hal_thread(Mpp *mpp)
|
|||
|
||||
static MPP_RET try_proc_dec_task(Mpp *mpp, DecTask *task)
|
||||
{
|
||||
MppDec *dec = mpp->mDec;
|
||||
MppDecImpl *dec = (MppDecImpl *)mpp->mDec;
|
||||
HalTaskGroup tasks = dec->tasks;
|
||||
MppBufSlots frame_slots = dec->frame_slots;
|
||||
MppBufSlots packet_slots = dec->packet_slots;
|
||||
|
|
@ -823,7 +824,7 @@ void *mpp_dec_parser_thread(void *data)
|
|||
{
|
||||
Mpp *mpp = (Mpp*)data;
|
||||
MppThread *parser = mpp->mThreadCodec;
|
||||
MppDec *dec = mpp->mDec;
|
||||
MppDecImpl *dec = (MppDecImpl *)mpp->mDec;
|
||||
MppBufSlots packet_slots = dec->packet_slots;
|
||||
|
||||
DecTask task;
|
||||
|
|
@ -886,7 +887,7 @@ void *mpp_dec_hal_thread(void *data)
|
|||
{
|
||||
Mpp *mpp = (Mpp*)data;
|
||||
MppThread *hal = mpp->mThreadHal;
|
||||
MppDec *dec = mpp->mDec;
|
||||
MppDecImpl *dec = (MppDecImpl *)mpp->mDec;
|
||||
HalTaskGroup tasks = dec->tasks;
|
||||
MppBufSlots frame_slots = dec->frame_slots;
|
||||
MppBufSlots packet_slots = dec->packet_slots;
|
||||
|
|
@ -1051,7 +1052,7 @@ static MPP_RET dec_release_task_in_port(MppPort port)
|
|||
void *mpp_dec_advanced_thread(void *data)
|
||||
{
|
||||
Mpp *mpp = (Mpp*)data;
|
||||
MppDec *dec = mpp->mDec;
|
||||
MppDecImpl *dec = (MppDecImpl *)mpp->mDec;
|
||||
MppBufSlots frame_slots = dec->frame_slots;
|
||||
MppBufSlots packet_slots = dec->packet_slots;
|
||||
MppThread *thd_dec = mpp->mThreadCodec;
|
||||
|
|
@ -1216,7 +1217,7 @@ static const char *timing_str[DEC_TIMING_BUTT] = {
|
|||
"hw wait ",
|
||||
};
|
||||
|
||||
MPP_RET mpp_dec_init(MppDec **dec, MppDecCfg *cfg)
|
||||
MPP_RET mpp_dec_init(MppDec *dec, MppDecCfg *cfg)
|
||||
{
|
||||
RK_S32 i;
|
||||
MPP_RET ret;
|
||||
|
|
@ -1226,7 +1227,7 @@ MPP_RET mpp_dec_init(MppDec **dec, MppDecCfg *cfg)
|
|||
Parser parser = NULL;
|
||||
MppHal hal = NULL;
|
||||
RK_S32 hal_task_count = 0;
|
||||
MppDec *p = NULL;
|
||||
MppDecImpl *p = NULL;
|
||||
IOInterruptCB cb = {NULL, NULL};
|
||||
|
||||
dec_dbg_func("in\n");
|
||||
|
|
@ -1239,7 +1240,7 @@ MPP_RET mpp_dec_init(MppDec **dec, MppDecCfg *cfg)
|
|||
|
||||
*dec = NULL;
|
||||
|
||||
p = mpp_calloc(MppDec, 1);
|
||||
p = mpp_calloc(MppDecImpl, 1);
|
||||
if (NULL == p) {
|
||||
mpp_err_f("failed to malloc context\n");
|
||||
return MPP_ERR_MALLOC;
|
||||
|
|
@ -1333,9 +1334,10 @@ MPP_RET mpp_dec_init(MppDec **dec, MppDecCfg *cfg)
|
|||
return MPP_NOK;
|
||||
}
|
||||
|
||||
MPP_RET mpp_dec_deinit(MppDec *dec)
|
||||
MPP_RET mpp_dec_deinit(MppDec ctx)
|
||||
{
|
||||
RK_S32 i;
|
||||
MppDecImpl *dec = (MppDecImpl *)ctx;
|
||||
|
||||
dec_dbg_func("%p in\n", dec);
|
||||
if (NULL == dec) {
|
||||
|
|
@ -1400,8 +1402,10 @@ MPP_RET mpp_dec_deinit(MppDec *dec)
|
|||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET mpp_dec_reset(MppDec *dec)
|
||||
MPP_RET mpp_dec_reset(MppDec ctx)
|
||||
{
|
||||
MppDecImpl *dec = (MppDecImpl *)ctx;
|
||||
|
||||
dec_dbg_func("%p in\n", dec);
|
||||
if (NULL == dec) {
|
||||
mpp_err_f("found NULL input dec %p\n", dec);
|
||||
|
|
@ -1425,8 +1429,10 @@ MPP_RET mpp_dec_reset(MppDec *dec)
|
|||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET mpp_dec_flush(MppDec *dec)
|
||||
MPP_RET mpp_dec_flush(MppDec ctx)
|
||||
{
|
||||
MppDecImpl *dec = (MppDecImpl *)ctx;
|
||||
|
||||
dec_dbg_func("%p in\n", dec);
|
||||
if (NULL == dec) {
|
||||
mpp_err_f("found NULL input dec %p\n", dec);
|
||||
|
|
@ -1440,12 +1446,14 @@ MPP_RET mpp_dec_flush(MppDec *dec)
|
|||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET mpp_dec_notify(MppDec *dec, RK_U32 flag)
|
||||
MPP_RET mpp_dec_notify(MppDec ctx, RK_U32 flag)
|
||||
{
|
||||
dec_dbg_func("%p in flag %08x\n", dec, flag);
|
||||
MppDecImpl *dec = (MppDecImpl *)ctx;
|
||||
Mpp *mpp = (Mpp *)dec->mpp;
|
||||
MppThread *thd_dec = mpp->mThreadCodec;
|
||||
|
||||
dec_dbg_func("%p in flag %08x\n", dec, flag);
|
||||
|
||||
thd_dec->lock();
|
||||
{
|
||||
RK_U32 old_flag = dec->parser_notify_flag;
|
||||
|
|
@ -1463,8 +1471,11 @@ MPP_RET mpp_dec_notify(MppDec *dec, RK_U32 flag)
|
|||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET mpp_dec_control(MppDec *dec, MpiCmd cmd, void *param)
|
||||
MPP_RET mpp_dec_control(MppDec ctx, MpiCmd cmd, void *param)
|
||||
{
|
||||
MPP_RET ret = MPP_OK;
|
||||
MppDecImpl *dec = (MppDecImpl *)ctx;
|
||||
|
||||
dec_dbg_func("%p in %08x %p\n", dec, cmd, param);
|
||||
if (NULL == dec) {
|
||||
mpp_err_f("found NULL input dec %p\n", dec);
|
||||
|
|
@ -1486,6 +1497,9 @@ MPP_RET mpp_dec_control(MppDec *dec, MpiCmd cmd, void *param)
|
|||
mpp_frame_get_ver_stride(frame));
|
||||
|
||||
} break;
|
||||
case MPP_DEC_SET_INFO_CHANGE_READY: {
|
||||
ret = mpp_buf_slot_ready(dec->frame_slots);
|
||||
} break;
|
||||
case MPP_DEC_GET_VPUMEM_USED_COUNT: {
|
||||
RK_S32 *p = (RK_S32 *)param;
|
||||
*p = mpp_slots_get_used_count(dec->frame_slots);
|
||||
|
|
@ -1508,5 +1522,5 @@ MPP_RET mpp_dec_control(MppDec *dec, MpiCmd cmd, void *param)
|
|||
}
|
||||
|
||||
dec_dbg_func("%p out\n", dec);
|
||||
return MPP_OK;
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ public:
|
|||
MppThread *mThreadHal;
|
||||
MppThread *mThreadVproc;
|
||||
|
||||
MppDec *mDec;
|
||||
MppDec mDec;
|
||||
MppEnc *mEnc;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -789,7 +789,7 @@ MPP_RET Mpp::control_dec(MpiCmd cmd, MppParam param)
|
|||
if (mpp_debug & MPP_DBG_INFO)
|
||||
mpp_log("set info change ready\n");
|
||||
|
||||
ret = mpp_buf_slot_ready(mDec->frame_slots);
|
||||
ret = mpp_dec_control(mDec, cmd, param);
|
||||
notify(MPP_DEC_NOTIFY_INFO_CHG_DONE | MPP_DEC_NOTIFY_BUFFER_MATCH);
|
||||
} break;
|
||||
case MPP_DEC_SET_PARSER_SPLIT_MODE: {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#include "mpp_mem.h"
|
||||
#include "mpp_common.h"
|
||||
|
||||
#include "mpp.h"
|
||||
#include "mpp_dec_impl.h"
|
||||
|
||||
#include "mpp_frame_impl.h"
|
||||
#include "mpp_dec_vproc.h"
|
||||
|
|
@ -191,7 +191,7 @@ static void *dec_vproc_thread(void *data)
|
|||
HalTaskGroup tasks = ctx->task_group;
|
||||
MppThread *thd = ctx->thd;
|
||||
Mpp *mpp = ctx->mpp;
|
||||
MppDec *dec = mpp->mDec;
|
||||
MppDecImpl *dec = (MppDecImpl *)mpp->mDec;
|
||||
MppBufSlots slots = dec->frame_slots;
|
||||
IepImg img;
|
||||
|
||||
|
|
@ -375,7 +375,7 @@ MPP_RET dec_vproc_init(MppDecVprocCtx *ctx, MppDecVprocCfg *cfg)
|
|||
}
|
||||
|
||||
p->mpp = (Mpp *)cfg->mpp;
|
||||
p->slots = p->mpp->mDec->frame_slots;
|
||||
p->slots = ((MppDecImpl *)p->mpp->mDec)->frame_slots;
|
||||
p->thd = new MppThread(dec_vproc_thread, p, "mpp_dec_vproc");
|
||||
ret = hal_task_group_init(&p->task_group, 4);
|
||||
if (ret) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue