[mpp]: add header for advanced task api

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@913 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming
2016-06-14 12:12:52 +00:00
parent c394441f63
commit 6a552fb7e4
3 changed files with 236 additions and 11 deletions

200
inc/mpp_task.h Normal file
View File

@@ -0,0 +1,200 @@
/*
* 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_TASK_H__
#define __MPP_TASK_H__
#include "mpp_frame.h"
#include "mpp_packet.h"
/*
* Advanced task flow
* Advanced task flow introduces three concepts: port, task and item
*
* Port is from OpenMAX
* Port has two type: input port and output port which are all for data transaction.
* Port work like a queue. task will be dequeue from or enqueue to one port.
* On input side user will dequeue task from input port, setup task and enqueue task
* back to input port.
* On output side user will dequeue task from output port, get the information from
* and then enqueue task back to output port.
*
* Task indicates one transaction on the port.
* Task has two working mode: async mode and sync mode
* If mpp is work in sync mode on task enqueue function return the task has been done
* If mpp is work in async mode on task enqueue function return the task is just put
* on the task queue for process.
* Task can carry different items. Task just like a container of items
*
* Item indicates MppPacket or MppFrame which is contained in one task
*/
/*
* mpp has two ports: input and output
* Each port uses its task queue to communication
*/
typedef enum {
MPP_PORT_INPUT,
MPP_PORT_OUTPUT,
MPP_PORT_BUTT,
} MppPortType;
/*
* Advance task work flow mode:
******************************************************************************
* 1. async mode (default)
*
* mpp_init(type, coding, MPP_WORK_ASYNC)
*
* input thread
* a - dequeue(input, *task)
* b - task_set_item(packet/frame)
* c - enqueue(input, task) // when enqueue return the task is not done yet
*
* output thread
* a - dequeue(output, *task)
* b - task_get_item(frame/packet)
* c - enqueue(output, task)
******************************************************************************
* 2. sync mode
*
* mpp_init(type, coding, MPP_WORK_SYNC)
*
* a - dequeue(input, *task)
* b - task_set_item(packet/frame)
* c - enqueue(task) // when enqueue return the task is finished
******************************************************************************
*/
typedef enum {
MPP_TASK_ASYNC,
MPP_TASK_SYNC,
MPP_TASK_WORK_MODE_BUTT,
} MppTaskWorkMode;
/*
* MppTask is descriptor of a task which send to mpp for process
* mpp can support different type of work mode, for example:
*
* decoder:
*
* 1. typical decoder mode:
* input - MppPacket (normal cpu buffer, need cpu copy)
* output - MppFrame (ion/drm buffer in external/internal mode)
* 2. secure decoder mode:
* input - MppPacket (externel ion/drm buffer, cpu can not access)
* output - MppFrame (ion/drm buffer in external/internal mode, cpu can not access)
*
* interface usage:
*
* typical flow
* input side:
* task_dequeue(ctx, PORT_INPUT, &task);
* task_put_item(task, MODE_INPUT, packet)
* task_enqueue(ctx, PORT_INPUT, task);
* output side:
* task_dequeue(ctx, PORT_OUTPUT, &task);
* task_get_item(task, MODE_OUTPUT, &frame)
* task_enqueue(ctx, PORT_OUTPUT, task);
*
* secure flow
* input side:
* task_dequeue(ctx, PORT_INPUT, &task);
* task_put_item(task, MODE_INPUT, packet)
* task_put_item(task, MODE_OUTPUT, frame) // buffer will be specified here
* task_enqueue(ctx, PORT_INPUT, task);
* output side:
* task_dequeue(ctx, PORT_OUTPUT, &task);
* task_get_item(task, MODE_OUTPUT, &frame)
* task_enqueue(ctx, PORT_OUTPUT, task);
*
* encoder:
*
* 1. typical encoder mode:
* input - MppFrame (ion/drm buffer in external mode)
* output - MppPacket (normal cpu buffer, need cpu copy)
* 2. user input encoder mode:
* input - MppFrame (normal cpu buffer, need to build hardware table for this buffer)
* output - MppPacket (normal cpu buffer, need cpu copy)
* 3. secure encoder mode:
* input - MppFrame (ion/drm buffer in external mode, cpu can not access)
* output - MppPacket (externel ion/drm buffer, cpu can not access)
*
* typical / user input flow
* input side:
* task_dequeue(ctx, PORT_INPUT, &task);
* task_put_item(task, MODE_INPUT, frame)
* task_enqueue(ctx, PORT_INPUT, task);
* output side:
* task_dequeue(ctx, PORT_OUTPUT, &task);
* task_get_item(task, MODE_OUTPUT, &packet)
* task_enqueue(ctx, PORT_OUTPUT, task);
*
* secure flow
* input side:
* task_dequeue(ctx, PORT_INPUT, &task);
* task_put_item(task, MODE_OUTPUT, packet) // buffer will be specified here
* task_put_item(task, MODE_INPUT, frame)
* task_enqueue(ctx, PORT_INPUT, task);
* output side:
* task_dequeue(ctx, PORT_OUTPUT, &task);
* task_get_item(task, MODE_OUTPUT, &packet)
* task_enqueue(ctx, PORT_OUTPUT, task);
*
* image processing
*
* 1. typical image process mode:
* input - MppFrame (ion/drm buffer in external mode)
* output - MppFrame (ion/drm buffer in external mode)
*
* typical / user input flow
* input side:
* task_dequeue(ctx, PORT_INPUT, &task);
* task_put_item(task, MODE_INPUT, frame)
* task_enqueue(ctx, PORT_INPUT, task);
* output side:
* task_dequeue(ctx, PORT_OUTPUT, &task);
* task_get_item(task, MODE_OUTPUT, &frame)
* task_enqueue(ctx, PORT_OUTPUT, task);
*/
/* NOTE: use index rather then handle to descripbe task */
typedef RK_S32 MppTask;
typedef void* MppItem;
typedef enum {
ITEM_MODE_INPUT,
ITEM_MODE_OUTPUT,
ITEM_MODE_BUTT,
} MppItemMode;
typedef enum {
ITEM_TYPE_PACKET,
ITEM_TYPE_FRAME,
ITEM_TYPE_CONFIG,
ITEM_TYPE_BUTT,
} MppItemType;
#ifdef __cplusplus
extern "C" {
#endif
void mpp_task_set_item(MppTask task, MppItemMode mode, MppItemType type, MppItem item);
void mpp_task_get_item(MppTask task, MppItemMode mode, MppItemType type, MppItem *item);
#ifdef __cplusplus
}
#endif
#endif /*__MPP_QUEUE_H__*/

