示例#1
0
int main(int argc, char** argv)
{
	init_ogl(p_state);

	create_perspective_matrix(&p_state->p_matrix, 45, 1.0, 0.1, 100);

	identity(&p_state->mv_matrix);
	identity(&p_state->send_mv_matrix);

	rotate_matrix(&p_state->send_mv_matrix, 180, 1.0, 0, 0);
	translate_matrix(&p_state->send_mv_matrix, 0, 0, -5);
	//rotate_matrix(&p_state->mv_matrix, 45, 1.0, 0, 0);
	translate_matrix(&p_state->mv_matrix, 0, 0, -5);

	init_shaders(p_state);

	init_framebuffer(p_state);

	init_textures(p_state);

	encode_loop(p_state);

        while(1)
        {
        }

//	return NULL;
}
示例#2
0
static gboolean 
gst_sh_video_sink_start (GstBaseSink *bsink)
{
	GstSHVideoSink *sink = GST_SH_VIDEO_SINK (bsink);
	
	GST_DEBUG_OBJECT(sink,"START, opening devices.");

	if(!init_framebuffer(&sink->fb))
	{
		GST_ELEMENT_ERROR((GstElement*)sink,
			CORE,FAILED,("Failed to init framebuffer."), 
			("%s failed (Failed to init framebuffer)",
			__FUNCTION__));            
	}
	GST_DEBUG_OBJECT(sink,"Framebuffer: %dx%d %dbpp.",sink->fb.vinfo.xres,
		sink->fb.vinfo.yres,sink->fb.vinfo.bits_per_pixel);

	if(!init_veu(&sink->veu))
	{
		GST_ELEMENT_ERROR((GstElement*)sink,
			CORE,FAILED,("Failed to init VEU."), 
			("%s failed (Failed to init VEU)",__FUNCTION__));
	}
	GST_DEBUG_OBJECT(sink,"VEU, name: %s path: %s",
			sink->veu.dev.name, sink->veu.dev.path);

	return TRUE;
}
示例#3
0
/**
 * Setup frame buffer, background color, foreground color.
 */
void init_video(void) {
  FrameBufferInfo *p_framebuffer;
  p_framebuffer = init_framebuffer(1024, 768, 16);
  set_graphics_address(p_framebuffer);
  set_fore_colour(COLOR_WHITE);
  set_back_colour(COLOR_BLACK);
}
示例#4
0
文件: main.c 项目: arnew/matelight
int main(void) {
	platform_init();

	debug_init();
	DEBUG_PRINT("Booting...\n\n");

	com_init();
	
	spi_init();

	init_framebuffer(framebuffer1);
	init_framebuffer(framebuffer2);

	DEBUG_PRINT("Booted.\n");

	while(1);
}
示例#5
0
int main() {
    if (!init_framebuffer()) {
        // TODO: add cleanup

        while (1) ;
    }

    while (1) ;
}
示例#6
0
static void mainproc(void *arg)
{
    Dynamic    *dynamicp;
    Gfx        *glistp;
    Control    cont;

    init_dma();
    init_task();
    init_framebuffer();

    read_rom( _staticSegmentStart,
              _staticSegmentRomStart, _staticSegmentRomEnd  );
    read_rom( _dkSegmentStart, _dkSegmentRomStart, _dkSegmentRomEnd  );
    read_rom( _dk7SegmentStart, _dk7SegmentRomStart, _dk7SegmentRomEnd  );
    read_rom( _roadSegmentStart, _roadSegmentRomStart,
              _roadSegmentRomEnd  );
    read_rom( _l2_tvSegmentStart, _l2_tvSegmentRomStart,
              _l2_tvSegmentRomEnd  );

    init_controlers( &cont );

    game_init();

    while (1)
    {
        read_controler( &cont );

        dynamicp = &dynamic;

        guOrtho( &dynamicp->projection,
                 -(float) SCREEN_WD / 2.0F, (float) SCREEN_WD / 2.0F,
                 -(float) SCREEN_HT / 2.0F, (float) SCREEN_HT / 2.0F,
                 1.0F, 10.0F, 1.0F );
        guRotate( &dynamicp->modeling, 0.0F, 0.0F, 0.0F, 1.0F );

        glistp = dynamicp->glist;

        /* rcp rdp & color frame buffer initialize */
        glistp = init_rcprdp( glistp, (char *)_staticSegmentStart, draw_buffer );
        glistp = clear_cfb( glistp );

        /* game main */
        glistp = game_main( glistp, &cont );

        gDPFullSync(glistp++);
        gSPEndDisplayList(glistp++);

        assert((glistp - dynamicp->glist) < GLIST_LEN);

        start_task( glistp, dynamicp );

        swap_framebuffer( draw_buffer );
        draw_buffer ^= 1;
    }
}
示例#7
0
 void swap_buffers(std::shared_ptr<TGAImage> &pImage)
 {
     std::swap(pImage, m_pImage);
     if (!m_pImage)
     {
         init_framebuffer();
     }
     else
     {
         ++m_framesCount;
         int averageFrameTime = (SDL_GetTicks() - m_startTicks) / m_framesCount;
         char title[1024];
         sprintf(title, "Rendered %d frames, average time %d ms", m_framesCount, averageFrameTime);
         SDL_SetWindowTitle(m_pWindow, title);
         SDL_UpdateWindowSurface(m_pWindow);
     }
 }
