⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vpusdk.c

📁 Microsoft WinCE 6.0 BSP FINAL release source code for use with the i.MX27ADS TO2 WCE600_FINAL_MX27_S
💻 C
📖 第 1 页 / 共 4 页
字号:
        ERRORMSG(TRUE, (TEXT("IOCTL_DEC_SET_ESC_SEQ_INIT failed!\r\n")));
		return RETCODE_FAILURE;
    }

    return retcode;
}

//------------------------------------------------------------------------------
//
//  Function:  vpu_DecGetInitialInfo
//
//  This function gets the bitstream header information such as picture size.
//
//  Parameters: 
//      handle
//          [in] Pointer to the handle obtained form vpu_DecOpen().
//      info
//          [out] Pointer to DecInitialInfo data structure that contains header info
//  Returns:
//      RETCODE_SUCCESS for successful closing.
//      RETCODE_FAILURE for failure in getting initial information
//      RETCODE_INVALID_HANDLE for invalid handle.
//      RETCODE_INVALID_PARAM for invalid info pinter.
//      RETCODE_WRONG_CALL_SEQUENCE for wrong calling sequence.
//      RETCODE_CALLED_BEFORE for the case called before.
//      RETCODE_FAILURE_TIMEOUT for timeout on the calling
//
//------------------------------------------------------------------------------
RetCode vpu_DecGetInitialInfo(DecHandle handle, DecInitialInfo *info)
{
    DecGetInitialInfoOutput outputparam;
	DWORD retnum;

    if(!handle || !info)
	{
        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_DEC_GET_INITIAL_INFO,     // I/O control code
        &handle,					    // in buffer
        sizeof(DecHandle),              // in buffer size
        &outputparam,                   // out buffer
        sizeof(DecGetInitialInfoOutput),// out buffer size
        &retnum,                        // number of bytes returned
        NULL))                          // ignored (=NULL)
    {
        ERRORMSG(TRUE, (TEXT("IOCTL_DEC_GET_INITIAL_INFO failed!\r\n")));
		return RETCODE_FAILURE;
    }
    *info = outputparam.intialinfo;
    return outputparam.retcode;
}



//------------------------------------------------------------------------------
//
//  Function:  vpu_DecRegisterFrameBuffer
//
//  This function registers the frame buffers requested by vpu_DecGetInitialInfo.
//
//  Parameters: 
//      handle
//          [in] Pointer to the handle obtained form vpu_DecOpen().
//      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_DecRegisterFrameBuffer(DecHandle handle, FrameBuffer *bufArray, int num, int stride, DecBufInfo *pBufInfo)
{
    DecRegisterFrameBufferInput 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;
	inputparam.pbufinfo = pBufInfo;

	// Issue the IOCTL to register frame buffers and Slice save buffer
	// to a decoder
    if (!DeviceIoControl(g_hVPU,        // file handle to the driver
        IOCTL_DEC_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_DEC_REGISTER_FRAME_BUF failed!\r\n")));
		return RETCODE_FAILURE;
    }

    return retcode;
}

//------------------------------------------------------------------------------
//
//  Function:  vpu_DecGetBitstreamBuffer
//
//  This function gets the informtion about the bitstream for decoder
//
//  Parameters: 
//      handle
//          [in] Pointer to the handle obtained form vpu_DecOpen().
//      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_DecGetBitstreamBuffer(DecHandle handle, PhysicalAddress *prdPrt,
		           PhysicalAddress *pwrPtr, Uint32 *size )
{
    DecGetBitstreamBufferOutput 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_DEC_GET_BITSTREAM_BUF,    // I/O control code
        &handle,				    	// in buffer
        sizeof(DecHandle),              // in buffer size
        &output,                         // out buffer
        sizeof(output),                  // out buffer size
        &retnum,                        // number of bytes returned
        NULL))                          // ignored (=NULL)
    {
        ERRORMSG(TRUE, (TEXT("IOCTL_DEC_GET_BITSTREAM_BUF failed!\r\n")));
		return RETCODE_FAILURE;
    }

	*prdPrt = output.readptr;
	*pwrPtr = output.writeptr;
	*size = output.size;
    return output.retcode;
}

