コード例 #1
0
ファイル: util.c プロジェクト: dormclub/tjphone
int sysInfoToCSV(FILE *f_csv)
{
    char infoBuffer[256];
    const  IppLibraryVersion *verIppSC, *verIppSP;

    if(f_csv == NULL) return -1;

#ifndef OSX32
    infoBuffer[0] = '\0';
    vm_sys_info_get_date((char*)infoBuffer,DDMMYY);
    vm_string_fprintf(f_csv,VM_STRING("Date,%s"),infoBuffer);

    infoBuffer[0] = '\0';
    vm_sys_info_get_time((char*)infoBuffer,HHMMSS);
    vm_string_fprintf(f_csv,VM_STRING(",Time,%s\n"),infoBuffer);

    infoBuffer[0] = '\0';
    vm_sys_info_get_cpu_name((char*)infoBuffer);
    vm_string_fprintf(f_csv,VM_STRING("CPU,%s\n"),infoBuffer);

    infoBuffer[0] = '\0';
    vm_sys_info_get_os_name((char*)infoBuffer);
    vm_string_fprintf(f_csv,VM_STRING("OS,%s\n"),infoBuffer);

    infoBuffer[0] = '\0';
    vm_sys_info_get_computer_name((char*)infoBuffer);
    vm_string_fprintf(f_csv,VM_STRING("Computer name,%s\n"),infoBuffer);
#endif

    verIppSC = ippscGetLibVersion();
    verIppSP = ippsGetLibVersion();

    fprintf(f_csv,"IPPS library,%s,%s,%s\n",
        verIppSP->Name,verIppSP->Version,verIppSP->BuildDate);

    fprintf(f_csv,"IPPSC library,%s,%s,%s\n",
        verIppSC->Name,verIppSC->Version,verIppSC->BuildDate);
    fprintf(f_csv,"EC TYPE,alg type,adaptation,bits,sampling rate,rin file,sin file,speech in sec,speed in mHz\n");
return 0;
}
コード例 #2
0
void vm_sys_info_get_computer_name(vm_char *computer_name)
{
    vm_char data[_MAX_LEN] = {0,};
    /* it can be wchar variable */
    DWORD dwSize = sizeof(data) / sizeof(data[0]);

    /* check error(s) */
    if (NULL == computer_name)
        return;

    GetComputerName(data, &dwSize);
    vm_string_sprintf(computer_name, VM_STRING("%s"), data);
}
コード例 #3
0
void vm_sys_info_get_computer_name(vm_char *computer_name)
{
    vm_char data[_MAX_LEN] = {0,};
    /* it can be wchar variable */
    Ipp32u dwSize = sizeof(data) / sizeof(data[0]);

    /* check error(s) */
    if (NULL == computer_name)
        return;

    SystemParametersInfo(SPI_GETOEMINFO, dwSize, data, 0);
    vm_string_sprintf(computer_name, VM_STRING("%s"), data);
}
コード例 #4
0
ファイル: umc_malloc.cpp プロジェクト: ykiryanov/andopal
    void ReportLeak()
    {
        if(FILE *f = _tfopen(g_OutputFileName, VM_STRING("a")))
        {
            fprintf(f, "Memory leak %d, %s, %s, %d\n",
                              m_size,
                    0 == m_lpcBinaryName ? "UnknownBinary" : m_lpcBinaryName,
                    0 == m_lpcFileName   ? "UnknownFile"   : m_lpcFileName,
                              m_iStringNumber);

            fclose(f);
        }
    }
