📄 vpusdk.c
字号:
ERRORMSG(TRUE, (TEXT("Input parameter is invalid!\r\n")));
return RETCODE_INVALID_PARAM;
}
// Issue the IOCTL to get a decoder initializing information
if (!DeviceIoControl(g_hVPU, // file handle to the driver
IOCTL_ENC_GET_INITIAL_INFO, // I/O control code
&handle, // in buffer
sizeof(EncHandle), // in buffer size
&outputparam, // out buffer
sizeof(EncGetInitialInfoOutput),// out buffer size
&retnum, // number of bytes returned
NULL)) // ignored (=NULL)
{
ERRORMSG(TRUE, (TEXT("IOCTL_ENC_GET_INITIAL_INFO failed!\r\n")));
return RETCODE_FAILURE;
}
*info = outputparam.intialinfo;
return outputparam.retcode;
}
//------------------------------------------------------------------------------
//
// Function: vpu_EncRegisterFrameBuffer
//
// This function registers the frame buffers requested by vpu_EncGetInitialInfo.
//
// Parameters:
// handle
// [in] Pointer to the handle obtained form vpu_EncOpen().
// bufArray
// [in] Pointer to the first element of an array of FrameBuffer.
// num
// [in] Number fo elements of the array.
// stride
// [in] Stride value of frame buffers being registered.
// Returns:
// RETCODE_SUCCESS for successful closing.
// RETCODE_INVALID_HANDLE for invalid handle.
// RETCODE_WRONG_CALL_SEQUENCE for wrong calling sequence.
// RETCODE_INVALID_FRAME_BUFFER Buffer for invalid bufArray pointer.
// RETCODE_INSUFFICIENT_FRAME_BUFFERS for less num than the value requested.
// RETCODE_INVALID_STRIDE for less stride than the picture width.
// RETCODE_CALLED_BEFORE for the case called before.
//
//------------------------------------------------------------------------------
RetCode vpu_EncRegisterFrameBuffer(EncHandle handle, FrameBuffer * bufArray, int num, int stride)
{
EncRegisterFrameBufferInput inputparam;
RetCode retcode;
DWORD retnum;
if(!handle)
{
ERRORMSG(TRUE, (TEXT("Invalid instance!\r\n")));
return RETCODE_INVALID_HANDLE;
}
inputparam.handle = handle;
inputparam.pbufarray = bufArray;
inputparam.num = num;
inputparam.stride = stride;
// Issue the IOCTL to register frame buffers and Slice save buffer
// to a decoder
if (!DeviceIoControl(g_hVPU, // file handle to the driver
IOCTL_ENC_REGISTER_FRAME_BUF, // I/O control code
&inputparam, // in buffer
sizeof(inputparam), // in buffer size
&retcode, // out buffer
sizeof(RetCode), // out buffer size
&retnum, // number of bytes returned
NULL)) // ignored (=NULL)
{
ERRORMSG(TRUE, (TEXT("IOCTL_ENC_REGISTER_FRAME_BUF failed!\r\n")));
return RETCODE_FAILURE;
}
return retcode;
}
//------------------------------------------------------------------------------
//
// Function: vpu_EncGetBitstreamBuffer
//
// This function gets the informtion about the bitstream for encoder
//
// Parameters:
// handle
// [in] Pointer to the handle obtained form vpu_EncOpen().
// prdPrt
// [out] Pointer to the storage that stores the physical address at
// which BIT Processor can get bitstream
// pwrPtr
// [out] Pointer to the storage that stores the physical address at
// which you can put bitstream
// size
// [out] Pointer to an integer that stores the size of available space.
// Returns:
// RETCODE_SUCCESS for successful closing.
// RETCODE_INVALID_HANDLE for invalid handle.
// RETCODE_INVALID_PARAM for invalid bufAddr or size buffers.
//
//------------------------------------------------------------------------------
RetCode vpu_EncGetBitstreamBuffer(EncHandle handle, PhysicalAddress * prdPrt,
PhysicalAddress * pwrPtr, Uint32 * size)
{
EncGetBitstreamBufferOutput output;
DWORD retnum;
if(!handle)
{
ERRORMSG(TRUE, (TEXT("Invalid instance!\r\n")));
return RETCODE_INVALID_HANDLE;
}
// Issue the IOCTL to get current read and write pointers
// and the available buffer size for input
if (!DeviceIoControl(g_hVPU, // file handle to the driver
IOCTL_ENC_GET_BITSTREAM_BUF, // I/O control code
&handle, // in buffer
sizeof(EncHandle), // in buffer size
&output, // out buffer
sizeof(output), // out buffer size
&retnum, // number of bytes returned
NULL)) // ignored (=NULL)
{
ERRORMSG(TRUE, (TEXT("IOCTL_ENC_GET_BITSTREAM_BUF failed!\r\n")));
return RETCODE_FAILURE;
}
*prdPrt = output.readptr;
*pwrPtr = output.writeptr;
*size = output.size;
return output.retcode;
}
//------------------------------------------------------------------------------
//
// Function: vpu_EncUpdateBitstreamBuffer
//
// This function updates the current bitstream position.
//
// Parameters:
// handle
// [in] Pointer to the handle obtained form vpu_EncOpen().
// size
// [in] Size of input bitstream.
// Returns:
// RETCODE_SUCCESS for successful closing.
// RETCODE_INVALID_HANDLE for invalid handle.
// RETCODE_INVALID_PARAM for invalid bitstream size.
//
//------------------------------------------------------------------------------
RetCode vpu_EncUpdateBitstreamBuffer(EncHandle handle, Uint32 size)
{
EncUpdateBitstreamBufferInput input;
RetCode retcode;
DWORD retnum;
if(!handle)
{
ERRORMSG(TRUE, (TEXT("Invalid instance!\r\n")));
return RETCODE_INVALID_HANDLE;
}
input.handle = handle;
input.size = size;
// Issue the IOCTL to update input bitstream buffer read and write pointers
if (!DeviceIoControl(g_hVPU, // file handle to the driver
IOCTL_ENC_UPDATE_BITSTREAM_BUF, // I/O control code
&input, // in buffer
sizeof(EncUpdateBitstreamBufferInput), // in buffer size
&retcode, // out buffer
sizeof(RetCode), // out buffer size
&retnum, // number of bytes returned
NULL)) // ignored (=NULL)
{
ERRORMSG(TRUE, (TEXT("IOCTL_ENC_UPDATE_BITSTREAM_BUF failed!\r\n")));
return RETCODE_FAILURE;
}
return retcode;
}
//------------------------------------------------------------------------------
//
// Function: vpu_EncStartOneFrame
//
// This function starts encoding one frame.
//
// Parameters:
// handle
// [in] Handle obtained form vpu_EncOpen().
// Returns:
// RETCODE_SUCCESS for success.
// RETCODE_INVALID_HANDLE for invalid handle.
// RETCODE_WRONG_CALL_SEQUENCE for wrong calling sequence.
//
//------------------------------------------------------------------------------
RetCode vpu_EncStartOneFrame(EncHandle handle, EncParam * param )
{
EncStartOneFrameInput input;
RetCode retcode;
DWORD retnum;
if(!handle || !param)
{
ERRORMSG(TRUE, (TEXT("Invalid input parameters!\r\n")));
return RETCODE_INVALID_HANDLE;
}
input.handle = handle;
input.pencparam = param;
// Issue the IOCTL to start a frame decoding operation
if (!DeviceIoControl(g_hVPU, // file handle to the driver
IOCTL_ENC_START_ONE_FRAME, // I/O control code
&input, // in buffer
sizeof(EncStartOneFrameInput), // in buffer size
&retcode, // out buffer
sizeof(RetCode), // out buffer size
&retnum, // number of bytes returned
NULL)) // ignored (=NULL)
{
ERRORMSG(TRUE, (TEXT("IOCTL_ENC_START_ONE_FRAME failed!\r\n")));
return RETCODE_FAILURE;
}
return retcode;
}
//------------------------------------------------------------------------------
//
// Function: vpu_EncGetOutputInfo
//
// This function gets the information of output of encoding.
//
// Parameters:
// handle
// [in] Handle obtained form vpu_EncOpen().
// info
// [out] Pointer to the EncOutputInfo data structure
// Returns:
// RETCODE_SUCCESS for successful closing.
// RETCODE_INVALID_HANDLE for invalid handle.
// RETCODE_INVALID_PARAM Info for invalid info pointer.
// RETCODE_WRONG_CALL_SEQUENCE for wrong calling sequence.
//
//------------------------------------------------------------------------------
RetCode vpu_EncGetOutputInfo(EncHandle handle, EncOutputInfo * info)
{
EncGetOutputInfoOutput output;
DWORD retnum;
if(!handle || !info)
{
ERRORMSG(TRUE, (TEXT("Invalid input parameters!\r\n")));
return RETCODE_INVALID_HANDLE;
}
// Issue the IOCTL to start a frame decoding operation
if (!DeviceIoControl(g_hVPU, // file handle to the driver
IOCTL_ENC_GET_OUTPUT_INFO, // I/O control code
&handle, // in buffer
sizeof(EncHandle), // in buffer size
&output, // out buffer
sizeof(EncGetOutputInfoOutput), // out buffer size
&retnum, // number of bytes returned
NULL)) // ignored (=NULL)
{
ERRORMSG(TRUE, (TEXT("IOCTL_ENC_GET_OUTPUT_INFO failed!\r\n")));
return RETCODE_FAILURE;
}
*info = output.outputinfo;
return output.retcode;
}
//------------------------------------------------------------------------------
//
// Function: vpu_EncGiveCommand
//
// This function sends the command to the encoder.
//
// Parameters:
// handle
// [in] Handle obtained form vpu_EncOpen().
// cmd
// [in] Command sent to Encoder
// param
// [in/out] Parameter used for specific cmd.
// Returns:
// RETCODE_SUCCESS for successful closing.
// RETCODE_INVALID_HANDLE for invalid handle.
// RETCODE_INVALID_COMMAND for invalid command
// RETCODE_INVALID_PARAM for invalid parameter.
// RETCODE_ROTATOR_OUTPUT_NOT_SET for no output setting.
// RETCODE_ROTATOR_STRIDE_NOT_SET for no stride setting.
// RETCODE_INVALID_STRIDE for invalid input stride value
//
//------------------------------------------------------------------------------
RetCode vpu_EncGiveCommand(EncHandle handle, CodecCommand cmd, void * parameter)
{
EncGiveCommandInput input;
RetCode retcode;
DWORD retnum;
if(!handle)
{
ERRORMSG(TRUE, (TEXT("Invalid instance!\r\n")));
return RETCODE_INVALID_HANDLE;
}
input.handle = handle;
input.cmd = cmd;
input.pparam = parameter;
// Issue the IOCTL to send the command to a decoder
if (!DeviceIoControl(g_hVPU, // file handle to the driver
IOCTL_ENC_GIVE_COMMAND, // I/O control code
&input, // in buffer
sizeof(EncGiveCommandInput), // in buffer size
&retcode, // out buffer
sizeof(RetCode), // out buffer size
&retnum, // number of bytes returned
NULL)) // ignored (=NULL)
{
ERRORMSG(TRUE, (TEXT("IOCTL_ENC_GIVE_COMMAND failed!\r\n")));
return RETCODE_FAILURE;
}
return retcode;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -