コード例 #1
0
ファイル: MP4Decoder.cpp プロジェクト: Jinwoo-Song/gecko-dev
static bool
IsSupportedH264Codec(const nsAString& aCodec)
{
  int16_t profile = 0, level = 0;

  if (!ExtractH264CodecDetails(aCodec, profile, level)) {
    return false;
  }

#ifdef XP_WIN
  // Disable 4k video on windows vista since it performs poorly.
  if (!IsWin7OrLater() &&
      level >= H264_LEVEL_5) {
    return false;
  }
#endif

  // Just assume what we can play on all platforms the codecs/formats that
  // WMF can play, since we don't have documentation about what other
  // platforms can play... According to the WMF documentation:
  // http://msdn.microsoft.com/en-us/library/windows/desktop/dd797815%28v=vs.85%29.aspx
  // "The Media Foundation H.264 video decoder is a Media Foundation Transform
  // that supports decoding of Baseline, Main, and High profiles, up to level
  // 5.1.". We also report that we can play Extended profile, as there are
  // bitstreams that are Extended compliant that are also Baseline compliant.
  return level >= H264_LEVEL_1 &&
         level <= H264_LEVEL_5_1 &&
         (profile == H264_PROFILE_BASE ||
          profile == H264_PROFILE_MAIN ||
          profile == H264_PROFILE_EXTENDED ||
          profile == H264_PROFILE_HIGH);
}
コード例 #2
0
//
//  Program entry point
//
int APIENTRY wWinMain(HINSTANCE hInstance,
                      HINSTANCE /*hPrevInstance*/,
                      LPWSTR    /*lpCmdLine*/,
                      int       /*nCmdShow*/)
{
    if (!IsWin7OrLater())
    {
        MessageBox(NULL, L"This sample requires Windows 7 or later", L"Incompatible OS Version", MB_OK);
        return 0;
    }

    static const INITCOMMONCONTROLSEX commonCtrls =
    {
        sizeof(INITCOMMONCONTROLSEX),
        ICC_STANDARD_CLASSES | ICC_BAR_CLASSES
    };

    HRESULT hr = CoInitialize(NULL);

    InitCommonControlsEx(&commonCtrls);

    g_hInstance = hInstance; // Store instance handle in our global variable

    INT_PTR id = DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_CHAT), NULL, ChatDialogProc);

    CoUninitialize();

    return (int) id;
}
コード例 #3
0
ファイル: sccf.c プロジェクト: cpylua/wsuite
/*
 * Apply Starcraft fix in Windows 7
 *
 */
