[mpp_frame]: Add stopwatch to MppFrame for timing

Usage:

1. Enable timing trace
   mpp_frame_set_stopwatch_enable(frame, 1);

2. Get stopwatch and record on each step
   stopwatch = mpp_frame_get_stopwatch(frame);
   mpp_stopwatch_record(stopwatch, "step 0");
   mpp_stopwatch_record(stopwatch, "step 1");
   mpp_stopwatch_record(stopwatch, "step 2");

3. Get timing log on stopwatch disable or MppFrame destroy
   mpp_frame_set_stopwatch_enable(frame, 0);
   or
   mpp_frame_deinit(&frame);

Change-Id: I47c235e95c9f2f39d970ef1f2948b72dcc254146
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
Herman Chen
2020-12-24 10:52:57 +08:00
parent 7b415f98be
commit ff56c151e2
2 changed files with 39 additions and 0 deletions

View File

@@ -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

View File

@@ -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)) {