コード例 #5
0
void vm_sys_info_get_cpu_name(vm_char *cpu_name)
{
    HKEY hKey;
    vm_char data[_MAX_LEN] = {0,};
    /* it can be wchar variable */
    DWORD dwSize = sizeof(data) / sizeof(data[0]);
    Ipp32s i = 0;
    LONG lErr;

    /* check error(s) */
    if (NULL == cpu_name)
        return;

    lErr = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                        VM_STRING("Hardware\\Description\\System\\CentralProcessor\\0"),
                        0,
                        KEY_QUERY_VALUE,
                        &hKey);
    if (ERROR_SUCCESS == lErr)
    {
        RegQueryValueEx(hKey,
                        _T("ProcessorNameString"),
                        NULL,
                        NULL,
                        (LPBYTE)&data,
                        &dwSize);
        /* error protection */
        data[sizeof(data) / sizeof(data[0]) - 1] = 0;
        while (data[i++] == ' ');
        vm_string_strcpy(cpu_name, (vm_char *)(data + i - 1));
        RegCloseKey (hKey);
    }
    else
        vm_string_sprintf(cpu_name, VM_STRING("Unknown"));

} /* void vm_sys_info_get_cpu_name(vm_char *cpu_name) */
コード例 #6
0
///////////////////////////////////////////////////////////////////////////////
// freeLongTermRef
// Mark the long-term reference frame with specified LongTermFrameIdx
// as not used
///////////////////////////////////////////////////////////////////////////////
H264DecoderFrame * H264DBPList::freeLongTermRefIdx(Ipp32s  LongTermFrameIdx, H264DecoderFrame * pCurrentFrame)
{
    H264DecoderFrame *pCurr = m_pHead;

    while (pCurr)
    {
        if (pCurr->m_PictureStructureForRef >= FRM_STRUCTURE)
        {
            if (pCurr->isLongTermRef() && (pCurr->LongTermFrameIdx() == LongTermFrameIdx ))
            {
                if (pCurrentFrame == pCurr)
                    return 0;
                pCurr->unSetisLongTermRef(0);
                return pCurr;
            }
        }
        else
        {
            if (pCurr->isLongTermRef(0) && (pCurr->LongTermFrameIdx() == LongTermFrameIdx ))
            {
                if (pCurrentFrame == pCurr)
                    return 0;
                pCurr->unSetisLongTermRef(0);
                pCurr->unSetisLongTermRef(1);
                return pCurr;
            }

            if (pCurr->isLongTermRef(1) && (pCurr->LongTermFrameIdx() == LongTermFrameIdx ))
            {
                if (pCurrentFrame == pCurr)
                    return 0;
                pCurr->unSetisLongTermRef(0);
                pCurr->unSetisLongTermRef(1);
                return pCurr;
            }
        }

        pCurr = pCurr->future();
    }

//  VM_ASSERT(false);
    vm_debug_trace2(VM_DEBUG_ERROR, VM_STRING("frame not found LongTermFrameIdx=%ld pCurrentFrame=%p"), LongTermFrameIdx, pCurrentFrame);
    return NULL;
}    // freeLongTermRefIdx
コード例 #7
0
///////////////////////////////////////////////////////////////////////////////
// changeSTtoLTRef
//    Mark the short-term reference frame with specified PicNum as long-term
//  with specified long term idx.
///////////////////////////////////////////////////////////////////////////////
void H264DBPList::changeSTtoLTRef(Ipp32s  picNum, Ipp32s  longTermFrameIdx)
{
    H264DecoderFrame *pCurr = m_pHead;
    while (pCurr)
    {
        if (pCurr->m_PictureStructureForRef >= FRM_STRUCTURE)
        {
            if (pCurr->isShortTermRef() && (pCurr->PicNum(0) == picNum))
            {
                pCurr->unSetisShortTermRef(0);
                pCurr->setLongTermFrameIdx(longTermFrameIdx);
                pCurr->SetisLongTermRef(0);
                pCurr->UpdateLongTermPicNum(2);
                return;
            }
        }
        else
        {
            if (pCurr->isShortTermRef(0) && (pCurr->PicNum(0) == picNum))
            {
                pCurr->unSetisShortTermRef(0);
                pCurr->setLongTermFrameIdx(longTermFrameIdx);
                pCurr->SetisLongTermRef(0);
                pCurr->UpdateLongTermPicNum(pCurr->m_bottom_field_flag[0]);
                return;
            }

            if (pCurr->isShortTermRef(1) && (pCurr->PicNum(1) == picNum))
            {
                pCurr->unSetisShortTermRef(1);
                pCurr->setLongTermFrameIdx(longTermFrameIdx);
                pCurr->SetisLongTermRef(1);
                pCurr->UpdateLongTermPicNum(pCurr->m_bottom_field_flag[1]);
                return;
            }
        }
        pCurr = pCurr->future();
    }
    
    vm_debug_trace(VM_DEBUG_ERROR, VM_STRING("frame not found in changeSTtoLTRef"));
//    VM_ASSERT(false);    // No match found, should not happen.
    return;
}    // changeSTtoLTRef
コード例 #8
0
void vm_sys_info_get_vga_card(vm_char *vga_card)
{
    SP_DEVINFO_DATA sp_dev_info;
    HDEVINFO DeviceInfoSet;
    vm_char string1[] = VM_STRING("Display");
    Ipp32u dwIndex = 0;
    vm_char data[_MAX_LEN] = {0,};

    /* check error(s) */
    if (NULL == vga_card)
        return;

    ZeroMemory(&sp_dev_info, sizeof(SP_DEVINFO_DATA));
    ZeroMemory(&DeviceInfoSet, sizeof(HDEVINFO));

    DeviceInfoSet = SetupDiGetClassDevs(NULL, NULL, NULL, DIGCF_ALLCLASSES | DIGCF_PRESENT);
    sp_dev_info.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
    while (SetupDiEnumDeviceInfo(DeviceInfoSet, dwIndex, &sp_dev_info))
    {
        SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
                                         &sp_dev_info,
                                         SPDRP_CLASS,
                                         NULL,
                                         (Ipp8u *) data,
                                         _MAX_LEN,
                                         NULL);
        if (!vm_string_strcmp((vm_char*)data, string1))
        {
            SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
                                             &sp_dev_info,
                                             SPDRP_DEVICEDESC,
                                             NULL,
                                             (PBYTE) vga_card,
                                             _MAX_LEN,
                                             NULL);
            break;
        }
        dwIndex++;
    }
    SetupDiDestroyDeviceInfoList(DeviceInfoSet);

} /* void vm_sys_info_get_vga_card(vm_char *vga_card) */
コード例 #9
0
///////////////////////////////////////////////////////////////////////////////
// freeLongTermRef
// Mark the long-term reference frame with specified LongTermPicNum as not used
///////////////////////////////////////////////////////////////////////////////
H264DecoderFrame * H264DBPList::freeLongTermRef(Ipp32s  LongTermPicNum)
{
    H264DecoderFrame *pCurr = m_pHead;
    bool found = false;

    while (pCurr)
    {
        if (pCurr->m_PictureStructureForRef>=FRM_STRUCTURE)
        {
            if (pCurr->isLongTermRef() && (pCurr->LongTermPicNum(0) == LongTermPicNum))
            {
                pCurr->unSetisLongTermRef(0);
                return pCurr;
            }
        }
        else
        {
            if (pCurr->isLongTermRef(0) && (pCurr->LongTermPicNum(0) == LongTermPicNum))
            {
                pCurr->unSetisLongTermRef(0);
                found = true;
            }

            if (pCurr->isLongTermRef(1) && (pCurr->LongTermPicNum(1) == LongTermPicNum))
            {
                pCurr->unSetisLongTermRef(1);
                found = true;
            }

            if (found)
                return pCurr;
        }

        pCurr = pCurr->future();
    }


//    VM_ASSERT(false);    // No match found, should not happen.
    vm_debug_trace1(VM_DEBUG_ERROR, VM_STRING("frame not found LongTermPicNum=%ld"), LongTermPicNum);
    return NULL;
}    // freeLongTermRef
コード例 #10
0
Ipp32u vm_sys_info_get_cpu_speed(void)
{
    HKEY hKey;
    Ipp32u data = 0;
    DWORD dwSize = sizeof(Ipp32u);
    LONG lErr;

    lErr = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                        VM_STRING("Hardware\\Description\\System\\CentralProcessor\\0"),
                        0,
                        KEY_QUERY_VALUE,
                        &hKey);
    if (ERROR_SUCCESS == lErr)
    {
        RegQueryValueEx (hKey, _T("~MHz"), NULL, NULL, (LPBYTE)&data, &dwSize);
        RegCloseKey(hKey);
        return data;
    }
    else
        return 0;
}
コード例 #11
0
///////////////////////////////////////////////////////////////////////////////
// freeShortTermRef
// Mark the short-term reference frame with specified picNum as not used
///////////////////////////////////////////////////////////////////////////////
H264DecoderFrame * H264DBPList::freeShortTermRef(Ipp32s  picNum)
{
    H264DecoderFrame *pCurr = m_pHead;
    bool found = false;
    while (pCurr)
    {
        if (pCurr->m_PictureStructureForRef >= FRM_STRUCTURE)
        {
            if (pCurr->isShortTermRef() && (pCurr->PicNum(0) == picNum))
            {
                pCurr->unSetisShortTermRef(0);
                return pCurr;
            }
        }
        else
        {
            if (pCurr->isShortTermRef(0) && (pCurr->PicNum(0) == picNum))
            {
                pCurr->unSetisShortTermRef(0);
                found = true;
            }

            if (pCurr->isShortTermRef(1) && (pCurr->PicNum(1) == picNum))
            {
                pCurr->unSetisShortTermRef(1);
                found = true;
            }

            if (found)
                return pCurr;
        }

        pCurr = pCurr->future();
    }

    //VM_ASSERT(false);
    vm_debug_trace1(VM_DEBUG_ERROR, VM_STRING("frame not found picNum=%ld"), picNum);
    return 0;
}    // freeShortTermRef
コード例 #12
0
H264DecoderFrame *H264DBPList::findShortTermPic(Ipp32s  picNum, Ipp32s * field)
{
    H264DecoderFrame *pCurr = m_pHead;

    while (pCurr)
    {
        if (pCurr->m_PictureStructureForRef >= FRM_STRUCTURE)
        {
            if ((pCurr->isShortTermRef() == 3) && (pCurr->PicNum(0) == picNum))
            {
                return pCurr;
            }
        }
        else
        {
            if (pCurr->isShortTermRef(0) && (pCurr->PicNum(0) == picNum))
            {
                if (field)
                    *field = 0;
                return pCurr;
            }

            if (pCurr->isShortTermRef(1) && (pCurr->PicNum(1) == picNum))
            {
                if (field)
                    *field = 1;
                return pCurr;
            }
        }

        pCurr = pCurr->future();
    }

    throw h264_exception(UMC_ERR_INVALID_STREAM);
    //SB !!!  VM_ASSERT(false);    // No match found, should not happen.
    vm_debug_trace1(VM_DEBUG_ERROR, VM_STRING("frame not found in findShortTermPic(picNum=%ld)"), picNum);
    return NULL;
}    // findShortTermPic
コード例 #13
0
void vm_sys_info_get_cpu_name(vm_char *cpu_name)
{
    PROCESSOR_INFO pi;
    Ipp32u dwBytesReturned;
    Ipp32u dwSize = sizeof(PROCESSOR_INFO);
    BOOL bResult;

    /* check error(s) */
    if (NULL == cpu_name)
        return;

    ZeroMemory(&pi, sizeof(PROCESSOR_INFO));
    bResult = KernelIoControl(IOCTL_PROCESSOR_INFORMATION,
                              NULL,
                              0,
                              &pi,
                              sizeof(PROCESSOR_INFO),
                              &dwBytesReturned);

    vm_string_sprintf(cpu_name,
                      VM_STRING("%s %s"),
                      pi.szProcessCore,
                      pi.szProcessorName);
}
コード例 #14
0
ファイル: util.c プロジェクト: paranojik/multitv
Ipp32s OutputSysInfo2CSVFile(vm_file *f_csv)
{
   vm_char infoBuffer[256];
   const  IppLibraryVersion *verIppSC, *verIppSP;

   if(f_csv == NULL) return -1;

   infoBuffer[0] = '\0';
   vm_sys_info_get_date(infoBuffer,DDMMYY);
   vm_string_fprintf(f_csv,VM_STRING("Date,%s"),infoBuffer);

   infoBuffer[0] = '\0';
   vm_sys_info_get_time(infoBuffer,HHMMSS);
   vm_string_fprintf(f_csv,VM_STRING(",Time,%s\n"),infoBuffer);

   infoBuffer[0] = '\0';
   vm_sys_info_get_cpu_name(infoBuffer);
   vm_string_fprintf(f_csv,VM_STRING("CPU,%s\n"),infoBuffer);

   infoBuffer[0] = '\0';
   vm_sys_info_get_os_name(infoBuffer);
   vm_string_fprintf(f_csv,VM_STRING("OS,%s\n"),infoBuffer);

   infoBuffer[0] = '\0';
   vm_sys_info_get_computer_name(infoBuffer);
   vm_string_fprintf(f_csv,VM_STRING("Computer name,%s\n"),infoBuffer);

   verIppSC = ippscGetLibVersion();
   verIppSP = ippsGetLibVersion();

   vm_string_fprintf(f_csv,VM_STRING("IPPS library,%s,%s,%s\n"),
      verIppSP->Name,verIppSP->Version,verIppSP->BuildDate);

   vm_string_fprintf(f_csv,VM_STRING("IPPSC library,%s,%s,%s\n"),
      verIppSC->Name,verIppSC->Version,verIppSC->BuildDate);
   return 0;
}
コード例 #15
0
ファイル: jpegbase.cpp プロジェクト: ph0b/MediaSDK
const vm_char* GetErrorStr(JERRCODE code)
{
  const vm_char* str;

  switch(code)
  {
    case JPEG_OK:               str = VM_STRING("no error"); break;
    case JPEG_NOT_IMPLEMENTED:  str = VM_STRING("requested feature is not implemented"); break;
    case JPEG_ERR_INTERNAL:     str = VM_STRING("internal error"); break;
    case JPEG_ERR_PARAMS:       str = VM_STRING("wrong parameters"); break;
    case JPEG_ERR_BUFF:         str = VM_STRING("buffer too small"); break;
    case JPEG_ERR_FILE:         str = VM_STRING("file io operation failed"); break;
    case JPEG_ERR_ALLOC:        str = VM_STRING("memory allocation failed"); break;
    case JPEG_ERR_BAD_DATA:     str = VM_STRING("bad segment data"); break;
    case JPEG_ERR_DHT_DATA:     str = VM_STRING("bad huffman table segment"); break;
    case JPEG_ERR_DQT_DATA:     str = VM_STRING("bad quant table segment"); break;
    case JPEG_ERR_SOS_DATA:     str = VM_STRING("bad scan segment"); break;
    case JPEG_ERR_SOF_DATA:     str = VM_STRING("bad frame segment"); break;
    case JPEG_ERR_RST_DATA:     str = VM_STRING("wrong restart marker"); break;
    default:                    str = VM_STRING("unknown code"); break;
  }

  return str;
} // GetErrorStr()
コード例 #16
0
ファイル: util.c プロジェクト: paranojik/multitv
void AddCodecTableHeader2CSVFile(vm_file *f_csv)
{
   if(f_csv==NULL) return;
   vm_string_fprintf(f_csv,VM_STRING("Codec,Voice Activity Detection,Bitrate(bps),Audio file,Duration(sec),Encode(MHz),Decode(MHz),nChannels\n"));
   return;
}
コード例 #17
0
void vm_sys_info_get_time(vm_char *m_time, TimeFormat tf)
{
    SYSTEMTIME SystemTime;

    /* check error(s) */
    if (NULL == m_time)
        return;

    GetLocalTime(&SystemTime);

    switch (tf)
    {
    case HHMMSS:
        vm_string_sprintf(m_time,
                          VM_STRING("%.2d:%.2d:%.2d"),
                          SystemTime.wHour,
                          SystemTime.wMinute,
                          SystemTime.wSecond);
        break;

    case HHMM:
        vm_string_sprintf(m_time,
                          VM_STRING("%.2d:%.2d"),
                          SystemTime.wHour,
                          SystemTime.wMinute);
        break;

    case HHMMSSMS1:
        vm_string_sprintf(m_time,
                          VM_STRING("%.2d:%.2d:%.2d.%d"),
                          SystemTime.wHour,
                          SystemTime.wMinute,
                          SystemTime.wSecond,
                          SystemTime.wMilliseconds / 100);
        break;

    case HHMMSSMS2:
        vm_string_sprintf(m_time,
                          VM_STRING("%.2d:%.2d:%.2d.%d"),
                          SystemTime.wHour,
                          SystemTime.wMinute,
                          SystemTime.wSecond,
                          SystemTime.wMilliseconds / 10);
        break;

    case HHMMSSMS3:
        vm_string_sprintf(m_time,
                          VM_STRING("%.2d:%.2d:%.2d.%d"),
                          SystemTime.wHour,
                          SystemTime.wMinute,
                          SystemTime.wSecond,
                          SystemTime.wMilliseconds);
        break;

    default:
        vm_string_sprintf(m_time,
                          VM_STRING("%.2d:%.2d:%.2d"),
                          SystemTime.wHour,
                          SystemTime.wMinute,
                          SystemTime.wSecond);
        break;
    }
} /* void vm_sys_info_get_time(vm_char *m_time, TimeFormat tf) */
コード例 #18
0
vm_status vm_sys_info_cpu_loading_avg(struct VM_SYSINFO_CPULOAD *dbuf, Ipp32u timeslice/* in msec */) {
  PDH_STATUS sts = ERROR_SUCCESS;
  HQUERY tmpq = 0;
  vm_status rtval = VM_NULL_PTR;
  vm_char scountername[MAX_COUNTER_NAME];
  PDH_HCOUNTER cptr = NULL;
  BOOL isprepared = FALSE;
  DWORD t;
  PDH_FMT_COUNTERVALUE v;
  int i;
  /* we need 1 ms period to hold timeslice time correct */
  timeBeginPeriod(ONEMILLISECOND);
  do {
#ifdef VM_CHECK_CPU_CHECK_TIMESLICE
    if (timeslice < 10) {
      rtval = VM_NOT_ENOUGH_DATA;
      break;
      }
#endif
    if (dbuf == NULL) {
      dbuf = (struct VM_SYSINFO_CPULOAD *)malloc(sizeof(struct VM_SYSINFO_CPULOAD));
      if (dbuf != NULL)
        dbuf[0].cpudes = NULL;
      }
    if (dbuf == NULL)
      break;
    if (dbuf[0].ncpu == 0)
      break;
    if (dbuf[0].cpudes == NULL) {
      dbuf[0].ncpu = vm_sys_info_get_cpu_num();
      dbuf[0].cpudes = (struct VM_SYSINFO_CPULOAD_ENTRY *)(malloc(sizeof(struct VM_SYSINFO_CPULOAD_ENTRY)*(dbuf[0].ncpu+1)));
      }
    if (dbuf[0].cpudes == NULL)
      break;
    /* if cpu description buffer was not NULL I hope it will be enough to hold all information
       about all the CPUs */
    tmpq = dbuf[0].CpuLoadQuery;
    if ( tmpq == 0) {/* no more performance handle created yet */
      PdhOpenQuery(NULL, 0, &tmpq);
      if (tmpq == 0)
        break;
      dbuf[0].CpuLoadQuery = tmpq;
      }
    if (dbuf[0].CpuPerfCounters[0] != 0)
      isprepared = TRUE; /* performance monitor already prepared */
    if (dbuf[0].CpuLoadQuery == 0)
      break;
    if (!isprepared) {
        /* create buffers for counters */
        rtval = VM_OK;
        for( i = 0; i < MAX_PERF_PARAMETERS; ++i ) {
          dbuf[0].CpuPerfCounters[i] = NULL;
          dbuf[0].CpuPerfCounters[i] = (PDH_HCOUNTER *)malloc((dbuf[0].ncpu+1/*for overall counter*/)*sizeof(PDH_HCOUNTER));
          if (dbuf[0].CpuPerfCounters[i] == NULL) {
            rtval = VM_OPERATION_FAILED;
            break;
            }
          }
        if (rtval != VM_OK) {
          for( i = 0; i < MAX_PERF_PARAMETERS; ++i )
            if (dbuf[0].CpuPerfCounters[i] != NULL) {
              free(dbuf[0].CpuPerfCounters[i]);
              dbuf[0].CpuPerfCounters[i] = NULL;
              }
          break;
          }          
        /* add performance counters */
        /* user time                */
        vm_string_strcpy(scountername, VM_STRING("\\Processor     "));
        for( i = 0; i < dbuf[0].ncpu; ++i ) {
          vm_string_sprintf(&scountername[10], VM_STRING("(%d)\\%% User Time"), i);
          cptr = dbuf[0].CpuPerfCounters[0] + i*sizeof(PDH_HCOUNTER);
          sts = PdhAddCounter(dbuf[0].CpuLoadQuery, scountername, 0, cptr);    
          vm_string_sprintf(&scountername[10], VM_STRING("(%d)\\%% Privileged Time"), i);
          cptr = dbuf[0].CpuPerfCounters[1] + i*sizeof(PDH_HCOUNTER);
          sts = PdhAddCounter(dbuf[0].CpuLoadQuery, scountername, 0, cptr);

          vm_string_sprintf(&scountername[10], VM_STRING("(%d)\\%% Interrupt Time"), i);
          cptr = dbuf[0].CpuPerfCounters[2] + i*sizeof(PDH_HCOUNTER);
          sts = PdhAddCounter(dbuf[0].CpuLoadQuery, scountername, 0, cptr);
          }
        }        
      vm_time_sleep(timeslice);
      if ((sts = PdhCollectQueryData(dbuf[0].CpuLoadQuery)) != ERROR_SUCCESS)
        break;
      /* fill in output data structure */
      for(i = 0; i < dbuf[0].ncpu; ++i) {
        sts = PdhGetFormattedCounterValue(dbuf[0].CpuPerfCounters[0][i], PDH_FMT_LONG, &t, &v);
        dbuf[0].cpudes[i].usrload = AVGFLOAT(v.longValue);
        sts = PdhGetFormattedCounterValue(dbuf[0].CpuPerfCounters[1][i], PDH_FMT_LONG, &t, &v); 
        dbuf[0].cpudes[i].sysload = AVGFLOAT(v.longValue);           
        dbuf[0].cpudes[i].idleload = (float)1. - dbuf[0].cpudes[i].usrload - dbuf[0].cpudes[i].sysload;
        dbuf[0].cpudes[i].idleload = (dbuf[0].cpudes[i].idleload < 0) ? 0 : dbuf[0].cpudes[i].idleload;
        sts = PdhGetFormattedCounterValue(dbuf[0].CpuPerfCounters[2][i], PDH_FMT_LONG, &t, &v);
        dbuf[0].cpudes[i].irqsrvload = AVGFLOAT(v.longValue);
        /* clear other parameters for each processor */
        dbuf[0].cpudes[i].iowaitsload = dbuf[0].cpudes[i].softirqsrvload = 0.;
          dbuf[0].cpudes[i].usrniceload = dbuf[0].cpudes[i].vmstalled = 0.;
        }
      rtval = VM_OK;
    } while (0);
    if ((NULL != dbuf) && (ticks_on_avg_call != 0))
      dbuf[0].tickspassed = (vm_tick)((vm_time_get_tick() - ticks_on_avg_call)*1000/vm_time_get_frequency());
    ticks_on_avg_call = vm_time_get_tick();
    timeEndPeriod(ONEMILLISECOND);
  return rtval;
  }
