📄 pfsdk.c
字号:
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//-----------------------------------------------------------------------------
//
// Copyright (C) 2004, Freescale Semiconductor, Inc. All Rights Reserved
// THIS SOURCE CODE IS CONFIDENTIAL AND PROPRIETARY AND MAY NOT
// BE USED OR DISTRIBUTED WITHOUT THE WRITTEN PERMISSION OF
// Freescale Semiconductor, Inc.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// File: pfsdk.c
//
// This module provides wrapper functions for accessing
// the stream interface for the PF driver.
//
//-----------------------------------------------------------------------------
#include <windows.h>
#include <Devload.h>
#include "mxarm11.h"
#include "pf.h"
//-----------------------------------------------------------------------------
// External Functions
//-----------------------------------------------------------------------------
// External Variables
//-----------------------------------------------------------------------------
// Defines
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
// Global Variables
//------------------------------------------------------------------------------
// Local Variables
//------------------------------------------------------------------------------
// Local Functions
//------------------------------------------------------------------------------
//
// Function: PFOpenHandle
//
// This method creates a handle to the PF stream driver.
//
// Parameters:
// None
//
// Returns:
// Handle to PF driver, which is set in this method.
// Returns INVALID_HANDLE_VALUE if failure.
//
//------------------------------------------------------------------------------
HANDLE PFOpenHandle(void)
{
HANDLE hPF;
hPF = CreateFile(TEXT("POF1:"), // name of device
GENERIC_READ|GENERIC_WRITE, // desired access
FILE_SHARE_READ|FILE_SHARE_WRITE, // sharing mode
NULL, // security attributes (ignored)
OPEN_EXISTING, // creation disposition
FILE_FLAG_RANDOM_ACCESS, // flags/attributes
NULL); // template file (ignored)
// if we failed to get handle to PF
if (hPF == INVALID_HANDLE_VALUE)
{
ERRORMSG(1, (TEXT("%s: CreateFile PF failed!\r\n"), __WFUNCTION__));
}
return hPF;
}
//------------------------------------------------------------------------------
//
// Function: PFCloseHandle
//
// This method closes a handle to the PF stream driver.
//
// Parameters:
// hPF
// [in/out] Handle to close.
//
// Returns:
// TRUE if success.
// FALSE if failure.
//
//------------------------------------------------------------------------------
BOOL PFCloseHandle(HANDLE hPF)
{
BOOL retVal = TRUE;
// if we don't have handle to PF driver
if (hPF != NULL)
{
if (!CloseHandle(hPF))
{
retVal = FALSE;
}
}
return retVal;
}
//------------------------------------------------------------------------------
//
// Function: PFConfigure
//
// This method configures the Post-filter driver using parameters passed
// in by the caller.
//
// Parameters:
// hPF
// [in] Handle to PF driver.
//
// pPfConfigData
// [in] Pointer to PF configuration data structure.
//
// Returns:
// None.
//
//------------------------------------------------------------------------------
void PFConfigure(HANDLE hPF, pPfConfigData pConfigData)
{
// issue the IOCTL to configure the PF
if (!DeviceIoControl(hPF, // file handle to the driver
PF_IOCTL_CONFIGURE, // I/O control code
pConfigData, // in buffer
sizeof(pfConfigData), // in buffer size
NULL, // out buffer
0, // out buffer size
0, // number of bytes returned
NULL)) // ignored (=NULL)
{
ERRORMSG(1, (TEXT("%s: PF_IOCTL_CONFIGURE failed!\r\n"), __WFUNCTION__));
}
}
//------------------------------------------------------------------------------
//
// Function: PFStart
//
// This method starts the Post-filter task.
//
// Parameters:
// hPF
// [in] Handle to PF driver.
//
// pStartParms
// [in] Pointer to structure containing input and output buffer data
// for the Post-filter operation.
//
// Returns:
// None.
//
//------------------------------------------------------------------------------
void PFStart(HANDLE hPF, pPfStartParams pStartParms)
{
// issue the IOCTL to start the PF task
if (!DeviceIoControl(hPF, // file handle to the driver
PF_IOCTL_START, // I/O control code
pStartParms, // in buffer
sizeof(pfStartParams), // in buffer size
NULL, // out buffer
0, // out buffer size
0, // number of bytes returned
NULL)) // ignored (=NULL)
{
DEBUGMSG(1, (TEXT("%s: PF_IOCTL_START failed!\r\n"), __WFUNCTION__));
}
}
//------------------------------------------------------------------------------
//
// Function: PFResume
//
// This method resumes an H.264 deblocking operation that was previously
// started with a pause row specified. A new pause row may be specified
//
// Parameters:
// hPF
// [in] Handle to PF driver.
//
// h264_pause_row
// [in] Integer indicating the Y row at which to pause the operation.
// Should be set to 0 to disable an additional pause.
//
// Returns:
// If success, PF_SUCCESS.
// If failure, one of the following:
// PF_ERR_NOT_RUNNING
// PF_ERR_PAUSE_NOT_ENABLED
// PF_ERR_INVALID_PARAMETER
//
//------------------------------------------------------------------------------
DWORD PFResume(HANDLE hPF, UINT32 h264_pause_row)
{
DWORD retVal;
// issue the IOCTL to resume the PF task
if (!DeviceIoControl(hPF, // file handle to the driver
PF_IOCTL_RESUME, // I/O control code
&h264_pause_row, // in buffer
sizeof(UINT32), // in buffer size
&retVal, // out buffer
sizeof(DWORD), // out buffer size
0, // number of bytes returned
NULL)) // ignored (=NULL)
{
DEBUGMSG(1, (TEXT("%s: PF_IOCTL_RESUME failed!\r\n"), __WFUNCTION__));
}
return retVal;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -