コード例 #1
0
ファイル: UiPlayVideo.cpp プロジェクト: XeanoRRR/mmo-resourse
int	KUiPlayVideo::OpenVideo(const char* pszVideoFile)
{
	if (m_bInitialized == false || m_Width == 0 || m_Height == 0)
		return false;
	m_nbAlreadyPaintBlack = false;
	CloseVideo(false);
	m_bnk = m_KLVideoOpen(pszVideoFile, 0, g_GetMainHWnd());
	if(!m_bnk)
		return false;

	if(m_Width < (int)m_bnk->Width || m_Height < (int)m_bnk->Height)
	{
		CloseVideo();
		return false;
	}

	m_KLVideoSetSoundVolume(m_bnk, 100);

	for (int i = 0; i < 10000; i++)
	{
		sprintf(m_szBitmapName, "VideoBitmap_%d", i);
		m_uBitmapId = g_pRepresentShell->CreateImage(m_szBitmapName, m_bnk->Width, m_bnk->Height, ISI_T_BITMAP16);
		if (m_uBitmapId)
			break;
	}

	if (m_uBitmapId)
	{
		m_uBitmapIsPosition = IMAGE_IS_POSITION_INIT;
		g_pRepresentShell->ClearImageData(m_szBitmapName, m_uBitmapId, m_uBitmapIsPosition);

		m_nBlackHeight = m_bnk->Height  * m_Width / m_bnk->Width;
		if (m_nBlackHeight <= m_Height)
		{
			m_nBlackHeight = (m_Height - m_nBlackHeight) / 2;
		}
		else
		{
			m_nBlackHeight = 0;
			m_nBlackWidth = m_bnk->Width * m_Height / m_bnk->Height;
			if (m_nBlackWidth < m_Width)
			{
				m_nBlackWidth = (m_Width - m_nBlackWidth) / 2;
			}
			else
			{
				m_nBlackWidth = 0;
			}
		}

		return true;
	}

	CloseVideo();
	return false;
}
コード例 #2
0
ファイル: UiPlayVideo.cpp プロジェクト: XeanoRRR/mmo-resourse
void KUiPlayVideo::Breathe()
{
	if(!m_bnk)
		return;

	KBitmapDataBuffInfo bufInfo;
	void *pBuf = g_pRepresentShell->GetBitmapDataBuffer(m_szBitmapName, &bufInfo);
	if(!pBuf)
		return;

	unsigned int uFormat;
	if (bufInfo.eFormat == DBDF_24BIT)
		uFormat = KLVIDEOSURFACE24;
	else if (bufInfo.eFormat == BDBF_16BIT_565)
		uFormat = KLVIDEOSURFACE565;
	else// if (bufInfo.eFormat == BDBF_16BIT_555)
		uFormat = KLVIDEOSURFACE555;
	m_KLVideoToBuffer(m_bnk, pBuf, 0, 0, bufInfo.nPitch, m_bnk->Height, uFormat);

	g_pRepresentShell->ReleaseBitmapDataBuffer(m_szBitmapName,pBuf);

	if(m_bnk->FrameNum >= m_bnk->Frames)
	{
		CloseVideo();
	}
}
コード例 #3
0
ファイル: ffplayer.cpp プロジェクト: github188/SPlayer
bool ffplayer::OpenVideoCode()
{
	if (m_videoStream == -1)
	{
		return false;
	}
	// Get a pointer to the codec context for the video stream
	m_pCodecCtx = m_pFormatCtx->streams[m_videoStream]->codec;

	// Find the decoder for the video stream
	AVCodec *pCodec = avcodec_find_decoder(m_pCodecCtx->codec_id);

	if (pCodec == NULL)
	{
		//	m_errorMsg = "Could not find a video decoder";
		CloseVideo();
		return false;
	}

	// Open the codec
	if (avcodec_open2(m_pCodecCtx, pCodec, 0) < 0)
	{
		//	m_errorMsg = "Could not open the video decoder";
		CloseVideo();
		return false;
	}

	m_iWidth = m_pCodecCtx->width;
	m_iHeight = m_pCodecCtx->height;
	// Allocate video frames
	m_pFrame = av_frame_alloc();

	if (!m_pFrame)
	{
		//	m_errorMsg = "Could not allocate memory for a frame";
		CloseVideo();
		return false;
	}

	m_fps = (float)(m_pFormatCtx->streams[m_videoStream]->r_frame_rate.num) / (float)(m_pFormatCtx->streams[m_videoStream]->r_frame_rate.den) + 0.5f;
	
	return true;

}
コード例 #4
0
ファイル: UiPlayVideo.cpp プロジェクト: XeanoRRR/mmo-resourse
void KUiPlayVideo::Terminate()
{
	CloseVideo();

	if(m_hVideoDll)
	{
		FreeLibrary(m_hVideoDll);
		m_hVideoDll = NULL;
	}
	m_bInitialized = false;
}
コード例 #5
0
ファイル: ffplayer.cpp プロジェクト: github188/SPlayer
void ffplayer::Close()
{
	CloseAudio();
	CloseVideo();

	// Close the video file
	if (m_pFormatCtx)
		avformat_close_input(&m_pFormatCtx);

	m_pFormatCtx = 0;
	
}
コード例 #6
0
ファイル: UiPlayVideo.cpp プロジェクト: XeanoRRR/mmo-resourse
//--------------------------------------------------------------------------
//	功能:输入处理消息以及一些特定窗口消息的响应
//--------------------------------------------------------------------------
int KUiPlayVideo::WndProc(unsigned int uMsg, unsigned int uParam, int nParam)
{
	int nRet = 0;

	switch(uMsg)
	{
	case WM_KEYDOWN:
		if (m_bProcessInput && m_bnk &&
			(uParam == VK_ESCAPE || uParam == VK_RETURN || uParam == VK_SPACE))
		{
			CloseVideo();
		}
		break;
	case WM_LBUTTONDOWN:
		if (m_bProcessInput && m_bnk)
			CloseVideo();
		break;
	default:
		nRet = KWndWindow::WndProc(uMsg, uParam, nParam);
		break;
	}
	return nRet;
}
コード例 #7
0
ファイル: project.cpp プロジェクト: Aegisub/Aegisub
void Project::LoadUnloadFiles(ProjectProperties properties) {
	auto load_linked = OPT_GET("App/Auto/Load Linked Files")->GetInt();
	if (!load_linked) return;

	auto audio     = context->path->MakeAbsolute(properties.audio_file, "?script");
	auto video     = context->path->MakeAbsolute(properties.video_file, "?script");
	auto timecodes = context->path->MakeAbsolute(properties.timecodes_file, "?script");
	auto keyframes = context->path->MakeAbsolute(properties.keyframes_file, "?script");

	if (video == video_file && audio == audio_file && keyframes == keyframes_file && timecodes == timecodes_file)
		return;

	if (load_linked == 2) {
		wxString str = _("Do you want to load/unload the associated files?");
		str += "\n";

		auto append_file = [&](agi::fs::path const& p, wxString const& unload, wxString const& load) {
			if (p.empty())
				str += "\n" + unload;
			else
				str += "\n" + agi::wxformat(load, p);
		};

		if (audio != audio_file)
			append_file(audio, _("Unload audio"), _("Load audio file: %s"));
		if (video != video_file)
			append_file(video, _("Unload video"), _("Load video file: %s"));
		if (timecodes != timecodes_file)
			append_file(timecodes, _("Unload timecodes"), _("Load timecodes file: %s"));
		if (keyframes != keyframes_file)
			append_file(keyframes, _("Unload keyframes"), _("Load keyframes file: %s"));

		if (wxMessageBox(str, _("(Un)Load files?"), wxYES_NO | wxCENTRE, context->parent) != wxYES)
			return;
	}

	bool loaded_video = false;
	if (video != video_file) {
		if (video.empty())
			CloseVideo();
		else if ((loaded_video = DoLoadVideo(video))) {
			auto vc = context->videoController.get();
			vc->JumpToFrame(properties.video_position);

			auto ar_mode = static_cast<AspectRatio>(properties.ar_mode);
			if (ar_mode == AspectRatio::Custom)
				vc->SetAspectRatio(properties.ar_value);
			else
				vc->SetAspectRatio(ar_mode);
			context->videoDisplay->SetZoom(properties.video_zoom);
		}
	}

	if (!timecodes.empty()) LoadTimecodes(timecodes);
	if (!keyframes.empty()) LoadKeyframes(keyframes);

	if (audio != audio_file) {
		if (audio.empty())
			CloseAudio();
		else
			DoLoadAudio(audio, false);
	}
	else if (loaded_video && OPT_GET("Video/Open Audio")->GetBool() && audio_file != video_file && video_provider->HasAudio())
		DoLoadAudio(video, true);
}