From 3adfc995bd2cda3fc21754c79a2df13e7e5a1a8f Mon Sep 17 00:00:00 2001 From: ChenHengming Date: Tue, 29 Jan 2008 23:03:13 +0000 Subject: [PATCH] [mpp_hal]: add more hal api function [misc]: remove anonymous struct name git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@208 6e48237b-75ef-9749-8fc9-41990f28c85a --- inc/mpp_buffer.h | 2 +- inc/rk_mpi.h | 4 +-- mpp/codec/inc/mpp_dec.h | 4 +-- mpp/codec/mpp_buf_slot.cpp | 4 +-- mpp/codec/mpp_dec.cpp | 15 +++++--- mpp/hal/inc/hal_task.h | 8 ++--- mpp/hal/inc/mpp_hal.h | 12 ++++--- mpp/hal/mpp_hal.cpp | 70 +++++++++++++++++++++++++++++++------- mpp/mpp_packet_impl.h | 2 +- osal/inc/mpp_allocator.h | 2 +- osal/mpp_allocator_impl.h | 2 +- osal/os_allocator.h | 2 +- 12 files changed, 90 insertions(+), 37 deletions(-) diff --git a/inc/mpp_buffer.h b/inc/mpp_buffer.h index c5dba913..53912c14 100644 --- a/inc/mpp_buffer.h +++ b/inc/mpp_buffer.h @@ -170,7 +170,7 @@ typedef enum { * * TODO: to be implemented. */ -typedef struct { +typedef struct MppBufferInfo_t { MppBufferType type; size_t size; void *ptr; diff --git a/inc/rk_mpi.h b/inc/rk_mpi.h index 03d255ed..682be05b 100644 --- a/inc/rk_mpi.h +++ b/inc/rk_mpi.h @@ -93,7 +93,7 @@ typedef void* MppParam; * send a stream header to mpi ctx using parameter data / size * and decoder will try to decode the */ -typedef struct { +typedef struct MppEncConfig_t { /* * input source data format */ @@ -136,7 +136,7 @@ typedef struct { RK_S32 trans8x8_en; } MppEncConfig; -typedef struct { +typedef struct MppApi_t { RK_U32 size; RK_U32 version; diff --git a/mpp/codec/inc/mpp_dec.h b/mpp/codec/inc/mpp_dec.h index 2de2fbd6..62da52b7 100644 --- a/mpp/codec/inc/mpp_dec.h +++ b/mpp/codec/inc/mpp_dec.h @@ -28,7 +28,7 @@ * * the reset wait for extension */ -typedef struct { +typedef struct MppParserInitCfg_t { MppBufSlots slots; } MppParserInitCfg; @@ -50,7 +50,7 @@ typedef struct MppDec_t MppDec; * flush - decoder output all frames * control - decoder configure function */ -typedef struct { +typedef struct MppDecParser_t { char *name; MppCodingType coding; RK_U32 ctx_size; diff --git a/mpp/codec/mpp_buf_slot.cpp b/mpp/codec/mpp_buf_slot.cpp index eb2a7cb1..54a0d412 100644 --- a/mpp/codec/mpp_buf_slot.cpp +++ b/mpp/codec/mpp_buf_slot.cpp @@ -30,12 +30,12 @@ #define MPP_SLOT_USED_AS_DECODING (0x00000004) #define MPP_SLOT_USED_AS_DISPLAY (0x00000008) -typedef struct { +typedef struct MppBufSlotEntry_t { MppBuffer buffer; RK_U32 status; } MppBufSlotEntry; -typedef struct { +typedef struct MppBufSlotsImpl_t { Mutex *lock; RK_U32 count; RK_U32 size; diff --git a/mpp/codec/mpp_dec.cpp b/mpp/codec/mpp_dec.cpp index 8dc9aa1e..1631da40 100644 --- a/mpp/codec/mpp_dec.cpp +++ b/mpp/codec/mpp_dec.cpp @@ -16,15 +16,15 @@ #define MODULE_TAG "mpp_dec" +#include + #include "mpp_mem.h" #include "mpp_log.h" #include "mpp_common.h" #include "mpp.h" #include "mpp_dec.h" -#include "mpp_packet.h" #include "mpp_packet_impl.h" -#include "mpp_buf_slot.h" #include "h264d_api.h" #include "h265d_api.h" @@ -51,13 +51,15 @@ void *mpp_dec_parser_thread(void *data) MppDec *dec = mpp->mDec; mpp_list *packets = mpp->mPackets; MppPacketImpl packet; - HalTask task_local; HalTaskHnd task_hnd = NULL; RK_U32 packet_ready = 0; RK_U32 packet_parsed = 0; RK_U32 syntax_ready = 0; RK_U32 slot_ready = 0; + HalTask task_local; + memset(&task_local, 0, sizeof(task_local)); + while (MPP_THREAD_RUNNING == parser->get_status()) { /* * wait for stream input @@ -121,8 +123,9 @@ void *mpp_dec_parser_thread(void *data) * frame to hal loop. */ - //MppBuffer buffer; - //mpp_buffer_get(mpp->mFrameGroup, &buffer, MPP_TEST_FRAME_SIZE); + // RK_S32 output = task_local.dec.output; + // MppBuffer buffer; + // mpp_buffer_get(mpp->mFrameGroup, &buffer, MPP_TEST_FRAME_SIZE); /* @@ -153,7 +156,9 @@ void *mpp_dec_hal_thread(void *data) MppDec *dec = mpp->mDec; mpp_list *frames = mpp->mFrames; HalTaskHnd task_hnd = NULL; + HalTask task_local; + memset(&task_local, 0, sizeof(task_local)); while (MPP_THREAD_RUNNING == hal->get_status()) { /* diff --git a/mpp/hal/inc/hal_task.h b/mpp/hal/inc/hal_task.h index 355a3d08..4db5623a 100644 --- a/mpp/hal/inc/hal_task.h +++ b/mpp/hal/inc/hal_task.h @@ -28,7 +28,7 @@ * number : the number of the data pointer array element * data : the address of the pointer array, parser will add its data here */ -typedef struct { +typedef struct MppSyntax_t { RK_U32 number; void *data; } MppSyntax; @@ -64,7 +64,7 @@ typedef struct { * | | | * +----------------------+ +----v----+ */ -typedef struct { +typedef struct HalDecTask_t { // current tesk protocol syntax information MppSyntax syntax; @@ -74,7 +74,7 @@ typedef struct { RK_S32 refer[MAX_DEC_REF_NUM]; } HalDecTask; -typedef struct { +typedef struct HalEncTask_t { // current tesk protocol syntax information MppSyntax syntax; @@ -89,7 +89,7 @@ typedef struct { RK_S32 recon; } HalEncTask; -typedef union { +typedef union HalTask_u { HalDecTask dec; HalEncTask enc; } HalTask; diff --git a/mpp/hal/inc/mpp_hal.h b/mpp/hal/inc/mpp_hal.h index 58b022ca..27558058 100644 --- a/mpp/hal/inc/mpp_hal.h +++ b/mpp/hal/inc/mpp_hal.h @@ -32,7 +32,7 @@ typedef struct MppHalCfg_t { RK_U32 task_count; } MppHalCfg; -typedef struct { +typedef struct MppHalApi_t { char *name; MppCodingType coding; RK_U32 ctx_size; @@ -62,9 +62,13 @@ extern "C" { MPP_RET mpp_hal_init(MppHal *ctx, MppHalCfg *cfg); MPP_RET mpp_hal_deinit(MppHal ctx); -MPP_RET mpp_hal_reg_gen(MppHal ctx, HalDecTask *task); -MPP_RET mpp_hal_hw_start(MppHal ctx, HalDecTask *task); -MPP_RET mpp_hal_hw_wait(MppHal ctx, HalDecTask *task); +MPP_RET mpp_hal_reg_gen(MppHal ctx, HalTask *task); +MPP_RET mpp_hal_hw_start(MppHal ctx, HalTask *task); +MPP_RET mpp_hal_hw_wait(MppHal ctx, HalTask *task); + +MPP_RET mpp_hal_reset(MppHal ctx); +MPP_RET mpp_hal_flush(MppHal ctx); +MPP_RET mpp_hal_control(MppHal ctx, RK_S32 cmd, void *param); #ifdef __cplusplus } diff --git a/mpp/hal/mpp_hal.cpp b/mpp/hal/mpp_hal.cpp index 4b99ad5c..96864eaf 100644 --- a/mpp/hal/mpp_hal.cpp +++ b/mpp/hal/mpp_hal.cpp @@ -33,7 +33,7 @@ static const MppHalApi *hw_apis[] = { &api_h264d_hal, }; -typedef struct { +typedef struct MppHalImpl_t { MppCtxType type; MppCodingType coding; @@ -107,25 +107,69 @@ MPP_RET mpp_hal_deinit(MppHal ctx) return MPP_OK; } -MPP_RET mpp_hal_reg_gen(MppHal ctx, HalDecTask *task) +MPP_RET mpp_hal_reg_gen(MppHal ctx, HalTask *task) { - (void)ctx; - (void)task; - return MPP_OK; + if (NULL == ctx || NULL == task) { + mpp_err_f("found NULL input ctx %p task %p\n", ctx, task); + return MPP_ERR_NULL_PTR; + } + + MppHalImpl *p = (MppHalImpl*)ctx; + return p->api->reg_gen(p->ctx, task); } -MPP_RET mpp_hal_hw_start(MppHal ctx, HalDecTask *task) +MPP_RET mpp_hal_hw_start(MppHal ctx, HalTask *task) { - (void)ctx; - (void)task; - return MPP_OK; + if (NULL == ctx || NULL == task) { + mpp_err_f("found NULL input ctx %p task %p\n", ctx, task); + return MPP_ERR_NULL_PTR; + } + + MppHalImpl *p = (MppHalImpl*)ctx; + return p->api->start(p->ctx, task); } -MPP_RET mpp_hal_hw_wait(MppHal ctx, HalDecTask *task) +MPP_RET mpp_hal_hw_wait(MppHal ctx, HalTask *task) { - (void)ctx; - (void)task; - return MPP_OK; + if (NULL == ctx || NULL == task) { + mpp_err_f("found NULL input ctx %p task %p\n", ctx, task); + return MPP_ERR_NULL_PTR; + } + + MppHalImpl *p = (MppHalImpl*)ctx; + return p->api->wait(p->ctx, task); } +MPP_RET mpp_hal_reset(MppHal ctx) +{ + if (NULL == ctx) { + mpp_err_f("found NULL input\n"); + return MPP_ERR_NULL_PTR; + } + + MppHalImpl *p = (MppHalImpl*)ctx; + return p->api->reset(p->ctx); +} + +MPP_RET mpp_hal_flush(MppHal ctx) +{ + if (NULL == ctx) { + mpp_err_f("found NULL input\n"); + return MPP_ERR_NULL_PTR; + } + + MppHalImpl *p = (MppHalImpl*)ctx; + return p->api->flush(p->ctx); +} + +MPP_RET mpp_hal_control(MppHal ctx, RK_S32 cmd, void *param) +{ + if (NULL == ctx) { + mpp_err_f("found NULL input\n"); + return MPP_ERR_NULL_PTR; + } + + MppHalImpl *p = (MppHalImpl*)ctx; + return p->api->control(p->ctx, cmd, param); +} diff --git a/mpp/mpp_packet_impl.h b/mpp/mpp_packet_impl.h index a864bc29..51092a68 100644 --- a/mpp/mpp_packet_impl.h +++ b/mpp/mpp_packet_impl.h @@ -32,7 +32,7 @@ * pts : packet pts * dts : packet dts */ -typedef struct { +typedef struct MppPacketImpl_t { void *data; void *pos; size_t size; diff --git a/osal/inc/mpp_allocator.h b/osal/inc/mpp_allocator.h index 80180541..32c32ca3 100644 --- a/osal/inc/mpp_allocator.h +++ b/osal/inc/mpp_allocator.h @@ -22,7 +22,7 @@ typedef void *MppAllocator; -typedef struct { +typedef struct MppAllocatorApi_t { RK_U32 size; RK_U32 version; diff --git a/osal/mpp_allocator_impl.h b/osal/mpp_allocator_impl.h index cb3f2b74..d162478b 100644 --- a/osal/mpp_allocator_impl.h +++ b/osal/mpp_allocator_impl.h @@ -20,7 +20,7 @@ #include "mpp_thread.h" #include "os_allocator.h" -typedef struct { +typedef struct MppAllocatorImpl_t { pthread_mutex_t lock; MppBufferType type; size_t alignment; diff --git a/osal/os_allocator.h b/osal/os_allocator.h index 813289a7..0f3436b4 100644 --- a/osal/os_allocator.h +++ b/osal/os_allocator.h @@ -19,7 +19,7 @@ #include "mpp_allocator.h" -typedef struct { +typedef struct os_allocator_t { MPP_RET (*open)(void **ctx, size_t alignment); MPP_RET (*alloc)(void *ctx, MppBufferInfo *info); MPP_RET (*free)(void *ctx, MppBufferInfo *info);