示例#8
0
文件: main.c 项目: drhastings/balance
void *render_task(void *dummy)
{
  init_ogl(p_state);

  create_perspective_matrix(&p_state->p_matrix, 45, 1.0, 0.1, 100);

  identity(&p_state->mv_matrix);
  identity(&p_state->send_mv_matrix);

  rotate_matrix(&p_state->send_mv_matrix, 180, 1.0, 0, 0);
  translate_matrix(&p_state->send_mv_matrix, 0, 0, -5);
  //rotate_matrix(&p_state->mv_matrix, 45, 1.0, 0, 0);
  translate_matrix(&p_state->mv_matrix, 0, -10, -15);

  init_shaders(p_state);

  init_framebuffer(p_state);

  init_textures(p_state);

  encode_loop(p_state, &robot);

  return NULL;
}
示例#9
0
文件: luvcview.c 项目: wushifeng/arm
int main(int argc, char *argv[])
{
#ifndef EMBEDED_X210  //PC platform
    const SDL_VideoInfo *info;
    char driver[128];
    SDL_Surface *pscreen;
    SDL_Overlay *overlay;
    SDL_Rect drect;
    SDL_Event sdlevent;
    SDL_Thread *mythread;
    SDL_mutex *affmutex;
    Uint32 currtime;
    Uint32 lasttime;
#endif
    int status;

    unsigned char *p = NULL;
    int hwaccel = 0;
    const char *videodevice = NULL;
    const char *mode = NULL;
    int format = V4L2_PIX_FMT_MJPEG;
    int i;
    int grabmethod = 1;
    int width = 320;
    int height = 240;
    int fps = 15;
    unsigned char frmrate = 0;
    char *avifilename = NULL;
    int queryformats = 0;
    int querycontrols = 0;
    int readconfigfile = 0;
    char *separateur;
    char *sizestring = NULL;
    char *fpsstring  = NULL;
    int enableRawStreamCapture = 0;
    int enableRawFrameCapture = 0;
    char * pRGBData=NULL;



    printf("luvcview version %s \n", version);
    for (i = 1; i < argc; i++)
    {
        /* skip bad arguments */
        if (argv[i] == NULL || *argv[i] == 0 || *argv[i] != '-') {
            continue;
        }
        if (strcmp(argv[i], "-d") == 0) {
            if (i + 1 >= argc) {
                printf("No parameter specified with -d, aborting.\n");
                exit(1);
            }
            videodevice = strdup(argv[i + 1]);
        }
        if (strcmp(argv[i], "-g") == 0) {
            /* Ask for read instead default  mmap */
            grabmethod = 0;
        }
        if (strcmp(argv[i], "-w") == 0) {
            /* disable hw acceleration */
            hwaccel = 1;
        }
        if (strcmp(argv[i], "-f") == 0) {
            if (i + 1 >= argc) {
                printf("No parameter specified with -f, aborting.\n");
                exit(1);
            }
            mode = strdup(argv[i + 1]);

            if (strncmp(mode, "yuv", 3) == 0) {
                format = V4L2_PIX_FMT_YUYV;

            } else if (strncmp(mode, "jpg", 3) == 0) {
                format = V4L2_PIX_FMT_MJPEG;

            } else {
                format = V4L2_PIX_FMT_MJPEG;

            }
        }
        if (strcmp(argv[i], "-s") == 0) {
            if (i + 1 >= argc) {
                printf("No parameter specified with -s, aborting.\n");
                exit(1);
            }

            sizestring = strdup(argv[i + 1]);

            width = strtoul(sizestring, &separateur, 10);
            if (*separateur != 'x') {
                printf("Error in size use -s widthxheight \n");
                exit(1);
            } else {
                ++separateur;
                height = strtoul(separateur, &separateur, 10);
                if (*separateur != 0)
                    printf("hmm.. dont like that!! trying this height \n");
                printf(" size width: %d height: %d \n", width, height);
            }
        }
        if (strcmp(argv[i], "-i") == 0){
            if (i + 1 >= argc) {
                printf("No parameter specified with -i, aborting. \n");
                exit(1);
            }
            fpsstring = strdup(argv[i + 1]);
            fps = strtoul(fpsstring, &separateur, 10);
            printf(" interval: %d fps \n", fps);
        }
        if (strcmp(argv[i], "-S") == 0) {
            /* Enable raw stream capture from the start */
            enableRawStreamCapture = 1;
        }
        if (strcmp(argv[i], "-c") == 0) {
            /* Enable raw frame capture for the first frame */
            enableRawFrameCapture = 1;
        }
        if (strcmp(argv[i], "-C") == 0) {
            /* Enable raw frame stream capture from the start*/
            enableRawFrameCapture = 2;
        }
        if (strcmp(argv[i], "-o") == 0) {
            /* set the avi filename */
            if (i + 1 >= argc) {
                printf("No parameter specified with -o, aborting.\n");
                exit(1);
            }
            avifilename = strdup(argv[i + 1]);
        }
        if (strcmp(argv[i], "-L") == 0) {
            /* query list of valid video formats */
            queryformats = 1;
        }
        if (strcmp(argv[i], "-l") == 0) {
            /* query list of valid video formats */
            querycontrols = 1;
        }

        if (strcmp(argv[i], "-r") == 0) {
            /* query list of valid video formats */
            readconfigfile = 1;
        }
        if (strcmp(argv[i], "-h") == 0) {
            printf("usage: uvcview [-h -d -g -f -s -i -c -o -C -S -L -l -r] \n");
            printf("-h	print this message \n");
            printf("-d	/dev/videoX       use videoX device\n");
            printf("-g	use read method for grab instead mmap \n");
            printf("-w	disable SDL hardware accel. \n");
            printf("-f	video format  default jpg  others options are yuv jpg \n");
            printf("-i	fps           use specified frame interval \n");
            printf("-s	widthxheight      use specified input size \n");
            printf("-c	enable raw frame capturing for the first frame\n");
            printf("-C	enable raw frame stream capturing from the start\n");
            printf("-S	enable raw stream capturing from the start\n");
            printf("-o	avifile  create avifile, default video.avi\n");
            printf("-L	query valid video formats\n");
            printf("-l	query valid controls and settings\n");
            printf("-r	read and set control settings from luvcview.cfg\n");
            exit(0);
        }
    }

#ifndef   EMBEDED_X210 //PC platform

    /************* Test SDL capabilities ************/
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
        exit(1);
    }
    
    /* For this version, we'll be save and disable hardware acceleration */
    if(hwaccel)
    {
        if ( ! getenv("SDL_VIDEO_YUV_HWACCEL") )
        {
            putenv("SDL_VIDEO_YUV_HWACCEL=0");
        }
    }

    if (SDL_VideoDriverName(driver, sizeof(driver)))
    {
        printf("Video driver: %s\n", driver);
    }
    info = SDL_GetVideoInfo();

    if (info->wm_available) {
        printf("A window manager is available\n");
    }
    if (info->hw_available) {
        printf("Hardware surfaces are available (%dK video memory)\n",
               info->video_mem);
        SDL_VIDEO_Flags |= SDL_HWSURFACE;
    }
    if (info->blit_hw) {
        printf("Copy blits between hardware surfaces are accelerated\n");
        SDL_VIDEO_Flags |= SDL_ASYNCBLIT;
    }
    if (info->blit_hw_CC) {
        printf
                ("Colorkey blits between hardware surfaces are accelerated\n");
    }
    if (info->blit_hw_A) {
        printf("Alpha blits between hardware surfaces are accelerated\n");
    }
    if (info->blit_sw) {
        printf
                ("Copy blits from software surfaces to hardware surfaces are accelerated\n");
    }
    if (info->blit_sw_CC) {
        printf
                ("Colorkey blits from software surfaces to hardware surfaces are accelerated\n");
    }
    if (info->blit_sw_A) {
        printf
                ("Alpha blits from software surfaces to hardware surfaces are accelerated\n");
    }
    if (info->blit_fill) {
        printf("Color fills on hardware surfaces are accelerated\n");
    }



    if (!(SDL_VIDEO_Flags & SDL_HWSURFACE))
        SDL_VIDEO_Flags |= SDL_SWSURFACE;

