void play_video(HINSTANCE hInstance, int videoId) { String movieFileStr; movieFileStr = DIR_MOVIE; if( videoId == 0 ) { movieFileStr += "intro.mpg"; } else { movieFileStr += "movie"; movieFileStr += videoId; movieFileStr += ".avi"; } video.set_skip_on_fail(); if( m.is_file_exist(movieFileStr) ) { //---------- play the movie now ---------// video.init(); if( video.init_success ) { video.play_until_end( movieFileStr, hInstance, 60 ); } video.deinit(); } }
static void play_video(HINSTANCE hInstance, int videoId) { String movieFileStr; // movieFileStr = DIR_MOVIE; if( videoId == 0 ) { movieFileStr += "INTRO.AVI"; } else { movieFileStr += "MOVIE"; movieFileStr += videoId; movieFileStr += ".AVI"; } video.set_skip_on_fail(); if( m.is_file_exist(movieFileStr) ) { //---------- play the movie now ---------// video.init(); if( video.init_success ) { video.play_until_end( movieFileStr, hInstance, 60 ); } else { // display a message box (note:sys.main_hwnd is not valid) // MessageBox( NULL, "Cannot initialize ActiveMovie", // "Virtual U", MB_OK | MB_ICONWARNING | MB_DEFBUTTON1 | MB_TASKMODAL ); } video.deinit(); } }
void PCACloudReducer::analyse(const CloudAction & c){ Video flatten; for (const Video & v: c._landmarks){ flatten.insert(flatten.end(),v.begin(),v.end()); } _pca = std::unique_ptr<PCA_Result<66>>(new PCA_Result<66>(std::move(computePCA<66>(flatten)))); }
bool D3D9Sprite::CreateRenderTarget( VideoWeakPtr video, const unsigned int width, const unsigned int height, const Texture::TARGET_FORMAT format) { if (m_type != Sprite::T_NOT_LOADED && m_type != Sprite::T_RELOAD) { m_video.lock()->Message(L"The sprite can't be loaded twice - D3D9Sprite::CreateRenderTarget"); return false; } m_video = video; Video* pVideo = m_video.lock().get(); const unsigned int screenX = static_cast<unsigned int>(pVideo->GetScreenSize().x); const unsigned int screenY = static_cast<unsigned int>(pVideo->GetScreenSize().y); if (width > screenX || height > screenY) { pVideo->Message(L"The render target surface size can't be greater than the backbuffer - D3D9Sprite::CreateRenderTarget"); return false; } m_texture = pVideo->CreateRenderTargetTexture(width, height, format); if (!m_texture) return false; m_size = Vector2(static_cast<float>(width), static_cast<float>(height)); D3D9Video::RENDER_TARGET target(this, width, height, format); D3D9Video::AddToTargetList(target); m_type = Sprite::T_TARGET; m_targetFormat = format; SetupSpriteRects(1, 1); return GetInternalData(); }
void SDL_Window::applySettings(const WindowSettings& settings) throw (Exception){ Video *video = Video::getInstance(); VideoSettings videoSettings = video->currentSettings(); SDL_VideoSettings sdlVideoSettings(videoSettings); SDL_WindowSettings sdlWindowSettings(settings); Uint32 videoFlags = sdlVideoSettings.getFlags(); Uint32 windowFlags = sdlWindowSettings.getFlags(); Uint32 flags = videoFlags | windowFlags; int bitsPerPixel = sdlWindowSettings.getBitsPerPixel(); surface = SDL_SetVideoMode(settings.width, settings.height, bitsPerPixel, flags); if (surface == NULL){ throw Exception("Error on SDL_SetVideoMode()"); } if (canvas) delete canvas; canvas = new SDL_Canvas(); if (!canvas){ throw Exception("Sem memoria"); } SDL_WM_SetCaption(sdlWindowSettings.title.c_str(), NULL); this->settings = settings; }
/* FUNCTION: ViewObject :: DragDrop ARGUMENTS: none RETURN: n/a DESCRIPTION: Hook function called when user drops files in application window. Essentially, determine if file is image or video. */ void ViewObject :: DragDrop(entry_ref *ref, float mouse_x, float mouse_y) { // Image file? BPath path(ref); BBitmap *bitmap = BTranslationUtils::GetBitmap(path.Path(), NULL); if (bitmap) { MediaSource *media = new MediaSource(this); GLCreateTexture(media, bitmap); if (!SurfaceUpdate(media, mouse_x, mouse_y)) delete media; delete bitmap; return; } // Video file Video *video = new Video(ref); if (video->GetStatus() == B_OK) { MediaSource *media = new MediaSource(this); GLCreateTexture(media, video->GetBitmap()); media->SetVideo(video); if (SurfaceUpdate(media, mouse_x, mouse_y)) video->Start(); else delete media; return; } else delete video; printf("Unsupported file\n"); }
int main() { try { std::string vert_src = LoadFile("normal.vert.glsl"); std::string frag_src = LoadFile("normal.frag.glsl"); Shader *vert = new Shader(GL_VERTEX_SHADER, vert_src.c_str()); Shader *frag = new Shader(GL_FRAGMENT_SHADER, frag_src.c_str()); _vid.AddShader(0, vert, frag); delete vert; delete frag; auto tile = std::unique_ptr<Texture>(new Texture("tile.png")); for (int x = -64; x + tile->width < _vid.width; x += 64) { for (int y = -64; y + tile->height < _vid.height; y += 16) { int x1 = x; if (y % 32 == 0) x1 -= 32; _sprite_container.objects.emplace_back(tile.get(), x1, y); } } auto icecream = std::unique_ptr<Texture>(new Texture("icecream.png", "icecream_mask.png")); _sprite_container.objects.emplace_back(icecream.get(), 544, 256); _vid.Loop(); } catch (const std::runtime_error &e) { std::cerr << e.what() << std::endl; return 1; } return 0; }
std::string saveScreenTga(const Video& video) { Int32 num = 0; std::string name; // Vyhledani cisla pod ktere ukladat while (num < 1000) { num++; name = Format("screenshot_{0}.tga") << num; if (!File::exists(name)) { break; } } // Maximalne 1000 screenshotu if (num >= 1000) { D6_THROW(IoException, "Maximum number of 1000 screenshots reached"); } Image image(video.getScreen().getClientWidth(), video.getScreen().getClientHeight()); glReadPixels(0, 0, video.getScreen().getClientWidth(), video.getScreen().getClientHeight(), GL_RGBA, GL_UNSIGNED_BYTE, &image.at(0)); saveTarga(name, image); return name; }
// Draw fog on the small bitmap void MapControl::DrawFog(unsigned short XWin, unsigned short YWin) { Video *video = core->GetVideoDriver(); Region old_clip; video->GetClipRect(old_clip); Region r( XWin + XPos, YWin + YPos, Width, Height ); video->SetClipRect(&r); // FIXME: this is ugly, the knowledge of Map and ExploredMask // sizes should be in Map.cpp int w = MyMap->GetWidth() / 2; int h = MyMap->GetHeight() / 2; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { Point p( (short) (MAP_MULT * x), (short) (MAP_MULT * y) ); bool visible = MyMap->IsVisible( p, true ); if (! visible) { Region rgn = Region ( MAP_TO_SCREENX(MAP_DIV * x), MAP_TO_SCREENY(MAP_DIV * y), MAP_DIV, MAP_DIV ); video->DrawRect( rgn, colors[black] ); } } } video->SetClipRect(&old_clip); }
bool VideoPlayer::reopenVideo(Video &video) { if (video.isEmpty()) return true; if (video.fileName.empty()) { video.close(); return false; } Properties properties; properties.type = video.properties.type; Common::String fileName = findFile(video.fileName, properties); if (fileName.empty()) { video.close(); return false; } Common::SeekableReadStream *stream = _vm->_dataIO->getFile(fileName); if (!stream) { video.close(); return false; } if (!video.decoder->reloadStream(stream)) { delete stream; return false; } return true; }
void STWarp<T>::computePartialDerivatives( const WarpingField<T> &warpField, Video<T> &Bx, Video<T> &By, Video<T> &Bt, Video<T> &C) { VideoProcessing::dx(*videoB,Bx,true); VideoProcessing::dy(*videoB,By,true); VideoProcessing::dt(*videoB,Bt,true); Video<stwarp_video_t> warpedB(videoA->size()); C.copy(*videoA); VideoProcessing::backwardWarp(*videoB,warpField,warpedB); C.subtract(warpedB); // TODO: out of bounds set to 0 Video<T> temp(videoA->size()); VideoProcessing::backwardWarp(Bx,warpField,temp); Bx.copy(temp); temp.reset(0); VideoProcessing::backwardWarp(By,warpField,temp); By.copy(temp); temp.reset(0); if( !params.bypassTimeWarp ){ VideoProcessing::backwardWarp(Bt,warpField,temp); } Bt.copy(temp); }
void GlobalTimer::DoFadeStep(ieDword count) { Video *video = core->GetVideoDriver(); if (fadeToCounter) { fadeToCounter-=count; if (fadeToCounter<0) { fadeToCounter=0; } video->SetFadePercent( ( ( fadeToMax - fadeToCounter ) * 100 ) / fadeToMax ); //bug/patch #1837747 made this unneeded //goto end; //hmm, freeze gametime? } //i think this 'else' is needed now because of the 'goto' cut above else if (fadeFromCounter!=fadeFromMax) { if (fadeFromCounter>fadeFromMax) { fadeFromCounter-=count; if (fadeFromCounter<fadeFromMax) { fadeFromCounter=fadeFromMax; } //don't freeze gametime when already dark } else { fadeFromCounter+=count; if (fadeToCounter>fadeFromMax) { fadeToCounter=fadeFromMax; } video->SetFadePercent( ( ( fadeFromMax - fadeFromCounter ) * 100 ) / fadeFromMax ); //bug/patch #1837747 made this unneeded //goto end; //freeze gametime? } } if (fadeFromCounter==fadeFromMax) { video->SetFadePercent( 0 ); } }
/* FUNCTION: Video :: VideoThread ARGUMENTS: cookie RETURN: thread exit status DESCRIPTION: Video playback thread */ int32 Video :: VideoThread(void *cookie) { Video *video = (Video *) cookie; if (video->fVideoTrack == NULL) { exit_thread(B_ERROR); return B_ERROR; } float frames_per_second = (float)video->fVideoTrack->CountFrames() / (float)video->fVideoTrack->Duration() * 1000000.0f; bigtime_t frame_time = (bigtime_t) (1000000.0f / frames_per_second); video->fPerformanceTime = real_time_clock_usecs() + frame_time; status_t err = B_OK; printf("frame_rate = %f\n", frames_per_second); while (1) { err = video->ShowNextFrame(); bigtime_t zzz = video->fPerformanceTime - real_time_clock_usecs(); if (zzz < 0) zzz = 1; video->fPerformanceTime += frame_time; snooze(zzz); } exit_thread(err); return err; }
Scheme_Object *video_tcoords(int argc, Scheme_Object **argv) { Scheme_Object *ret = NULL; Scheme_Object **coord_list = NULL; MZ_GC_DECL_REG(2); MZ_GC_VAR_IN_REG(0, argv); MZ_GC_VAR_IN_REG(1, coord_list); MZ_GC_REG(); if (!SCHEME_NUMBERP(argv[0])) scheme_wrong_type("video-tcoords", "number", 0, argc, argv); Video *v = find_video("video-tcoords", argv[0]); if (v != NULL) { coord_list = (Scheme_Object **)scheme_malloc(4 * sizeof(Scheme_Object *)); float *coords = v->get_tcoords(); coord_list[0] = scheme_vector(coords[0], coords[4], coords[2]); coord_list[1] = scheme_vector(coords[3], coords[4], coords[5]); coord_list[2] = scheme_vector(coords[3], coords[1], coords[5]); coord_list[3] = scheme_vector(coords[0], coords[1], coords[2]); ret = scheme_build_list(4, coord_list); } else { ret = scheme_void; } MZ_GC_UNREG(); return ret; }
void AnimationManager::FinishUpdateLoadedTextures(string newLocationId) { for (map<string, Video *>::iterator iter = videoByIdMap.begin(); iter != videoByIdMap.end(); ++iter) { bool loadSprite = false; bool deleteSprite = false; string videoId = iter->first; Video *pVideo = iter->second; if (pVideo == NULL) { continue; } pVideo->UpdateReadiness(newLocationId, &loadSprite, &deleteSprite); if (loadSprite) { ResourceLoader::GetInstance()->AddVideoToLoadList(pVideo); } else if (deleteSprite) { ResourceLoader::GetInstance()->AddVideoToDeleteList(pVideo); } } }
Scheme_Object *video_load(int argc, Scheme_Object **argv) { char *filename = NULL; MZ_GC_DECL_REG(2); MZ_GC_VAR_IN_REG(0, argv); MZ_GC_VAR_IN_REG(1, filename); MZ_GC_REG(); if (!SCHEME_CHAR_STRINGP(argv[0])) scheme_wrong_type("video-load", "string", 0, argc, argv); filename = scheme_utf8_encode_to_buffer(SCHEME_CHAR_STR_VAL(argv[0]), SCHEME_CHAR_STRLEN_VAL(argv[0]), NULL, 0); Video *v; map<string, Video *>::iterator i = VideoFilenames.find(filename); if (i != VideoFilenames.end()) v = i->second; else { v = new Video(filename); Videos[v->get_texture_id()] = v; VideoFilenames[filename] = v; } MZ_GC_UNREG(); return scheme_make_integer_value(v->get_texture_id()); }
bool MotionSpecialTest() { Video video; if (SOURCE.length() == 0) { TEST_LOG_SS(Error, "Video source is undefined (-s parameter)!"); return false; } if(!video.SetSource(SOURCE)) { TEST_LOG_SS(Error, "Can't open video file '" << SOURCE << "'!"); return false; } Filter filter; video.SetFilter(&filter); video.Start(); #ifdef TEST_PERFORMANCE_TEST_ENABLE TEST_LOG_SS(Info, PerformanceMeasurerStorage::s_storage.Report(false, true)); PerformanceMeasurerStorage::s_storage.Clear(); #endif return true; }
int main(int argc, char **argv) { Video *input = NULL; int width, height, time; if (argc<4) { cout << "Usage: t_adaptive_scaling <input_folder> <ratio> <output_folder>" << endl; return 0; //default parameters } double ratio = atof(argv[2]); // load input video cout << "Loading input video..." << endl; input = new Video(argv[1]); //vpyramid = VideoPyramid(input); // simple calculation of motion energy of every frame double *gradient = MotionEnergy(input,0.0); //double *energy = SmoothMotionEnergy(gradient,input->GetTime(),5); cout << "Adaptively scaling video ..." << endl; AdaptiveTemporalReduce(input, gradient, ceil(input->GetTime()*ratio),argv[3]); delete gradient; delete input; }
void STWarp<T>::buildPyramid(vector<vector<int> > pyrSizes, vector<Video<stwarp_video_t>*> &pyramidA, vector<Video<stwarp_video_t>*> &pyramidB ) const{ int n = pyrSizes.size(); if(params.verbosity > 0) { printf("+ Building ST-pyramids with %d levels...",n); } pyramidA[0] = videoA; pyramidB[0] = videoB; Video<stwarp_video_t> copy; for (int i = 1; i < n; ++i) { pyramidA[i] = new Video<stwarp_video_t>(pyrSizes[i][0], pyrSizes[i][1],pyrSizes[i][2],dimensions[3]); pyramidB[i] = new Video<stwarp_video_t>(pyrSizes[i][0], pyrSizes[i][1],pyrSizes[i][2],dimensions[3]); // Lowpass and downsample copy.copy(*pyramidA[i-1]); VideoProcessing::resize(copy,pyramidA[i]); copy.copy(*pyramidB[i-1]); VideoProcessing::resize(copy,pyramidB[i]); } if(params.verbosity >0) { printf("done.\n"); } }
bool Scene::drawCutscene() { if (_cutscene.isPlaying()) { if (_cutscene.hasNewFrame()) { DGFrame* frame = _cutscene.currentFrame(); _cutsceneTexture->loadRawData(frame->data, frame->width, frame->height); } _cutsceneTexture->bind(); // Note this is inverted float coords[] = { 0, 0, float(config.displayWidth), 0, float(config.displayWidth), float(config.displayHeight), 0, float(config.displayHeight) }; renderManager.enablePostprocess(); cameraManager.beginOrthoView(); renderManager.enableTextures(); renderManager.drawSlide(coords); renderManager.disablePostprocess(); renderManager.drawPostprocessedView(); return true; } return false; }
void Sprite::Draw( void ) { Video *video = Video::Instance(); Trig *trig = Trig::Instance(); Camera *camera = Camera::Instance(); if( !video->OutOfBounds( sx, sy ) ) image->DrawCentered( sx, sy, trig->RadToDeg( ang ) - trig->RadToDeg( (1.57 - camera->GetAngle() ) ) ); }
void AcceptPagedPoolMemWarningCallback() { Video *self = static_cast<Video*>( CBaseModPanel::GetSingleton().GetWindow( WT_VIDEO ) ); if( self ) { self->OpenPagedPoolMem(); } }
int Font::PrintInitial(int x, int y, const Region &rgn, unsigned char currChar) const { Video *video = core->GetVideoDriver(); video->BlitSpriteRegion( sprBuffer, size[currChar], x + rgn.x, y + rgn.y - yPos[currChar], true, &rgn ); x += size[currChar].w; return x; }
bool VideoPlayer::closeVideo(int slot) { Video *video = getVideoBySlot(slot); if (!video) return false; video->close(); return true; }
void MediaView::copyVideoLink() { Video *video = playlistModel->activeVideo(); if (!video) return; QApplication::clipboard()->setText(video->getStreamUrl()); QString message = tr("You can now paste the video stream URL into another application") + ". " + tr("The link will be valid only for a limited time."); MainWindow::instance()->showMessage(message); }
void MediaView::copyWebPage() { Video *video = playlistModel->activeVideo(); if (!video) return; QString address = video->getWebpage(); QApplication::clipboard()->setText(address); QString message = tr("You can now paste the YouTube link into another application"); MainWindow::instance()->showMessage(message); }
int Font::PrintInitial(int x, int y, const Region &rgn, unsigned char currChar) const { Video *video = core->GetVideoDriver(); video->BlitSpriteRegion( sprBuffer, getInfo(currChar).size, x + rgn.x, y + rgn.y - getInfo(currChar).yPos, true, &rgn ); x += getInfo(currChar).size.w; return x; }
Font::~Font(void) { Video *video = core->GetVideoDriver(); video->FreeSprite( sprBuffer ); SetPalette(NULL); free(resRefs); }
void MediaView::openWebPage() { Video *video = playlistModel->activeVideo(); if (!video) return; media->pause(); QString url = video->getWebpage() + QLatin1String("&t=") + QString::number(media->position() / 1000); QDesktopServices::openUrl(url); }
void VideoDetailsModel::retriveRealUrl() { Video *video = new Video; QUrl videoUrl(m_videoUrl); video->setWebpage(videoUrl); video->loadStreamUrl(); connect(video, SIGNAL(gotStreamUrl(QUrl)), this, SLOT(streamUrl(QUrl))); }