bool BootAnimation::threadLoop()
{
    bool r;
    if (mAndroidAnimation) {
        r = android();
    } else {
        r = movie();
    }

    eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
    eglDestroyContext(mDisplay, mContext);
    eglDestroySurface(mDisplay, mSurface);
    mFlingerSurface.clear();
    mFlingerSurfaceControl.clear();
    eglTerminate(mDisplay);
    IPCThreadState::self()->stopProcess();
    return r;
}
Exemple #2
0
void ImageView::GetScreenShot(QImage& image, const ThumbItem *item)
{
    QFileInfo fi(item->GetPath());
    QString screenshot = QString("%1%2-screenshot.jpg")
                                .arg(ThumbGenerator::getThumbcacheDir(fi.path()))
                                .arg(item->GetName());

    if (QFile::exists(screenshot))
    {
        QImage img(screenshot);
        image = img;
    }
    else
    {
        QString movie("gallery-moviethumb.png");
        if (GetMythUI()->FindThemeFile(movie))
            image.load(movie);
    }
}
Exemple #3
0
main()
{
	ozgetauxsize();
	ozclick(0);
	ozcls();
	if(load==1)
	{
		loadconfig();
	}
	if(mov==1)
	{
		if(watch==1)
		{
			movie();
			watch=0;
		}
	}
	ozcls();
	high=1;
	prevhigh=0;
	score=0;
	shots=25;
	hits=0;
	misses=0;
	acc=0;
	bullseyes=0;
	ozquiet();
	ozsetfont(FONT_OZ_LARGE);
	ozputs(0,0,"OZ Clay Pigeons");
	ozsetfont(FONT_OZ_NORMAL);
	ozputs(95,3,"Version 2.0");
	ozputs(0,20,"(1) Play OZ Clay Pigeons");
	ozputs(0,30,"(2) High Scores");
	ozputs(0,40,"(3) Keys");
	ozputs(0,50,"(4) Options");
	ozputs(0,60,"(5) Quit OZ Clay Pigeons");
	ozputs(130,20,"Made with Hi-Tech C;");
	ozputs(130,30,"USE AT YOUR OWN RISK!");
	ozputs(130,50,"Up/Dn arrows to select");
	highlight();
	main();
}
bool BootAnimation::threadLoop()
{
    bool r;
    // We have no bootanimation file, so we use the stock android logo
    // animation.
    if (mZip == NULL) {
        r = android();
    } else {
        r = movie();
    }

    eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
    eglDestroyContext(mDisplay, mContext);
    eglDestroySurface(mDisplay, mSurface);
    mFlingerSurface.clear();
    mFlingerSurfaceControl.clear();
    eglTerminate(mDisplay);
    IPCThreadState::self()->stopProcess();
    return r;
}
bool BootAnimation::threadLoop()
{
    bool r;
    if (mAndroidAnimation) {
        r = android();
    } else {
        r = movie();
    }

    // No need to force exit anymore
    property_set(EXIT_PROP_NAME, "0");

    eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
    eglDestroyContext(mDisplay, mContext);
    eglDestroySurface(mDisplay, mSurface);
    mFlingerSurface.clear();
    mFlingerSurfaceControl.clear();
    eglTerminate(mDisplay);
    IPCThreadState::self()->stopProcess();
    return r;
}
Exemple #6
0
void fileio_do_movie_stop(void)
{
	Nes::Api::Movie movie( emulator );

	if (movieRecFile || moviePlayFile)
	{
		movie.Stop();
		movie.Eject();

		if (movieRecFile)
		{
			delete movieRecFile;
			movieRecFile = NULL;
		}

		if (moviePlayFile)
		{
			delete moviePlayFile;
			moviePlayFile = NULL;
		}
	}
}
Exemple #7
0
void CMouseCursor::loadCursorImages() {
	const CResourceKey key("ycursors.avi");

	// Iterate through getting each cursor
	for (int idx = 0; idx < NUM_CURSORS; ++idx) {
		assert(CURSOR_DATA[idx][0] == (idx + 1));
		_cursors[idx]._centroid = Common::Point(CURSOR_DATA[idx][2],
			CURSOR_DATA[idx][3]);

		// Create the surface
		CVideoSurface *surface = _screenManager->createSurface(CURSOR_SIZE, CURSOR_SIZE);
		_cursors[idx]._videoSurface = surface;

		// Open the cursors video and move to the given frame
		OSMovie movie(key, surface);
		movie.setFrame(idx);
		
		Graphics::ManagedSurface *transSurface = movie.duplicateTransparency();
		_cursors[idx]._transSurface = transSurface;
		surface->setTransparencySurface(transSurface);
	}
}
void CMouseCursor::loadCursorImages() {
	const CResourceKey key("ycursors.avi");
	g_vm->_filesManager->fn4(key.getString());

	// Iterate through getting each cursor
	for (int idx = 0; idx < NUM_CURSORS; ++idx) {
		assert(CURSOR_DATA[idx][0] == (idx + 1));
		_cursors[idx]._centroid = Common::Point(CURSOR_DATA[idx][2],
			CURSOR_DATA[idx][3]);

		// Create the surface
		CVideoSurface *surface = _screenManager->createSurface(64, 64);
		_cursors[idx]._videoSurface = surface;

		// Open the cursors video and move to the given frame
		OSMovie movie(key, surface);
		movie.setFrame(idx);
		
		Graphics::ManagedSurface *frameSurface = movie.duplicateFrame();
		_cursors[idx]._frameSurface = frameSurface;
		surface->setMovieFrameSurface(frameSurface);
	}
}
MyPlanes::MyPlanes(QDeclarativeItem *parent) :
    QDeclarativeItem(parent)
{
    count=0;//用来记录爆炸时播放到了第几张图片
    planesState=false;
    setFlag(QGraphicsItem::ItemHasNoContents,false);
#ifdef HARMATTAN_BOOSTER
    double imageScaled=0.96;
#elif defined(Q_OS_SYMBIAN_V5)
    double imageScaled=0.72;
#else
    double imageScaled=0.72;
    //double imageScaled=0.96;
#endif
    image.load(":/Image/F1_01.png");
    pixmap1=QPixmap::fromImage(image.scaled(imageScaled*image.size(),Qt::KeepAspectRatio,Qt::SmoothTransformation));

    image.load(":/Image/F1_02.png");
    pixmap2=QPixmap::fromImage(image.scaled(imageScaled*image.size(),Qt::KeepAspectRatio,Qt::SmoothTransformation));

    image.load(":/Image/F1_03.png");
    pixmap3=QPixmap::fromImage(image.scaled(imageScaled*image.size(),Qt::KeepAspectRatio,Qt::SmoothTransformation));

    image.load(":/Image/F1_04.png");
    pixmap4=QPixmap::fromImage(image.scaled(imageScaled*image.size(),Qt::KeepAspectRatio,Qt::SmoothTransformation));

    image.load(":/Image/F1_05.png");
    pixmap5=QPixmap::fromImage(image.scaled(imageScaled*image.size(),Qt::KeepAspectRatio,Qt::SmoothTransformation));

    pixmap=&pixmap1;
    setSize(pixmap->size());

    connect(&timer,SIGNAL(timeout()),SLOT(setPlanesState()));
    connect(&mymovie,SIGNAL(timeout()),SLOT(movie()));
    setZValue(1);
    //setSmooth(true);
}
Exemple #10
0
void tst_QMovie::playMovie()
{
    QFETCH(QString, fileName);
    QFETCH(int, frameCount);

    QMovie movie(QFINDTESTDATA(fileName));

    QCOMPARE(movie.state(), QMovie::NotRunning);
    movie.setSpeed(1000);
    movie.start();
    QCOMPARE(movie.state(), QMovie::Running);
    movie.setPaused(true);
    QCOMPARE(movie.state(), QMovie::Paused);
    movie.start();
    QCOMPARE(movie.state(), QMovie::Running);
    movie.stop();
    QCOMPARE(movie.state(), QMovie::NotRunning);
    movie.jumpToFrame(0);
    QCOMPARE(movie.state(), QMovie::NotRunning);
    movie.start();
    QCOMPARE(movie.state(), QMovie::Running);

    connect(&movie, SIGNAL(finished()), this, SLOT(exitLoopSlot()));

#ifndef QT_NO_WIDGETS
    QLabel label;
    label.setMovie(&movie);
    label.show();

    QTestEventLoop::instance().enterLoop(20);
    QVERIFY2(!QTestEventLoop::instance().timeout(),
            "Timed out while waiting for finished() signal");

    QCOMPARE(movie.state(), QMovie::NotRunning);
    QCOMPARE(movie.frameCount(), frameCount);
#endif
}
// Handle the QTSS_RTSPFilter_Role role call back.
QTSS_Error Filter(QTSS_Filter_Params* inParams)
{
    QTSS_Error err = QTSS_NoErr;
    QTSS_RTSPRequestObject theRequest = inParams->inRTSPRequest;
    QTSS_RTSPSessionObject theSession = inParams->inRTSPSession;
    char theURL[512];
    
    // If this module is disabled do nothing but return.
    if (!sRefMovieXferEnabled)
        return QTSS_NoErr;
            
   // Get the full RTSP request from the server's attribute.
    StrPtrLen theFullRequest;
    err = QTSS_GetValuePtr(theRequest, qtssRTSPReqFullRequest, 0, (void**)&theFullRequest.Ptr, &theFullRequest.Len);
    
    if (err != QTSS_NoErr) 
    {
        return QTSS_NoErr;
    }
    
    // if this is not an HTTP GET then ignore it.
    if (!IsHTTPGet(theFullRequest))
        return QTSS_NoErr;
    
    // If this is a tunneled RTSP request we ignore it.
    if (IsTunneledRTSP(theFullRequest))
    {
        return QTSS_NoErr;
    }
        
    // if we can't parse out the URL then we just ignore this request.
    if (!ParseURL(theFullRequest, theURL, 512))
    {
        return QTSS_NoErr;
    }
    
    // Make sure that this is not an admin request before
    // we go any further.
    StrPtrLen movie(theURL);
    if (IsAdminURL(movie))
    {
        // The file path in the URL is actually an admin request.
        // Just ignore it and let the admin module handle it.
        return QTSS_NoErr;
    }
    
    Bool16 isHomeDir = IsHomeDirURL(movie);
    
    // Get the server's movie folder location.
    char* movieFolderString = NULL;
    err = QTSS_GetValueAsString (sServerPrefs, qtssPrefsMovieFolder, 0, &movieFolderString);
    if (err != QTSS_NoErr)
        return QTSS_NoErr;
        
    OSCharArrayDeleter movieFolder(movieFolderString);
    StrPtrLen theMovieFolder(movieFolderString);
    
    if (!isHomeDir && !FileExists(theMovieFolder, movie))
    {
        // we couldn't find a file at the specified location
        // so we will ignore this HTTP request and let some other module
        // deal with the issue.
        return QTSS_NoErr;
    }
    else
    {
        // Eureka!!! We found a file at the specified location.
        // We assume that it is a valid movie file and we send
        // the client an RTSP text reference movie in the HTTP reply.
        err = SendTheResponse(theSession,theRequest, movie);
    }
        
    return QTSS_NoErr;
}
int main(int argc, char const * const argv[])
{
  if (argc < 4)
  {
    std::cerr << "Missing arguments! 2 images + 1 movie name are required.\n";
    return EXIT_FAILURE;
  }

  // Load 2 images
  cv::Mat I0 = cv::imread(argv[argc-3], 0);
  if (!I0.data)
  {
    std::cerr << "Error reading: " << argv[argc-3] << std::endl;
    return EXIT_FAILURE;
  }

  cv::Mat I1 = cv::imread(argv[argc-2], 0);
  if (!I1.data)
  {
    std::cerr << "Error reading: " << argv[argc-2] << std::endl;
    return EXIT_FAILURE;
  }

  CV_Assert(I0.size() == I1.size());

  // Output movie
  double fps = 1.25;
  int fourcc = cv::VideoWriter::fourcc('m','p','4','v');
  cv::Size frameSize = I0.size();

  cv::VideoWriter movie(argv[argc-1], fourcc, fps, frameSize, true);
  CV_Assert(movie.isOpened());
  
  float mixCoeff = 0.0;
  float mixStep = 0.1;
  cv::Mat mixf, mixc, mix8;

  cv::Mat I0f;
  I0.convertTo(I0f, CV_32F, 1.0/255.0);
  cv::Mat I1f;
  I1.convertTo(I1f, CV_32F, 1.0/255.0);

  std::cout << "Forward...\n";
  while (mixCoeff <= 1.0)
  {
    mixf = (1.0-mixCoeff)*I0f + mixCoeff*I1f;
    mixf.convertTo(mix8, CV_8U, 255.0);
    cv::cvtColor(mix8, mixc, cv::COLOR_GRAY2BGR);

    movie << mixc;

    mixCoeff += mixStep;
  }

  mixCoeff = 1.0;
  std::cout << "Backward...\n";
  while (mixCoeff >= 0.0)
  {
    mixf = (1.0-mixCoeff)*I0f + mixCoeff*I1f;
    mixf.convertTo(mix8, CV_8U, 255.0);
    cv::cvtColor(mix8, mixc, cv::COLOR_GRAY2BGR);

    movie << mixc;

    mixCoeff -= mixStep;
  }
}
Exemple #13
0
  /*
   *  Vertex update function - computes the least square step
   */
  void update(graphchi_vertex<VertexDataType, EdgeDataType> &vertex, graphchi_context &gcontext) {


    if (gcontext.iteration == 0){
    if (is_user(vertex.id())) { //user node. find the last rated item and store it
      vertex_data_libfm user = latent_factors_inmem[vertex.id()]; 
      int max_time = 0;
      for(int e=0; e < vertex.num_outedges(); e++) {
        const edge_data & edge = vertex.edge(e)->get_data();
        if (edge.time >= max_time){
          max_time = (int)(edge.time - time_offset);
          *user.last_item = vertex.edge(e)->vertex_id() - M;
        }
      }
    }
if (is_user(vertex.id()) && vertex.num_outedges() == 0)
      logstream(LOG_WARNING)<<"Vertex: " << vertex.id() << " with no edges: " << std::endl;
    return;
    return;
  } 
 
    //go over all user nodes
    if (is_user(vertex.id())){
      vertex_data_libfm user = latent_factors_inmem[vertex.id()]; 
      assert(*user.last_item >= 0 && *user.last_item < (int)N);
      vertex_data & last_item = latent_factors_inmem[M+N+K+(*user.last_item)]; 

      for(int e=0; e < vertex.num_outedges(); e++) {
        vertex_data_libfm movie(latent_factors_inmem[vertex.edge(e)->vertex_id()]);

        float rui = vertex.edge(e)->get_data().weight;
        double pui;
        vec sum;
        vertex_data & time = latent_factors_inmem[(int)vertex.edge(e)->get_data().time - time_offset];
        float sqErr = libfm_predict(user, movie, time, rui, pui, &sum);
        float eui = pui - rui;

        globalMean -= libfm_rate * (eui + reg0 * globalMean);
        *user.bias -= libfm_rate * (eui + libfm_regw * *user.bias);
        *movie.bias -= libfm_rate * (eui + libfm_regw * *movie.bias);
        time.bias -= libfm_rate * (eui + libfm_regw * time.bias);
        assert(!std::isnan(time.bias));
        last_item.bias -= libfm_rate * (eui + libfm_regw * last_item.bias);

        for(int f = 0; f < D; f++){
          // user
          float grad = sum[f] - user.v[f];
          user.v[f] -= libfm_rate * (eui * grad + libfm_regv * user.v[f]);
          // item
          grad = sum[f] - movie.v[f];
          movie.v[f] -= libfm_rate * (eui * grad + libfm_regv * movie.v[f]);
          // time
          grad = sum[f] - time.pvec[f];
          time.pvec[f] -= libfm_rate * (eui * grad + libfm_regv * time.pvec[f]);
          // last item
          grad = sum[f] - last_item.pvec[f];
          last_item.pvec[f] -= libfm_rate * (eui * grad + libfm_regv * last_item.pvec[f]);

        }

        rmse_vec[omp_get_thread_num()] += sqErr;
      }

    }

  };