#endif

    if (videodevice == NULL || *videodevice == 0) {
        videodevice = "/dev/video0";
    }

    if (avifilename == NULL || *avifilename == 0) {
        avifilename = "video.avi";
    }

    videoIn = (struct vdIn *) calloc(1, sizeof(struct vdIn));
    if ( queryformats ) {
        /* if we're supposed to list the video formats, do that now and go out */
        check_videoIn(videoIn,(char *) videodevice);
        free(videoIn);
#ifndef EMBEDED_X210
        SDL_Quit();
#endif
        exit(1);
    }

    if (init_videoIn(videoIn, (char *) videodevice, width, height, fps, format, grabmethod, avifilename) < 0)
        exit(1);
    /* if we're supposed to list the controls, do that now */
    if ( querycontrols )
        enum_controls(videoIn->fd);
    
    /* if we're supposed to read the control settings from a configfile, do that now */
    if ( readconfigfile )
        load_controls(videoIn->fd);


#ifdef EMBEDED_X210
#ifdef SOFT_COLOR_CONVERT
    init_framebuffer();
#else
    x6410_init_Draw(videoIn->width,videoIn->height);
#endif

#else
    pscreen = SDL_SetVideoMode(videoIn->width, videoIn->height+30 , 0,SDL_VIDEO_Flags);
    overlay =SDL_CreateYUVOverlay(videoIn->width, videoIn->height+30 , SDL_YUY2_OVERLAY, pscreen);
    p = (unsigned char *) overlay->pixels[0];

    drect.x = 0;
    drect.y = 0;
    drect.w =pscreen->w;
    drect.h = pscreen->h;