static BOOL DoScFix()
{
	DWORD pid = -1;
	BOOL status = TRUE;
	TCHAR szPath[MAX_PATH] = {0};
	TCHAR szCmdLine[MAX_PATH] = {0};
	
	if (IsWin7OrLater()) {
		while (TRUE) {
			pid = GetPidByName(TEXT("explorer.exe"));
			if (pid == -1) break;
			status = KillProcessByPid(pid);
		}
		
		if (status) {
			status = StartAndWaitForProcess(TEXT("StarCraft.exe"));
			
			GetWindowsDirectory(szPath, MAX_PATH);
			_tcscpy_s(szCmdLine, MAX_PATH, szPath);
			_tcscat_s(szCmdLine, MAX_PATH, TEXT("\\explorer.exe"));
			status = StartProcess(szCmdLine, szPath);
		}
	}
	else {
		status = StartProcess(TEXT("StarCraft.exe"), NULL);
	}
	
	return status;
}
コード例 #4
0
ファイル: WMFUtils.cpp プロジェクト: ShakoHo/gecko-dev
HRESULT
MFStartup()
{
  const int MF_VISTA_VERSION = (0x0001 << 16 | MF_API_VERSION);
  const int MF_WIN7_VERSION = (0x0002 << 16 | MF_API_VERSION);

  // decltype is unusable for functions having default parameters
  DECL_FUNCTION_PTR(MFStartup, ULONG, DWORD);
  ENSURE_FUNCTION_PTR_(MFStartup, Mfplat.dll)
  if (!IsWin7OrLater())
    return MFStartupPtr(MF_VISTA_VERSION, MFSTARTUP_FULL);
  else
    return MFStartupPtr(MF_WIN7_VERSION, MFSTARTUP_FULL);
}
コード例 #5
0
/* static */
bool
WMFDecoder::IsMP3Supported()
{
  MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread.");
  if (!MediaDecoder::IsWMFEnabled()) {
    return false;
  }
  // MP3 works fine in WMF on Windows Vista and Windows 8.
  if (!IsWin7OrLater()) {
    return true;
  }
  // MP3 support is disabled if we're on Windows 7 and no service packs are
  // installed, since it's crashy. Win7 with service packs is not so crashy,
  // so we enable it there. Note we prefer DirectShow for MP3 playback, but
  // we still support MP3 in MP4 via WMF, or MP3 in WMF if DirectShow is
  // disabled.
  return IsWin7SP1OrLater();
}
コード例 #6
0
bool D3D9Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) {
	bool windowed = true;
	hWnd = wnd;

	DIRECT3DCREATE9EX g_pfnCreate9ex;

	hD3D9 = LoadLibrary(TEXT("d3d9.dll"));
	if (!hD3D9) {
		ELOG("Missing d3d9.dll");
		*error_message = "D3D9.dll missing - try reinstalling DirectX.";
		return false;
	}

	int d3dx_version = LoadD3DX9Dynamic();
	if (!d3dx_version) {
		*error_message = "D3DX DLL not found! Try reinstalling DirectX.";
		return false;
	}

	g_pfnCreate9ex = (DIRECT3DCREATE9EX)GetProcAddress(hD3D9, "Direct3DCreate9Ex");
	has9Ex = (g_pfnCreate9ex != NULL) && IsVistaOrHigher();

	if (has9Ex) {
		HRESULT result = g_pfnCreate9ex(D3D_SDK_VERSION, &d3dEx);
		d3d = d3dEx;
		if (FAILED(result)) {
			FreeLibrary(hD3D9);
			*error_message = "D3D9Ex available but context creation failed. Try reinstalling DirectX.";
			return false;
		}
	} else {
		d3d = Direct3DCreate9(D3D_SDK_VERSION);
		if (!d3d) {
			FreeLibrary(hD3D9);
			*error_message = "Failed to create D3D9 context. Try reinstalling DirectX.";
			return false;
		}
	}

	D3DCAPS9 d3dCaps;

	D3DDISPLAYMODE d3ddm;
	if (FAILED(d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm))) {
		*error_message = "GetAdapterDisplayMode failed";
		d3d->Release();
		return false;
	}

	adapterId = D3DADAPTER_DEFAULT;
	if (FAILED(d3d->GetDeviceCaps(adapterId, D3DDEVTYPE_HAL, &d3dCaps))) {
		*error_message = "GetDeviceCaps failed (???)";
		d3d->Release();
		return false;
	}

	HRESULT hr;
	if (FAILED(hr = d3d->CheckDeviceFormat(D3DADAPTER_DEFAULT,
		D3DDEVTYPE_HAL,
		d3ddm.Format,
		D3DUSAGE_DEPTHSTENCIL,
		D3DRTYPE_SURFACE,
		D3DFMT_D24S8))) {
		if (hr == D3DERR_NOTAVAILABLE) {
			*error_message = "D24S8 depth/stencil not available";
			d3d->Release();
			return false;
		}
	}

	DWORD dwBehaviorFlags = D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE;
	if (d3dCaps.VertexProcessingCaps != 0)
		dwBehaviorFlags |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
	else
		dwBehaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;

	int xres, yres;
	GetRes(hWnd, xres, yres);

	memset(&pp, 0, sizeof(pp));
	pp.BackBufferWidth = xres;
	pp.BackBufferHeight = yres;
	pp.BackBufferFormat = d3ddm.Format;
	pp.MultiSampleType = D3DMULTISAMPLE_NONE;
	pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	pp.Windowed = windowed;
	pp.hDeviceWindow = wnd;
	pp.EnableAutoDepthStencil = true;
	pp.AutoDepthStencilFormat = D3DFMT_D24S8;
	pp.PresentationInterval = (g_Config.bVSync) ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;

	if (has9Ex) {
		if (windowed && IsWin7OrLater()) {
			// This new flip mode gives higher performance.
			// TODO: This makes it slower?
			//pp.BackBufferCount = 2;
			//pp.SwapEffect = D3DSWAPEFFECT_FLIPEX;
		}
		hr = d3dEx->CreateDeviceEx(adapterId, D3DDEVTYPE_HAL, wnd, dwBehaviorFlags, &pp, NULL, &deviceEx);
		device = deviceEx;
	} else {
		hr = d3d->CreateDevice(adapterId, D3DDEVTYPE_HAL, wnd, dwBehaviorFlags, &pp, &device);
	}

	if (FAILED(hr)) {
		*error_message = "Failed to create D3D device";
		d3d->Release();
		return false;
	}

	device->BeginScene();
	DX9::pD3Ddevice = device;
	DX9::pD3DdeviceEx = deviceEx;

	if (!DX9::CompileShaders(*error_message)) {
		*error_message = "Unable to compile shaders: " + *error_message;
		device->EndScene();
		device->Release();
		d3d->Release();
		DX9::pD3Ddevice = nullptr;
		DX9::pD3DdeviceEx = nullptr;
		device = nullptr;
		UnloadD3DXDynamic();
		return false;
	}

	DX9::fbo_init(d3d);

	if (deviceEx && IsWin7OrLater()) {
		// TODO: This makes it slower?
		//deviceEx->SetMaximumFrameLatency(1);
	}

	return true;
}