diff --git a/mpp/base/inc/mpp_frame_impl.h b/mpp/base/inc/mpp_frame_impl.h index 90ab9aa9..36534d36 100644 --- a/mpp/base/inc/mpp_frame_impl.h +++ b/mpp/base/inc/mpp_frame_impl.h @@ -17,6 +17,7 @@ #ifndef __MPP_FRAME_IMPL_H__ #define __MPP_FRAME_IMPL_H__ +#include "mpp_time.h" #include "mpp_frame.h" typedef struct MppFrameImpl_t MppFrameImpl; @@ -105,6 +106,7 @@ struct MppFrameImpl_t { * meta data information */ MppMeta meta; + MppStopwatch stopwatch; /* * frame buffer compression (FBC) information @@ -137,6 +139,12 @@ MPP_RET mpp_frame_info_cmp(MppFrame frame0, MppFrame frame1); RK_U32 mpp_frame_get_fbc_offset(MppFrame frame); RK_U32 mpp_frame_get_fbc_stride(MppFrame frame); +/* + * Debug for frame process timing + */ +void mpp_frame_set_stopwatch_enable(MppFrame frame, RK_S32 enable); +MppStopwatch mpp_frame_get_stopwatch(const MppFrame frame); + MPP_RET check_is_mpp_frame(void *pointer); #ifdef __cplusplus diff --git a/mpp/base/mpp_frame.cpp b/mpp/base/mpp_frame.cpp index 688b9c7a..8ca044e5 100644 --- a/mpp/base/mpp_frame.cpp +++ b/mpp/base/mpp_frame.cpp @@ -74,6 +74,9 @@ MPP_RET mpp_frame_deinit(MppFrame *frame) if (p->meta) mpp_meta_put(p->meta); + if (p->stopwatch) + mpp_stopwatch_put(p->stopwatch); + mpp_free(*frame); *frame = NULL; return MPP_OK; @@ -160,6 +163,34 @@ void mpp_frame_set_meta(MppFrame frame, MppMeta meta) p->meta = meta; } +void mpp_frame_set_stopwatch_enable(MppFrame frame, RK_S32 enable) +{ + if (check_is_mpp_frame(frame)) + return ; + + MppFrameImpl *p = (MppFrameImpl *)frame; + if (enable && NULL == p->stopwatch) { + char name[32]; + + snprintf(name, sizeof(name) - 1, "frm %8llx", p->pts); + p->stopwatch = mpp_stopwatch_get(name); + if (p->stopwatch) + mpp_stopwatch_set_show_on_exit(p->stopwatch, 1); + } else if (!enable && p->stopwatch) { + mpp_stopwatch_put(p->stopwatch); + p->stopwatch = NULL; + } +} + +MppStopwatch mpp_frame_get_stopwatch(const MppFrame frame) +{ + if (check_is_mpp_frame(frame)) + return NULL; + + MppFrameImpl *p = (MppFrameImpl *)frame; + return p->stopwatch; +} + MPP_RET mpp_frame_copy(MppFrame dst, MppFrame src) { if (NULL == dst || check_is_mpp_frame(src)) {