当前位置: 首页>>代码示例>>C++>>正文


C++ VideoDecoder::start方法代码示例

本文整理汇总了C++中video::VideoDecoder::start方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoDecoder::start方法的具体用法?C++ VideoDecoder::start怎么用?C++ VideoDecoder::start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在video::VideoDecoder的用法示例。


在下文中一共展示了VideoDecoder::start方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: playVideo

void PrinceEngine::playVideo(Common::String videoFilename) {
        // Set the correct video mode
        initGraphics(640, 480, true, 0);
        if (_system->getScreenFormat().bytesPerPixel == 1) {
                warning("Couldn't switch to a RGB color video mode to play a video.");
                return;
        }

        debug(2, "Screen format: %s", _system->getScreenFormat().toString().c_str());

	Video::VideoDecoder *videoDecoder = new Video::AVIDecoder();
	if (!videoDecoder->loadFile(videoFilename)) {
		delete videoDecoder;
		warning("Unable to open video %s", videoFilename.c_str());
		initGraphics(640, 480, true);
		return;
	}

	videoDecoder->start();

	bool skipVideo = false;

	while (!shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) {
		if (videoDecoder->needsUpdate()) {
			const Graphics::Surface *frame = videoDecoder->decodeNextFrame();
			if (frame) {
				if (frame->format.bytesPerPixel > 1) {
					Graphics::Surface *frame1 = frame->convertTo(_system->getScreenFormat());
					_system->copyRectToScreen(frame1->getPixels(), frame1->pitch, 0, 0, frame1->w, frame1->h);
					frame1->free();
					delete frame1;
				} else {
					_system->copyRectToScreen(frame->getPixels(), frame->pitch, 0, 0, frame->w, frame->h);
				}
				_system->updateScreen();
			}
		}

		Common::Event event;
		while (_system->getEventManager()->pollEvent(event)) {
			if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) ||
				event.type == Common::EVENT_LBUTTONUP)
				skipVideo = true;
		}

		_system->delayMillis(10);
	}

	delete videoDecoder;

	initGraphics(640, 480, true);
}
开发者ID:86400,项目名称:scummvm,代码行数:52,代码来源:videoplayer.cpp

示例2: playVideo

void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect, bool skippable, Subtitle *sub) {
	Common::Rect dst = destRect;
	// If destRect is empty, no specific scaling was requested. However, we may choose to do scaling anyway
	if (dst.isEmpty())
		dst = Common::Rect(vid.getWidth(), vid.getHeight());

	Graphics::Surface scaled;

	if (vid.getWidth() != dst.width() || vid.getHeight() != dst.height())
		scaled.create(dst.width(), dst.height(), vid.getPixelFormat());

	uint16 x = _workingWindow.left + dst.left;
	uint16 y = _workingWindow.top + dst.top;
	uint16 finalWidth = dst.width() < _workingWindow.width() ? dst.width() : _workingWindow.width();
	uint16 finalHeight = dst.height() < _workingWindow.height() ? dst.height() : _workingWindow.height();
	bool showSubs = (_scriptManager->getStateValue(StateKey_Subtitles) == 1);

	_clock.stop();
	vid.start();
	_videoIsPlaying = true;

	// Only continue while the video is still playing
	while (!shouldQuit() && !vid.endOfVideo() && vid.isPlaying()) {
		// Check for engine quit and video stop key presses
		while (_eventMan->pollEvent(_event)) {
			switch (_event.type) {
			case Common::EVENT_KEYDOWN:
				switch (_event.kbd.keycode) {
				case Common::KEYCODE_q:
					if (_event.kbd.hasFlags(Common::KBD_CTRL))
						quitGame();
					break;
				case Common::KEYCODE_SPACE:
					if (skippable) {
						vid.stop();
					}
					break;
				default:
					break;
				}
			default:
				break;
			}
		}

		if (vid.needsUpdate()) {
			const Graphics::Surface *frame = vid.decodeNextFrame();
			if (sub && showSubs)
				sub->process(vid.getCurFrame());

			if (frame) {
				if (scaled.getPixels()) {
					_renderManager->scaleBuffer(frame->getPixels(), scaled.getPixels(), frame->getWidth(), frame->getHeight(), frame->getFormat().bytesPerPixel, scaled.getWidth(), scaled.getHeight());
					frame = &scaled;
				}
				Common::Rect rect = Common::Rect(x, y, x + finalWidth, y + finalHeight);
				_renderManager->copyToScreen(*frame, rect, 0, 0);
				_renderManager->processSubs(0);
			}
		}

		// Always update the screen so the mouse continues to render
		_system->updateScreen();

		_system->delayMillis(vid.getTimeToNextFrame() / 2);
	}

	_videoIsPlaying = false;
	_clock.start();
}
开发者ID:project-cabal,项目名称:cabal,代码行数:70,代码来源:video.cpp