#endif

    if (enableRawStreamCapture)
    {
        videoIn->captureFile = fopen("stream.raw", "wb");
        if(videoIn->captureFile == NULL) {
            perror("Unable to open file for raw stream capturing");
        } else {
            printf("Starting raw stream capturing to stream.raw ...\n");
        }
    }
    if (enableRawFrameCapture)
        videoIn->rawFrameCapture = enableRawFrameCapture;

    initLut();

#ifndef EMBEDED_X210
    SDL_WM_SetCaption(title_act[A_VIDEO].title, NULL);
    lasttime = SDL_GetTicks();
    creatButt(videoIn->width, 32);
    SDL_LockYUVOverlay(overlay);
    memcpy(p + (videoIn->width * (videoIn->height) * 2), YUYVbutt,
           videoIn->width * 64);
    SDL_UnlockYUVOverlay(overlay);

    /* initialize thread data */
    ptdata.ptscreen = &pscreen;
    ptdata.ptvideoIn = videoIn;
    ptdata.ptsdlevent = &sdlevent;
    ptdata.drect = &drect;
    affmutex = SDL_CreateMutex();
    ptdata.affmutex = affmutex;
    mythread = SDL_CreateThread(eventThread, (void *) &ptdata);
#endif



    pRGBData = (unsigned char *)malloc(videoIn->width*videoIn->width*4*sizeof(char));
    if(pRGBData==NULL)
    {
        return ;
	}
    /* main big loop */
    while (videoIn->signalquit)
    {
#ifndef EMBEDED_X210
        currtime = SDL_GetTicks();
        if (currtime - lasttime > 0) {
            frmrate = 1000/(currtime - lasttime);
        }
        lasttime = currtime;
#endif
        if (uvcGrab(videoIn) < 0) {
            printf("Error grabbing \n");
            break;
        }

        /* if we're grabbing video, show the frame rate */
        if (videoIn->toggleAvi)
            printf("\rframe rate: %d     ",frmrate);

#ifndef EMBEDED_X210
        SDL_LockYUVOverlay(overlay);
        memcpy(p, videoIn->framebuffer, videoIn->width * (videoIn->height) * 2);
        SDL_UnlockYUVOverlay(overlay);
        SDL_DisplayYUVOverlay(overlay, &drect);
#endif

#ifdef EMBEDED_X210
#ifdef SOFT_COLOR_CONVERT
        // yuv to rgb565 ,and to frambuffer
        process_image(videoIn->framebuffer,fbp,videoIn->width,videoIn->height,vinfo,finfo);
    
    //    convertYUYVtoRGB565(videoIn->framebuffer,pRGBData,videoIn->width,videoIn->height);

   //   Pyuv422torgb24(videoIn->framebuffer, pRGBData, videoIn->width, videoIn->height);
    //    memcpy(fbp,pRGBData,videoIn->width*videoIn->height*2);
     
     

#else   //X6410 post processor convert yuv to rgb,X210 not suport now.

        /*
        memcpy(pInbuffer, videoIn->framebuffer, videoIn->width * (videoIn->height) * 2);

        ioctl(dev_fb0, GET_FB_INFO, &fb_info);

        pp_param.SrcFrmSt = ioctl(dev_pp, S3C_PP_GET_RESERVED_MEM_ADDR_PHY); //must be  physical adress
        pp_param.DstFrmSt = fb_info.map_dma_f1; //must be physical adress

        ioctl(dev_pp, S3C_PP_SET_PARAMS, &pp_param);
        ioctl(dev_pp, S3C_PP_SET_DST_BUF_ADDR_PHY, &pp_param);
        ioctl(dev_pp, S3C_PP_SET_SRC_BUF_ADDR_PHY, &pp_param);
        ioctl(dev_pp, S3C_PP_START);
        */
#endif
#endif
        if (videoIn->getPict)
        {
            switch(videoIn->formatIn){
            case V4L2_PIX_FMT_MJPEG:
                get_picture(videoIn->tmpbuffer,videoIn->buf.bytesused);
                break;
            case V4L2_PIX_FMT_YUYV:
                get_pictureYV2(videoIn->framebuffer,videoIn->width,videoIn->height);
                break;
            default:
                break;
            }
            videoIn->getPict = 0;
            printf("get picture !\n");
        }

#ifndef EMBEDED_X210
        SDL_LockMutex(affmutex);
        ptdata.frmrate = frmrate;
        SDL_WM_SetCaption(videoIn->status, NULL);
        SDL_UnlockMutex(affmutex);
#endif

#ifdef  EMBEDED_X210
        usleep(10);
#else
        SDL_Delay(10);
#endif


    }