Exemple #14
0
int
Goodbye()
{
  extern void movie();
  char genbuf[200];

/*
woju
*/
  char ans[4];


  setuserfile(genbuf, fn_writelog);
  if (more(genbuf, NA) != -1) {
/* MH */
/* Àˬd¤ô²y°O¿ý®e¶q, ÁקK¦³¤H¡u¤Ù¿n¡v¤j¶q¤ô²y */
     struct stat st;
     int writelog_limit;
    
     if (HAS_PERM(PERM_BM))
        writelog_limit = MH_WRITELOGLIMIT_BM;
     else if (HAS_PERM(PERM_LOGINOK))
        writelog_limit = MH_WRITELOGLIMIT_LOGINOK;
     else
        writelog_limit = MH_WRITELOGLIMIT_BASIC;
     do
     {
       char buf[80];
       
       setuserfile(buf, fn_writelog);
       stat(buf, &st);
       if(!HAVE_PERM(PERM_SYSOP) && !HAVE_PERM(PERM_MAILLIMIT) && st.st_size / 1024 > writelog_limit)
       {
         my_outmsg_row("±zªº¤ô²y°O¿ý¤w¶W¹L­­©w®e¶q¡AµLªk¿ï¾Ü¡u«O¯d¡v", b_lines - 2);
         getdata(b_lines - 1, 0, "²M°£(C) ²¾¦Ü³Æ§Ñ¿ý(M) (C/M)?[M]",
            ans, 3, LCECHO, 0);
       }
       else
       {
         getdata(b_lines - 1, 0, "²M°£(C) ²¾¦Ü³Æ§Ñ¿ý(M) «O¯d(R) (C/M/R)?[R]",
            ans, 3, LCECHO, 0);
       }
       if (*ans == 'm') {
          fileheader mymail;
          char title[128], buf[80];

          sethomepath(buf, cuser.userid);
          stampfile(buf, &mymail);

          mymail.savemode = 'H';        /* hold-mail flag */
          mymail.filemode = FILE_READ;
          strcpy(mymail.owner, "[³Æ.§Ñ.¿ý]");
          strcpy(mymail.title, "¼ö½u°O¿ý");
          if(mh_memoforward(cuser.userid, genbuf, &mymail, sizeof(mymail)))
          {
            sethomedir(title, cuser.userid);
            append_record(title, &mymail, sizeof(mymail));
            /* MH: ³Æ§Ñ¿ý¥[¤W§@ªÌ¼ÐÃDµ¥¸ê°T...¤£µM¦b'x'Âà±H©Î¬Obuildirªº®É­Ô
                   ·|Äê±¼ */
#if 1
            {
              FILE *src, *dst;
              char buf2[200];
              time_t now;
              
              if((src = fopen(genbuf, "r")) == NULL)
              {
                sprintf(buf2, "errno: %d, genbuf:%s", errno, genbuf);
                log_usies("MH ", buf2);
              }
              if((dst = fopen(buf, "w")) == NULL)
              {
                sprintf(buf2, "errno: %d, buf:%s", errno, buf);
                log_usies("MH ", buf2);
                fclose(src);
              }
              now = time(NULL);
              sprintf(buf2, "§@ªÌ: %s\n¼ÐÃD: %s\n®É¶¡: %s\n", mymail.owner, mymail.title, ctime(&now));
              fputs(buf2, dst);
              while(fgets(buf2, 199, src) != NULL)
                fputs(buf2, dst);
              fclose(src);
              fclose(dst);
              unlink(genbuf);
            }
#else
            Rename(genbuf, buf);
#endif
          }
        }
       else if (*ans == 'c') {
          char buf[80];

          setuserfile(buf, fn_writelog);
          unlink(buf);
       }
     } while(!HAVE_PERM(PERM_SYSOP) && !HAVE_PERM(PERM_MAILLIMIT) && st.st_size / 1024 > writelog_limit && *ans != 'm' && *ans != 'c');

      clear();
      move(0, 0);
      prints("                             °ª¶¯¤¤¾Ç-¬õ¼Ó¿v¹Ú                                ");
      movie(0);
  }
/*    */

  getdata(b_lines - 1, 0, "±z½T©w­nÂ÷¶}¡i " BOARDNAME " ¡j¶Ü(Y/N)¡H[N] ",
    genbuf, 3, LCECHO, 0);

  if (*genbuf != 'y')
    return 0;

  movie(999);
  if (cuser.userlevel)
  {
    getdata(b_lines - 1, 0, "(G)ÀH­·¦Ó³u (M)¦«¹Ú¯¸ªø (N)¦X§@ªÀªº¨¥½×¼s³õ¡H[G] ",
      genbuf, 3, LCECHO, 0);
    if (genbuf[0] == 'm')
      mail_sysop();
    else if (genbuf[0] == 'n')
      note();
  }

  save_userrc();
#if 0
  save_mailmsg();
#endif

  clear();
  prints("¿Ë·Rªº %s(%s)¡A§O§Ñ¤F¦A«×¥úÁ{"
    " %s ¡I\n¥H¤U¬O±z¦b¯¸¤ºªºµù¥U¸ê®Æ:\n",
    cuser.userid, cuser.username, BoardName);
  user_display(&cuser, 0);

  if (currmode)
    u_exit("EXIT ");

  pressanykey();
  sleep(1);
  reset_tty();
  exit(0);
}
Exemple #15
0
bool CGEEngine::showTitle(const char *name) {
	if (_eventManager->_quitFlag)
		return false;

	_bitmapPalette = _vga->_sysPal;
	BitmapPtr *LB = new BitmapPtr[2];
	LB[0] = new Bitmap(this, name);
	LB[1] = NULL;
	_bitmapPalette = NULL;

	Sprite D(this, LB);
	D._flags._kill = true;
	D._flags._bDel = true;
	D.center();
	D.show(2);

	if (_mode == 2) {
		inf(kSavegame0Name);
		_talk->show(2);
	}

	_vga->sunset();
	_vga->copyPage(1, 2);
	_vga->copyPage(0, 1);
	selectPocket(-1);
	_vga->sunrise(_vga->_sysPal);

	if (_mode < 2 && !_soundOk) {
		_vga->copyPage(1, 2);
		_vga->copyPage(0, 1);
		_vga->_showQ->append(_mouse);
		_mouse->on();
		for (; !_commandHandler->idle() || Vmenu::_addr;) {
			mainLoop();
			if (_eventManager->_quitFlag)
				return false;
		}

		_mouse->off();
		_vga->_showQ->clear();
		_vga->copyPage(0, 2);
		_soundOk = 2;
		if (_music)
			_midiPlayer->loadMidi(0);
	}

	if (_mode < 2) {
		// At this point the game originally set the protection variables
		// used by the copy protection check
		movie(kPaylistExt); // paylist
		_vga->copyPage(1, 2);
		_vga->copyPage(0, 1);
		_vga->_showQ->append(_mouse);
		// In the original game, the user had to enter his name
		// As it was only used to name savegames, it has been removed
		_vga->_showQ->clear();
		_vga->copyPage(0, 2);

		if (_mode == 0) {
// The auto-load of savegame #0 is currently disabled
#if 0
			if (savegameExists(0)) {
				// Load the savegame
				loadGame(0, NULL, true); // only system vars
				_vga->setColors(_vga->_sysPal, 64);
				_vga->update();
				if (_flag[3]) { //flag FINIS
					_mode++;
					_flag[3] = false;
				}
			} else
#endif
				_mode++;
		}
	}

	if (_mode < 2)
		movie(kWinkExt);

	_vga->copyPage(0, 2);

	return true;
}
Exemple #16
0
bool CGEEngine::showTitle(const char *name) {
	if (_quitFlag)
		return false;

	_bitmapPalette = _vga->_sysPal;
	BitmapPtr *LB = new BitmapPtr[2];
	LB[0] = new Bitmap(this, name);
	LB[1] = NULL;
	_bitmapPalette = NULL;

	Sprite D(this, LB);
	D._flags._kill = true;
	D._flags._bDel = true;
	D.center();
	D.show(2);

	if (_mode == 2) {
		inf(kSavegame0Name);
		_talk->show(2);
	}

	_vga->sunset();
	_vga->copyPage(1, 2);
	_vga->copyPage(0, 1);
	selectPocket(-1);
	_vga->sunrise(_vga->_sysPal);

	if (_mode < 2 && !_soundOk) {
		_vga->copyPage(1, 2);
		_vga->copyPage(0, 1);
		_vga->_showQ->append(_mouse);
		_mouse->on();
		for (; !_commandHandler->idle() || Vmenu::_addr;) {
			mainLoop();
			if (_quitFlag)
				return false;
		}

		_mouse->off();
		_vga->_showQ->clear();
		_vga->copyPage(0, 2);
		_soundOk = 2;
		if (_music)
			_midiPlayer->loadMidi(0);
	}

	if (_mode < 2) {
		// At this point the game originally set the protection variables
		// used by the copy protection check
		movie(kPaylistExt); // paylist
		_vga->copyPage(1, 2);
		_vga->copyPage(0, 1);
		_vga->_showQ->append(_mouse);
		// In the original game, the user had to enter his name
		// As it was only used to name savegames, it has been removed
		_vga->_showQ->clear();
		_vga->copyPage(0, 2);

		// The original was automatically loading the savegame when available
		if (_mode == 0)
			_mode++;
	}

	if (_mode < 2)
		movie(kWinkExt);

	_vga->copyPage(0, 2);

	return true;
}
Exemple #17
0
static void send_codes(vx_display_t * disp, const uint8_t * data, int datalen)
{
    state_t * state = disp->impl;

    vx_code_input_stream_t * cins = vx_code_input_stream_create(data, datalen);
    // Peek at the code type to determine which function to call
    uint32_t code = cins->read_uint32(cins);
    pthread_mutex_lock(&state->mutex);
    switch(code) {
        case OP_BUFFER_RESOURCES:
            vx_resc_manager_buffer_resources(state->mgr, data, datalen);
            break;

        case OP_BUFFER_ENABLED:
            vx_gl_renderer_buffer_enabled(state->glrend, cins);
            break;
        case OP_BUFFER_CODES:
            vx_gl_renderer_set_buffer_render_codes(state->glrend, cins);
            break;
        case OP_LAYER_INFO:
            vx_gl_renderer_update_layer(state->glrend, cins);
            {
                vx_code_input_stream_t * c2 = vx_code_input_stream_create(data, datalen);
                c2->read_uint32(c2); //discard code

                process_layer(state, c2);
                vx_code_input_stream_destroy(c2);
            }
            // XXX Also need to intercept these!
            break;
        case OP_DEALLOC_RESOURCES:
            vx_gl_renderer_remove_resources(state->glrend, cins);
            break;

        case OP_LAYER_VIEWPORT_REL:
            process_viewport_rel(state, cins);
            break;
        case OP_LAYER_VIEWPORT_ABS:
            process_viewport_abs(state, cins);
            break;

        case OP_LAYER_CAMERA:
            process_camera_codes(state, cins);
            break;

        case OP_WINDOW_SCENE: {
            save_scene(state, cins);
            break;
        }

        case OP_WINDOW_SCREENSHOT:
            screen_shot(state, cins);
            break;
        case OP_WINDOW_MOVIE_RECORD:
        case OP_WINDOW_MOVIE_STOP:
            movie(state, cins, code == OP_WINDOW_MOVIE_RECORD);
            break;
        default:
            assert(0);
    }
    pthread_mutex_unlock(&state->mutex);

    // Buffer layer manager, outside the lock
    switch(code) {
        case OP_BUFFER_ENABLED:
            vx_gtk_buffer_manager_codes(state->buffer_manager, data, datalen);
            break;
        case OP_BUFFER_CODES:
            vx_gtk_buffer_manager_codes(state->buffer_manager, data, datalen);
            break;
        case OP_LAYER_INFO:
            vx_gtk_buffer_manager_codes(state->buffer_manager, data, datalen);
            break;
    }


    vx_code_input_stream_destroy(cins);
}
Exemple #18
0
static void
hit_alarm_clock()
{
  static int stay_time = 0;
  static int idle_time = 0;

  time_t now = time(0);
  char buf[100]="\0";

  if(currutmp->pid != currpid)
    setup_utmp(XMODE);   /* 重新配置 shm */

#ifdef  DOTIMEOUT
  if((idle_time = now - currutmp->lastact) > IDLE_TIMEOUT && !HAS_PERM(PERM_RESEARCH))
#else
  if((idle_time = now - currutmp->lastact) > !HAS_PERM(PERM_RESEARCH))
#endif
  {
    outmsg("超過閒置時間!踢出去囉……");
    abort_bbs();
  }

  if (HAS_HABIT(HABIT_MOVIE) && (currstat && (currstat < CLASS || currstat == MAILALL)))
    movie(0);

  alarm(MOVIE_INT);
  stay_time += MOVIE_INT;

#ifdef  DOTIMEOUT
  if(idle_time > IDLE_TIMEOUT - 60 && !HAS_PERM(PERM_RESEARCH)) 
#else
  if(idle_time > 60 && !HAS_PERM(PERM_RESEARCH))
#endif
    sprintf(buf, "警告:您已閒置過久,若無回應,系統即將切離!!");
  else if(stay_time > 10 * 60 && chkmail(0)) 
  {
    sprintf(buf, "\033[1;33;41m[%s] 信箱�媮晹釣S看過的信唷\033[m",
      Etime(&now));
    stay_time = 0 ;
  }
  else if(stay_time > STAY_TIMEOUT && HAS_HABIT(HABIT_ALARM))
  {
    /* 在這裡提示 user 休息一下 */
    char *msg[10] = {
    "伸伸腰, 揉揉眼, 喝口茶....喘口氣...再繼續...!",
    "一邊是友情 一邊是愛情 左右的故事為難著自己...",
    "是否有人瞭解您內心的孤寂? 大家來talk talk吧.. ",
    "左三圈,右三圈,脖子扭扭屁股扭扭 大家來作運動唷~",
    "我灌..我灌..我灌灌灌! 灌到硬碟爆掉...",
    "用•功\•唸•書",
    "書念完了沒啊....^.^",
    "明天有沒有考試啊...念書重要唷...!",
    "看∼流星!",
    "•書在心中氣自皇•讀書去•"};
    int i = rand() % 10;

    sprintf(buf, "[%s] %s", Etime(&now), msg[i]);
    stay_time = 0 ;
  }

  if(buf[0]) 
  {
    outmsg(buf);
    bell();
  }
}
int User::seenMovie(int id) const{
	uint r = userBinarySearch((db->storedUsers + offset), (uint)id, 0, m_size - 1);
	if (movie(r) == id)
		return score(r);
	return -1;
}
Exemple #20
0
int main()
{
	//return test_();

	try
	{
		mysqlhs_init();
		atexit(mysqlhs_end);

		mysqlhs::connection c("127.0.0.1", 9999);
		mysqlhs::index movie(c, "test", "movie", "PRIMARY", "id,genre,title,view_count");

		bool ret = movie.open();
		if (!ret)
		{
			std::cout << "failed to open index\n";
			return 1;
		}

		std::vector<std::string> insert_data;
		//
			insert_data.push_back("0");
			insert_data.push_back("Sci-Fi");
			insert_data.push_back("Star wars");
		//

		for (int i = 0; i < 10; ++i)
		{
			ret = movie.insert(insert_data);
			if (!ret)
			{
				std::cout << "failed to insert\n";
			}
			std::cout << "insert : " << ret << "\n";
		}

		ret = movie.select_where_index('>', 0, 10, 0);
		if (!ret)
		{
			std::cout << "failed to select" << "\n";
		}
		std::cout << "select : " << ret << "\n";

		mysqlhs::result rs(movie);
		std::cout << "num_rows : " << rs.num_rows() << "\n";

		while (rs.fetch())
		{
			std::cout << rs.get<int32_t>("id") << "\n";
			std::cout << rs.get<std::string>("genre") << "\n";
			std::cout << rs.get<std::string>("title") << "\n";
			std::cout << rs.get<int32_t>("view_count") << "\n";
			std::cout << "\n";
		}

		std::vector<std::string> update_data;
		//
			update_data.push_back("11");
			update_data.push_back("Sci-Fi updated");
			update_data.push_back("Star wars updated");
			update_data.push_back("101");
		//

		ret = movie.update_where_index('=', 10, update_data);
		if (!ret)
		{
			std::cout << "failed to update" << "\n";
		}
		std::cout << "update : " << movie.conn().affected_rows() << "\n";

		ret = movie.delete_where_index('=', 9);
		if (!ret)
		{
			std::cout << "failed to delete\n";
		}
		std::cout << "delete : " << movie.conn().affected_rows() << "\n";
	}
	catch (std::exception& e)
	{
		std::cerr << e.what() << std::endl;
	}

	std::cin.get();
	return 0;
}
Exemple #21
0
void
ClipObject::loadImage(QString imgFile, int imgFrame)
{
  if (m_imageName == imgFile && m_imageFrame == imgFrame)
    return;

  m_imageName = imgFile;
  m_imageFrame = imgFrame;

  if (m_imageName.isEmpty())
    {
      m_imageFrame = 0;
      m_imagePresent = false;
      return;
    }

  //----------------
  // file is assumed to be relative to .pvl.nc file
  // get the absolute path
  VolumeInformation pvlInfo = VolumeInformation::volumeInformation();
  QFileInfo fileInfo(pvlInfo.pvlFile);
  QString absoluteImageFile = QFileInfo(fileInfo.absolutePath(),
					m_imageName).absoluteFilePath();
  //----------------

  QFileInfo f(absoluteImageFile);
  if (f.exists() == false)
    {
      m_textureHeight = m_textureWidth = 10;      
      m_imagePresent = true;

      clearCaption();
      return;
    }

  QMovie movie(absoluteImageFile);
  movie.setCacheMode(QMovie::CacheAll);
  movie.start();
  movie.setPaused(true);
  movie.jumpToFrame(0);

  if (movie.jumpToFrame(m_imageFrame) == false)
    movie.jumpToFrame(0);

  QImage mapImage(movie.currentImage());
  m_textureHeight = mapImage.height();
  m_textureWidth = mapImage.width();
  int nbytes = mapImage.byteCount();
  int rgb = nbytes/(m_textureWidth*m_textureHeight);

  unsigned char *image = new unsigned char[rgb*m_textureWidth*m_textureHeight];
  memcpy(image, mapImage.bits(), rgb*m_textureWidth*m_textureHeight);

  GLuint fmt;
  if (rgb == 1) fmt = GL_LUMINANCE;
  else if (rgb == 2) fmt = GL_LUMINANCE_ALPHA;
  else if (rgb == 3) fmt = GL_RGB;
  else if (rgb == 4) fmt = GL_BGRA;

  glActiveTexture(GL_TEXTURE0);
  glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_imageTex);
  glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 
  glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 
  glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexImage2D(GL_TEXTURE_RECTANGLE_ARB,
	       0,
	       rgb,
	       m_textureWidth,
	       m_textureHeight,
	       0,
	       fmt,
	       GL_UNSIGNED_BYTE,
	       image);
  glDisable(GL_TEXTURE_RECTANGLE_ARB);

  delete [] image;

  clearCaption();

  m_imagePresent = true;
}
Exemple #22
0
void SvdOrder::calculateFeaturesByOrder()
{
    qDebug() << "Training";

    // Keep looping until you have passed the maximum number
    // of epochs or have stopped making significant progress
    double prevErr = 1e8;
    double err     = 1e7;
    Movie movie(currDb);
    
    float PROGRESS_INTERVAL = 1; 
    clock_t referTime = clock();

    int numTestsPerUser = 1000;

    for (unsigned int i = 0;
         i < MIN_EPOCHS || 
            (i < MAX_EPOCHS && (prevErr - err) > MIN_IMPROVEMENT);
         i++)
    {
        prevErr = err;
        err = 0;

        User user(currDb,6);
        int numUsers = currDb->totalUsers();

        user.setId(6);

        for (int j = 0; j < numUsers; j++)
        {  
            if (((float) (clock() - referTime)) / CLOCKS_PER_SEC >
                    PROGRESS_INTERVAL)
            {
                qDebug() << j << err / (j + 1);
                referTime = clock(); 
            }
            
            float userErr = 0;
            int numTests = 0;

            // Only process some of the movies per user per epoch. Otherwise,
            // the algorithm takes up alot of time per epoch
            int userIndex = j;
            int userVotes = user.votes();

            
            int thisUserTests = numTestsPerUser;
            if (thisUserTests > userVotes * userVotes)
                thisUserTests = userVotes * userVotes;
 
            for (int testI = 0; testI < thisUserTests; testI++)
            {
                int m1 = rand() % userVotes;
                int m2 = rand() % userVotes;
                 
                int movieIndex1 = user.movie(m1) - 1;
                float rating1 = user.score(m1);

                int movieIndex2 = user.movie(m2) - 1;
                float rating2 = user.score(m2);
                
                // Only do tests on movies that are not the same
                if (rating1 == rating2)
                    continue;
                numTests ++;

                float predict1 = predictRating(movieIndex1, userIndex);
                float predict2 = predictRating(movieIndex2, userIndex);
                
                // This value is positive only when the prediction
                // order was correct
                float ratingDiff  = (rating1 - rating2)/fabs(rating1 - rating2);
                float x = ratingDiff * (predict1 - predict2);

                if (x < 1)
                {
                    // If the prediction was not correct to some
                    // threshold (in this case 1), move the user factors
                    // accordingly to fix it
                    for (unsigned int fI = 0; fI < NUM_FEATURES; fI++)
                    {
                        float oldUF = userFeatures[userIndex][fI];
                        float oldMF1 = movieFeatures[movieIndex1][fI];
                        float oldMF2 = movieFeatures[movieIndex2][fI];

                        userFeatures[userIndex][fI] -=
                            LRATE2 * (-ratingDiff * (oldMF1 - oldMF2) 
                                     + REGULARIZE2 * oldUF);  

                        movieFeatures[movieIndex1][fI] -=
                            LRATE2 * (-ratingDiff * oldUF 
                                     + REGULARIZE2 * oldMF1);

                        movieFeatures[movieIndex2][fI] -=
                            LRATE2 * (ratingDiff * oldUF 
                                     + REGULARIZE2 * oldMF2);
                    } 
                    
                    if (x < 0) 
                        userErr += 1;
                }
            } 

            err += userErr / (numTests + 1);
            user.next();
        }
       

        err /= numUsers;
        qDebug() << "Epoch" << i + 1 << "Error: " << err;
    }                

    qDebug() << "Done with training";
}
Exemple #23
0
bool Overlay::isBusy() const
{
    return movie();
}
void UpdateMediaVolumeInfo::run()
{
    QThread backend;
    backend.start();

    QNetworkAccessManager manager;
    manager.moveToThread(&backend);

    MediaLibrary library(m_log);

    QSqlQuery query;
    query.prepare("SELECT media.id, media.filename, mime_type.name from media LEFT OUTER JOIN mime_type ON media.mime_type=mime_type.id WHERE media.is_reachable=1");

    if (query.exec())
    {
        while (query.next())
        {
            int idMedia = query.record().value("id").toInt();
            QString filename = query.record().value("filename").toString();
            QString mime_type = query.record().value("name").toString();
            QHash<QString, double> volumeInfo = library.volumeInfo(idMedia);

            if (volumeInfo.isEmpty())
            {
                if (mime_type.startsWith("audio/"))
                {
                    qWarning() << "Analyze audio" << filename;

                    DlnaMusicTrackFile track(m_log, filename, "HOST", 80);
                    if (!library.setVolumeInfo(idMedia, track.volumeInfo()))
                        qWarning() << "Unable to set volume information for" << filename;
                }
                else if (mime_type.startsWith("video/")  && !filename.startsWith("http"))
                {
                    qWarning() << "Analyze local video" << filename;

                    DlnaVideoFile movie(m_log, filename, "HOST", 80);
                    if (!library.setVolumeInfo(idMedia, movie.volumeInfo(-1)))
                        qWarning() << "Unable to set volume information for" << filename;
                }
                else if (mime_type.startsWith("video/") && filename.startsWith("http"))
                {
                    qWarning() << "Analyze internet video" << filename;

                    DlnaYouTubeVideo video(m_log, "HOST", 80);
                    video.moveToThread(&backend);
                    video.setNetworkAccessManager(&manager);
                    video.setUrl(filename);
                    bool res = video.waitUrl(30000);

                    if (res && video.isValid())
                    {
                        if (!library.setVolumeInfo(idMedia, video.volumeInfo(-1)))
                            qWarning() << "Unable to set volume information for" << filename;
                    }
                    else
                    {
                        qWarning() << "NO VOLUME INFO (TIMEOUT)" << filename;
                    }

                }
                else
                {
                    qWarning() << "NO VOLUME INFO" << filename;
                }
            }
        }
    }
    else
    {
        qWarning() << "ERROR in request" << query.lastError().text();
    }

    backend.quit();
}
Exemple #25
0
  /*
   *  Vertex update function - computes the least square step
   */
  void update(graphchi_vertex<VertexDataType, EdgeDataType> &vertex, graphchi_context &gcontext) {

    //go over all user nodes
    if (is_user(vertex.id())){
      vertex_data & user = latent_factors_inmem[vertex.id()]; 
      time_svdpp_usr usr(user);

      unsigned int userRatings = vertex.num_outedges();
      double rRuNum = 1/sqrt(userRatings+10);
      int dim = D;
      double sumY = 0.0;

      //go over all ratings
      for(int e=0; e < vertex.num_outedges(); e++) {
        uint pos = vertex.edge(e)->vertex_id();
        assert(pos >= M && pos < M+N);
        vertex_data & data = latent_factors_inmem[pos];
        time_svdpp_movie movie(data);
        Map<vec> y(movie.y, D);
        sumY += sum((const vec&)y); //y
      }

      for( int k=0; k<dim; ++k) {
        usr.ptemp[k] = usr.pu[k] + rRuNum * sumY; // pTemp = pu + rRuNum*sumY
      }
      vec sum = zeros(dim);
      for(int e=0; e < vertex.num_edges(); e++) {  
        //edge_data & edge = scope.edge_data(oedgeid);
        //float rui = edge.weight;
        float rui = vertex.edge(e)->get_data().weight; 
        uint t = (uint)(vertex.edge(e)->get_data().time - 1); // we assume time bins start from 1
        assert(t < M+N+K);
        vertex_data & data = latent_factors_inmem[vertex.edge(e)->vertex_id()];
        time_svdpp_movie mov(data);
        time_svdpp_time time(latent_factors_inmem[t]);
        double pui = 0; 
        time_svdpp_predict(usr, mov, time, rui, pui);
        double eui = rui - pui;
        *usr.bu += tsp.lrate*(eui - tsp.beta* *usr.bu);
        *mov.bi += tsp.lrate * (eui - tsp.beta* *mov.bi);

        for (int k = 0; k < dim; k++) {
          double oldValue = mov.q[k];
          double userValue = usr.ptemp[k] + usr.pu[k] * time.pt[k];
          sum[k] += eui * mov.q[k];
          mov.q[k] += tsp.lrate * (eui * userValue - tsp.gamma*mov.q[k]);
          usr.ptemp[k] += tsp.lrate * ( eui * oldValue - tsp.gamma * usr.ptemp[k]);
          usr.p[k] += tsp.lrate * ( eui * oldValue - tsp.gamma*usr.p[k] );
          usr.pu[k] += tsp.lrate * (eui * oldValue  * time.pt[k] - tsp.gamma * usr.pu[k]);
          time.pt[k] += tsp.lrate * (eui * oldValue * usr.pu[k] - tsp.gamma * time.pt[k]);
          double xOldValue = usr.x[k];
          double zOldValue = time.z[k];
          usr.x[k] += tsp.lrate * (eui * zOldValue - tsp.gamma * xOldValue);
          time.z[k] += tsp.lrate * (eui * xOldValue - tsp.gamma * zOldValue);
        }

         rmse_vec[omp_get_thread_num()] += eui*eui;
      }

      for(int e=0; e < vertex.num_edges(); e++) {  
        time_svdpp_movie mov = latent_factors_inmem[vertex.edge(e)->vertex_id()];
        for(int k=0;k<dim;k++){
          mov.y[k] += tsp.lrate * (rRuNum * sum[k]- tsp.gamma*mov.y[k]);
        }
      }

    }

  };