Esempio n. 1
0
void *thread_pop(void * camera){
	 camera_t *cam=(camera_t *)camera;
	 sc_frame_t *f;
	 int count=0;
	 zbfp=fopen("zbzb.yuv","wb");


	 slogi("pop ");
	 while(!cam->stopflag){
	 	if(count==0){
	 		sc_lock(&cam->q->mutex);
			slogi("wait for signal");
			pthread_cond_wait(&cam->q->cond,&cam->q->mutex);/*等待*/
			slogi("wake up");
			sc_unlock(&cam->q->mutex);
	 	}
	 	count++;
	 	int ret=queue_popfront(cam->q,&f);
		 if(ret==0 && f!=NULL){
		 	// slogi("pop ok delete it");
			  if(zbfp)
			  {
			  	 yuv_write(f->data, f->len, zbfp);
                // sc_write_onebyone(f->data, f->len, count);

			  }else{
				slogi("#####zbzb.yuv open fail#####");
			  }
			 delete_frame(f);}
		 if(ret==QEMPTY_POPFAIL || ret==QGNEL_FAIL ){//宁愿popfail,也不能让push数据放不进去而丢帧
				usleep(300);
		 }
	 }

}
Esempio n. 2
0
// OK
void test_yuv_write(){

    int h = 288, w = 352, f = 30 ;
    int*** Y = new3d<int>(f,h,w,0);
    int*** U = new3d<int>(f,h/2,w/2.0);
    int*** V = new3d<int>(f,h/2,w/2,0);

    yuv_read("stefan_cif.yuv",h,w,f,Y,NULL,NULL);
    yuv_write("test",Y,NULL,NULL,f,h,w);

    deleteY(Y);
    deleteY(U);
    deleteY(V);
}