View File

@@ -17,8 +17,7 @@
#ifndef __RK_MPI_H__ #ifndef __RK_MPI_H__
#define __RK_MPI_H__ #define __RK_MPI_H__
#include "mpp_packet.h" #include "mpp_task.h"
#include "mpp_frame.h"
typedef enum { typedef enum {
MPP_CTX_DEC, MPP_CTX_DEC,
@@ -59,7 +58,6 @@ typedef enum {
MPP_VIDEO_CodingMax = 0x7FFFFFFF MPP_VIDEO_CodingMax = 0x7FFFFFFF
} MppCodingType; } MppCodingType;
typedef enum { typedef enum {
MPP_CMD_BASE = 0, MPP_CMD_BASE = 0,
MPP_ENABLE_DEINTERLACE, MPP_ENABLE_DEINTERLACE,
@@ -92,7 +90,6 @@ typedef enum {
MPI_CMD_BUTT, MPI_CMD_BUTT,
} MpiCmd; } MpiCmd;
typedef void* MppCtx; typedef void* MppCtx;
typedef void* MppParam; typedef void* MppParam;
@@ -149,16 +146,32 @@ typedef struct MppEncConfig_t {
* size : MppApi structure size * size : MppApi structure size
* version : Mpp svn revision * version : Mpp svn revision
* *
* all api function are seperated into two sets: data io api set and control api set
*
* the data api set is for data input/output flow including:
*
* simple data api set:
*
* decode : both send video stream packet to decoder and get video frame from * decode : both send video stream packet to decoder and get video frame from
* decoder at the same time. * decoder at the same time.
* encode : both send video frame to encoder and get encoded video stream from
* encoder at the same time.
*
* decode_put_packet: send video stream packet to decoder only, async interface * decode_put_packet: send video stream packet to decoder only, async interface
* decode_get_frame : get video frame from decoder only, async interface * decode_get_frame : get video frame from decoder only, async interface
* *
* encode : both send video frame to encoder and get encoded video stream from
* encoder at the same time.
* encode_put_frame : send video frame to encoder only, async interface * encode_put_frame : send video frame to encoder only, async interface
* encode_get_packet: get encoded video packet from encoder only, async interface * encode_get_packet: get encoded video packet from encoder only, async interface
* *
* advance task api set:
*
*
* the control api set is for mpp context control including:
* control : similiar to ioctl in kernel driver, setup or get mpp internal parameter
* reset : clear all data in mpp context, reset to initialized status
* the simple api set is for simple codec usage including:
*
*
* reset : discard all packet and frame, reset all component, * reset : discard all packet and frame, reset all component,
* for both decoder and encoder * for both decoder and encoder
* control : control function for mpp property setting * control : control function for mpp property setting
@@ -168,17 +181,24 @@ typedef struct MppApi_t {
RK_U32 size; RK_U32 size;
RK_U32 version; RK_U32 version;
// sync interface // simple data flow interface
MPP_RET (*decode)(MppCtx ctx, MppPacket packet, MppFrame *frame); MPP_RET (*decode)(MppCtx ctx, MppPacket packet, MppFrame *frame);
MPP_RET (*encode)(MppCtx ctx, MppFrame frame, MppPacket *packet);
// async interface
MPP_RET (*decode_put_packet)(MppCtx ctx, MppPacket packet); MPP_RET (*decode_put_packet)(MppCtx ctx, MppPacket packet);
MPP_RET (*decode_get_frame)(MppCtx ctx, MppFrame *frame); MPP_RET (*decode_get_frame)(MppCtx ctx, MppFrame *frame);
MPP_RET (*encode)(MppCtx ctx, MppFrame frame, MppPacket *packet);
MPP_RET (*encode_put_frame)(MppCtx ctx, MppFrame frame); MPP_RET (*encode_put_frame)(MppCtx ctx, MppFrame frame);
MPP_RET (*encode_get_packet)(MppCtx ctx, MppPacket *packet); MPP_RET (*encode_get_packet)(MppCtx ctx, MppPacket *packet);
MPP_RET (*isp)(MppCtx ctx, MppFrame dst, MppFrame src);
MPP_RET (*isp_put_frame)(MppCtx ctx, MppFrame frame);
MPP_RET (*isp_get_frame)(MppCtx ctx, MppFrame *frame);
// advance data flow interface
MPP_RET (*dequeue)(MppCtx ctx, MppPortType type, MppTask *task);
MPP_RET (*enqueue)(MppCtx ctx, MppPortType type, MppTask task);
// control interface
MPP_RET (*reset)(MppCtx ctx); MPP_RET (*reset)(MppCtx ctx);
MPP_RET (*control)(MppCtx ctx, MpiCmd cmd, MppParam param); MPP_RET (*control)(MppCtx ctx, MpiCmd cmd, MppParam param);
MPP_RET (*config)(MppCtx ctx, MppEncConfig cfg); MPP_RET (*config)(MppCtx ctx, MppEncConfig cfg);

View File

@@ -195,11 +195,16 @@ static MppApi mpp_api = {
sizeof(mpp_api), sizeof(mpp_api),
0, 0,
mpi_decode, mpi_decode,
mpi_encode,
mpi_decode_put_packet, mpi_decode_put_packet,
mpi_decode_get_frame, mpi_decode_get_frame,
mpi_encode,
mpi_encode_put_frame, mpi_encode_put_frame,
mpi_encode_get_packet, mpi_encode_get_packet,
NULL,
NULL,
NULL,
NULL,
NULL,
mpi_reset, mpi_reset,
mpi_control, mpi_control,
mpi_config, mpi_config,