Skip to content

Commit 226cecb

Browse files
committed
add function processFrame
1 parent a4980db commit 226cecb

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

system/camerad/cameras/spectra.cc

+26-25
Original file line numberDiff line numberDiff line change
@@ -1396,31 +1396,7 @@ bool SpectraCamera::handle_camera_event(const cam_req_mgr_message *event_data) {
13961396

13971397
int buf_idx = (request_id - 1) % ife_buf_depth;
13981398
uint64_t timestamp = event_data->u.frame_msg.timestamp; // this is timestamped in the kernel's SOF IRQ callback
1399-
if (syncFirstFrame(cc.camera_num, request_id, frame_id_raw, timestamp)) {
1400-
// wait for this frame's EOF, then queue up the next one
1401-
if (enqueue_buffer(buf_idx, request_id + ife_buf_depth)) {
1402-
// Frame is ready
1403-
1404-
// in IFE_PROCESSED mode, we can't know the true EOF, so recover it with sensor readout time
1405-
uint64_t timestamp_eof = timestamp + sensor->readout_time_ns;
1406-
1407-
// Update buffer and frame data
1408-
buf.cur_buf_idx = buf_idx;
1409-
buf.cur_frame_data = {
1410-
.frame_id = (uint32_t)(frame_id_raw - camera_sync_data[cc.camera_num].frame_id_offset),
1411-
.request_id = (uint32_t)request_id,
1412-
.timestamp_sof = timestamp,
1413-
.timestamp_eof = timestamp_eof,
1414-
.processing_time = float((nanos_since_boot() - timestamp_eof) * 1e-9)
1415-
};
1416-
return true;
1417-
}
1418-
// LOGW("camerad %d synced req %d fid %d, publishing ts %.2f cereal_frame_id %d", cc.camera_num, (int)request_id, (int)frame_id_raw, (double)(timestamp)*1e-6, meta_data.frame_id);
1419-
} else {
1420-
// Frames not yet synced
1421-
enqueue_req_multi(request_id + ife_buf_depth, 1);
1422-
// LOGW("camerad %d not synced req %d fid %d", cc.camera_num, (int)request_id, (int)frame_id_raw);
1423-
}
1399+
return processFrame(request_id, buf_idx, frame_id_raw, timestamp);
14241400
} else { // not ready
14251401
if (frame_id_raw > frame_id_raw_last + 10) {
14261402
LOGE("camera %d reset after half second of no response", cc.camera_num);
@@ -1434,6 +1410,31 @@ bool SpectraCamera::handle_camera_event(const cam_req_mgr_message *event_data) {
14341410
return false;
14351411
}
14361412

1413+
bool SpectraCamera::processFrame(uint64_t request_id, int buf_idx, uint64_t frame_id_raw, uint64_t timestamp) {
1414+
// wait for this frame's EOF, then queue up the next one
1415+
if (!enqueue_buffer(buf_idx, request_id + ife_buf_depth)) {
1416+
return false;
1417+
}
1418+
1419+
if (!syncFirstFrame(cc.camera_num, request_id, frame_id_raw, timestamp)) {
1420+
return false;
1421+
}
1422+
1423+
// in IFE_PROCESSED mode, we can't know the true EOF, so recover it with sensor readout time
1424+
uint64_t timestamp_eof = timestamp + sensor->readout_time_ns;
1425+
1426+
// Update buffer and frame data
1427+
buf.cur_buf_idx = buf_idx;
1428+
buf.cur_frame_data = {
1429+
.frame_id = (uint32_t)(frame_id_raw - camera_sync_data[cc.camera_num].frame_id_offset),
1430+
.request_id = (uint32_t)request_id,
1431+
.timestamp_sof = timestamp,
1432+
.timestamp_eof = timestamp_eof,
1433+
.processing_time = float((nanos_since_boot() - timestamp_eof) * 1e-9)};
1434+
1435+
return true;
1436+
}
1437+
14371438
bool SpectraCamera::syncFirstFrame(int camera_id, uint64_t request_id, uint64_t raw_id, uint64_t timestamp) {
14381439
if (first_frame_synced) return true;
14391440

system/camerad/cameras/spectra.h

+1
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class SpectraCamera {
198198
SpectraMaster *m;
199199

200200
private:
201+
bool processFrame(uint64_t request_id, int buf_idx, uint64_t frame_id_raw, uint64_t timestamp);
201202
static bool syncFirstFrame(int camera_id, uint64_t request_id, uint64_t raw_id, uint64_t timestamp);
202203
struct SyncData {
203204
uint64_t timestamp;

0 commit comments

Comments
 (0)