9 #include <VP_Api/vp_api.h>
10 #include <VP_Api/vp_api_thread_helper.h>
11 #include <VP_Api/vp_api_error.h>
12 #include <VP_Api/vp_api_picture.h>
13 #include <VP_Stages/vp_stages_configs.h>
14 #include <VP_Stages/vp_stages_io_console.h>
15 #include <VP_Stages/vp_stages_o_sdl.h>
16 #include <VP_Stages/vp_stages_io_com.h>
17 #include <VP_Stages/vp_stages_io_file.h>
18 #include <VP_Os/vp_os_print.h>
19 #include <VP_Os/vp_os_malloc.h>
20 #include <VP_Os/vp_os_delay.h>
23 vp_stages_output_sdl_config_t osc;
25 #define ACQ_WIDTH (osc.width)
26 #define ACQ_HEIGHT (osc.height)
31 PIPELINE_HANDLE pipeline_handle;
34 // used by buffer_to_picture
35 static vp_api_picture_t picture;
38 PROTO_THREAD_ROUTINE(escaper,nomParams);
39 PROTO_THREAD_ROUTINE(app,nomParams);
43 THREAD_TABLE_ENTRY(escaper,20)
44 THREAD_TABLE_ENTRY(app,20)
49 buffer_to_picture_open(int *cfg)
51 picture.format = PIX_FMT_YUV420P;
53 picture.width = ACQ_WIDTH;
54 picture.height = ACQ_HEIGHT;
55 picture.framerate = 15;
57 picture.y_line_size = ACQ_WIDTH;
58 picture.cb_line_size = 0; //ACQ_WIDTH/2;
59 picture.cr_line_size = 0; //ACQ_WIDTH/2;
65 buffer_to_picture_transform(int *cfg, vp_api_io_data_t *in, vp_api_io_data_t *out)
67 vp_os_mutex_lock(&out->lock);
70 if(out->status == VP_API_STATUS_INIT)
73 out->size = ACQ_WIDTH*ACQ_HEIGHT; //(ACQ_WIDTH*ACQ_HEIGHT*3)/2;
74 out->buffers = (int8_t **)(int8_t *)&picture;
76 out->status = VP_API_STATUS_PROCESSING;
79 if(out->status == VP_API_STATUS_ENDED)
83 if(out->status == VP_API_STATUS_PROCESSING)
85 picture.y_buf = in->buffers[in->indexBuffer];
86 picture.cb_buf = in->buffers[in->indexBuffer]+ACQ_WIDTH*ACQ_HEIGHT;
87 picture.cr_buf = in->buffers[in->indexBuffer]+(ACQ_WIDTH*ACQ_HEIGHT*5)/4;
90 out->status = in->status;
92 vp_os_mutex_unlock(&out->lock);
98 buffer_to_picture_close(int *cfg)
104 const vp_api_stage_funcs_t buffer_to_picture_funcs =
106 (vp_api_stage_handle_msg_t) NULL,
107 (vp_api_stage_open_t)buffer_to_picture_open,
108 (vp_api_stage_transform_t)buffer_to_picture_transform,
109 (vp_api_stage_close_t)buffer_to_picture_close
114 main(int argc, char **argv)
116 START_THREAD(escaper, NO_PARAM);
117 START_THREAD(app, argv);
119 JOIN_THREAD(escaper);
126 PROTO_THREAD_ROUTINE(app,argv)
128 vp_api_io_pipeline_t pipeline;
129 vp_api_io_data_t out;
130 vp_api_io_stage_t stages[NB_STAGES];
133 vp_stages_input_com_config_t icc;
134 vp_com_serial_config_t config;
137 vp_os_memset(&icc,0,sizeof(vp_stages_input_com_config_t));
138 vp_os_memset(&com, 0, sizeof(vp_com_t));
139 vp_stages_fill_default_config(UART1_COM_CONFIG, &config, sizeof(config));
140 vp_stages_fill_default_config(SDL_RAW_QCIF_CONFIG, &osc, sizeof(osc));
142 com.type = VP_COM_SERIAL;
144 icc.socket.type = VP_COM_CLIENT;
145 icc.config = (vp_com_config_t *)&config;
146 icc.buffer_size = 176*144; //ACQ_WIDTH*ACQ_HEIGHT;
149 stages[0].type = VP_API_INPUT_SOCKET;
150 stages[0].cfg = (void *)&icc;
151 stages[0].funcs = vp_stages_input_com_funcs;
153 stages[1].type = VP_API_FILTER_DECODER;
154 stages[1].cfg = (void *)NULL;
155 stages[1].funcs = buffer_to_picture_funcs;
157 stages[2].type = VP_API_OUTPUT_SDL;
158 stages[2].cfg = (void *)&osc;
159 stages[2].funcs = vp_stages_output_sdl_funcs;
161 pipeline.nb_stages = NB_STAGES;
162 pipeline.stages = &stages[0];
165 vp_api_open(&pipeline, &pipeline_handle);
166 out.status = VP_API_STATUS_PROCESSING;
167 while(SUCCEED(vp_api_run(&pipeline, &out)) && (out.status == VP_API_STATUS_PROCESSING || out.status == VP_API_STATUS_STILL_RUNNING))
172 vp_api_close(&pipeline, &pipeline_handle);