#ifndef EMBEDED_X210
    SDL_WaitThread(mythread, &status);
    SDL_DestroyMutex(affmutex);
#endif
    /* if avifile is defined, we made a video: compute the exact fps and
       set it in the video */
    if (videoIn->avifile != NULL) {
        float fps=(videoIn->framecount/(videoIn->recordtime/1000));
        fprintf(stderr,"setting fps to %f\n",fps);
        AVI_set_video(videoIn->avifile, videoIn->width, videoIn->height,
                      fps, "MJPG");
        AVI_close(videoIn->avifile);
    }

    close_v4l2(videoIn);

#ifdef EMBEDED_X210
#ifdef SOFT_COLOR_CONVERT
    close_frambuffer();
#else
    x6410_DeInit_Draw();
#endif

#endif
    free(pRGBData);
    free(videoIn);
    destroyButt();
    freeLut();
    printf(" Clean Up done Quit \n");
#ifndef EMBEDED_X210
    SDL_Quit();
#endif
}
示例#10
0
int main(int argc, char* argv[])
{
	/*
	pid_t childPID;
	g_forcefbmode = false;
	if( argc > 1 && strcmp(argv[1], "fb")==0)
		g_forcefbmode = true;

	childPID = fork();

	if( childPID >= 0 )
	{
		if( childPID == 0 ) // child process
		{
			Log("\n Child Activated\n");
		    //--- fb initialize
		    if( init_framebuffer() == 0 ) {
		        Err("init framebuffer failed\n");
		        return 0;
		    }
		    Log("Surfaceflinger initialized.\n");

			Log("\n Child Activated - init server\n");
		    InitServer(); // endless loop
		}
		else
		{
			sleep(3);
			Log("\n Launch Process succeeded\n");
		}
	}
	*/

	fprintf(stderr,"%s\n", RUISVC_VERSION);


	g_forcefbmode = false;
	if( argc > 1 && strcmp(argv[1], "fb")==0)
		g_forcefbmode = true;

	if( argc > 1 && strcmp(argv[1], "verbose")==0)
		LogEnable(1);

	signal (SIGHUP, SIG_IGN);

    //--- fb initialize
    if( init_framebuffer() == 0 ) {
        Err("init framebuffer failed\n");
        return 0;
    }
    Log("Surfaceflinger initialized.\n");

    InitServer(); // endless loop


    // --- never come here
    /*
    int cnt = 0;
    while(1) {
        sleep(1);
        Log("%04d:Idle\n",cnt++);
    }

    //--- exit
    if( exit_framebuffer() == 0 ) {
        Err("exit framebuffer failed\n");
        return 0;
    }

    Log("Framebuffer Exit.\n");
	*/

    fprintf(stderr,"BYE\n");
    return true;
}