示例3: playVideo

void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect, bool skippable) {
	byte bytesPerPixel = videoDecoder.getPixelFormat().bytesPerPixel;

	uint16 origWidth = videoDecoder.getWidth();
	uint16 origHeight = videoDecoder.getHeight();

	uint scale = 1;
	// If destRect is empty, no specific scaling was requested. However, we may choose to do scaling anyway
	if (destRect.isEmpty()) {
		// Most videos are very small. Therefore we do a simple 2x scale
		if (origWidth * 2 <= 640 && origHeight * 2 <= 480) {
			scale = 2;
		}
	} else {
		// Assume bilinear scaling. AKA calculate the scale from just the width.
		// Also assume that the scaling is in integral intervals. AKA no 1.5x scaling
		// TODO: Test ^these^ assumptions
		scale = destRect.width() / origWidth;

		// TODO: Test if we need to support downscale.
	}

	uint16 pitch = origWidth * bytesPerPixel;

	uint16 finalWidth = origWidth * scale;
	uint16 finalHeight = origHeight * scale;

	byte *scaledVideoFrameBuffer;
	if (scale != 1) {
		scaledVideoFrameBuffer = new byte[finalWidth * finalHeight * bytesPerPixel];
	}

	uint16 x = ((WINDOW_WIDTH - finalWidth) / 2) + destRect.left;
	uint16 y = ((WINDOW_HEIGHT - finalHeight) / 2) + destRect.top;

	_clock.stop();
	videoDecoder.start();

	// Only continue while the video is still playing
	while (!shouldQuit() && !videoDecoder.endOfVideo() && videoDecoder.isPlaying()) {
		// Check for engine quit and video stop key presses
		while (!videoDecoder.endOfVideo() && videoDecoder.isPlaying() && _eventMan->pollEvent(_event)) {
			switch (_event.type) {
			case Common::EVENT_KEYDOWN:
				switch (_event.kbd.keycode) {
				case Common::KEYCODE_q:
					if (_event.kbd.hasFlags(Common::KBD_CTRL))
						quitGame();
					break;
				case Common::KEYCODE_SPACE:
					if (skippable) {
						videoDecoder.stop();
					}
					break;
				default:
					break;
				}
			default:
				break;
			}
		}

		if (videoDecoder.needsUpdate()) {
			const Graphics::Surface *frame = videoDecoder.decodeNextFrame();

			if (frame) {
				if (scale != 1) {
					scaleBuffer((const byte *)frame->getPixels(), scaledVideoFrameBuffer, origWidth, origHeight, bytesPerPixel, scale);
					_system->copyRectToScreen(scaledVideoFrameBuffer, pitch * 2, x, y, finalWidth, finalHeight);
				} else {
					_system->copyRectToScreen((const byte *)frame->getPixels(), pitch, x, y, finalWidth, finalHeight);
				}
			}
		}

		// Always update the screen so the mouse continues to render
		_system->updateScreen();

		_system->delayMillis(videoDecoder.getTimeToNextFrame());
	}

	_clock.start();

	if (scale != 1) {
		delete[] scaledVideoFrameBuffer;
	}
}
开发者ID:jaeyeonkim,项目名称:scummvm-kor,代码行数:87,代码来源:video.cpp


注:本文中的video::VideoDecoder::start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。