mirror of
https://github.com/thead-yocto-mirror/csi_hal
synced 2026-06-21 08:52:22 +02:00
Linux_SDK_V1.1.2
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
#define LOG_PREFIX "cam_demo_dual_ir"
|
||||
#include <syslog.h>
|
||||
|
||||
#include <csi_frame.h>
|
||||
#include <csi_frame_ex.h>
|
||||
#include <csi_camera.h>
|
||||
#include <csi_camera_dev_api.h>
|
||||
#include "list.h"
|
||||
@@ -72,7 +72,7 @@ typedef struct{
|
||||
typedef struct camera_sync_msg{
|
||||
cam_sync_message_type_e type;
|
||||
union{
|
||||
csi_frame_s frame;
|
||||
csi_frame_ex_s frame;
|
||||
cam_ai_info_t ai_info;
|
||||
cam_dsp_info_t dsp_info;
|
||||
};
|
||||
@@ -193,7 +193,7 @@ typedef struct dual_dsp_handle{
|
||||
int file_id = 0;
|
||||
extern void *vi_plink_create(csi_camera_channel_cfg_s *chn_cfg);
|
||||
extern void vi_plink_release(void * plink);
|
||||
extern void display_camera_frame(void * plink, csi_frame_s *frame);
|
||||
extern void display_camera_frame(void * plink, csi_frame_ex_s *frame);
|
||||
|
||||
static void *cam_frame_sync_process(void *ctx);
|
||||
static void* dsp_dual_ir_porcess(void *arg);
|
||||
@@ -920,7 +920,7 @@ static void cam_sync_destroy(void *arg)
|
||||
free(ctx);
|
||||
LOG_O("cam sync destroy\n");
|
||||
}
|
||||
static int push_new_frame(struct list_head *frame_list, csi_frame_s * new_frame)
|
||||
static int push_new_frame(struct list_head *frame_list, csi_frame_ex_s * new_frame)
|
||||
{
|
||||
int entry_num =0;
|
||||
frame_item_t *frame_item = NULL;
|
||||
@@ -936,8 +936,8 @@ static int push_new_frame(struct list_head *frame_list, csi_frame_s * new_frame)
|
||||
if((entry_num+1)>MAX_FIFO_FRAME_NUM)
|
||||
{
|
||||
frame_item = list_first_entry(frame_list,frame_item_t,head);
|
||||
LOG_D("release frame fd:%d\n",((csi_frame_s *)frame_item->item)->img.fds[0]);
|
||||
csi_camera_put_frame((csi_frame_s *)frame_item->item);
|
||||
LOG_D("release frame fd:%d\n",((csi_frame_ex_s *)frame_item->item)->frame_data.fd[0]);
|
||||
csi_camera_put_frame((csi_frame_ex_s *)frame_item->item);
|
||||
free(frame_item->item);
|
||||
list_del(&frame_item->head);
|
||||
free(frame_item);
|
||||
@@ -948,9 +948,9 @@ static int push_new_frame(struct list_head *frame_list, csi_frame_s * new_frame)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static csi_frame_s * pop_matched_frame_with_fd(struct list_head *frame_list,int fd)
|
||||
static csi_frame_ex_s * pop_matched_frame_with_fd(struct list_head *frame_list,int fd)
|
||||
{
|
||||
csi_frame_s * frame = NULL;
|
||||
csi_frame_ex_s * frame = NULL;
|
||||
frame_item_t *frame_item = NULL;
|
||||
frame_item_t * temp;
|
||||
if(frame_list==NULL)
|
||||
@@ -958,12 +958,12 @@ static csi_frame_s * pop_matched_frame_with_fd(struct list_head *frame_list,int
|
||||
return NULL;
|
||||
}
|
||||
list_for_each_entry_safe(frame_item,temp,frame_list,head){
|
||||
frame = (csi_frame_s *)frame_item->item;
|
||||
if(frame->img.fds[0]==fd)
|
||||
frame = (csi_frame_ex_s *)frame_item->item;
|
||||
if(frame->frame_data.fd[0]==fd)
|
||||
{
|
||||
list_del(&frame_item->head);
|
||||
free(frame_item);
|
||||
LOG_D("get frame fd:%d\n",frame->img.fds[0]);
|
||||
LOG_D("get frame fd:%d\n",frame->frame_data.fd[0]);
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
@@ -971,11 +971,11 @@ static csi_frame_s * pop_matched_frame_with_fd(struct list_head *frame_list,int
|
||||
}
|
||||
|
||||
|
||||
static csi_frame_s * pop_matched_frame_with_ts(struct list_head *frame_list, csi_frame_s * target_frame,uint32_t rang_us,bool clear_early)
|
||||
static csi_frame_ex_s * pop_matched_frame_with_ts(struct list_head *frame_list, csi_frame_ex_s * target_frame,uint32_t rang_us,bool clear_early)
|
||||
{
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)target_frame->meta.data;
|
||||
csi_camrea_meta_unit_s target_ts,loop_ts;
|
||||
csi_frame_s * frame;
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)target_frame->frame_meta.data;
|
||||
csi_camera_meta_unit_s target_ts,loop_ts;
|
||||
csi_frame_ex_s * frame;
|
||||
frame_item_t *frame_item = NULL;
|
||||
frame_item_t * tmp;
|
||||
struct timeval time_value;
|
||||
@@ -994,8 +994,8 @@ static csi_frame_s * pop_matched_frame_with_ts(struct list_head *frame_list, csi
|
||||
target_us = target_ts.time_value.tv_sec*1000000 + target_ts.time_value.tv_usec;
|
||||
|
||||
list_for_each_entry_safe(frame_item,tmp,frame_list,head){
|
||||
frame = ( csi_frame_s *)frame_item->item;
|
||||
meta_data = (csi_camera_meta_s *)frame->meta.data;
|
||||
frame = ( csi_frame_ex_s *)frame_item->item;
|
||||
meta_data = (csi_camera_meta_s *)frame->frame_meta.data;
|
||||
csi_camera_frame_get_meta_unit(
|
||||
&loop_ts, meta_data, CSI_CAMERA_META_ID_TIMESTAMP);
|
||||
loop_us = loop_ts.time_value.tv_sec*1000000 + loop_ts.time_value.tv_usec;
|
||||
@@ -1018,20 +1018,20 @@ static csi_frame_s * pop_matched_frame_with_ts(struct list_head *frame_list, csi
|
||||
|
||||
}
|
||||
|
||||
static int send_paired_frame_to_dsp(msg_queue_ctx_t *queue,csi_frame_s *master_frame,csi_frame_s *slave_frame,struct list_head *send_frames)
|
||||
static int send_paired_frame_to_dsp(msg_queue_ctx_t *queue,csi_frame_ex_s *master_frame,csi_frame_ex_s *slave_frame,struct list_head *send_frames)
|
||||
{
|
||||
dsp_dual_ir_frame_msg_t *dsp_msg_payload;
|
||||
msg_queue_item_t *dsp_msg;
|
||||
frame_item_t *main_item,*slave_item;
|
||||
csi_camera_meta_s *meta_data;
|
||||
csi_camrea_meta_unit_s timestap;
|
||||
csi_camera_meta_unit_s timestap;
|
||||
if(queue==NULL || master_frame==NULL || slave_frame==NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(master_frame->img.width!=slave_frame->img.width||
|
||||
master_frame->img.height!=slave_frame->img.height)
|
||||
if(master_frame->frame_info.width!=slave_frame->frame_info.width||
|
||||
master_frame->frame_info.height!=slave_frame->frame_info.height)
|
||||
{
|
||||
LOG_E("paird frame not the same picture param\n");
|
||||
return -1;
|
||||
@@ -1046,20 +1046,20 @@ static int send_paired_frame_to_dsp(msg_queue_ctx_t *queue,csi_frame_s *master_f
|
||||
free(dsp_msg);
|
||||
return -1;
|
||||
}
|
||||
meta_data = (csi_camera_meta_s *)master_frame->meta.data;
|
||||
meta_data = (csi_camera_meta_s *)master_frame->frame_meta.data;
|
||||
csi_camera_frame_get_meta_unit(
|
||||
×tap, meta_data, CSI_CAMERA_META_ID_TIMESTAMP);
|
||||
|
||||
dsp_msg->payload = dsp_msg_payload;
|
||||
|
||||
dsp_msg_payload->size = master_frame->img.height*master_frame->img.strides[0];
|
||||
dsp_msg_payload->width = master_frame->img.width;
|
||||
dsp_msg_payload->height = master_frame->img.height;
|
||||
dsp_msg_payload->pix_format = master_frame->img.pix_format;
|
||||
dsp_msg_payload->master_stride = master_frame->img.strides[0];
|
||||
dsp_msg_payload->master_fd = master_frame->img.fds[0];
|
||||
dsp_msg_payload->slave_fd = slave_frame->img.fds[0];
|
||||
dsp_msg_payload->slave_stride = slave_frame->img.strides[0];
|
||||
dsp_msg_payload->size = master_frame->frame_info.height*master_frame->frame_data.stride[0];
|
||||
dsp_msg_payload->width = master_frame->frame_info.width;
|
||||
dsp_msg_payload->height = master_frame->frame_info.height;
|
||||
dsp_msg_payload->pix_format = master_frame->frame_info.pixel_format;
|
||||
dsp_msg_payload->master_stride = master_frame->frame_data.stride[0];
|
||||
dsp_msg_payload->master_fd = master_frame->frame_data.fd[0];
|
||||
dsp_msg_payload->slave_fd = slave_frame->frame_data.fd[0];
|
||||
dsp_msg_payload->slave_stride = slave_frame->frame_data.stride[0];
|
||||
dsp_msg_payload->timestap = timestap.time_value.tv_sec*1000000+timestap.time_value.tv_usec;
|
||||
enqueue_msg(queue,dsp_msg);
|
||||
main_item = malloc(sizeof(frame_item_t));
|
||||
@@ -1072,12 +1072,12 @@ static int send_paired_frame_to_dsp(msg_queue_ctx_t *queue,csi_frame_s *master_f
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cam_dual_frame_process(struct list_head * pair_frame_list,struct list_head * free_frame_list, struct list_head *busy_frame_list,csi_frame_s *frame, msg_queue_ctx_t *dsp_prcoess_queue,cam_sync_message_type_e type)
|
||||
static int cam_dual_frame_process(struct list_head * pair_frame_list,struct list_head * free_frame_list, struct list_head *busy_frame_list,csi_frame_ex_s *frame, msg_queue_ctx_t *dsp_prcoess_queue,cam_sync_message_type_e type)
|
||||
{
|
||||
csi_frame_s *new_frame = NULL;
|
||||
csi_frame_s *pair_frame = NULL;
|
||||
csi_frame_s *master_frame = NULL;
|
||||
csi_frame_s *slave_frame = NULL;
|
||||
csi_frame_ex_s *new_frame = NULL;
|
||||
csi_frame_ex_s *pair_frame = NULL;
|
||||
csi_frame_ex_s *master_frame = NULL;
|
||||
csi_frame_ex_s *slave_frame = NULL;
|
||||
|
||||
if(pair_frame_list == NULL ||free_frame_list==NULL ||busy_frame_list ==NULL ||
|
||||
frame == NULL || dsp_prcoess_queue == NULL || type >CAM_SYNC_MSG_SLAVE_FRAME)
|
||||
@@ -1086,14 +1086,14 @@ static int cam_dual_frame_process(struct list_head * pair_frame_list,struct list
|
||||
return -1;
|
||||
}
|
||||
|
||||
new_frame = malloc(sizeof(csi_frame_s));
|
||||
new_frame = malloc(sizeof(csi_frame_ex_s));
|
||||
if(new_frame==NULL)
|
||||
{
|
||||
LOG_E("malloc fail\n");
|
||||
csi_camera_put_frame(frame);
|
||||
return -1;
|
||||
}
|
||||
memcpy(new_frame,frame,sizeof(csi_frame_s));
|
||||
memcpy(new_frame,frame,sizeof(csi_frame_ex_s));
|
||||
pair_frame = pop_matched_frame_with_ts(pair_frame_list,frame,0,true);
|
||||
if(pair_frame == NULL)
|
||||
{
|
||||
@@ -1117,7 +1117,7 @@ static int cam_dual_frame_process(struct list_head * pair_frame_list,struct list
|
||||
}
|
||||
if(send_paired_frame_to_dsp(dsp_prcoess_queue,master_frame,slave_frame,busy_frame_list))
|
||||
{
|
||||
LOG_E("fail to send paired frame fd (%d,%d) to dsp\n",new_frame->img.fds[0],pair_frame->img.fds[0]);
|
||||
LOG_E("fail to send paired frame fd (%d,%d) to dsp\n",new_frame->frame_data.fd[0],pair_frame->frame_data.fd[0]);
|
||||
csi_camera_put_frame(master_frame);
|
||||
free(master_frame);
|
||||
csi_camera_put_frame(slave_frame);
|
||||
@@ -1131,8 +1131,8 @@ static int cam_dual_frame_process(struct list_head * pair_frame_list,struct list
|
||||
static void *cam_frame_sync_process(void *arg)
|
||||
{
|
||||
camera_sync_msg_t *msg;
|
||||
csi_frame_s * master_frame=NULL;
|
||||
csi_frame_s * slave_frame=NULL;
|
||||
csi_frame_ex_s * master_frame=NULL;
|
||||
csi_frame_ex_s * slave_frame=NULL;
|
||||
struct list_head *matched_list=NULL;
|
||||
msg_queue_item_t * item;
|
||||
cam_sync_process_ctx_t *ctx =(cam_sync_process_ctx_t *)arg;
|
||||
@@ -1214,7 +1214,7 @@ static int camera_get_chl_id(int env_type, int *chl_id)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static int cam_send_frame_to_sync_process(msg_queue_ctx_t *queue,csi_frame_s *frame, cam_sync_message_type_e type)
|
||||
static int cam_send_frame_to_sync_process(msg_queue_ctx_t *queue,csi_frame_ex_s *frame, cam_sync_message_type_e type)
|
||||
{
|
||||
camera_sync_msg_t *msg_palyload = malloc(sizeof(camera_sync_msg_t));
|
||||
msg_queue_item_t * item=NULL;
|
||||
@@ -1229,7 +1229,7 @@ static int cam_send_frame_to_sync_process(msg_queue_ctx_t *queue,csi_frame_s *fr
|
||||
return -1;
|
||||
}
|
||||
msg_palyload->type= type;
|
||||
memcpy(&msg_palyload->frame,frame,sizeof(csi_frame_s));
|
||||
memcpy(&msg_palyload->frame,frame,sizeof(csi_frame_ex_s));
|
||||
item->payload = msg_palyload;
|
||||
return enqueue_msg(queue,item);
|
||||
|
||||
@@ -1248,7 +1248,7 @@ static int camera_event_process(void *arg)
|
||||
type = ctx->cam_id==0?CAM_SYNC_MSG_MAIN_FRAME:CAM_SYNC_MSG_SLAVE_FRAME;
|
||||
struct timeval cur_time;
|
||||
struct csi_camera_event event;
|
||||
csi_frame_s frame;
|
||||
csi_frame_ex_s frame;
|
||||
|
||||
if (ev_handle == NULL) {
|
||||
LOG_E("fail to get ev_handle ev_handle\n");
|
||||
@@ -1579,22 +1579,6 @@ ONR_ERR:
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static void dump_camera_meta(csi_frame_s *frame)
|
||||
{
|
||||
int i;
|
||||
//printf("%s\n", __func__);
|
||||
if (frame->meta.type != CSI_META_TYPE_CAMERA)
|
||||
return;
|
||||
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->meta.data;
|
||||
int meta_count = meta_data->count;
|
||||
csi_camrea_meta_unit_s meta_unit;
|
||||
|
||||
|
||||
csi_camera_frame_get_meta_unit(
|
||||
&meta_unit, meta_data, CSI_CAMERA_META_ID_FRAME_ID);
|
||||
LOG_I("meta_id=%d, meta_type=%d, meta_value=%d\n",
|
||||
meta_unit.id, meta_unit.type, meta_unit.int_value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ typedef struct frame_fps {
|
||||
struct timeval initTick;
|
||||
float fps;
|
||||
} frame_fps_t;
|
||||
static void dump_camera_meta(csi_frame_s *frame);
|
||||
static void dump_camera_frame(csi_frame_s *frame, int ch_id);
|
||||
static void dump_camera_meta(csi_frame_ex_s *frame);
|
||||
static void dump_camera_frame(csi_frame_ex_s *frame, int ch_id);
|
||||
|
||||
|
||||
typedef struct event_queue_item{
|
||||
@@ -92,7 +92,7 @@ static void* camera_channle_process(void* arg)
|
||||
|
||||
struct timeval init_time, cur_time;
|
||||
frame_fps_t demo_fps;
|
||||
csi_frame_s frame;
|
||||
csi_frame_ex_s frame;
|
||||
memset(&init_time, 0, sizeof(init_time));
|
||||
memset(&cur_time, 0, sizeof(cur_time));
|
||||
channel_handle_ctx_t * ctx = (channel_handle_ctx_t *)arg;
|
||||
@@ -126,7 +126,6 @@ static void* camera_channle_process(void* arg)
|
||||
|
||||
// csi_camera_frame_unlock(cam_handle, &frame);
|
||||
csi_camera_put_frame(&frame);
|
||||
csi_frame_release(&frame);
|
||||
}
|
||||
unsigned long diff;
|
||||
if (init_time.tv_usec == 0)
|
||||
@@ -550,14 +549,14 @@ int main(int argc, char *argv[])
|
||||
csi_camera_close(cam_handle);
|
||||
}
|
||||
|
||||
static void dump_camera_meta(csi_frame_s *frame)
|
||||
static void dump_camera_meta(csi_frame_ex_s *frame)
|
||||
{
|
||||
int i;
|
||||
if (frame->meta.type != CSI_META_TYPE_CAMERA)
|
||||
if (frame->frame_meta.type != CSI_META_TYPE_CAMERA)
|
||||
return;
|
||||
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->meta.data;
|
||||
csi_camrea_meta_unit_s meta_frame_id,meta_frame_ts;
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->frame_meta.data;
|
||||
csi_camera_meta_unit_s meta_frame_id,meta_frame_ts;
|
||||
|
||||
|
||||
csi_camera_frame_get_meta_unit(
|
||||
@@ -567,138 +566,96 @@ static void dump_camera_meta(csi_frame_s *frame)
|
||||
LOG_O("meta frame id=%d,time stap:(%ld,%ld)\n",
|
||||
meta_frame_id.int_value,meta_frame_ts.time_value.tv_sec,meta_frame_ts.time_value.tv_usec);
|
||||
}
|
||||
|
||||
static void dump_camera_frame(csi_frame_s *frame, int ch_id)
|
||||
int file_id = 0;
|
||||
static void dump_camera_frame(csi_frame_ex_s *frame, int ch_id)
|
||||
{
|
||||
char file[128];
|
||||
static int file_indx=0;
|
||||
int size,buf_size;
|
||||
int size;
|
||||
uint32_t indexd, j;
|
||||
void *buf[3];
|
||||
void *buf[3]={NULL,NULL,NULL};
|
||||
int buf_size;
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->frame_meta.data;
|
||||
csi_camera_meta_unit_s meta_unit;
|
||||
|
||||
sprintf(file,"demo_save_img_ch_%d_%d", ch_id,file_indx++%6);
|
||||
csi_camera_frame_get_meta_unit(&meta_unit, meta_data, CSI_CAMERA_META_ID_CAMERA_NAME);
|
||||
|
||||
sprintf(file, "demo_save_img_%s_ch%d_%d_%d", meta_unit.str_value, ch_id,file_id, file_indx++%10);
|
||||
int fd = open(file, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IROTH);
|
||||
if(fd == -1) {
|
||||
LOG_E("%s, %d, open file error!!!!!!!!!!!!!!!\n", __func__, __LINE__);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
if (frame->img.type == CSI_IMG_TYPE_DMA_BUF) {
|
||||
|
||||
buf_size = frame->img.strides[0]*frame->img.height;
|
||||
switch(frame->img.pix_format) {
|
||||
case CSI_PIX_FMT_NV12:
|
||||
case CSI_PIX_FMT_YUV_SEMIPLANAR_420:
|
||||
if(frame->img.num_planes ==2)
|
||||
{
|
||||
buf_size+=frame->img.strides[1]*frame->img.height/2;
|
||||
}
|
||||
else{
|
||||
LOG_E("img fomrat is not match with frame planes:%d\n",frame->img.num_planes);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case CSI_PIX_FMT_YUV_SEMIPLANAR_422:
|
||||
if(frame->img.num_planes ==2)
|
||||
{
|
||||
buf_size+=frame->img.strides[1]*frame->img.height;
|
||||
}
|
||||
else{
|
||||
LOG_E("img fomrat is not match with frame planes:%d\n",frame->img.num_planes);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
buf[0]= mmap(0, buf_size, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, frame->img.dmabuf[0].fds, frame->img.dmabuf[0].offset);
|
||||
// plane_size[1] = frame->img.strides[1]*frame->img.height;
|
||||
// printf("frame plane 1 stride:%d,offset:%d\n", frame->img.strides[1],(uint32_t)frame->img.dmabuf[1].offset);
|
||||
if(frame->img.num_planes ==2)
|
||||
{
|
||||
// buf[1] = mmap(0, plane_size[1]/2, PROT_READ | PROT_WRITE,
|
||||
// MAP_SHARED, frame->img.dmabuf[1].fds, frame->img.dmabuf[1].offset);
|
||||
buf[1] = buf[0]+frame->img.dmabuf[1].offset;
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
buf[0] = frame->img.usr_addr[0];
|
||||
buf[1] = frame->img.usr_addr[1];
|
||||
for(j =0;j<frame->frame_data.num_plane;j++)
|
||||
{
|
||||
buf[j] = frame->frame_data.vir_addr[j];
|
||||
}
|
||||
|
||||
LOG_O("save img from :%d, to %s, fmt:%d width:%d stride:%d height:%d\n",frame->img.dmabuf[0].fds, file, frame->img.pix_format , frame->img.width, frame->img.strides[0], frame->img.height);
|
||||
frame->img.pix_format = CSI_PIX_FMT_RAW_12BIT;
|
||||
switch(frame->img.pix_format) {
|
||||
LOG_I("save img from: addr:%p,to %s, fd:%d,fmt:%d width:%d stride:%d height:%d\n", buf[0], file, frame->frame_data.fd[0],
|
||||
frame->frame_info.pixel_format, frame->frame_info.width, frame->frame_data.stride[0], frame->frame_info.height);
|
||||
|
||||
switch(frame->frame_info.pixel_format) {
|
||||
case CSI_PIX_FMT_NV12:
|
||||
case CSI_PIX_FMT_YUV_SEMIPLANAR_420:
|
||||
if (frame->img.strides[0] == 0) {
|
||||
frame->img.strides[0] = frame->img.width;
|
||||
for (j = 0; j < frame->frame_info.height; j++) { //Y
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[0] + indexd, frame->frame_info.width);
|
||||
}
|
||||
for (j = 0; j < frame->img.height; j++) { //Y
|
||||
indexd = j*frame->img.strides[0];
|
||||
write(fd, buf[0] + indexd, frame->img.width);
|
||||
}
|
||||
for (j = 0; j < frame->img.height / 2; j++) { //UV
|
||||
indexd = j*frame->img.strides[0];
|
||||
write(fd, buf[1] + indexd, frame->img.width);
|
||||
for (j = 0; j < frame->frame_info.height / 2; j++) { //UV
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[1] + indexd, frame->frame_info.width);
|
||||
}
|
||||
break;
|
||||
case CSI_PIX_FMT_RGB_INTEVLEAVED_888:
|
||||
case CSI_PIX_FMT_YUV_TEVLEAVED_444:
|
||||
size = frame->img.width*3;
|
||||
for (j = 0; j < frame->img.height; j++) {
|
||||
indexd = j*frame->img.strides[0];
|
||||
size = frame->frame_info.width*3;
|
||||
for (j = 0; j < frame->frame_info.height; j++) {
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[0] + indexd, size);
|
||||
}
|
||||
break;
|
||||
case CSI_PIX_FMT_BGR:
|
||||
case CSI_PIX_FMT_RGB_PLANAR_888:
|
||||
case CSI_PIX_FMT_YUV_PLANAR_444:
|
||||
size = frame->img.width * frame->img.height * 3;
|
||||
size = frame->frame_info.width * frame->frame_info.height * 3;
|
||||
write(fd, buf[0], size);
|
||||
break;
|
||||
case CSI_PIX_FMT_RAW_8BIT:
|
||||
size = frame->img.width;
|
||||
for (j = 0; j < frame->img.height; j++) {
|
||||
indexd = j*frame->img.strides[0];
|
||||
case CSI_PIX_FMT_RAW_8BIT:
|
||||
size = frame->frame_info.width;
|
||||
for (j = 0; j < frame->frame_info.height; j++) {
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[0] + indexd, size);
|
||||
}
|
||||
break;
|
||||
case CSI_PIX_FMT_YUV_TEVLEAVED_422:
|
||||
case CSI_PIX_FMT_RAW_10BIT:
|
||||
case CSI_PIX_FMT_RAW_12BIT:
|
||||
case CSI_PIX_FMT_RAW_14BIT:
|
||||
case CSI_PIX_FMT_RAW_16BIT:
|
||||
size = frame->img.width*2;
|
||||
for (j = 0; j < frame->img.height; j++) {
|
||||
indexd = j*frame->img.strides[0];
|
||||
case CSI_PIX_FMT_RAW_10BIT:
|
||||
case CSI_PIX_FMT_RAW_12BIT:
|
||||
case CSI_PIX_FMT_RAW_14BIT:
|
||||
case CSI_PIX_FMT_RAW_16BIT:
|
||||
size = frame->frame_info.width*2;
|
||||
for (j = 0; j < frame->frame_info.height; j++) {
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[0] + indexd, size);
|
||||
}
|
||||
break;
|
||||
case CSI_PIX_FMT_YUV_SEMIPLANAR_422:
|
||||
if (frame->img.strides[0] == 0) {
|
||||
frame->img.strides[0] = frame->img.width;
|
||||
if (frame->frame_data.stride[0] == 0) {
|
||||
frame->frame_data.stride[0] = frame->frame_info.width;
|
||||
}
|
||||
for (j = 0; j < frame->img.height; j++) { //Y
|
||||
indexd = j*frame->img.strides[0];
|
||||
write(fd,buf[0] + indexd, frame->img.width);
|
||||
for (j = 0; j < frame->frame_info.height; j++) { //Y
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd,buf[0] + indexd, frame->frame_info.width);
|
||||
}
|
||||
for (j = 0; j < frame->img.height; j++) { //UV
|
||||
indexd = j*frame->img.strides[0];
|
||||
write(fd, buf[1]+ indexd, frame->img.width);
|
||||
for (j = 0; j < frame->frame_info.height; j++) { //UV
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[1]+ indexd, frame->frame_info.width);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LOG_E("%s unsupported format to save\n", __func__);
|
||||
exit(-1);
|
||||
LOG_E("%s unsupported format to save\n", __func__);
|
||||
break;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
munmap(buf[0],buf_size);
|
||||
// munmap(buf[1],plane_size[1]);
|
||||
LOG_O("%s exit\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
#endif
|
||||
#define MAX_CAM_NUM 3
|
||||
#define MAX_CHANNEL_NUM 3
|
||||
static void dump_camera_meta(csi_frame_s *frame);
|
||||
static void dump_camera_frame(csi_frame_s *frame, csi_pixel_fmt_e fmt, int camera_id);
|
||||
static void dump_camera_meta(csi_frame_ex_s *frame);
|
||||
static void dump_camera_frame(csi_frame_ex_s *frame, int ch_id);
|
||||
|
||||
// extern int csi_camera_frame_unlock(csi_cam_handle_t cam_handle, csi_frame_s *frame);
|
||||
|
||||
@@ -94,7 +94,7 @@ typedef struct _camera_ctx{
|
||||
int file_id = 0;
|
||||
extern void *vi_plink_create(csi_camera_channel_cfg_s *chn_cfg);
|
||||
extern void vi_plink_release(void * plink);
|
||||
extern void display_camera_frame(void * plink, csi_frame_s *frame);
|
||||
extern void display_camera_frame(void * plink, csi_frame_ex_s *frame);
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
@@ -255,7 +255,7 @@ static void *camera_event_thread(void *arg)
|
||||
|
||||
frame_fps_t demo_fps;
|
||||
memset(&demo_fps, 0, sizeof(demo_fps));
|
||||
csi_frame_s frame;
|
||||
csi_frame_ex_s frame;
|
||||
|
||||
if (ev_handle == NULL) {
|
||||
LOG_E("fail to get ev_handle ev_handle\n");
|
||||
@@ -314,10 +314,10 @@ static void *camera_event_thread(void *arg)
|
||||
csi_camera_get_frame(ctx->cam_handle, chn_id, &frame, timeout);
|
||||
dump_camera_meta(&frame);
|
||||
if (ctx->frame_mode[chn_id] == FRAME_SAVE_IMG) {
|
||||
dump_camera_frame(&frame, ch_cfg->img_fmt.pix_fmt, chn_id);
|
||||
dump_camera_frame(&frame, chn_id);
|
||||
}
|
||||
if (ctx->disaply_plink && ctx->frame_mode[chn_id]==FRAME_SAVE_DISPLAY) {
|
||||
frame.img.pix_format = ch_cfg->img_fmt.pix_fmt;
|
||||
|
||||
display_camera_frame(ctx->disaply_plink, &frame);
|
||||
}
|
||||
csi_camera_put_frame(&frame);
|
||||
@@ -645,16 +645,16 @@ ONR_ERR:
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static void dump_camera_meta(csi_frame_s *frame)
|
||||
static void dump_camera_meta(csi_frame_ex_s *frame)
|
||||
{
|
||||
int i;
|
||||
//printf("%s\n", __func__);
|
||||
if (frame->meta.type != CSI_META_TYPE_CAMERA)
|
||||
if (frame->frame_meta.type != CSI_META_TYPE_CAMERA)
|
||||
return;
|
||||
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->meta.data;
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->frame_meta.data;
|
||||
int meta_count = meta_data->count;
|
||||
csi_camrea_meta_unit_s meta_unit;
|
||||
csi_camera_meta_unit_s meta_unit;
|
||||
|
||||
|
||||
csi_camera_frame_get_meta_unit(
|
||||
@@ -663,145 +663,95 @@ static void dump_camera_meta(csi_frame_s *frame)
|
||||
meta_unit.id, meta_unit.type, meta_unit.int_value);
|
||||
}
|
||||
|
||||
static void dump_camera_frame(csi_frame_s *frame, csi_pixel_fmt_e fmt, int chan_id)
|
||||
static void dump_camera_frame(csi_frame_ex_s *frame, int ch_id)
|
||||
{
|
||||
char file[128];
|
||||
static int file_indx=0;
|
||||
int size;
|
||||
uint32_t indexd, j;
|
||||
void *buf[3];
|
||||
void *buf[3]={NULL,NULL,NULL};
|
||||
int buf_size;
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->meta.data;
|
||||
csi_camrea_meta_unit_s meta_unit;
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->frame_meta.data;
|
||||
csi_camera_meta_unit_s meta_unit;
|
||||
|
||||
csi_camera_frame_get_meta_unit(&meta_unit, meta_data, CSI_CAMERA_META_ID_CAMERA_NAME);
|
||||
|
||||
csi_camera_frame_get_meta_unit(
|
||||
&meta_unit, meta_data, CSI_CAMERA_META_ID_CAMERA_NAME);
|
||||
|
||||
|
||||
sprintf(file,"demo_save_img%s_%d_%d",meta_unit.str_value,chan_id, file_indx++%10);
|
||||
sprintf(file, "demo_save_img_%s_ch%d_%d_%d", meta_unit.str_value, ch_id,file_id, file_indx++%10);
|
||||
int fd = open(file, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IROTH);
|
||||
if(fd == -1) {
|
||||
LOG_E("%s, %d, open file error!!!!!!!!!!!!!!!\n", __func__, __LINE__);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
if (frame->img.type == CSI_IMG_TYPE_DMA_BUF) {
|
||||
|
||||
buf_size = frame->img.strides[0]*frame->img.height;
|
||||
switch(fmt) {
|
||||
case CSI_PIX_FMT_NV12:
|
||||
case CSI_PIX_FMT_YUV_SEMIPLANAR_420:
|
||||
if(frame->img.num_planes ==2)
|
||||
{
|
||||
buf_size+=frame->img.strides[1]*frame->img.height/2;
|
||||
}
|
||||
else{
|
||||
LOG_O("img fomrat is not match with frame planes:%d\n",frame->img.num_planes);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case CSI_PIX_FMT_YUV_SEMIPLANAR_422:
|
||||
if(frame->img.num_planes ==2)
|
||||
{
|
||||
buf_size+=frame->img.strides[1]*frame->img.height;
|
||||
}
|
||||
else{
|
||||
LOG_O("img fomrat is not match with frame planes:%d\n",frame->img.num_planes);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
buf[0]= mmap(0, buf_size, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, frame->img.dmabuf[0].fds, frame->img.dmabuf[0].offset);
|
||||
// plane_size[1] = frame->img.strides[1]*frame->img.height;
|
||||
// printf("frame plane 1 stride:%d,offset:%d\n", frame->img.strides[1],(uint32_t)frame->img.dmabuf[1].offset);
|
||||
if(frame->img.num_planes ==2)
|
||||
{
|
||||
// buf[1] = mmap(0, plane_size[1]/2, PROT_READ | PROT_WRITE,
|
||||
// MAP_SHARED, frame->img.dmabuf[1].fds, frame->img.dmabuf[1].offset);
|
||||
buf[1] = buf[0]+frame->img.dmabuf[1].offset;
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
buf[0] = frame->img.usr_addr[0];
|
||||
buf[1] = frame->img.usr_addr[1];
|
||||
for(j =0;j<frame->frame_data.num_plane;j++)
|
||||
{
|
||||
buf[j] = frame->frame_data.vir_addr[j];
|
||||
}
|
||||
|
||||
LOG_O("%s,save img from : (%lx,%lx)size:%d to %s, fmt:%d width:%d stride:%d height:%d\n",__FUNCTION__, (uint64_t)buf[0],(uint64_t)buf[1],size, file, fmt, frame->img.width, frame->img.strides[0], frame->img.height);
|
||||
LOG_I("save img from: addr:%p,to %s, fd:%d,fmt:%d width:%d stride:%d height:%d\n", buf[0], file, frame->frame_data.fd[0],
|
||||
frame->frame_info.pixel_format, frame->frame_info.width, frame->frame_data.stride[0], frame->frame_info.height);
|
||||
|
||||
if (frame->img.strides[0] == 0) {
|
||||
frame->img.strides[0] = frame->img.width;
|
||||
}
|
||||
switch(fmt) {
|
||||
switch(frame->frame_info.pixel_format) {
|
||||
case CSI_PIX_FMT_NV12:
|
||||
case CSI_PIX_FMT_YUV_SEMIPLANAR_420:
|
||||
for (j = 0; j < frame->img.height; j++) { //Y
|
||||
indexd = j*frame->img.strides[0];
|
||||
write(fd, buf[0] + indexd, frame->img.width);
|
||||
for (j = 0; j < frame->frame_info.height; j++) { //Y
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[0] + indexd, frame->frame_info.width);
|
||||
}
|
||||
for (j = 0; j < frame->img.height / 2; j++) { //UV
|
||||
indexd = j*frame->img.strides[0];
|
||||
write(fd, buf[1] + indexd, frame->img.width);
|
||||
for (j = 0; j < frame->frame_info.height / 2; j++) { //UV
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[1] + indexd, frame->frame_info.width);
|
||||
}
|
||||
break;
|
||||
case CSI_PIX_FMT_RGB_INTEVLEAVED_888:
|
||||
case CSI_PIX_FMT_YUV_TEVLEAVED_444:
|
||||
size = frame->img.width*3;
|
||||
for (j = 0; j < frame->img.height; j++) {
|
||||
indexd = j*frame->img.strides[0];
|
||||
size = frame->frame_info.width*3;
|
||||
for (j = 0; j < frame->frame_info.height; j++) {
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[0] + indexd, size);
|
||||
}
|
||||
break;
|
||||
case CSI_PIX_FMT_BGR:
|
||||
case CSI_PIX_FMT_RGB_PLANAR_888:
|
||||
case CSI_PIX_FMT_YUV_PLANAR_444:
|
||||
size = frame->img.width * frame->img.height * 3;
|
||||
size = frame->frame_info.width * frame->frame_info.height * 3;
|
||||
write(fd, buf[0], size);
|
||||
break;
|
||||
case CSI_PIX_FMT_RAW_8BIT:
|
||||
size = frame->img.width;
|
||||
for (j = 0; j < frame->img.height; j++) {
|
||||
indexd = j*frame->img.strides[0];
|
||||
case CSI_PIX_FMT_RAW_8BIT:
|
||||
size = frame->frame_info.width;
|
||||
for (j = 0; j < frame->frame_info.height; j++) {
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[0] + indexd, size);
|
||||
}
|
||||
break;
|
||||
case CSI_PIX_FMT_YUV_TEVLEAVED_422:
|
||||
case CSI_PIX_FMT_RAW_10BIT:
|
||||
case CSI_PIX_FMT_RAW_12BIT:
|
||||
case CSI_PIX_FMT_RAW_14BIT:
|
||||
case CSI_PIX_FMT_RAW_16BIT:
|
||||
size = frame->img.width*2;
|
||||
for (j = 0; j < frame->img.height; j++) {
|
||||
indexd = j*frame->img.strides[0];
|
||||
case CSI_PIX_FMT_RAW_10BIT:
|
||||
case CSI_PIX_FMT_RAW_12BIT:
|
||||
case CSI_PIX_FMT_RAW_14BIT:
|
||||
case CSI_PIX_FMT_RAW_16BIT:
|
||||
size = frame->frame_info.width*2;
|
||||
for (j = 0; j < frame->frame_info.height; j++) {
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[0] + indexd, size);
|
||||
}
|
||||
break;
|
||||
case CSI_PIX_FMT_YUV_SEMIPLANAR_422:
|
||||
if (frame->img.strides[0] == 0) {
|
||||
frame->img.strides[0] = frame->img.width;
|
||||
if (frame->frame_data.stride[0] == 0) {
|
||||
frame->frame_data.stride[0] = frame->frame_info.width;
|
||||
}
|
||||
for (j = 0; j < frame->img.height; j++) { //Y
|
||||
indexd = j*frame->img.strides[0];
|
||||
write(fd,buf[0] + indexd, frame->img.width);
|
||||
for (j = 0; j < frame->frame_info.height; j++) { //Y
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd,buf[0] + indexd, frame->frame_info.width);
|
||||
}
|
||||
for (j = 0; j < frame->img.height; j++) { //UV
|
||||
indexd = j*frame->img.strides[0];
|
||||
write(fd, buf[1]+ indexd, frame->img.width);
|
||||
for (j = 0; j < frame->frame_info.height; j++) { //UV
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[1]+ indexd, frame->frame_info.width);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LOG_E("%s unsupported format to save\n", __func__);
|
||||
exit(-1);
|
||||
LOG_E("%s unsupported format to save\n", __func__);
|
||||
break;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
munmap(buf[0],buf_size);
|
||||
// munmap(buf[1],plane_size[1]);
|
||||
LOG_O("%s exit\n", __func__);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#define LOG_PREFIX "cam_demo_simple"
|
||||
#include <syslog.h>
|
||||
|
||||
#include <csi_frame.h>
|
||||
#include <csi_frame_ex.h>
|
||||
#include <csi_camera.h>
|
||||
#include "csi_camera_dev_api.h"
|
||||
// #include "vi_mem.h"
|
||||
@@ -25,8 +25,8 @@
|
||||
#include "apputilities.h"
|
||||
#endif
|
||||
|
||||
static void dump_camera_meta(csi_frame_s *frame);
|
||||
static void dump_camera_frame(csi_frame_s *frame, csi_pixel_fmt_e fmt);
|
||||
static void dump_camera_meta(csi_frame_ex_s *frame);
|
||||
static void dump_camera_frame(csi_frame_ex_s *frame, int ch_id);
|
||||
|
||||
|
||||
#define TEST_DEVICE_NAME "/dev/video0"
|
||||
@@ -102,7 +102,7 @@ static void get_system_time(const char *func, int line_num)
|
||||
int file_id = 0;
|
||||
extern void *vi_plink_create(csi_camera_channel_cfg_s *chn_cfg);
|
||||
extern void vi_plink_release(void * plink);
|
||||
extern void display_camera_frame(void * plink, csi_frame_s *frame);
|
||||
extern void display_camera_frame(void * plink, csi_frame_ex_s *frame);
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
bool running = true;
|
||||
@@ -452,7 +452,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
get_system_time(__func__, __LINE__);
|
||||
// 处理订阅的Event
|
||||
csi_frame_s frame;
|
||||
csi_frame_ex_s frame;
|
||||
struct csi_camera_event event;
|
||||
|
||||
while (running) {
|
||||
@@ -524,17 +524,15 @@ int main(int argc, char *argv[])
|
||||
dump_camera_meta(&frame);
|
||||
chn_cfg.chn_id = chn_id;
|
||||
csi_camera_channel_query(cam_handle, &chn_cfg);
|
||||
frame.img.pix_format = chn_cfg.img_fmt.pix_fmt;
|
||||
|
||||
if (dump_enable) {
|
||||
dump_camera_frame(&frame, chn_cfg.img_fmt.pix_fmt);
|
||||
dump_camera_frame(&frame, chn_id);
|
||||
}
|
||||
if (display_enable == 1) {
|
||||
display_camera_frame(display_plink, &frame);
|
||||
continue;
|
||||
}
|
||||
csi_camera_put_frame(&frame);
|
||||
csi_frame_release(&frame);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -563,16 +561,16 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
static void dump_camera_meta(csi_frame_s *frame)
|
||||
static void dump_camera_meta(csi_frame_ex_s *frame)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (frame->meta.type != CSI_META_TYPE_CAMERA)
|
||||
if (frame->frame_meta.type != CSI_META_TYPE_CAMERA)
|
||||
return;
|
||||
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->meta.data;
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->frame_meta.data;
|
||||
int meta_count = meta_data->count;
|
||||
csi_camrea_meta_unit_s meta_unit;
|
||||
csi_camera_meta_unit_s meta_unit;
|
||||
|
||||
|
||||
csi_camera_frame_get_meta_unit(
|
||||
@@ -581,145 +579,95 @@ static void dump_camera_meta(csi_frame_s *frame)
|
||||
meta_unit.id, meta_unit.type, meta_unit.int_value);
|
||||
}
|
||||
|
||||
static void dump_camera_frame(csi_frame_s *frame, csi_pixel_fmt_e fmt)
|
||||
static void dump_camera_frame(csi_frame_ex_s *frame, int ch_id)
|
||||
{
|
||||
char file[128];
|
||||
static int file_indx=0;
|
||||
int size;
|
||||
uint32_t indexd, j;
|
||||
void *buf[3];
|
||||
void *buf[3]={NULL,NULL,NULL};
|
||||
int buf_size;
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->meta.data;
|
||||
csi_camrea_meta_unit_s meta_unit;
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->frame_meta.data;
|
||||
csi_camera_meta_unit_s meta_unit;
|
||||
|
||||
csi_camera_frame_get_meta_unit(&meta_unit, meta_data, CSI_CAMERA_META_ID_CAMERA_NAME);
|
||||
|
||||
csi_camera_frame_get_meta_unit(
|
||||
&meta_unit, meta_data, CSI_CAMERA_META_ID_CAMERA_NAME);
|
||||
|
||||
|
||||
sprintf(file,"demo_save_img%s_%d_%d",meta_unit.str_value,file_id, file_indx++%10);
|
||||
sprintf(file, "demo_save_img_%s_ch%d_%d_%d", meta_unit.str_value, ch_id,file_id, file_indx++%10);
|
||||
int fd = open(file, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IROTH);
|
||||
if(fd == -1) {
|
||||
LOG_E("%s, %d, open file error!!!!!!!!!!!!!!!\n", __func__, __LINE__);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
if (frame->img.type == CSI_IMG_TYPE_DMA_BUF) {
|
||||
|
||||
buf_size = frame->img.strides[0]*frame->img.height;
|
||||
switch(fmt) {
|
||||
case CSI_PIX_FMT_NV12:
|
||||
case CSI_PIX_FMT_YUV_SEMIPLANAR_420:
|
||||
if(frame->img.num_planes ==2)
|
||||
{
|
||||
buf_size+=frame->img.strides[1]*frame->img.height/2;
|
||||
}
|
||||
else{
|
||||
LOG_E("img fomrat is not match with frame planes:%d\n",frame->img.num_planes);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case CSI_PIX_FMT_YUV_SEMIPLANAR_422:
|
||||
if(frame->img.num_planes ==2)
|
||||
{
|
||||
buf_size+=frame->img.strides[1]*frame->img.height;
|
||||
}
|
||||
else{
|
||||
LOG_E("img fomrat is not match with frame planes:%d\n",frame->img.num_planes);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
buf[0]= mmap(0, buf_size, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, frame->img.dmabuf[0].fds, frame->img.dmabuf[0].offset);
|
||||
// plane_size[1] = frame->img.strides[1]*frame->img.height;
|
||||
// printf("frame plane 1 stride:%d,offset:%d\n", frame->img.strides[1],(uint32_t)frame->img.dmabuf[1].offset);
|
||||
if(frame->img.num_planes ==2)
|
||||
{
|
||||
// buf[1] = mmap(0, plane_size[1]/2, PROT_READ | PROT_WRITE,
|
||||
// MAP_SHARED, frame->img.dmabuf[1].fds, frame->img.dmabuf[1].offset);
|
||||
buf[1] = buf[0]+frame->img.dmabuf[1].offset;
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
buf[0] = frame->img.usr_addr[0];
|
||||
buf[1] = frame->img.usr_addr[1];
|
||||
for(j =0;j<frame->frame_data.num_plane;j++)
|
||||
{
|
||||
buf[j] = frame->frame_data.vir_addr[j];
|
||||
}
|
||||
|
||||
LOG_O("%s,save img from : (%lx,%lx)size:%d to %s, fmt:%d width:%d stride:%d height:%d\n",__FUNCTION__, (uint64_t)buf[0],(uint64_t)buf[1],size, file, fmt, frame->img.width, frame->img.strides[0], frame->img.height);
|
||||
LOG_I("save img from: addr:%p,to %s, fd:%d,fmt:%d width:%d stride:%d height:%d\n", buf[0], file, frame->frame_data.fd[0],
|
||||
frame->frame_info.pixel_format, frame->frame_info.width, frame->frame_data.stride[0], frame->frame_info.height);
|
||||
|
||||
if (frame->img.strides[0] == 0) {
|
||||
frame->img.strides[0] = frame->img.width;
|
||||
}
|
||||
switch(fmt) {
|
||||
switch(frame->frame_info.pixel_format) {
|
||||
case CSI_PIX_FMT_NV12:
|
||||
case CSI_PIX_FMT_YUV_SEMIPLANAR_420:
|
||||
for (j = 0; j < frame->img.height; j++) { //Y
|
||||
indexd = j*frame->img.strides[0];
|
||||
write(fd, buf[0] + indexd, frame->img.width);
|
||||
for (j = 0; j < frame->frame_info.height; j++) { //Y
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[0] + indexd, frame->frame_info.width);
|
||||
}
|
||||
for (j = 0; j < frame->img.height / 2; j++) { //UV
|
||||
indexd = j*frame->img.strides[0];
|
||||
write(fd, buf[1] + indexd, frame->img.width);
|
||||
for (j = 0; j < frame->frame_info.height / 2; j++) { //UV
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[1] + indexd, frame->frame_info.width);
|
||||
}
|
||||
break;
|
||||
case CSI_PIX_FMT_RGB_INTEVLEAVED_888:
|
||||
case CSI_PIX_FMT_YUV_TEVLEAVED_444:
|
||||
size = frame->img.width*3;
|
||||
for (j = 0; j < frame->img.height; j++) {
|
||||
indexd = j*frame->img.strides[0];
|
||||
size = frame->frame_info.width*3;
|
||||
for (j = 0; j < frame->frame_info.height; j++) {
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[0] + indexd, size);
|
||||
}
|
||||
break;
|
||||
case CSI_PIX_FMT_BGR:
|
||||
case CSI_PIX_FMT_RGB_PLANAR_888:
|
||||
case CSI_PIX_FMT_YUV_PLANAR_444:
|
||||
size = frame->img.width * frame->img.height * 3;
|
||||
size = frame->frame_info.width * frame->frame_info.height * 3;
|
||||
write(fd, buf[0], size);
|
||||
break;
|
||||
case CSI_PIX_FMT_RAW_8BIT:
|
||||
size = frame->img.width;
|
||||
for (j = 0; j < frame->img.height; j++) {
|
||||
indexd = j*frame->img.strides[0];
|
||||
case CSI_PIX_FMT_RAW_8BIT:
|
||||
size = frame->frame_info.width;
|
||||
for (j = 0; j < frame->frame_info.height; j++) {
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[0] + indexd, size);
|
||||
}
|
||||
break;
|
||||
case CSI_PIX_FMT_YUV_TEVLEAVED_422:
|
||||
case CSI_PIX_FMT_RAW_10BIT:
|
||||
case CSI_PIX_FMT_RAW_12BIT:
|
||||
case CSI_PIX_FMT_RAW_14BIT:
|
||||
case CSI_PIX_FMT_RAW_16BIT:
|
||||
size = frame->img.width*2;
|
||||
for (j = 0; j < frame->img.height; j++) {
|
||||
indexd = j*frame->img.strides[0];
|
||||
case CSI_PIX_FMT_RAW_10BIT:
|
||||
case CSI_PIX_FMT_RAW_12BIT:
|
||||
case CSI_PIX_FMT_RAW_14BIT:
|
||||
case CSI_PIX_FMT_RAW_16BIT:
|
||||
size = frame->frame_info.width*2;
|
||||
for (j = 0; j < frame->frame_info.height; j++) {
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[0] + indexd, size);
|
||||
}
|
||||
break;
|
||||
case CSI_PIX_FMT_YUV_SEMIPLANAR_422:
|
||||
if (frame->img.strides[0] == 0) {
|
||||
frame->img.strides[0] = frame->img.width;
|
||||
if (frame->frame_data.stride[0] == 0) {
|
||||
frame->frame_data.stride[0] = frame->frame_info.width;
|
||||
}
|
||||
for (j = 0; j < frame->img.height; j++) { //Y
|
||||
indexd = j*frame->img.strides[0];
|
||||
write(fd,buf[0] + indexd, frame->img.width);
|
||||
for (j = 0; j < frame->frame_info.height; j++) { //Y
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd,buf[0] + indexd, frame->frame_info.width);
|
||||
}
|
||||
for (j = 0; j < frame->img.height; j++) { //UV
|
||||
indexd = j*frame->img.strides[0];
|
||||
write(fd, buf[1]+ indexd, frame->img.width);
|
||||
for (j = 0; j < frame->frame_info.height; j++) { //UV
|
||||
indexd = j*frame->frame_data.stride[0];
|
||||
write(fd, buf[1]+ indexd, frame->frame_info.width);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LOG_E("%s unsupported format to save\n", __func__);
|
||||
exit(-1);
|
||||
LOG_E("%s unsupported format to save\n", __func__);
|
||||
break;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
munmap(buf[0],buf_size);
|
||||
// munmap(buf[1],plane_size[1]);
|
||||
LOG_O("%s exit\n", __func__);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "platform_action.h"
|
||||
#endif
|
||||
|
||||
static void dump_camera_meta(csi_frame_s *frame);
|
||||
static void dump_camera_meta(csi_frame_ex_s *frame);
|
||||
|
||||
//#define TEST_DEVICE_NAME "/dev/fake"
|
||||
#define TEST_DEVICE_NAME "/dev/video0"
|
||||
@@ -222,7 +222,7 @@ int main(int argc, char *argv[])
|
||||
csi_camera_channel_start(cam_handle, CSI_CAMERA_CHANNEL_0);
|
||||
|
||||
// 处理订阅的Event
|
||||
csi_frame_s frame;
|
||||
csi_frame_ex_s frame;
|
||||
struct csi_camera_event event;
|
||||
|
||||
while (running) {
|
||||
@@ -283,15 +283,15 @@ int main(int argc, char *argv[])
|
||||
csi_camera_close(cam_handle);
|
||||
}
|
||||
|
||||
static void dump_camera_meta(csi_frame_s *frame)
|
||||
static void dump_camera_meta(csi_frame_ex_s *frame)
|
||||
{
|
||||
int i;
|
||||
if (frame->meta.type != CSI_META_TYPE_CAMERA)
|
||||
if (frame->frame_meta.type != CSI_META_TYPE_CAMERA)
|
||||
return;
|
||||
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->meta.data;
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->frame_meta.data;
|
||||
int meta_count = meta_data->count;
|
||||
csi_camrea_meta_unit_s meta_unit;
|
||||
csi_camera_meta_unit_s meta_unit;
|
||||
|
||||
for (i = 0; i < meta_count; i++) {
|
||||
csi_camera_frame_get_meta_unit(
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "platform_action.h"
|
||||
#endif
|
||||
|
||||
static void dump_camera_meta(csi_frame_s *frame);
|
||||
static void dump_camera_meta(csi_frame_ex_s *frame);
|
||||
|
||||
#define TEST_DEVICE_NAME "/dev/video0"
|
||||
int main(int argc, char *argv[])
|
||||
@@ -240,7 +240,7 @@ int main(int argc, char *argv[])
|
||||
LOG_O("Channel start OK\n");
|
||||
|
||||
// 处理订阅的Event
|
||||
csi_frame_s frame;
|
||||
csi_frame_ex_s frame;
|
||||
struct csi_camera_event event;
|
||||
|
||||
LOG_O("Starting get frame...\n");
|
||||
@@ -272,7 +272,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
dump_camera_meta(&frame);
|
||||
|
||||
csi_frame_release(&frame);
|
||||
csi_camera_put_frame(&frame);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -299,7 +299,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
dump_camera_meta(&frame);
|
||||
|
||||
csi_frame_release(&frame);
|
||||
csi_camera_put_frame(&frame);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -332,15 +332,15 @@ int main(int argc, char *argv[])
|
||||
csi_camera_close(cam_handle);
|
||||
}
|
||||
|
||||
static void dump_camera_meta(csi_frame_s *frame)
|
||||
static void dump_camera_meta(csi_frame_ex_s *frame)
|
||||
{
|
||||
int i;
|
||||
if (frame->meta.type != CSI_META_TYPE_CAMERA)
|
||||
if (frame->frame_meta.type != CSI_META_TYPE_CAMERA)
|
||||
return;
|
||||
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->meta.data;
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->frame_meta.data;
|
||||
int meta_count = meta_data->count;
|
||||
csi_camrea_meta_unit_s meta_unit;
|
||||
csi_camera_meta_unit_s meta_unit;
|
||||
|
||||
for (i = 0; i < meta_count; i++) {
|
||||
csi_camera_frame_get_meta_unit(
|
||||
|
||||
@@ -102,7 +102,7 @@ static int do_camera_event_action(cams_t *session, csi_camera_event_s *event)
|
||||
static int do_channel_event_action(cams_t *session, csi_camera_event_s *event)
|
||||
{
|
||||
_CHECK_SESSION_RETURN();
|
||||
csi_frame_s frame;
|
||||
csi_frame_ex_s frame;
|
||||
int ret = 0;
|
||||
|
||||
camera_event_action_union_t *event_action_u =
|
||||
@@ -160,7 +160,7 @@ static int do_channel_event_action(cams_t *session, csi_camera_event_s *event)
|
||||
LOG_D("read_frame_count = %d\n",read_frame_count);
|
||||
for (int i = 0; i < read_frame_count; i++) {
|
||||
csi_camera_get_frame(NULL,event->type - CSI_CAMERA_EVENT_TYPE_CHANNEL0, &frame, timeout);
|
||||
if(frame.img.usr_addr[0] != NULL) {
|
||||
if(frame.frame_data.vir_addr[0] != NULL) {
|
||||
camera_action_image_save(&frame);
|
||||
csi_camera_put_frame(&frame);
|
||||
}
|
||||
@@ -182,9 +182,9 @@ static int do_channel_event_action(cams_t *session, csi_camera_event_s *event)
|
||||
LOG_D("read_frame_count = %d\n",read_frame_count);
|
||||
//for (int i = 0; i < read_frame_count; i++) {
|
||||
csi_camera_get_frame(NULL,event->type - CSI_CAMERA_EVENT_TYPE_CHANNEL0, &frame, timeout);
|
||||
if(frame.img.usr_addr[0] != NULL) {
|
||||
if(frame.frame_data.vir_addr[0] != NULL) {
|
||||
camera_action_image_display(&frame);
|
||||
LOG_D("frame->usr_addr = %p\n",frame.img.usr_addr[0]);
|
||||
LOG_D("frame->usr_addr = %p\n",frame.frame_data.vir_addr[0]);
|
||||
csi_camera_put_frame(&frame);
|
||||
}
|
||||
//}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#define LOG_PREFIX "camera_demo4"
|
||||
#include <syslog.h>
|
||||
|
||||
#include <csi_frame.h>
|
||||
#include <csi_frame_ex.h>
|
||||
#include <csi_camera.h>
|
||||
|
||||
#define TEST_DEVICE_NAME "/dev/video0"
|
||||
@@ -29,7 +29,7 @@ typedef struct cam_channel_control {
|
||||
csi_camera_channel_cfg_s chn_cfg;
|
||||
} cam_channel_control_t;
|
||||
|
||||
static void dump_camera_meta(csi_frame_s *frame);
|
||||
static void dump_camera_meta(csi_frame_ex_s *frame);
|
||||
static void *channel_thread(void *arg);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -225,7 +225,7 @@ static void *channel_thread(void *arg)
|
||||
|
||||
// 处理订阅的Event
|
||||
LOG_O("[chn_%d] Starting get events...\n", chn_id);
|
||||
csi_frame_s frame;
|
||||
csi_frame_ex_s frame;
|
||||
struct csi_camera_event event;
|
||||
|
||||
while (chn_ctrl->run) {
|
||||
@@ -277,15 +277,15 @@ static void *channel_thread(void *arg)
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
static void dump_camera_meta(csi_frame_s *frame)
|
||||
static void dump_camera_meta(csi_frame_ex_s *frame)
|
||||
{
|
||||
int i;
|
||||
if (frame->meta.type != CSI_META_TYPE_CAMERA)
|
||||
if (frame->frame_meta.type != CSI_META_TYPE_CAMERA)
|
||||
return;
|
||||
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->meta.data;
|
||||
csi_camera_meta_s *meta_data = (csi_camera_meta_s *)frame->frame_meta.data;
|
||||
int meta_count = meta_data->count;
|
||||
csi_camrea_meta_unit_s meta_unit;
|
||||
csi_camera_meta_unit_s meta_unit;
|
||||
|
||||
for (i = 0; i < meta_count; i++) {
|
||||
csi_camera_frame_get_meta_unit(
|
||||
|
||||
@@ -38,7 +38,7 @@ typedef struct _CsiPlinkContext
|
||||
int useplink;
|
||||
int exitplink;
|
||||
CsiPictureBuffer sendbuffer[NUM_OF_BUFFERS];
|
||||
csi_frame_s frame_buf[NUM_OF_BUFFERS];
|
||||
csi_frame_ex_s frame_buf[NUM_OF_BUFFERS];
|
||||
int sendid;
|
||||
int available_bufs;
|
||||
void *vmem;
|
||||
@@ -99,11 +99,11 @@ static void* camera_buf_release_process(CsiPlinkContext * plink_ctx)
|
||||
LOG_W("invalid resp_id:%d\n",resp_id);
|
||||
continue;
|
||||
}
|
||||
if(plink_ctx->frame_buf[resp_id].img.dmabuf[0].fds!= 0)
|
||||
if(plink_ctx->frame_buf[resp_id].frame_data.fd[0]!= 0)
|
||||
{
|
||||
csi_camera_put_frame(&plink_ctx->frame_buf[resp_id]);
|
||||
LOG_D("release resp_id:%d, fd:%d\n",resp_id,plink_ctx->frame_buf[resp_id].img.dmabuf[0].fds);
|
||||
plink_ctx->frame_buf[resp_id].img.dmabuf[0].fds = 0;
|
||||
LOG_D("release resp_id:%d, fd:%d\n",resp_id,plink_ctx->frame_buf[resp_id].frame_data.fd[0]);
|
||||
plink_ctx->frame_buf[resp_id].frame_data.fd[0] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -125,6 +125,7 @@ static void* camera_buf_release_process(CsiPlinkContext * plink_ctx)
|
||||
LOG_O("Process is exit .....\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int allocate_sendbuffers(CsiPictureBuffer picbuffers[NUM_OF_BUFFERS], unsigned int size, void *vmem)
|
||||
{
|
||||
unsigned int buffer_size = (size + 0xFFF) & ~0xFFF;
|
||||
@@ -145,13 +146,15 @@ static int allocate_sendbuffers(CsiPictureBuffer picbuffers[NUM_OF_BUFFERS], uns
|
||||
picbuffers[i].size = buffer_size;
|
||||
picbuffers[i].fd = params.fd;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *vi_plink_create(csi_camera_channel_cfg_s *chn_cfg)
|
||||
{
|
||||
int ret = 0;
|
||||
CsiPlinkContext *plink_ctx = NULL;
|
||||
char *env=NULL;
|
||||
char *env = NULL;
|
||||
|
||||
if (chn_cfg == NULL) {
|
||||
LOG_E("%s failt to get chn_cfg\n", __func__);
|
||||
return NULL;
|
||||
@@ -264,32 +267,33 @@ void vi_plink_release(void * plink)
|
||||
VMEM_destroy(plink_ctx->vmem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void display_camera_frame(void *plink, csi_frame_s *frame)
|
||||
void display_camera_frame(void *plink, csi_frame_ex_s *frame)
|
||||
{
|
||||
|
||||
CsiPlinkContext * plink_ctx = (CsiPlinkContext *)plink;
|
||||
|
||||
if ((plink_ctx == NULL) || (frame == NULL)) {
|
||||
LOG_E("%s check param fail\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
LOG_O("fmt=%d img.strides[0] = %d\n",frame->img.pix_format, frame->img.strides[0]);
|
||||
LOG_I("fmt=%d,fd=%d,stride:%d\n",frame->frame_info.pixel_format,frame->frame_data.fd[0],frame->frame_data.stride[0]);
|
||||
|
||||
if (!plink_ctx->exitplink) {
|
||||
struct timeval tv_start, tv_end, tv_duration;
|
||||
gettimeofday(&tv_start, 0);
|
||||
PlinkPacket pkt = {0};
|
||||
// send one buffer if there is available slot
|
||||
if (frame->img.type == CSI_IMG_TYPE_DMA_BUF && !plink_ctx->exitplink
|
||||
&& plink_ctx->available_bufs > 0 && plink_ctx->plink != NULL && ((frame->img.pix_format == CSI_PIX_FMT_RAW_8BIT)|| (frame->img.pix_format == CSI_PIX_FMT_RAW_12BIT))) {
|
||||
if (!plink_ctx->exitplink&& plink_ctx->available_bufs > 0 &&
|
||||
plink_ctx->plink != NULL && ((frame->frame_info.pixel_format == CSI_PIX_FMT_RAW_8BIT)||
|
||||
(frame->frame_info.pixel_format == CSI_PIX_FMT_RAW_10BIT)||
|
||||
(frame->frame_info.pixel_format== CSI_PIX_FMT_RAW_12BIT)))
|
||||
{
|
||||
char str[200];
|
||||
static int i = 0;
|
||||
uint32_t dstw = frame->img.width;//800;
|
||||
uint32_t dsth = frame->img.height;//1280;
|
||||
uint32_t dsts = frame->img.strides[0];//896;
|
||||
uint32_t dstw = frame->frame_info.width;//800;
|
||||
uint32_t dsth = frame->frame_info.height;//1280;
|
||||
uint32_t dsts = frame->frame_data.stride[0];//896;
|
||||
|
||||
PlinkRawInfo info = {0};
|
||||
|
||||
@@ -303,33 +307,35 @@ void display_camera_frame(void *plink, csi_frame_s *frame)
|
||||
|
||||
info.img_width = dstw;
|
||||
info.img_height = dsth;
|
||||
info.stride = frame->img.strides[0];
|
||||
info.stride = frame->frame_data.stride[0];
|
||||
info.offset = 0;
|
||||
pkt.list[0] = &info;
|
||||
pkt.num = 1;
|
||||
pkt.fd = frame->img.dmabuf[0].fds;
|
||||
if(plink_ctx->frame_buf[plink_ctx->sendid].img.dmabuf[0].fds!=0)
|
||||
pkt.fd = frame->frame_data.fd[0];
|
||||
if(plink_ctx->frame_buf[plink_ctx->sendid].frame_data.fd[0]!=0)
|
||||
{
|
||||
LOG_W("previous sendid :%d,fd %d not release,release it now\n",plink_ctx->sendid,plink_ctx->frame_buf[plink_ctx->sendid].img.dmabuf[0].fds);
|
||||
LOG_W("previous sendid :%d,fd %d not release,release it now\n",plink_ctx->sendid,plink_ctx->frame_buf[plink_ctx->sendid].frame_data.fd[0]);
|
||||
csi_camera_put_frame(&plink_ctx->frame_buf[plink_ctx->sendid]);
|
||||
}
|
||||
memcpy(&plink_ctx->frame_buf[plink_ctx->sendid],frame,sizeof(csi_frame_s));
|
||||
memcpy(&plink_ctx->frame_buf[plink_ctx->sendid],frame,sizeof(csi_frame_ex_s));
|
||||
plink_ctx->sendid = (plink_ctx->sendid + 1) % NUM_OF_BUFFERS;
|
||||
if (PLINK_send(plink_ctx->plink, plink_ctx->chnid, &pkt) != PLINK_STATUS_OK)
|
||||
plink_ctx->exitplink = 1;
|
||||
gettimeofday(&tv_end, 0);
|
||||
timersub(&tv_end, &tv_start, &tv_duration);
|
||||
|
||||
|
||||
pthread_mutex_lock(&plink_ctx->mutex);
|
||||
plink_ctx->available_bufs -= 1;
|
||||
pthread_mutex_unlock(&plink_ctx->mutex);
|
||||
}
|
||||
else if (frame->img.type == CSI_IMG_TYPE_DMA_BUF && !plink_ctx->exitplink
|
||||
&& plink_ctx->available_bufs > 0 && plink_ctx->plink != NULL && ((frame->img.pix_format == CSI_PIX_FMT_YUV_SEMIPLANAR_420)|| (frame->img.pix_format == CSI_PIX_FMT_NV12))) {
|
||||
else if (!plink_ctx->exitplink && plink_ctx->available_bufs > 0 &&
|
||||
plink_ctx->plink != NULL && ((frame->frame_info.pixel_format == CSI_PIX_FMT_YUV_SEMIPLANAR_420)|| (frame->frame_info.pixel_format == CSI_PIX_FMT_NV12))) {
|
||||
char str[200];
|
||||
static int i = 0;
|
||||
uint32_t dstw = frame->img.width;//800;
|
||||
uint32_t dsth = frame->img.height;//1280;
|
||||
uint32_t dsts = frame->img.strides[0];//896;
|
||||
uint32_t dstw = frame->frame_info.width;//800;
|
||||
uint32_t dsth = frame->frame_info.height;//1280;
|
||||
uint32_t dsts = frame->frame_data.stride[0];//896;
|
||||
|
||||
|
||||
PlinkYuvInfo info = {0};
|
||||
@@ -349,46 +355,42 @@ void display_camera_frame(void *plink, csi_frame_s *frame)
|
||||
info.stride_u = dsts;
|
||||
info.stride_v = dsts;
|
||||
info.offset_y = 0;
|
||||
info.offset_u = frame->img.dmabuf[1].offset;
|
||||
info.offset_v = frame->img.dmabuf[2].offset;
|
||||
info.offset_u = frame->frame_data.offset[1];
|
||||
info.offset_v = frame->frame_data.offset[2];
|
||||
pkt.list[0] = &info;
|
||||
pkt.num = 1;
|
||||
pkt.fd = frame->img.dmabuf[0].fds;
|
||||
pkt.fd = frame->frame_data.fd[0];
|
||||
|
||||
if(plink_ctx->frame_buf[plink_ctx->sendid].img.dmabuf[0].fds!=0)
|
||||
if(plink_ctx->frame_buf[plink_ctx->sendid].frame_data.fd[0]!=0)
|
||||
{
|
||||
LOG_W("previous sendid :%d,fd %d not release,release it now\n",plink_ctx->sendid,plink_ctx->frame_buf[plink_ctx->sendid].img.dmabuf[0].fds);
|
||||
LOG_W("previous sendid :%d,fd %d not release,release it now\n",plink_ctx->sendid,plink_ctx->frame_buf[plink_ctx->sendid].frame_data.fd[0]);
|
||||
csi_camera_put_frame(&plink_ctx->frame_buf[plink_ctx->sendid]);
|
||||
}
|
||||
memcpy(&plink_ctx->frame_buf[plink_ctx->sendid],frame,sizeof(csi_frame_s));
|
||||
memcpy(&plink_ctx->frame_buf[plink_ctx->sendid],frame,sizeof(csi_frame_ex_s));
|
||||
plink_ctx->sendid = (plink_ctx->sendid + 1) % NUM_OF_BUFFERS;
|
||||
if (PLINK_send(plink_ctx->plink, plink_ctx->chnid, &pkt) != PLINK_STATUS_OK)
|
||||
plink_ctx->exitplink = 1;
|
||||
gettimeofday(&tv_end, 0);
|
||||
timersub(&tv_end, &tv_start, &tv_duration);
|
||||
|
||||
pthread_mutex_lock(&plink_ctx->mutex);
|
||||
plink_ctx->available_bufs -= 1;
|
||||
pthread_mutex_unlock(&plink_ctx->mutex);
|
||||
} else if (!plink_ctx->exitplink && plink_ctx->available_bufs > 0 && plink_ctx->plink != NULL && (frame->img.pix_format == CSI_PIX_FMT_BGR)) {
|
||||
|
||||
} else if (!plink_ctx->exitplink && plink_ctx->available_bufs > 0 && plink_ctx->plink != NULL && (frame->frame_info.pixel_format == CSI_PIX_FMT_BGR)) {
|
||||
CsiPictureBuffer *buf = &plink_ctx->sendbuffer[plink_ctx->sendid];
|
||||
int y = 0;
|
||||
// if (1) {
|
||||
// void *pbuf[3];
|
||||
// void *phyaddr = vi_mem_import(frame->img.dmabuf[0].fds);
|
||||
// pbuf[0] = vi_mem_map(phyaddr) + frame->img.dmabuf[0].offset;
|
||||
// pbuf[1] = pbuf[0] + frame->img.dmabuf[1].offset;
|
||||
// vi_mem_release(phyaddr);
|
||||
// frame->img.usr_addr[0] = pbuf[0];
|
||||
// }
|
||||
uint8_t *src = frame->img.usr_addr[0];
|
||||
int buf_size = frame->frame_info.width*frame->frame_info.height*3;
|
||||
|
||||
uint8_t *src = frame->frame_data.vir_addr[0] ;
|
||||
uint8_t *dst = buf->virtual_address;
|
||||
uint32_t srcw = frame->img.width;
|
||||
uint32_t srch = frame->img.height;
|
||||
uint32_t dstw = frame->img.width;
|
||||
uint32_t dsth = frame->img.height;
|
||||
uint32_t dsts = frame->img.width;
|
||||
switch (frame->img.pix_format ) {
|
||||
case CSI_PIX_FMT_BGR:
|
||||
uint32_t srcw = frame->frame_info.width;
|
||||
uint32_t srch = frame->frame_info.height;
|
||||
uint32_t dstw = frame->frame_info.width;
|
||||
uint32_t dsth = frame->frame_info.height;
|
||||
uint32_t dsts = frame->frame_info.width;
|
||||
switch (frame->frame_info.pixel_format) {
|
||||
case CSI_PIX_FMT_BGR:
|
||||
{
|
||||
dstw = 300;
|
||||
dsth = 304;
|
||||
@@ -404,7 +406,7 @@ void display_camera_frame(void *plink, csi_frame_s *frame)
|
||||
src += srcw;
|
||||
dst += dsts;
|
||||
}
|
||||
src = frame->img.usr_addr[0] + srcw*srch;
|
||||
src = frame->frame_data.vir_addr[0] + srcw*srch;
|
||||
dst = buf->virtual_address + dsts*dsth;
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
@@ -412,7 +414,7 @@ void display_camera_frame(void *plink, csi_frame_s *frame)
|
||||
src += srcw;
|
||||
dst += dsts;
|
||||
}
|
||||
src = frame->img.usr_addr[0] + srcw*srch*2;
|
||||
src = frame->frame_data.vir_addr[0] + srcw*srch*2;
|
||||
dst = buf->virtual_address + dsts*dsth*2;
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
@@ -457,7 +459,7 @@ void display_camera_frame(void *plink, csi_frame_s *frame)
|
||||
src += srcw;
|
||||
dst += dsts;
|
||||
}
|
||||
src = frame->img.usr_addr[0] + frame->img.strides[0] * frame->img.height;
|
||||
src = frame->frame_data.vir_addr[0] + frame->frame_data.stride[0] * frame->frame_info.height;
|
||||
dst = buf->virtual_address + (dsts * dsth);
|
||||
for (y = 0; y < h/2; y++)
|
||||
{
|
||||
@@ -490,7 +492,7 @@ void display_camera_frame(void *plink, csi_frame_s *frame)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
csi_camera_put_frame(frame);
|
||||
gettimeofday(&tv_end, 0);
|
||||
timersub(&tv_end, &tv_start, &tv_duration);
|
||||
pthread_mutex_lock(&plink_ctx->mutex);
|
||||
@@ -498,6 +500,17 @@ void display_camera_frame(void *plink, csi_frame_s *frame)
|
||||
plink_ctx->available_bufs -= 1;
|
||||
pthread_mutex_unlock(&plink_ctx->mutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_W("frame not send by plink,available_bufs:%d,fmt:%d\n",plink_ctx->available_bufs,
|
||||
frame->frame_info.pixel_format);
|
||||
csi_camera_put_frame(frame);
|
||||
}
|
||||
}
|
||||
LOG_O("%s exit \n", __func__);
|
||||
else
|
||||
{
|
||||
LOG_E("plink is exit\n");
|
||||
csi_camera_put_frame(frame);
|
||||
}
|
||||
LOG_I("%s exit \n");
|
||||
}
|
||||
|
||||
1225
examples/camera/camera_test1.c
Executable file → Normal file
1225
examples/camera/camera_test1.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
@@ -132,7 +132,7 @@ int consumer_process(int socket_fd)
|
||||
csi_dump_img_info(&camera_frame.img);
|
||||
|
||||
csi_camera_meta_s *camera_meta_data = (csi_camera_meta_s *)camera_frame.meta.data;
|
||||
camera_meta_data->units = (csi_camrea_meta_unit_s *)((char *)camera_meta_data + sizeof(csi_camera_meta_s));
|
||||
camera_meta_data->units = (csi_camera_meta_unit_s *)((char *)camera_meta_data + sizeof(csi_camera_meta_s));
|
||||
fdc_dump_camera_meta(camera_meta_data);
|
||||
|
||||
LOG_D("csi frame meta = {type=%d, size=%zd, data=%p}\n",
|
||||
|
||||
@@ -164,7 +164,7 @@ int fdc_create_csi_frame(csi_frame_s *camera_frame,
|
||||
void fdc_dump_camera_meta(csi_camera_meta_s *camera_meta)
|
||||
{
|
||||
int ret;
|
||||
csi_camrea_meta_unit_s meta_unit;
|
||||
csi_camera_meta_unit_s meta_unit;
|
||||
ret = csi_camera_frame_get_meta_unit(&meta_unit, camera_meta, CSI_CAMERA_META_ID_TIMESTAMP);
|
||||
if (ret == 0) {
|
||||
struct timeval tv = meta_unit.time_value;
|
||||
|
||||
@@ -41,7 +41,7 @@ extern "C" {
|
||||
*/
|
||||
|
||||
#define CSI_CAMERA_VERSION_MAJOR 0
|
||||
#define CSI_CAMERA_VERSION_MINOR 2
|
||||
#define CSI_CAMERA_VERSION_MINOR 3
|
||||
|
||||
#define CSI_CAMERA_NAME_MAX_LEN 32
|
||||
typedef void *csi_cam_handle_t;
|
||||
@@ -110,6 +110,7 @@ typedef enum csi_camera_property_type {
|
||||
CSI_CAMERA_PROPERTY_TYPE_ENUM = 3,
|
||||
CSI_CAMERA_PROPERTY_TYPE_STRING = 7,
|
||||
CSI_CAMERA_PROPERTY_TYPE_BITMASK = 8,
|
||||
CSI_CAMERA_PROPERTY_TYPE_FLOAT = 9,
|
||||
} csi_camera_property_type_e;
|
||||
|
||||
typedef union csi_camera_property_data {
|
||||
@@ -118,6 +119,7 @@ typedef union csi_camera_property_data {
|
||||
int enum_value;
|
||||
uint32_t bitmask_value;
|
||||
char str_value[32];
|
||||
float float_value;
|
||||
} csi_camera_property_data_u;
|
||||
|
||||
typedef struct csi_camera_property_description {
|
||||
@@ -177,6 +179,7 @@ typedef struct csi_camera_channel_cfg {
|
||||
csi_img_type_e img_type;
|
||||
unsigned int meta_fields; /* bitmask of: csi_camera_meta_id_e */
|
||||
csi_camera_channel_status_e status;
|
||||
csi_frame_alloctor_s alloctor; /***external frame buffer allocater***/
|
||||
} csi_camera_channel_cfg_s;
|
||||
|
||||
typedef enum csi_camera_event_type {
|
||||
@@ -227,7 +230,7 @@ typedef struct csi_camera_event {
|
||||
typedef enum csi_camera_error{
|
||||
CSI_CAMERA_RET_ERR_INVALID_DEV = -1001,/* device is not valid */
|
||||
CSI_CAMERA_RET_ERR_INVALID_PARA, /* input params is not valid */
|
||||
CSI_CAMERA_RET_ERR_NULL_PTR,
|
||||
CSI_CAMERA_RET_ERR_NULL_PTR,
|
||||
CSI_CAMERA_RET_ERR_DEV_BUSY, /* device is budy */
|
||||
CSI_CAMERA_RET_ERR_NOMEM, /* malloc fail */
|
||||
CSI_CAMERA_RET_ERR_TIMEOUT, /* evet or frame wait timeout */
|
||||
@@ -274,9 +277,9 @@ int csi_camera_get_frame_count(csi_cam_handle_t cam_handle,
|
||||
csi_camera_channel_id_e chn_id);
|
||||
int csi_camera_get_frame(csi_cam_handle_t cam_handle,
|
||||
csi_camera_channel_id_e chn_id,
|
||||
csi_frame_s *frame, int timeout);
|
||||
csi_frame_ex_s *frame, int timeout);
|
||||
|
||||
int csi_camera_put_frame(csi_frame_s *frame);
|
||||
int csi_camera_put_frame(csi_frame_ex_s *frame);
|
||||
|
||||
|
||||
int csi_camera_dequeue_frame(csi_cam_handle_t cam_handle,
|
||||
|
||||
@@ -46,18 +46,18 @@ typedef struct csi_camrea_meta_unit {
|
||||
char str_value[32];
|
||||
struct timeval time_value;
|
||||
};
|
||||
} csi_camrea_meta_unit_s;
|
||||
} csi_camera_meta_unit_s;
|
||||
|
||||
typedef struct csi_camera_meta {
|
||||
unsigned int count;
|
||||
size_t size;
|
||||
csi_camrea_meta_unit_s *units; // Is meta_unit array head
|
||||
csi_camera_meta_unit_s *units; // Is meta_unit array head
|
||||
} csi_camera_meta_s;
|
||||
|
||||
int csi_camera_frame_alloc_meta(csi_camera_meta_s **meta, int meta_count, size_t *meta_data_size);
|
||||
int csi_camera_frame_free_meta(csi_camera_meta_s *meta);
|
||||
|
||||
int csi_camera_frame_get_meta_unit(csi_camrea_meta_unit_s *meta_unit,
|
||||
int csi_camera_frame_get_meta_unit(csi_camera_meta_unit_s *meta_unit,
|
||||
csi_camera_meta_s *meta_data,
|
||||
csi_camera_meta_id_e meta_field);
|
||||
|
||||
|
||||
@@ -92,6 +92,8 @@ enum CSI_CAMERA_AUTO_PRESET_WHITE_BALANCE_MODE {
|
||||
#define CSI_CAMERA_PID_BAND_STOP_FILTER (CSI_CAMERA_PID_BASE + 0x62)
|
||||
#define CSI_CAMERA_PID_IMAGE_STABILIZATION (CSI_CAMERA_PID_BASE + 0x63)
|
||||
|
||||
#define CSI_CAMERA_PID_GAIN (CSI_CAMERA_PID_BASE + 0x64)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "csi_meta.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -62,14 +62,6 @@ typedef enum csi_color_gamut {
|
||||
CSI_COLOR_GAMUT_BT2020,
|
||||
} csi_color_gamut_e;
|
||||
|
||||
typedef enum csi_meta_type {
|
||||
CSI_META_TYPE_SYSTEM,
|
||||
CSI_META_TYPE_CAMERA,
|
||||
CSI_META_TYPE_VDEC,
|
||||
CSI_META_TYPE_GPU,
|
||||
CSI_META_TYPE_G2D,
|
||||
} csi_meta_type_e;
|
||||
|
||||
typedef enum csi_img_type {
|
||||
CSI_IMG_TYPE_DMA_BUF, // memory allocated via dma-buf
|
||||
CSI_IMG_TYPE_SYSTEM_CONTIG, // memory allocated via kmalloc
|
||||
@@ -78,15 +70,6 @@ typedef enum csi_img_type {
|
||||
CSI_IMG_TYPE_SHM, // memory allocated from share memory(<sys/shm.h>)
|
||||
} csi_img_type_e;
|
||||
|
||||
typedef enum csi_meta_value_type {
|
||||
CSI_META_VALUE_TYPE_BOOL,
|
||||
CSI_META_VALUE_TYPE_INT,
|
||||
CSI_META_VALUE_TYPE_UINT,
|
||||
CSI_META_VALUE_TYPE_STR,
|
||||
CSI_META_VALUE_TYPE_TIMEVAL,
|
||||
} csi_meta_value_type_e;
|
||||
|
||||
|
||||
/*
|
||||
* CSI frame config design
|
||||
*
|
||||
@@ -138,13 +121,6 @@ typedef struct csi_img {
|
||||
uint64_t modifier;
|
||||
void *priv;
|
||||
} csi_img_s;
|
||||
|
||||
typedef struct csi_meta {
|
||||
csi_meta_type_e type;
|
||||
size_t size;
|
||||
void *data;
|
||||
} csi_meta_s;
|
||||
|
||||
typedef struct csi_frame {
|
||||
csi_img_s img;
|
||||
csi_meta_s meta;
|
||||
|
||||
@@ -5,67 +5,12 @@
|
||||
#define _CSI_FRAME_EX_H
|
||||
|
||||
#include "csi_common.h"
|
||||
#include "csi_meta.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#define MAX_PLANE_COUNT 3
|
||||
|
||||
typedef enum {
|
||||
CSI_PIXEL_FORMAT_RGB_444 = 0,
|
||||
CSI_PIXEL_FORMAT_RGB_555,
|
||||
CSI_PIXEL_FORMAT_RGB_565,
|
||||
CSI_PIXEL_FORMAT_RGB_888,
|
||||
|
||||
CSI_PIXEL_FORMAT_BGR_444,
|
||||
CSI_PIXEL_FORMAT_BGR_555,
|
||||
CSI_PIXEL_FORMAT_BGR_565,
|
||||
CSI_PIXEL_FORMAT_BGR_888,
|
||||
|
||||
CSI_PIXEL_FORMAT_ARGB_1555,
|
||||
CSI_PIXEL_FORMAT_ARGB_4444,
|
||||
CSI_PIXEL_FORMAT_ARGB_8565,
|
||||
CSI_PIXEL_FORMAT_ARGB_8888,
|
||||
CSI_PIXEL_FORMAT_ARGB_2BPP,
|
||||
|
||||
CSI_PIXEL_FORMAT_ABGR_1555,
|
||||
CSI_PIXEL_FORMAT_ABGR_4444,
|
||||
CSI_PIXEL_FORMAT_ABGR_8565,
|
||||
CSI_PIXEL_FORMAT_ABGR_8888,
|
||||
|
||||
CSI_PIXEL_FORMAT_RGB_BAYER_8BPP,
|
||||
CSI_PIXEL_FORMAT_RGB_BAYER_10BPP,
|
||||
CSI_PIXEL_FORMAT_RGB_BAYER_12BPP,
|
||||
CSI_PIXEL_FORMAT_RGB_BAYER_14BPP,
|
||||
CSI_PIXEL_FORMAT_RGB_BAYER_16BPP,
|
||||
|
||||
CSI_PIXEL_FORMAT_YVU_PLANAR_422,
|
||||
CSI_PIXEL_FORMAT_YVU_PLANAR_420,
|
||||
CSI_PIXEL_FORMAT_YVU_PLANAR_444,
|
||||
|
||||
CSI_PIXEL_FORMAT_YVU_SEMIPLANAR_422,
|
||||
CSI_PIXEL_FORMAT_YVU_SEMIPLANAR_420,
|
||||
CSI_PIXEL_FORMAT_YVU_SEMIPLANAR_444,
|
||||
|
||||
CSI_PIXEL_FORMAT_YUV_SEMIPLANAR_422,
|
||||
CSI_PIXEL_FORMAT_YUV_SEMIPLANAR_420,
|
||||
CSI_PIXEL_FORMAT_YUV_SEMIPLANAR_444,
|
||||
|
||||
CSI_PIXEL_FORMAT_YUYV_PACKAGE_422,
|
||||
CSI_PIXEL_FORMAT_YVYU_PACKAGE_422,
|
||||
CSI_PIXEL_FORMAT_UYVY_PACKAGE_422,
|
||||
CSI_PIXEL_FORMAT_VYUY_PACKAGE_422,
|
||||
CSI_PIXEL_FORMAT_YYUV_PACKAGE_422,
|
||||
CSI_PIXEL_FORMAT_YYVU_PACKAGE_422,
|
||||
CSI_PIXEL_FORMAT_UVYY_PACKAGE_422,
|
||||
CSI_PIXEL_FORMAT_VUYY_PACKAGE_422,
|
||||
CSI_PIXEL_FORMAT_VY1UY0_PACKAGE_422,
|
||||
|
||||
CSI_PIXEL_FORMAT_YUV_400,
|
||||
CSI_PIXEL_FORMAT_UV_420,
|
||||
|
||||
CSI_PIXEL_FORMAT_MAX
|
||||
} csi_pixel_format_e;
|
||||
|
||||
#if 0
|
||||
typedef enum {
|
||||
CSI_PICTURE_TYPE_NONE = 0, /* undefined */
|
||||
@@ -129,13 +74,12 @@ typedef enum {
|
||||
CSI_VIDEO_FORMAT_MAC
|
||||
} csi_video_format_e;
|
||||
|
||||
|
||||
typedef struct csi_frame_info {
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
/* the region of interest of the frame */
|
||||
//csi_rect_s roi;
|
||||
csi_pixel_format_e pixel_format;
|
||||
int32_t pixel_format; //define in csi_pixel_fmt_e
|
||||
//csi_frame_compress_mode compress_mode;
|
||||
csi_color_space_e color_space;
|
||||
csi_chroma_location_e chroma_location;
|
||||
@@ -159,13 +103,18 @@ typedef struct csi_frame_data {
|
||||
};
|
||||
} csi_frame_data_s;
|
||||
|
||||
|
||||
typedef struct csi_frame_ex {
|
||||
csi_frame_info_s frame_info;
|
||||
csi_frame_data_s frame_data;
|
||||
void *opaque; /* not for user, DO NOT use or modify it */
|
||||
csi_meta_s frame_meta;
|
||||
void *opaque; /* for user private data, csi NOT use or modify it */
|
||||
void *csi_priv;/**for csi private data,user NOT use or modify it***************/
|
||||
} csi_frame_ex_s;
|
||||
|
||||
typedef struct csi_frame_alloctor{
|
||||
int (*alloc)(csi_frame_ex_s * frame); /* base on the frame info,alloc fill the fd */
|
||||
int (*free)(csi_frame_ex_s * frame);
|
||||
}csi_frame_alloctor_s;
|
||||
#if 0
|
||||
typedef struct csi_bitstream {
|
||||
void *buf;
|
||||
|
||||
46
include/hal/csi_meta.h
Normal file
46
include/hal/csi_meta.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Alibaba Group Holding Limited
|
||||
* Author: LuChongzhi <chongzhi.lcz@alibaba-inc.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef __CSI_META_H__
|
||||
#define __CSI_META_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
typedef enum csi_meta_type {
|
||||
CSI_META_TYPE_SYSTEM,
|
||||
CSI_META_TYPE_CAMERA,
|
||||
CSI_META_TYPE_VDEC,
|
||||
CSI_META_TYPE_GPU,
|
||||
CSI_META_TYPE_G2D,
|
||||
} csi_meta_type_e;
|
||||
typedef enum csi_meta_value_type {
|
||||
CSI_META_VALUE_TYPE_BOOL,
|
||||
CSI_META_VALUE_TYPE_INT,
|
||||
CSI_META_VALUE_TYPE_UINT,
|
||||
CSI_META_VALUE_TYPE_STR,
|
||||
CSI_META_VALUE_TYPE_TIMEVAL,
|
||||
} csi_meta_value_type_e;
|
||||
|
||||
typedef struct csi_meta {
|
||||
csi_meta_type_e type;
|
||||
size_t size;
|
||||
void *data;
|
||||
} csi_meta_s;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CSI_META_H__ */
|
||||
@@ -11,8 +11,8 @@
|
||||
#define __PLATFORM_ACTION_H__
|
||||
|
||||
#include <csi_camera.h>
|
||||
int camera_action_image_save(csi_frame_s *frame);
|
||||
int camera_action_image_display(csi_frame_s *frame);
|
||||
int camera_action_image_save(csi_frame_ex_s *frame);
|
||||
int camera_action_image_display(csi_frame_ex_s *frame);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int camera_action_image_save(csi_frame_s *frame)
|
||||
int camera_action_image_save(csi_frame_ex_s *frame)
|
||||
{
|
||||
//wait to complete
|
||||
return 0;
|
||||
}
|
||||
|
||||
int camera_action_image_display(csi_frame_s *frame)
|
||||
int camera_action_image_display(csi_frame_ex_s *frame)
|
||||
{
|
||||
//wait to complete
|
||||
return 0;
|
||||
|
||||
@@ -24,7 +24,7 @@ int csi_camera_frame_free_meta(csi_camera_meta_s *meta)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int csi_camera_frame_get_meta_unit(csi_camrea_meta_unit_s *meta_unit,
|
||||
int csi_camera_frame_get_meta_unit(csi_camera_meta_unit_s *meta_unit,
|
||||
csi_camera_meta_s *meta_data,
|
||||
csi_camera_meta_id_e meta_field)
|
||||
{
|
||||
|
||||
@@ -23,8 +23,8 @@ int csi_camera_frame_alloc_meta(csi_camera_meta_s **meta, int meta_count, size_t
|
||||
return -1;
|
||||
}
|
||||
|
||||
malloc_size = sizeof(csi_camera_meta_s) + sizeof(csi_camrea_meta_unit_s) * meta_count;
|
||||
LOG_D("malloc_size=(%zd+%zd)=%zd\n", sizeof(csi_camera_meta_s), sizeof(csi_camrea_meta_unit_s) * meta_count, malloc_size);
|
||||
malloc_size = sizeof(csi_camera_meta_s) + sizeof(csi_camera_meta_unit_s) * meta_count;
|
||||
LOG_D("malloc_size=(%zd+%zd)=%zd\n", sizeof(csi_camera_meta_s), sizeof(csi_camera_meta_unit_s) * meta_count, malloc_size);
|
||||
|
||||
*meta = malloc(malloc_size);
|
||||
if (*meta == NULL) {
|
||||
@@ -34,8 +34,8 @@ int csi_camera_frame_alloc_meta(csi_camera_meta_s **meta, int meta_count, size_t
|
||||
|
||||
memset(*meta, 0, malloc_size);
|
||||
(*meta)->count = meta_count;
|
||||
(*meta)->size = sizeof(csi_camrea_meta_unit_s) * meta_count;
|
||||
(*meta)->units = (csi_camrea_meta_unit_s *)((char*)(*meta) + sizeof(csi_camera_meta_s));
|
||||
(*meta)->size = sizeof(csi_camera_meta_unit_s) * meta_count;
|
||||
(*meta)->units = (csi_camera_meta_unit_s *)((char*)(*meta) + sizeof(csi_camera_meta_s));
|
||||
|
||||
LOG_D("*meta=%p, (*meta)->units=%p\n", *meta, (*meta)->units);
|
||||
|
||||
@@ -55,7 +55,7 @@ int csi_camera_frame_free_meta(csi_camera_meta_s *meta)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int csi_camera_frame_get_meta_unit(csi_camrea_meta_unit_s *meta_unit,
|
||||
int csi_camera_frame_get_meta_unit(csi_camera_meta_unit_s *meta_unit,
|
||||
csi_camera_meta_s *meta_data,
|
||||
csi_camera_meta_id_e meta_field)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user