固定帧率输出
2021-02-25 本文已影响0人
窝窝蜗牛
方式一:
adb shell setprop persist.vendor.debug.set.fixedfps xxxx
每次重开camera生效
int32_t QCameraParameters::setPreviewFpsRange(int min_fps,
int max_fps, int vid_min_fps,int vid_max_fps)
{
char str[32];
char value[PROPERTY_VALUE_MAX];
int fixedFpsValue;
/*This property get value should be the fps that user needs*/
property_get("persist.vendor.debug.set.fixedfps", value, "0");
fixedFpsValue = atoi(value);
LOGD("E minFps = %d, maxFps = %d , vid minFps = %d, vid maxFps = %d",
min_fps, max_fps, vid_min_fps, vid_max_fps);
if(fixedFpsValue != 0) {
min_fps = max_fps = fixedFpsValue*1000;
if (!isHfrMode()) {
vid_min_fps = vid_max_fps = fixedFpsValue*1000;
}
}
snprintf(str, sizeof(str), "%d,%d", min_fps, max_fps);
LOGH("Setting preview fps range %s", str);
updateParamEntry(KEY_PREVIEW_FPS_RANGE, str);
cam_fps_range_t fps_range;
memset(&fps_range, 0x00, sizeof(cam_fps_range_t));
fps_range.min_fps = (float)min_fps / 1000.0f;
fps_range.max_fps = (float)max_fps / 1000.0f;
fps_range.video_min_fps = (float)vid_min_fps / 1000.0f;
fps_range.video_max_fps = (float)vid_max_fps / 1000.0f;
LOGH("Updated: minFps = %d, maxFps = %d ,"
" vid minFps = %d, vid maxFps = %d",
min_fps, max_fps, vid_min_fps, vid_max_fps);
if ( NULL != m_AdjustFPS ) {
if (m_ThermalMode == QCAMERA_THERMAL_ADJUST_FPS &&
!m_bRecordingHint_new) {
float minVideoFps = min_fps, maxVideoFps = max_fps;
if (isHfrMode()) {
minVideoFps = m_hfrFpsRange.video_min_fps;
maxVideoFps = m_hfrFpsRange.video_max_fps;
}
m_AdjustFPS->recalcFPSRange(min_fps, max_fps, minVideoFps,
maxVideoFps, fps_range, m_bRecordingHint_new);
LOGH("Thermal adjusted Preview fps range %3.2f,%3.2f, %3.2f, %3.2f",
fps_range.min_fps, fps_range.max_fps,
fps_range.video_min_fps, fps_range.video_max_fps);
}
}
if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FPS_RANGE, fps_range)) {
return BAD_VALUE;
}
return NO_ERROR;
}
方式二
固定linecount方式固定帧率 adb shell setprop persist.vendor.camera.sensor.linecount xxx
{
.x_output = 1296,
.y_output = 972,
.line_length_pclk = 750,
.frame_length_lines = 2000,
.op_pixel_clk = 180000000,//clk = 450Mhz ,mipi_speed = 900Mbps = 180Mx10bit/2lane
.binning_factor = 2,
.min_fps = 10.00,
.max_fps = 30.00,
.mode = SENSOR_DEFAULT_MODE,
.offset_x = 0,
.offset_y = 0,
.scale_factor = 0,
.data_rate =900000000ULL * 2,
},
fixed_fps = line_length_pclk * frame_length_lines * max_fps / line_length_pclk / cur_line_count.
注意要开启相应的宏ENABLE_MANUAL_EXPOSURE_UPDATE
#ifdef ENABLE_MANUAL_EXPOSURE_UPDATE
if(updateExtGain(&ext_real_gain) == SENSOR_SUCCESS)
real_gain = ext_real_gain;
if(updateExtLinecount(&ext_linecount) == SENSOR_SUCCESS)
linecount = ext_linecount;
#endif
==>
static int32_t updateExtLinecount(uint32_t *linecount)
{
char ext_linecount[PROPERTY_VALUE_MAX];
RETURN_ERROR_ON_NULL(linecount);
property_get("persist.vendor.camera.sensor.linecount", ext_linecount, "0");
*linecount = atoi(ext_linecount);
if (*linecount > 0) {
SHIGH("Updated linecount: %d", *linecount);
return SENSOR_SUCCESS;
}
return SENSOR_FAILURE;
}