diff --git a/mpp/codec/inc/mpp_buf_slot.h b/mpp/codec/inc/mpp_buf_slot.h index 15cc77ef..1b5a155b 100644 --- a/mpp/codec/inc/mpp_buf_slot.h +++ b/mpp/codec/inc/mpp_buf_slot.h @@ -162,9 +162,23 @@ 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_clr_display(MppBufSlots slots, RK_U32 index); - -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); +/* + * mpp_buf_slot_set_buffer + * - called by dec thread when find a output index has not buffer + * + * mpp_buf_slot_get_buffer + * - called by hal module on register generation + * + * mpp_buf_slot_set_pts + * - called by parser when decoding a new frame + * + * mpp_buf_slot_get_pts + * - called by hal thread when output a frame + */ +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); +MPP_RET mpp_buf_slot_set_pts(MppBufSlots slots, RK_U32 index, RK_S64 pts); +RK_S64 mpp_buf_slot_get_pts(const MppBufSlots slots, RK_U32 index); #ifdef __cplusplus } diff --git a/mpp/codec/mpp_buf_slot.cpp b/mpp/codec/mpp_buf_slot.cpp index 7618c21f..3adbca54 100644 --- a/mpp/codec/mpp_buf_slot.cpp +++ b/mpp/codec/mpp_buf_slot.cpp @@ -33,6 +33,7 @@ typedef struct MppBufSlotEntry_t { MppBuffer buffer; RK_U32 status; + RK_S64 pts; } MppBufSlotEntry; typedef struct MppBufSlotsImpl_t { @@ -320,3 +321,32 @@ MppBuffer mpp_buf_slot_get_buffer(const MppBufSlots slots, RK_U32 index) return slot[index].buffer; } +MPP_RET mpp_buf_slot_set_pts(MppBufSlots slots, RK_U32 index, RK_S64 pts) +{ + if (NULL == slots) { + mpp_err_f("found NULL input\n"); + return MPP_ERR_NULL_PTR; + } + + MppBufSlotsImpl *impl = (MppBufSlotsImpl *)slots; + Mutex::Autolock auto_lock(impl->lock); + MppBufSlotEntry *slot = impl->slots; + mpp_assert(index < impl->count); + slot[index].pts = pts; + return MPP_OK; +} + +RK_S64 mpp_buf_slot_get_pts(const MppBufSlots slots, RK_U32 index) +{ + if (NULL == slots) { + mpp_err_f("found NULL input\n"); + return NULL; + } + + MppBufSlotsImpl *impl = (MppBufSlotsImpl *)slots; + Mutex::Autolock auto_lock(impl->lock); + MppBufSlotEntry *slot = impl->slots; + mpp_assert(index < impl->count); + return slot[index].pts; +} +