Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

camerad: debayer in the IFE #33720

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions system/camerad/cameras/camera_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include "common/clutil.h"
#include "common/swaglog.h"
#include "third_party/linux/include/msm_media_info.h"

#include "system/camerad/cameras/spectra.h"

Expand Down Expand Up @@ -65,34 +64,27 @@ void CameraBuf::init(cl_device_id device_id, cl_context context, SpectraCamera *

const SensorInfo *sensor = cam->sensor.get();

// RAW frame
const int frame_size = (sensor->frame_height + sensor->extra_height) * sensor->frame_stride;
// camera frame
camera_bufs = std::make_unique<VisionBuf[]>(frame_buf_count);
camera_bufs_metadata = std::make_unique<FrameMetadata[]>(frame_buf_count);

for (int i = 0; i < frame_buf_count; i++) {
camera_bufs[i].allocate(frame_size);
camera_bufs[i].allocate(cam->yuv_size);
camera_bufs[i].init_cl(device_id, context);
}
LOGD("allocated %d CL buffers", frame_buf_count);

out_img_width = sensor->frame_width;
out_img_height = sensor->hdr_offset > 0 ? (sensor->frame_height - sensor->hdr_offset) / 2 : sensor->frame_height;

int nv12_width = VENUS_Y_STRIDE(COLOR_FMT_NV12, out_img_width);
int nv12_height = VENUS_Y_SCANLINES(COLOR_FMT_NV12, out_img_height);
assert(nv12_width == VENUS_UV_STRIDE(COLOR_FMT_NV12, out_img_width));
assert(nv12_height/2 == VENUS_UV_SCANLINES(COLOR_FMT_NV12, out_img_height));
size_t nv12_uv_offset = nv12_width * nv12_height;

// the encoder HW tells us the size it wants after setting it up.
// TODO: VENUS_BUFFER_SIZE should give the size, but it's too small. dependent on encoder settings?
size_t nv12_size = (out_img_width <= 1344 ? 2900 : 2346)*nv12_width;
size_t nv12_size = (out_img_width <= 1344 ? 2900 : 2346)*cam->stride;

vipc_server->create_buffers_with_sizes(stream_type, YUV_BUFFER_COUNT, out_img_width, out_img_height, nv12_size, nv12_width, nv12_uv_offset);
LOGD("created %d YUV vipc buffers with size %dx%d", YUV_BUFFER_COUNT, nv12_width, nv12_height);
vipc_server->create_buffers_with_sizes(stream_type, YUV_BUFFER_COUNT, out_img_width, out_img_height, nv12_size, cam->stride, cam->uv_offset);
LOGD("created %d YUV vipc buffers with size %dx%d", YUV_BUFFER_COUNT, cam->stride, cam->y_height);

imgproc = new ImgProc(device_id, context, this, sensor, cam->cc.camera_num, nv12_width, nv12_uv_offset);
imgproc = new ImgProc(device_id, context, this, sensor, cam->cc.camera_num, cam->stride, cam->uv_offset);
}

CameraBuf::~CameraBuf() {
Expand All @@ -115,7 +107,8 @@ bool CameraBuf::acquire(int expo_time) {
cur_camera_buf = &camera_bufs[cur_buf_idx];

double start_time = millis_since_boot();
imgproc->runKernel(camera_bufs[cur_buf_idx].buf_cl, cur_yuv_buf->buf_cl, out_img_width, out_img_height, expo_time);
//imgproc->runKernel(camera_bufs[cur_buf_idx].buf_cl, cur_yuv_buf->buf_cl, out_img_width, out_img_height, expo_time);
memcpy(cur_yuv_buf->addr, cur_camera_buf->addr, cur_camera_buf->len);
cur_frame_data.processing_time = (millis_since_boot() - start_time) / 1000.0;

VisionIpcBufExtra extra = {
Expand Down
2 changes: 1 addition & 1 deletion system/camerad/cameras/camera_qcom2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void camerad_thread() {
}

for (auto &cam : cams) {
if (event_data->session_hdl == cam->camera.session_handle) {
if (cam->camera.enabled && event_data->session_hdl == cam->camera.session_handle) {
cam->camera.handle_camera_event(event_data);
break;
}
Expand Down
Loading
Loading