コード例 #19
0
ファイル: usc_ec.c プロジェクト: paranojik/multitv
Ipp32s WINAPI WinMain( HINSTANCE hinst, HINSTANCE xxx, LPWSTR lpCmdLine, Ipp32s yyy )
{
   Ipp8s line[WINCE_CMDLINE_SIZE];                     /* to copy command line */
   Ipp8s* argvv[WINCE_NCMD_PARAMS];
   Ipp8s** argv=argvv;

   wchar_t wexename[WINCE_EXENAME_SIZE];
   Ipp8s exename[WINCE_EXENAME_SIZE];
   Ipp8s cmdline[WINCE_CMDLINE_SIZE];

   /* simulate argc and argv parameters */
   Ipp32s argc;
#else /*Other OS*/
Ipp32s main(Ipp32s argc, Ipp8s *argv[])
{
#endif /*_WIN32_WCE*/
   CommandLineParams clParams;
   USC_EC_Params ecParams;
   USC_Status USCStatus;
   MeasureIt measure;
   FILE *fp_rin = NULL;
   FILE *fp_sin = NULL;
   FILE *fp_sout = NULL;
   FILE *f_log = NULL;
   vm_file *f_csv = NULL;        /* csv File    */
   Ipp8u *in1_buff_cur, *in2_buff_cur, *out_buff_cur;
   Ipp8u *in1_buff=NULL, *in2_buff=NULL, *out_buff=NULL;

   Ipp32s flen, in_len, lCallResult;
   Ipp32s i, frameNum, tailNum;
   Ipp32s usage=0, n_repeat=1;
   double speech_sec;
   Ipp32s delay=0;
   Ipp8s* appName=argv[0];
   Ipp8s pString[MAX_LEN_STRING];
   const  IppLibraryVersion *ver = NULL;
#if defined( _WIN32_WCE )

   GetModuleFileName( hinst, wexename, WINCE_EXENAME_SIZE );
   sprintf( exename, "%ls", wexename );
   sprintf( cmdline, "%ls", lpCmdLine );
   argc = parseCmndLine( exename, cmdline, line, WINCE_CMDLINE_SIZE, argv, WINCE_NCMD_PARAMS );

#endif

   ippStaticInit();

   SetCommandLineByDefault(&clParams);
   strcpy(clParams.csvFileName, "ec_speed.csv");

   usage = ReadCommandLine(&clParams, argc, argv);
   if(clParams.puttolog == 1) {
     if((f_log = fopen(clParams.logFileName, "a")) == NULL) return FOPEN_FAIL;
   } else f_log = NULL;
   if(usage) {
      if(clParams.enumerate == 1) {
         EnumerateStaticLinkedEC(f_log);
         if(f_log) fclose(f_log);
         return 0;
      } else {
        PrintUsage((const Ipp8s *)appName, f_log);
        return USAGE;
      }
   }

   lCallResult = LoadECByName((const Ipp8s *)clParams.ECName, &ecParams, f_log);
   if(lCallResult < 0) {
      sprintf(pString, "Cannot find %s echo canceller.\n", clParams.ECName);
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(f_log) fclose(f_log);
      return LOAD_EC_FAIL;
   }
   ecParams.pUSC_EC_Fxns->std.GetInfo((USC_Handle)NULL, &ecParams.pInfo);
   ecParams.objEC = NULL;
   ecParams.pBanks = NULL;
   ecParams.nBanks = 0;

   if((fp_rin = fopen(clParams.rinFileName,"rb")) == NULL)  {
      sprintf(pString, "echo canceller: File %s [r-in] could not be open.\n", clParams.rinFileName);
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(f_log) fclose(f_log);
      return FOPEN_FAIL;
   }
   if((fp_sin = fopen(clParams.sinFileName,"rb")) == NULL) {
      sprintf(pString, "echo canceller: File %s [s-in] could not be open.\n", clParams.sinFileName);
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(f_log) fclose(f_log);
      return FOPEN_FAIL;
   }
   if((fp_sout = fopen(clParams.soutFileName,"wb")) == NULL) {
      sprintf(pString, "echo canceller: File %s [s-out] could not be open.\n", clParams.soutFileName);
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(f_log) fclose(f_log);
      return FOPEN_FAIL;
   }
   if(clParams.puttocsv) { /* open the csv file */
      if((f_csv = vm_file_open(clParams.csvFileName, "a")) == NULL) {
         sprintf(pString, "\nFile %s could not be open.\n", clParams.csvFileName);
         OutputInfoString(1, f_log, (const Ipp8s*)pString);
         if(f_log) fclose(f_log);
         return FOPEN_FAIL;
      }
   }
    if(clParams.printSysInfo){
        OutputInfoString(0, f_log,"The Intel(R) echo canceller conformant to ITU G167 and G168,\n");
        ver = ippscGetLibVersion();
        sprintf(pString, "The Intel(R) IPPSC library used:  %d.%d.%d Build %d, name %s\n",
            ver->major,ver->minor,ver->majorBuild,ver->build,ver->Name);
        OutputInfoString(0, f_log, (const Ipp8s*)pString);
        ver = ippsGetLibVersion();
        sprintf(pString, "The Intel(R) IPPSP library used:  %d.%d.%d Build %d, name %s\n",
            ver->major,ver->minor,ver->majorBuild,ver->build,ver->Name);
        OutputInfoString(0, f_log, (const Ipp8s*)pString);
    }
    sprintf(pString, "Input  rin file: %s\n", clParams.rinFileName);
    OutputInfoString(1, f_log, (const Ipp8s*)pString);
    sprintf(pString, "Input  sin file: %s\n", clParams.sinFileName);
    OutputInfoString(1, f_log, (const Ipp8s*)pString);
    sprintf(pString, "Output sout file: %s\n", clParams.soutFileName);
    OutputInfoString(1, f_log, (const Ipp8s*)pString);
    switch(clParams.nlp) {
     case 0:
         sprintf(pString, "NLP disabled\n");
         break;
     case 1:
         sprintf(pString, "NLP type 1 enabled\n");
         break;
     default:
         sprintf(pString, "NLP  type 2 enabled\n");
    }

    switch(clParams.alg) {
     case EC_FULLBAND:
            ecParams.pInfo.params.algType = EC_FULLBAND;
            sprintf(pString, "mode : fullband \n");
            break;
     case EC_SUBBAND:
            ecParams.pInfo.params.algType = EC_SUBBAND;
            sprintf(pString, "mode : subband \n");
            break;
     case EC_AFFINESUBBAND:
         ecParams.pInfo.params.algType = EC_AFFINESUBBAND;
         sprintf(pString, "mode : subband affine projection \n");
         break;
     case EC_FASTSUBBAND:
            ecParams.pInfo.params.algType = EC_FASTSUBBAND;
            sprintf(pString, "mode : fast subband \n");
            break;
     default: return UNKNOWN_FORMAT;
   }
    OutputInfoString(1, f_log, (const Ipp8s*)pString);
    switch(clParams.adapt) {
        case 0:
            sprintf(pString, "adaptation : disable \n");
            ecParams.pInfo.params.modes.adapt = AD_OFF;
            break;
        case 2:
            sprintf(pString, "adaptation : lite \n");
            ecParams.pInfo.params.modes.adapt = AD_LITEADAPT;
            break;
        default:
            ecParams.pInfo.params.modes.adapt = AD_FULLADAPT;
            sprintf(pString, "adaptation : full \n");
    }
   OutputInfoString(1, f_log, (const Ipp8s*)pString);
   sprintf(pString, "echo tail length : %d\n", clParams.tail);
   OutputInfoString(1, f_log, (const Ipp8s*)pString);
   if(clParams.puttocsv) {
    if(clParams.printSysInfo){
        sysInfoToCSV(f_csv);
    }
   }
   ecParams.pInfo.params.pcmType.sample_frequency = clParams.freq;
   ecParams.pInfo.params.pcmType.bitPerSample = 16;
   ecParams.pInfo.params.echotail = clParams.tail;
   ecParams.pInfo.params.modes.zeroCoeff = 1;///???
   ecParams.pInfo.params.modes.nlp = clParams.nlp;
   ecParams.pInfo.params.modes.cng = clParams.cng;
   ecParams.pInfo.params.modes.td = 1;
   ecParams.pInfo.params.modes.ah = clParams.ah_mode;

   ecParams.pUSC_EC_Fxns->std.NumAlloc((const USC_EC_Option *)&ecParams.pInfo.params, &ecParams.nBanks);
   ecParams.pBanks = (USC_MemBank*)ippsMalloc_8u(sizeof(USC_MemBank)*ecParams.nBanks);
   if(!ecParams.pBanks) {
      sprintf(pString, "\nLow memory: %d bytes not allocated\n", (int)(sizeof(USC_MemBank)*ecParams.nBanks));
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(fp_rin) fclose(fp_rin);
      if(fp_sin) fclose(fp_sin);
      if(fp_sout) fclose(fp_sout);
      if(clParams.puttocsv) { if(f_csv) vm_file_fclose(f_csv); }
      if(f_log) fclose(f_log);
      return MEMORY_FAIL;
   }
   ecParams.pUSC_EC_Fxns->std.MemAlloc((const USC_EC_Option *)&ecParams.pInfo.params, ecParams.pBanks);
   for(i=0;i<ecParams.nBanks;i++) {
     ecParams.pBanks[i].pMem = (Ipp8s *)ippsMalloc_8u(ecParams.pBanks[i].nbytes);//375d60,377420
     if(!ecParams.pBanks[i].pMem) {
       sprintf(pString, "\nLow memory: %d bytes not allocated\n", ecParams.pBanks[i].nbytes);
       OutputInfoString(1, f_log, (const Ipp8s*)pString);
       if(ecParams.pBanks) ippsFree(ecParams.pBanks);
       if(fp_rin) fclose(fp_rin);
       if(fp_sin) fclose(fp_sin);
       if(fp_sout) fclose(fp_sout);
       if(clParams.puttocsv) { if(f_csv) vm_file_fclose(f_csv); }
       if(f_log) fclose(f_log);
       return MEMORY_FAIL;
     }
   }

   flen = PrepareInput(fp_rin, " receive-in input ", &in1_buff, f_log);
   in_len = PrepareInput(fp_sin, " send-in input ", &in2_buff, f_log);

   if(ecParams.pInfo.params.pcmType.sample_frequency == 8000){ /* 8 KHz */
      delay = (Ipp32s) (clParams.fdelay * 8000 * 2/1000);
   }else{ /* 16 KHz */
      delay = (Ipp32s) (clParams.fdelay * 16000 * 2/1000);
   }
   flen -= delay;
   if(flen < 0)  flen = 0;
   if (flen < in_len)
       in_len = flen;

   out_buff=(Ipp8u*)ippsMalloc_8u(in_len);/* allocate output buffer */
   if(!out_buff){ /* allocate output buffer */
      sprintf(pString, "\nNo memory for buffering of %d output bytes", in_len);
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(f_log) fclose(f_log);
      return MEMORY_FAIL;
   }

   /* time stamp prior to threads creation, creation and running time may overlap. */
   measure_start(&measure);

   n_repeat = clParams.nRepeat;
   while(n_repeat--) {
      USCStatus = ecParams.pUSC_EC_Fxns->std.Init((const USC_EC_Option *)&ecParams.pInfo.params, ecParams.pBanks, &ecParams.objEC);
      if(USCStatus!=USC_NoError) {
        OutputInfoString(1, f_log,"\nCan not initialize the EC object!");
        if(ecParams.pBanks) ippsFree(ecParams.pBanks);
        if(fp_rin) fclose(fp_rin);
        if(fp_sin) fclose(fp_sin);
        if(fp_sout) fclose(fp_sout);
        if(clParams.puttocsv) { if(f_csv) vm_file_fclose(f_csv); }
        if(f_log) fclose(f_log);
        return ERROR_INIT;
      }
      ecParams.pUSC_EC_Fxns->std.GetInfo(ecParams.objEC, (USC_EC_Info *)&ecParams.pInfo);
      frameNum = in_len/ecParams.pInfo.params.framesize;
      tailNum = (in_len/sizeof(Ipp16s)) - (ecParams.pInfo.params.framesize/sizeof(Ipp16s))*frameNum;

      out_buff_cur = out_buff;
      in1_buff_cur = in1_buff;
      in2_buff_cur = in2_buff+ delay; /* shift forward the sin at delay */

      for (i = 0; i < frameNum; i++) {
          ecParams.pUSC_EC_Fxns->CancelEcho(ecParams.objEC, (Ipp16s *)in2_buff_cur,
              (Ipp16s *)in1_buff_cur, (Ipp16s *)out_buff_cur);//4,6,9,11,14,19,21,26,29,31,34,36,39,41,44,46,49,51
          in1_buff_cur += ecParams.pInfo.params.framesize;
          in2_buff_cur += ecParams.pInfo.params.framesize;
          out_buff_cur += ecParams.pInfo.params.framesize;
      }
      for (i = 0; i < tailNum; i++) {
          ippsZero_16s((Ipp16s *)out_buff_cur, tailNum);
      }
   }

   measure_end(&measure);

   if (PostProcessPCMstream((Ipp8s *)out_buff, in_len)) {
       sprintf(pString, "No memory for load of %d bytes convert from linear PCM to special pack value.",in_len);
       OutputInfoString(1, f_log, (const Ipp8s*)pString);
       if(f_log) fclose(f_log);
       return MEMORY_FAIL;
   }
   /* Write output PCM to the output file */
   fwrite(out_buff, 1, in_len, fp_sout);

   for(i=0; i<ecParams.nBanks;i++){
     if(ecParams.pBanks[i].pMem) ippsFree(ecParams.pBanks[i].pMem);
     ecParams.pBanks[i].pMem = NULL;
   }
   if(ecParams.pBanks) { ippsFree(ecParams.pBanks); ecParams.pBanks = NULL; }
   ippsFree(out_buff);

   speech_sec = (in_len / 2 * clParams.nRepeat)/(double)ecParams.pInfo.params.pcmType.sample_frequency;
   measure_output(f_log, &measure, speech_sec);
   sprintf(pString, "Done %d samples of %d Hz PCM wave file (%g sec)\n",
       (in_len>>1) * clParams.nRepeat, ecParams.pInfo.params.pcmType.sample_frequency, speech_sec);
   OutputInfoString(1, f_log, (const Ipp8s*)pString);

   if(clParams.puttocsv) {
       Ipp8s* rinFile;
       Ipp8s* sinFile;
       if ((rinFile = strrchr(clParams.rinFileName, '/')) != NULL) {
           rinFile += 1;
       } else if ((rinFile = strrchr(clParams.rinFileName, '\\')) != NULL) {
           rinFile += 1;
       } else
           rinFile = clParams.rinFileName;
       if ((sinFile = strrchr(clParams.sinFileName, '/')) != NULL) {
           sinFile += 1;
       } else if ((sinFile = strrchr(clParams.sinFileName, '\\')) != NULL) {
           sinFile += 1;
       } else
           sinFile = clParams.sinFileName;
       i=sprintf(pString, clParams.ECName);
       i += sprintf(pString + i,",");
       switch(clParams.alg) {
            case EC_FULLBAND:
                i += sprintf(pString + i,"fullband,");
                break;
            case EC_SUBBAND:
                i += sprintf(pString + i,"subband,");
                break;
            case EC_FASTSUBBAND:
                i += sprintf(pString + i,"fast subband,");
                break;
            default:
                i += sprintf(pString + i,"subband,");
       }
       switch(clParams.adapt) {
            case 2:
                i += sprintf(pString + i,"lite,");
                break;
            default:
                i += sprintf(pString + i,"full,");
       }
       i += sprintf(pString + i,"%d,",clParams.tail);
       i += sprintf(pString + i,"%d,%s,%s,%4.2f,%4.2f",
            ecParams.pInfo.params.pcmType.sample_frequency, rinFile, sinFile, speech_sec,
            measure.speed_in_mhz);
       vm_string_fprintf(f_csv,VM_STRING("%s\n"),pString);
       vm_file_fclose(f_csv);
   }

   ippsFree(in1_buff);
   ippsFree(in2_buff);

   fclose(fp_rin);
   fclose(fp_sin);
   fclose(fp_sout);

   OutputInfoString(1, f_log,"Completed !\n");
   if(f_log) fclose(f_log);
   return 0;
}
コード例 #20
0
void vm_sys_info_get_os_name(vm_char *os_name)
{
    OSVERSIONINFO osvi;
    BOOL bOsVersionInfo;

    /* check error(s) */
    if (NULL == os_name)
        return;

    ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);

    bOsVersionInfo = GetVersionEx((OSVERSIONINFO *) &osvi);
    if (!bOsVersionInfo)
    {
        osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
        if (!GetVersionEx((OSVERSIONINFO *) &osvi))
        {
            vm_string_sprintf(os_name, VM_STRING("Unknown"));
            return;
        }
    }

    switch (osvi.dwPlatformId)
    {
    case 2:
        /* test for the specific product family. */
        if ((5 == osvi.dwMajorVersion) && (2 == osvi.dwMinorVersion))
            vm_string_sprintf(os_name, VM_STRING("Win2003"));

        if ((6 == osvi.dwMajorVersion) && (0 == osvi.dwMinorVersion))
            vm_string_sprintf(os_name, VM_STRING("WinVista"));

        if ((5 == osvi.dwMajorVersion) && (1 == osvi.dwMinorVersion))
            vm_string_sprintf(os_name, VM_STRING("WinXP"));

        if ((5 == osvi.dwMajorVersion) && (0 == osvi.dwMinorVersion))
            vm_string_sprintf(os_name, VM_STRING("Win2000"));

        if (4 >= osvi.dwMajorVersion)
            vm_string_sprintf(os_name, VM_STRING("WinNT"));
        break;

        /* test for the Windows 95 product family. */
    case 1:
        if ((4 == osvi.dwMajorVersion) && (0 == osvi.dwMinorVersion))
        {
            vm_string_sprintf(os_name, VM_STRING("Win95"));
            if (('C' == osvi.szCSDVersion[1]) || ('B' == osvi.szCSDVersion[1]))
                vm_string_strcat(os_name, VM_STRING("OSR2" ));
        }

        if ((4 == osvi.dwMajorVersion) && (10 == osvi.dwMinorVersion))
        {
            vm_string_sprintf(os_name, VM_STRING("Win98"));
            if ('A' == osvi.szCSDVersion[1])
                vm_string_strcat(os_name, VM_STRING("SE"));
        }

        if ((4 == osvi.dwMajorVersion) && (90 == osvi.dwMinorVersion))
        {
            vm_string_sprintf(os_name,VM_STRING("WinME"));
        }
        break;

    case 3:
        /* get platform string */
        /* SystemParametersInfo(257, MAX_PATH, os_name, 0); */
        if ((4 == osvi.dwMajorVersion) && (20 == osvi.dwMinorVersion))
        {
            vm_string_sprintf(os_name, VM_STRING("PocketPC 2003"));
        }

        if ((4 == osvi.dwMajorVersion) && (21 == osvi.dwMinorVersion))
        {
            vm_string_sprintf(os_name, VM_STRING("WinMobile2003SE"));
        }

        if ((5 == osvi.dwMajorVersion) && (0 == osvi.dwMinorVersion))
        {
            vm_string_sprintf(os_name, VM_STRING("WinCE 5.0"));
        }
        break;

        /* Something else */
    default:
        vm_string_sprintf(os_name, VM_STRING("Win..."));
        break;
    }
} /* void vm_sys_info_get_os_name(vm_char *os_name) */