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

📄 umc_fio_reader.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
字号:
/*////                  INTEL CORPORATION PROPRIETARY INFORMATION//     This software is supplied under the terms of a license agreement or//     nondisclosure agreement with Intel Corporation and may not be copied//     or disclosed except in accordance with the terms of that agreement.//          Copyright(c) 2003-2005 Intel Corporation. All Rights Reserved.//*/#include "umc_defs.h"#if defined (UMC_ENABLE_FIO_READER)#include <string.h>#include "umc_fio_reader.h"UMC::FIOReader::FIOReader():    m_pFile(NULL),    m_stFileSize(0),    m_stPos(0){}UMC::FIOReader::~FIOReader(){    Close();}UMC::StatusUMC::FIOReader::Init(DataReaderParams *pInit){    UMC::Status umcRes = UMC_OK;    FileReaderParams* pParams = DynamicCast<FileReaderParams, DataReaderParams>(pInit);    if (NULL == pParams)    {   umcRes = UMC_NULL_PTR;  }    if (UMC_OK == umcRes)    {        m_pFile = vm_file_open(pParams->m_file_name, VM_STRING("rb"));        if (NULL == m_pFile)        {   umcRes = UMC_OPERATION_FAILED;  }    }    if (UMC_OK == umcRes)    {        if (0 != fseek(m_pFile, 0, SEEK_END))        {   umcRes = UMC_OPERATION_FAILED;  }    }    if (UMC_OK == umcRes)    {        long lRes = ftell(m_pFile);        if (-1 == lRes)        {   umcRes = UMC_OPERATION_FAILED;  }        else        {   m_stFileSize = (vm_sizet)lRes;    }    }    if (UMC_OK == umcRes)    {        if (0 != fseek(m_pFile, 0, SEEK_SET))        {   umcRes = UMC_OPERATION_FAILED;  }    }    return umcRes;}UMC::StatusUMC::FIOReader::Close(){    if (NULL != m_pFile)    {   fclose(m_pFile);   }    m_stFileSize = NULL;    m_stFileSize = 0;    m_stPos = 0;    return UMC_OK;}UMC::StatusUMC::FIOReader::Reset(){    UMC::Status umcRes = UMC_OK;    if (UMC_OK == umcRes && NULL == m_pFile)    {   umcRes = UMC_NOT_INITIALIZED;   }    if (UMC_OK == umcRes)    {        if (0 != fseek(m_pFile, 0, SEEK_SET))        {   umcRes = UMC_OPERATION_FAILED;  }        else        {   m_stPos = 0;    }    }    return umcRes;}UMC::StatusUMC::FIOReader::ReadData(void *data, vm_var32 *nsize){    Status  umcRes = UMC_OK;    if(m_isRepositionHappend)    {   umcRes = UMC_WAIT_FOR_REPOSITION;   }    if (UMC_OK == umcRes && NULL == m_pFile)    {   umcRes = UMC_NOT_INITIALIZED;   }    if (UMC_OK == umcRes)    {        size_t stRes = fread(data, 1, *nsize, m_pFile);        if (stRes < *nsize)        {            if (feof(m_pFile))            {               *nsize = stRes;               umcRes = UMC_END_OF_STREAM;            }            else            {                *nsize = 0;                umcRes = UMC_OPERATION_FAILED;            }        }    }    if (UMC_OK == umcRes)    {   m_stPos = ftell(m_pFile);   }    return umcRes;}UMC::StatusUMC::FIOReader::CacheData(void *data, vm_var32 *nsize, int how_far){    Status umcRes = UMC_OK;    vm_sizet stInitialPos = m_stPos;    if (m_isRepositionHappend)    {   umcRes = UMC_WAIT_FOR_REPOSITION;   }    if (UMC_OK == umcRes && NULL == m_pFile)    {   return UMC_NOT_INITIALIZED;   }    if (UMC_OK == umcRes)    {        if (0 != fseek(m_pFile, how_far, SEEK_CUR))        {   umcRes = UMC_OPERATION_FAILED;  }    }    if (UMC_OK == umcRes)    {   umcRes = GetData(data, nsize);  }    if (UMC_OK == umcRes || UMC_END_OF_STREAM == umcRes)    {        if (0 != fseek(m_pFile, static_cast<long>(stInitialPos), SEEK_SET))        {   umcRes = UMC_OPERATION_FAILED; }        else        {   m_stPos = stInitialPos; }    }    return umcRes;}UMC::StatusUMC::FIOReader::MovePosition(vm_sizet npos){    UMC::Status  umcRes = UMC_OK;    if (m_isRepositionHappend)    {   umcRes = UMC_WAIT_FOR_REPOSITION;   }    if (UMC_OK == umcRes && NULL == m_pFile)    {   umcRes = UMC_NOT_INITIALIZED;   }    if (UMC_OK == umcRes && 0 != npos)    {        if (0 != fseek(m_pFile, (long)npos, SEEK_CUR))        {   umcRes = UMC_OPERATION_FAILED;  }        if (UMC_OK == umcRes)        {   m_stPos = ftell(m_pFile);   }    }    return umcRes;}vm_sizetUMC::FIOReader::GetPosition(){    return m_stPos;}UMC::StatusUMC::FIOReader::SetPosition(double position){    UMC::Status umcRes = UMC_OK;    if (UMC_OK == umcRes && NULL == m_pFile)    {   return UMC_NOT_INITIALIZED;   }    if (UMC_OK == umcRes)    {        m_isRepositionHappend = true;        long lOffset = static_cast<long>(            static_cast<vm_var64s>(m_stFileSize) * position);        if (0 != fseek(m_pFile, lOffset, SEEK_SET))        {   umcRes = UMC_OPERATION_FAILED;  }    }    if (UMC_OK == umcRes)    {   m_stPos = ftell(m_pFile);   }    return umcRes;}vm_sizetUMC::FIOReader::GetSize(){    return m_stFileSize;}#endif /* UMC_ENABLE_FIO_READER */

⌨️ 快捷键说明

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