第30讲 添加stream buffer interval统计图 -凯发k8旗舰厅

本讲是android camera性能分析专题的第30讲,我们介绍统计每路stream的buffer时间间隔耗时,包括如下内容:

  1. 添加stream buffer interval histogram
  2. 添加stream buffer interval trace
资源 描述
在线课程
知识星球 星球名称:深入浅出android camera
星球id: 17296815
wechat 极客笔记圈

添加stream buffer interval histogram

代码见视频讲解,运行效果如下:

添加stream buffer interval histogram

添加stream buffer interval trace

代码见视频讲解,运行效果如下:

添加stream buffer interval trace

代码修改点

diff --git a/android13/libcameraservice/device3/camera3outputstream.cpp b/android13/libcameraservice/device3/camera3outputstream.cpp
index 9ce1a7e..204947c 100644
--- a/android13/libcameraservice/device3/camera3outputstream.cpp
    b/android13/libcameraservice/device3/camera3outputstream.cpp
@@ -71,6  71,9 @@ camera3outputstream::camera3outputstream(int id,
         mdropbuffers(false),
         mmirrormode(mirrormode),
         mdequeuebufferlatency(kdequeuelatencybinsize),
 #ifdef deepinout
         mqueuebufferintervalhistogram(kqueuebufferintervalbinsize),
 #endif
         mipctransport(transport) {
     if (mconsumer == null) {
@@ -104,6  107,9 @@ camera3outputstream::camera3outputstream(int id,
         mdropbuffers(false),
         mmirrormode(mirrormode),
         mdequeuebufferlatency(kdequeuelatencybinsize),
 #ifdef deepinout
         mqueuebufferintervalhistogram(kqueuebufferintervalbinsize),
 #endif
         mipctransport(transport) {
     if (format != hal_pixel_format_blob && format != hal_pixel_format_raw_opaque) {
@@ -144,6  150,9 @@ camera3outputstream::camera3outputstream(int id,
         mdropbuffers(false),
         mmirrormode(mirrormode),
         mdequeuebufferlatency(kdequeuelatencybinsize),
 #ifdef deepinout
         mqueuebufferintervalhistogram(kqueuebufferintervalbinsize),
 #endif
         mipctransport(transport) {
     // deferred consumer only support preview surface format now.
     if (format != hal_pixel_format_implementation_defined) {
@@ -192,6  201,9 @@ camera3outputstream::camera3outputstream(int id, camera_stream_type_t type,
         mdropbuffers(false),
         mmirrormode(mirrormode),
         mdequeuebufferlatency(kdequeuelatencybinsize),
 #ifdef deepinout
         mqueuebufferintervalhistogram(kqueuebufferintervalbinsize),
 #endif
         mipctransport(transport) {
     bool needsreleasenotify = setid > camera3_stream_set_id_invalid;
@@ -312,6  324,17 @@ status_t camera3outputstream::returnbufferlocked(
     mlasttimestamp = timestamp;
     mframecount  ;
 #ifdef deepinout
     nsecs_t currentqueuebuffertime = systemtime(system_time_monotonic);
     if (mlastqueuebuffertime > 0) {
         mqueuebufferintervalhistogram.add(mlastqueuebuffertime, currentqueuebuffertime);
         char tracelog[48];
         snprintf(tracelog, sizeof(tracelog), "queuebufferinterval-%d", mid);
         atrace_async_begin(tracelog, mid);
         atrace_async_end(tracelog, mid);
     }
     mlastqueuebuffertime = currentqueuebuffertime;
 #endif
     return ok;
 }
@@ -521,6  544,10 @@ void camera3outputstream::dump(int fd, const vector &args) const {
     mdequeuebufferlatency.dump(fd,
         "      dequeuebuffer latency histogram:");
 #ifdef deepinout
     mqueuebufferintervalhistogram.dump(fd,
         "      queuebufferinterval histogram:");
 #endif
 }
 status_t camera3outputstream::settransform(int transform, bool maychangemirror) {
@@ -1025,6  1052,14 @@ status_t camera3outputstream::disconnectlocked() {
     mconsumername.string(),
     camera_stream::width,
     camera_stream::height);
     mqueuebufferintervalhistogram.log("camid(l:p):(%s:%s) stream %d-%s-%dx%d queuebuffer interval histogram",
     mlogicalcameraid.string(),
     getphysicalcameraid().string(),
     mid,
     mconsumername.string(),
     camera_stream::width,
     camera_stream::height);
     mqueuebufferintervalhistogram.reset();
 #endif
     mdequeuebufferlatency.reset();
     return ok;
diff --git a/android13/libcameraservice/device3/camera3outputstream.h b/android13/libcameraservice/device3/camera3outputstream.h
index e8065ce..05831ec 100644
--- a/android13/libcameraservice/device3/camera3outputstream.h
    b/android13/libcameraservice/device3/camera3outputstream.h
@@ -408,6  408,11 @@ class camera3outputstream :
     static const int32_t kdequeuelatencybinsize = 5; // in ms
     cameralatencyhistogram mdequeuebufferlatency;
 #ifdef deepinout
     nsecs_t mlastqueuebuffertime = 0;
     static const int32_t kqueuebufferintervalbinsize = 35; // in ms
     cameralatencyhistogram mqueuebufferintervalhistogram;
 #endif
     ipctransport mipctransport = ipctransport::invalid;
     int mimagedumpmask = 0;

camera课程

python教程

java教程

web教程

数据库教程

图形图像教程

办公软件教程

linux教程

计算机教程

大数据教程

开发工具教程

android camera性能分析

网站地图