mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-06 01:26:49 +08:00
[codec]: improve MppBufSlot interface
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@177 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -27,9 +27,8 @@
|
|||||||
#define MPP_SLOT_UNUSED (0x00000000)
|
#define MPP_SLOT_UNUSED (0x00000000)
|
||||||
#define MPP_SLOT_USED (0x00000001)
|
#define MPP_SLOT_USED (0x00000001)
|
||||||
#define MPP_SLOT_USED_AS_REF (0x00000002)
|
#define MPP_SLOT_USED_AS_REF (0x00000002)
|
||||||
#define MPP_SLOT_USED_AS_OUTPUT (0x00000004)
|
#define MPP_SLOT_USED_AS_DECODING (0x00000004)
|
||||||
#define MPP_SLOT_USED_AS_DISPLAY (0x00000008)
|
#define MPP_SLOT_USED_AS_DISPLAY (0x00000008)
|
||||||
#define MPP_SLOT_HW_READY (0x00000010)
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MppBuffer buffer;
|
MppBuffer buffer;
|
||||||
@@ -44,6 +43,17 @@ typedef struct {
|
|||||||
MppBufSlotEntry *slots;
|
MppBufSlotEntry *slots;
|
||||||
} MppBufSlotsImpl;
|
} MppBufSlotsImpl;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* only called on unref / displayed / decoded
|
||||||
|
*/
|
||||||
|
static void check_entry_unused(MppBufSlotEntry *entry)
|
||||||
|
{
|
||||||
|
if (entry->status == MPP_SLOT_USED) {
|
||||||
|
entry->status = MPP_SLOT_UNUSED;
|
||||||
|
mpp_buffer_put(entry->buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MPP_RET mpp_buf_slot_init(MppBufSlots *slots, RK_U32 count)
|
MPP_RET mpp_buf_slot_init(MppBufSlots *slots, RK_U32 count)
|
||||||
{
|
{
|
||||||
if (NULL == slots) {
|
if (NULL == slots) {
|
||||||
@@ -121,7 +131,7 @@ MPP_RET mpp_buf_slot_set_ref(MppBufSlots slots, RK_U32 index)
|
|||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPP_RET mpp_buf_slot_set_unref(MppBufSlots slots, RK_U32 index)
|
MPP_RET mpp_buf_slot_clr_ref(MppBufSlots slots, RK_U32 index)
|
||||||
{
|
{
|
||||||
if (NULL == slots) {
|
if (NULL == slots) {
|
||||||
mpp_err("%s found NULL input\n\n", __FUNCTION__);
|
mpp_err("%s found NULL input\n\n", __FUNCTION__);
|
||||||
@@ -133,10 +143,11 @@ MPP_RET mpp_buf_slot_set_unref(MppBufSlots slots, RK_U32 index)
|
|||||||
mpp_assert(index < impl->count);
|
mpp_assert(index < impl->count);
|
||||||
Mutex::Autolock auto_lock(impl->lock);
|
Mutex::Autolock auto_lock(impl->lock);
|
||||||
slot[index].status &= ~MPP_SLOT_USED_AS_REF;
|
slot[index].status &= ~MPP_SLOT_USED_AS_REF;
|
||||||
|
check_entry_unused(&slot[index]);
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPP_RET mpp_buf_slot_set_output(MppBufSlots slots, RK_U32 index)
|
MPP_RET mpp_buf_slot_set_decoding(MppBufSlots slots, RK_U32 index)
|
||||||
{
|
{
|
||||||
if (NULL == slots) {
|
if (NULL == slots) {
|
||||||
mpp_err("%s found NULL input\n\n", __FUNCTION__);
|
mpp_err("%s found NULL input\n\n", __FUNCTION__);
|
||||||
@@ -147,7 +158,24 @@ MPP_RET mpp_buf_slot_set_output(MppBufSlots slots, RK_U32 index)
|
|||||||
MppBufSlotEntry *slot = impl->slots;
|
MppBufSlotEntry *slot = impl->slots;
|
||||||
mpp_assert(index < impl->count);
|
mpp_assert(index < impl->count);
|
||||||
Mutex::Autolock auto_lock(impl->lock);
|
Mutex::Autolock auto_lock(impl->lock);
|
||||||
slot[index].status |= MPP_SLOT_USED_AS_OUTPUT;
|
slot[index].status |= MPP_SLOT_USED_AS_DECODING;
|
||||||
|
return MPP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
MPP_RET mpp_buf_slot_clr_decoding(MppBufSlots slots, RK_U32 index)
|
||||||
|
{
|
||||||
|
if (NULL == slots) {
|
||||||
|
mpp_err("%s found NULL input\n\n", __FUNCTION__);
|
||||||
|
return MPP_ERR_NULL_PTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
MppBufSlotsImpl *impl = (MppBufSlotsImpl *)slots;
|
||||||
|
MppBufSlotEntry *slot = impl->slots;
|
||||||
|
mpp_assert(index < impl->count);
|
||||||
|
Mutex::Autolock auto_lock(impl->lock);
|
||||||
|
slot[index].status &= ~MPP_SLOT_USED_AS_DECODING;
|
||||||
|
impl->decode_count++;
|
||||||
|
check_entry_unused(&slot[index]);
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +194,7 @@ MPP_RET mpp_buf_slot_set_display(MppBufSlots slots, RK_U32 index)
|
|||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPP_RET mpp_buf_slot_set_hw_ready(MppBufSlots slots, RK_U32 index)
|
MPP_RET mpp_buf_slot_clr_display(MppBufSlots slots, RK_U32 index)
|
||||||
{
|
{
|
||||||
if (NULL == slots) {
|
if (NULL == slots) {
|
||||||
mpp_err("%s found NULL input\n\n", __FUNCTION__);
|
mpp_err("%s found NULL input\n\n", __FUNCTION__);
|
||||||
@@ -177,25 +205,9 @@ MPP_RET mpp_buf_slot_set_hw_ready(MppBufSlots slots, RK_U32 index)
|
|||||||
MppBufSlotEntry *slot = impl->slots;
|
MppBufSlotEntry *slot = impl->slots;
|
||||||
mpp_assert(index < impl->count);
|
mpp_assert(index < impl->count);
|
||||||
Mutex::Autolock auto_lock(impl->lock);
|
Mutex::Autolock auto_lock(impl->lock);
|
||||||
slot[index].status |= MPP_SLOT_HW_READY;
|
slot[index].status &= ~MPP_SLOT_USED_AS_DISPLAY;
|
||||||
slot[index].status &= ~MPP_SLOT_USED_AS_OUTPUT;
|
|
||||||
impl->decode_count++;
|
|
||||||
return MPP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
MPP_RET mpp_buf_slot_set_unused(MppBufSlots slots, RK_U32 index)
|
|
||||||
{
|
|
||||||
if (NULL == slots) {
|
|
||||||
mpp_err("%s found NULL input\n\n", __FUNCTION__);
|
|
||||||
return MPP_ERR_NULL_PTR;
|
|
||||||
}
|
|
||||||
|
|
||||||
MppBufSlotsImpl *impl = (MppBufSlotsImpl *)slots;
|
|
||||||
MppBufSlotEntry *slot = impl->slots;
|
|
||||||
mpp_assert(index < impl->count);
|
|
||||||
Mutex::Autolock auto_lock(impl->lock);
|
|
||||||
slot[index].status = MPP_SLOT_UNUSED;
|
|
||||||
impl->display_count++;
|
impl->display_count++;
|
||||||
|
check_entry_unused(&slot[index]);
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,6 +223,7 @@ MPP_RET mpp_buf_slot_set_buffer(MppBufSlots slots, RK_U32 index, MppBuffer buffe
|
|||||||
mpp_assert(index < impl->count);
|
mpp_assert(index < impl->count);
|
||||||
Mutex::Autolock auto_lock(impl->lock);
|
Mutex::Autolock auto_lock(impl->lock);
|
||||||
slot[index].buffer = buffer;
|
slot[index].buffer = buffer;
|
||||||
|
mpp_buffer_inc_ref(buffer);
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -78,6 +78,21 @@
|
|||||||
* | | output frame information |
|
* | | output frame information |
|
||||||
* + + +
|
* + + +
|
||||||
*
|
*
|
||||||
|
* typical buffer status transfer
|
||||||
|
*
|
||||||
|
* -> unused initial
|
||||||
|
* -> set_decoding by parser
|
||||||
|
* -> set_buffer by mpp - do alloc buffer here / info change here
|
||||||
|
* -> clr_decoding by hal()
|
||||||
|
*
|
||||||
|
* next four step can be different order
|
||||||
|
* -> set_ref by parser
|
||||||
|
* -> set_display by parser - slot ready to display, can be output
|
||||||
|
* -> clr_display by mpp - output buffer struct
|
||||||
|
* -> clr_ref by parser
|
||||||
|
*
|
||||||
|
* -> set_unused automatic clear and dec buffer ref
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef void* MppBufSlots;
|
typedef void* MppBufSlots;
|
||||||
@@ -101,36 +116,34 @@ MPP_RET mpp_buf_slot_deinit(MppBufSlots slots);
|
|||||||
* mpp_buf_slot_set_ref
|
* mpp_buf_slot_set_ref
|
||||||
* - mark a slot to be used as reference
|
* - mark a slot to be used as reference
|
||||||
*
|
*
|
||||||
* mpp_buf_slot_set_unref
|
* mpp_buf_slot_clr_ref
|
||||||
* - mark a slot to be unused as reference
|
* - mark a slot to be unused as reference
|
||||||
*
|
*
|
||||||
* mpp_buf_slot_set_output
|
* mpp_buf_slot_set_decoding
|
||||||
* - mark a slot to be output destination buffer
|
* - mark a slot to be output destination buffer
|
||||||
*
|
*
|
||||||
* mpp_buf_slot_set_display
|
* mpp_buf_slot_set_display
|
||||||
* - mark a slot to be can be display
|
* - mark a slot to be can be display
|
||||||
*
|
*
|
||||||
|
* called by mpp
|
||||||
|
*
|
||||||
|
* mpp_buf_slot_clr_display
|
||||||
|
* - mark a slot has been send out to display
|
||||||
|
*
|
||||||
|
* called by hal
|
||||||
|
*
|
||||||
|
* mpp_buf_slot_clr_decoding
|
||||||
|
* - mark a slot's buffer is already decoded by hardware
|
||||||
|
* NOTE: this call will clear used as output flag
|
||||||
*/
|
*/
|
||||||
MPP_RET mpp_buf_slot_get_unused(MppBufSlots slots, RK_U32 *index);
|
MPP_RET mpp_buf_slot_get_unused(MppBufSlots slots, RK_U32 *index);
|
||||||
MPP_RET mpp_buf_slot_set_ref(MppBufSlots slots, RK_U32 index);
|
MPP_RET mpp_buf_slot_set_ref(MppBufSlots slots, RK_U32 index);
|
||||||
MPP_RET mpp_buf_slot_set_unref(MppBufSlots slots, RK_U32 index);
|
MPP_RET mpp_buf_slot_clr_ref(MppBufSlots slots, RK_U32 index);
|
||||||
MPP_RET mpp_buf_slot_set_output(MppBufSlots slots, RK_U32 index);
|
MPP_RET mpp_buf_slot_set_decoding(MppBufSlots slots, RK_U32 index);
|
||||||
|
MPP_RET mpp_buf_slot_clr_decoding(MppBufSlots slots, RK_U32 index);
|
||||||
MPP_RET mpp_buf_slot_set_display(MppBufSlots slots, RK_U32 index);
|
MPP_RET mpp_buf_slot_set_display(MppBufSlots slots, RK_U32 index);
|
||||||
|
MPP_RET mpp_buf_slot_clr_display(MppBufSlots slots, RK_U32 index);
|
||||||
|
|
||||||
/*
|
|
||||||
* called by hal
|
|
||||||
*
|
|
||||||
* mpp_buf_slot_set_hw_ready
|
|
||||||
* - mark a slot's buffer is already decoded by hardware
|
|
||||||
* NOTE: this call will clear used as output flag
|
|
||||||
*
|
|
||||||
* called by mpp context display loop
|
|
||||||
*
|
|
||||||
* mpp_buf_slot_set_unused
|
|
||||||
* - mark a slot's buffer is unused when this buffer is outputed from mpp
|
|
||||||
*/
|
|
||||||
MPP_RET mpp_buf_slot_set_hw_ready(MppBufSlots slots, RK_U32 index);
|
|
||||||
MPP_RET mpp_buf_slot_set_unused(MppBufSlots slots, RK_U32 index);
|
|
||||||
|
|
||||||
MPP_RET mpp_buf_slot_set_buffer(MppBufSlots slots, RK_U32 index, MppBuffer buffer);
|
MPP_RET mpp_buf_slot_set_buffer(MppBufSlots slots, RK_U32 index, MppBuffer buffer);
|
||||||
MppBuffer mpp_buf_slot_get_buffer(const MppBufSlots slots, RK_U32 index);
|
MppBuffer mpp_buf_slot_get_buffer(const MppBufSlots slots, RK_U32 index);
|
||||||
|
Reference in New Issue
Block a user