//------------------------------------------------------------------------------
//
//  Function:  vpu_DecUpdateBitstreamBuffer
//
//  This function updates the current bitstream position.
//
//  Parameters: 
//      handle
//          [in] Pointer to the handle obtained form vpu_DecOpen().
//      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_DecUpdateBitstreamBuffer(DecHandle handle, Uint32 size)
{
	DecUpdateBitstreamBufferInput 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_DEC_UPDATE_BITSTREAM_BUF,        // I/O control code
        &input,				    	           // in buffer
        sizeof(DecUpdateBitstreamBufferInput), // in buffer size
        &retcode,                              // out buffer
        sizeof(RetCode),                       // out buffer size
        &retnum,                               // number of bytes returned
        NULL))                                 // ignored (=NULL)
    {
        ERRORMSG(TRUE, (TEXT("IOCTL_DEC_UPDATE_BITSTREAM_BUF failed!\r\n")));
		return RETCODE_FAILURE;
    }
	return retcode;
}

//------------------------------------------------------------------------------
//
//  Function:  vpu_DecStartOneFrame
//
//  This function starts decoding one frame.
//
//  Parameters: 
//      handle
//          [in] Handle obtained form vpu_DecOpen().
//  Returns:
//      RETCODE_SUCCESS for success.
//      RETCODE_INVALID_HANDLE for invalid handle.
//      RETCODE_WRONG_CALL_SEQUENCE for wrong calling sequence.
//
//------------------------------------------------------------------------------
RetCode vpu_DecStartOneFrame(DecHandle handle, DecParam *param)
{
	DecStartOneFrameInput input;
	RetCode retcode;
	DWORD   retnum;

    if(!handle || !param)
	{
        ERRORMSG(TRUE, (TEXT("Invalid input parameters!\r\n")));
        return RETCODE_INVALID_HANDLE;
	}

	input.handle = handle;
	input.pdecparam = param;

	// Issue the IOCTL to start a frame decoding operation
    if (!DeviceIoControl(g_hVPU,        // file handle to the driver
        IOCTL_DEC_START_ONE_FRAME,      // I/O control code
        &input,				    	    // in buffer
        sizeof(DecStartOneFrameInput),  // in buffer size
        &retcode,                       // out buffer
        sizeof(RetCode),                // out buffer size
        &retnum,                        // number of bytes returned
        NULL))                          // ignored (=NULL)
    {
        ERRORMSG(TRUE, (TEXT("IOCTL_DEC_START_ONE_FRAME failed!\r\n")));
		return RETCODE_FAILURE;
    }

    return retcode;
}


//------------------------------------------------------------------------------
//
//  Function:  vpu_DecGetOutputInfo
//
//  This function gets the information of output of decoding.
//
//  Parameters: 
//      handle
//          [in] Handle obtained form vpu_DecOpen().
//      info
//          [out] Pointer to the DecOutputInfo 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_DecGetOutputInfo(DecHandle handle, DecOutputInfo *info)
{
    DecGetOutputInfoOutput 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_DEC_GET_OUTPUT_INFO,      // I/O control code
        &handle,				    	// in buffer
        sizeof(DecHandle),              // in buffer size
        &output,                        // out buffer
        sizeof(DecGetOutputInfoOutput), // out buffer size
        &retnum,                        // number of bytes returned
        NULL))                          // ignored (=NULL)
    {
        ERRORMSG(TRUE, (TEXT("IOCTL_DEC_GET_OUTPUT_INFO failed!\r\n")));
		return RETCODE_FAILURE;
    }
	*info = output.outputinfo;
    return output.retcode;
}


//------------------------------------------------------------------------------
//
//  Function:  vpu_DecBitBufferFlush
//
//  This function flushes bitstream which exist in decoder bitstream buffer 
//  without decoding of each instance.
//
//  Parameters: 
//      handle
//          [in] Handle obtained form vpu_DecOpen().
//  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_DecBitBufferFlush(DecHandle handle)
{
    DWORD retnum;
	RetCode retcode;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -