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

📄 win_main.cpp

📁 audio-video-codecs.rar语音编解码器
💻 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) 2005-2006 Intel Corporation. All Rights Reserved.
//
//              Intel(R) Integrated Performance Primitives
//                  Audio Coding (ippac)
//
*/
// win_main.cpp : Defines the entry point for WINCE version of audio_codec_con.
//

#if defined _WIN32_WCE

//#include <windows.h>
#include "vm_types.h"
#include "umc_thread.h"

Ipp32s main(Ipp32s argc, vm_char* argv[]);

Ipp32s
ParseCmdLine(vm_char* lpCmdLine,
             vm_char** pszArgv,
             Ipp32s& riArgc)
{
    Ipp32s iRes = 0;
    Ipp32s quot = 0;

    riArgc = 0;
    vm_char cPrevChar = ' ';
    Ipp32s iStrLen = vm_string_strlen(lpCmdLine);
    for (Ipp32s i = 0; i < iStrLen; i++) {
        switch (lpCmdLine[i]) {
        case ' ':
        case '\t':
            if ((' ' != cPrevChar) && (NULL != pszArgv) && (quot == 0)) {
              lpCmdLine[i] = 0;
            }
            cPrevChar = ' ';
            break;
        case '"':
            if (' ' == cPrevChar) {
              quot ++;
              if (NULL != pszArgv) {
                pszArgv[riArgc] = &(lpCmdLine[i]) + 1;
              }
              riArgc++;
            } else
            if ((i == iStrLen - 1) || (' ' == lpCmdLine[i + 1])) {
              quot --;
              if ((NULL != pszArgv) && (quot == 0)) {
                lpCmdLine[i] = 0;
              }
            }
            cPrevChar = ' ';
            break;
        default:
            if ((' ' == cPrevChar) && (quot == 0)) {
                if (NULL != pszArgv) {
                  pszArgv[riArgc] = &(lpCmdLine[i]);
                }
                riArgc++;
            }
            cPrevChar = lpCmdLine[i];
            break;
        }
    }
    return iRes;
}

static const vm_char *szWindowClassString =
             VM_STRING("Intel(R) UMC Simple Player Dummy Window");

void CreateDumyWindow(HINSTANCE hInst, HWND& rhWnd)
{
    WNDCLASS    wc;

    wc.style            = CS_HREDRAW | CS_VREDRAW;
    wc.lpszMenuName     = NULL;
    wc.lpfnWndProc      = (WNDPROC) DefWindowProc;
    wc.cbClsExtra       = 0;
    wc.cbWndExtra       = 8;
    wc.hInstance        = hInst;
    wc.hIcon            = 0;
    wc.hCursor          = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground    = (HBRUSH) GetStockObject(WHITE_BRUSH);
    wc.lpszMenuName     = 0;
    wc.lpszClassName    = szWindowClassString;

    ::RegisterClass(&wc);

    rhWnd = CreateWindow(szWindowClassString,
                          szWindowClassString,
                          WS_VISIBLE,
                          CW_USEDEFAULT,
                          CW_USEDEFAULT,
                          CW_USEDEFAULT,
                          CW_USEDEFAULT,
                          NULL,
                          NULL,
                          hInst,
                          NULL);

    ShowWindow(rhWnd, SW_SHOW);
}

void CloseDummyWindow(HINSTANCE hInst, HWND hWnd)
{
    ::DestroyWindow(hWnd);
    ::UnregisterClass(szWindowClassString, hInst);
}

struct MainParams
{
    Ipp32s argc;
    vm_char** argv;
    Ipp32s iRes;
};

Ipp32u MainCallback(void* pvParams)
{
    MainParams* pParams = reinterpret_cast<MainParams*>(pvParams);
    pParams->iRes = main(pParams->argc, pParams->argv);
    return pParams->iRes;
}

Ipp32s WINAPI
WinMain(HINSTANCE hInstance,
        HINSTANCE hPrevInstance,
        LPTSTR    lpCmdLine,
        Ipp32s    nCmdShow)
{
    Ipp32s iRes = 0;
    //  Count the number of parameters
    Ipp32s iArgc = 1;  //  1 is program name

    iRes = ParseCmdLine(lpCmdLine, NULL, iArgc);

    //  Get module file name and pass it to main as a first parameter
    vm_char szFileName[MAX_PATH];
    if (0 == iRes) {
        iRes = GetModuleFileName(hInstance, szFileName, MAX_PATH);
        if (0 != iRes) {
            iArgc++;    //  add program file name parameter
            iRes = 0;
        } else {
          iRes = -1;
        }
    }

    //  Allocate array of string pointers to keep poiners to args
    vm_char** pArgv = NULL;
    if (0 == iRes && 0 != iArgc) {
        pArgv = new vm_char*[iArgc];
        if (NULL == pArgv) {
          iRes = -1;
        }
    }

    if (0 == iRes) {
        pArgv[0] = szFileName;  //  Set up program name as first parameter

        if (1 < iArgc) {
            //  Get pointers to other parameters
            iRes = ParseCmdLine(lpCmdLine, &pArgv[1], iArgc);
            iArgc++;
        }
    }

    if (0 == iRes) {
        MainParams Params;
        Params.argc = iArgc;
        Params.argv = pArgv;
        Params.iRes = 0;
        UMC::Thread MainThread;

        HWND hWnd = 0;
        CreateDumyWindow(hInstance, hWnd);
        SetTimer(hWnd, 1, 100, 0);

        UMC::Status umcRes = MainThread.Create(MainCallback, &Params);
        if (UMC::UMC_OK == umcRes) {
            MSG msg;
            while (GetMessage(&msg, NULL, 0, 0)) {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
                if (!MainThread.IsValid()) {
                  PostQuitMessage(0);
                }

                // Signal to the main() function that ti's time to stop
                if (WM_SYSKEYDOWN == msg.message ||
                    WM_KEYDOWN == msg.message
#if defined(MT_WILSON)
                        && msg.wParam != 228 && // MtWilson brightness down
                        msg.wParam != 227 &&    // MtWilson brightness up
                        msg.wParam != 174 &&    // MtWilson volume down
                        msg.wParam != 175       // MtWilson volume up
#endif // MT_WILSON
                        )
                {
                    pArgv[0][0] = 0;
                }
            }
        }
//Sleep(1000);
        CloseDummyWindow(hInstance, hWnd);
    }

    delete pArgv;

    return iRes;
}

#endif  /* defined _WIN32_WCE */

⌨️ 快捷键说明

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