Skip to content
Permalink
Browse files

[mpp] : retrieve available input packet free slots

This is something that allows to know before putting a packet into
the decoder if it would accept it or if it is full.

This patch also adds a constant define for the input buffer count
rather than having the 4 hardcoded.
  • Loading branch information
LongChair committed Oct 24, 2017
1 parent 21a1264 commit a68592b1d4b7424c0e9216457ba1c93846e6f323
Showing with 9 additions and 3 deletions.
  1. +1 −0 inc/rk_mpi_cmd.h
  2. +8 −3 mpp/mpp.cpp
@@ -96,6 +96,7 @@ typedef enum {
MPP_DEC_SET_VC1_EXTRA_DATA,
MPP_DEC_SET_OUTPUT_FORMAT,
MPP_DEC_CHANGE_HARD_MODE,
MPP_DEC_GET_FREE_PACKET_SLOT_COUNT,
MPP_DEC_CMD_END,

MPP_ENC_CMD_BASE = CMD_MODULE_CODEC | CMD_CTX_ID_ENC,
@@ -33,6 +33,7 @@

#define MPP_TEST_FRAME_SIZE SZ_1M
#define MPP_TEST_PACKET_SIZE SZ_512K
#define MPP_MAX_INPUT_PACKETS 4

Mpp::Mpp()
: mPackets(NULL),
@@ -102,8 +103,8 @@ MPP_RET Mpp::init(MppCtxType type, MppCodingType coding)

mpp_task_queue_init(&mInputTaskQueue);
mpp_task_queue_init(&mOutputTaskQueue);
mpp_task_queue_setup(mInputTaskQueue, 4);
mpp_task_queue_setup(mOutputTaskQueue, 4);
mpp_task_queue_setup(mInputTaskQueue, MPP_MAX_INPUT_PACKETS);
mpp_task_queue_setup(mOutputTaskQueue, MPP_MAX_INPUT_PACKETS);
} else {
mThreadCodec = new MppThread(mpp_dec_advanced_thread, this, "mpp_dec_parser");

@@ -258,7 +259,7 @@ MPP_RET Mpp::put_packet(MppPacket packet)
AutoMutex autoLock(mPackets->mutex());
RK_U32 eos = mpp_packet_get_eos(packet);

if (mPackets->list_size() < 4 || eos) {
if (mPackets->list_size() < MPP_MAX_INPUT_PACKETS || eos) {
MppPacket pkt;
if (MPP_OK != mpp_packet_copy_init(&pkt, packet))
return MPP_NOK;
@@ -745,6 +746,10 @@ MPP_RET Mpp::control_dec(MpiCmd cmd, MppParam param)
case MPP_DEC_SET_OUTPUT_FORMAT: {
ret = mpp_dec_control(mDec, cmd, param);
} break;
case MPP_DEC_GET_FREE_PACKET_SLOT_COUNT: {
*((RK_S32 *)param) = MPP_MAX_INPUT_PACKETS - mPackets->list_size();
ret = MPP_OK;
} break;
default : {
} break;
}

0 comments on commit a68592b

Please sign in to comment.