Esempio n. 1
0
void FFMS_VideoSource::SetPP(const char *PP) {

#ifdef FFMS_USE_POSTPROC
	if (PPMode)
		pp_free_mode(PPMode);
	PPMode = NULL;

	if (PP != NULL && strcmp(PP, "")) {
		// due to a parsing bug in libpostproc it can read beyond the end of a string
		// adding a ',' prevents the bug from manifesting
		// libav head 2011-08-26
		std::string s = PP;
		s.append(",");
		PPMode = pp_get_mode_by_name_and_quality(s.c_str(), PP_QUALITY_MAX);
		if (!PPMode) {
			ResetPP();
			throw FFMS_Exception(FFMS_ERROR_POSTPROCESSING, FFMS_ERROR_INVALID_ARGUMENT,
				"Invalid postprocesing settings");
		}
		
	}

	ReAdjustPP(CodecContext->pix_fmt, CodecContext->width, CodecContext->height);
	OutputFrame(DecodeFrame);
#else
	throw FFMS_Exception(FFMS_ERROR_POSTPROCESSING, FFMS_ERROR_UNSUPPORTED,
		"FFMS2 was not compiled with postprocessing support");
#endif /* FFMS_USE_POSTPROC */
}
Esempio n. 2
0
void CCameraManager::ApplyDevice (float _viewport_near)
{
	// Device params
	Device.mView.build_camera_dir(m_cam_info.p, m_cam_info.d, m_cam_info.n);

	Device.vCameraPosition.set	( m_cam_info.p );
	Device.vCameraDirection.set	( m_cam_info.d );
	Device.vCameraTop.set		( m_cam_info.n );
	Device.vCameraRight.set		( m_cam_info.r );

	// projection
	Device.fFOV					= m_cam_info.fFov;
	Device.fASPECT				= m_cam_info.fAspect;
	Device.mProject.build_projection(deg2rad(m_cam_info.fFov), m_cam_info.fAspect, _viewport_near, m_cam_info.fFar);

	if( g_pGamePersistent && g_pGamePersistent->m_pMainMenu->IsActive() )
		ResetPP					();
	else
	{
		pp_affected.validate		("apply device");
		// postprocess
		IRender_Target*		T		= ::Render->getTarget();
		T->set_duality_h			(pp_affected.duality.h);
		T->set_duality_v			(pp_affected.duality.v);
		T->set_blur					(pp_affected.blur);
		T->set_gray					(pp_affected.gray);
		T->set_noise				(pp_affected.noise.intensity);

		clamp						(pp_affected.noise.grain,EPS_L,1000.0f);

		T->set_noise_scale			(pp_affected.noise.grain);

		T->set_noise_fps			(pp_affected.noise.fps);
		T->set_color_base			(pp_affected.color_base);
		T->set_color_gray			(pp_affected.color_gray);
		T->set_color_add			(pp_affected.color_add);
	}
}
Esempio n. 3
0
void FFMS_VideoSource::ReAdjustPP(PixelFormat VPixelFormat, int Width, int Height) {
#ifdef FFMS_USE_POSTPROC
	if (PPContext)
		pp_free_context(PPContext);
	PPContext = NULL;

	if (!PPMode)
		return;

	int Flags =  GetPPCPUFlags();

	switch (VPixelFormat) {
		case PIX_FMT_YUV420P:
		case PIX_FMT_YUVJ420P:
			Flags |= PP_FORMAT_420; break;
		case PIX_FMT_YUV422P:
		case PIX_FMT_YUVJ422P:
			Flags |= PP_FORMAT_422; break;
		case PIX_FMT_YUV411P:
			Flags |= PP_FORMAT_411; break;
		case PIX_FMT_YUV444P:
		case PIX_FMT_YUVJ444P:
			Flags |= PP_FORMAT_444; break;
		default:
			ResetPP();
			throw FFMS_Exception(FFMS_ERROR_POSTPROCESSING, FFMS_ERROR_UNSUPPORTED,
				"The video does not have a colorspace suitable for postprocessing");
	}

	PPContext = pp_get_context(Width, Height, Flags);

	avpicture_free(&PPFrame);
	avpicture_alloc(&PPFrame, VPixelFormat, Width, Height);
#else
	return;
#endif /* FFMS_USE_POSTPROC */

}