Пример #1
0
/****************************************************************************
REMARKS:
Main function to do the interactive tests.
****************************************************************************/
ibool doVideoCaptureTest(
    GC_devCtx *gc,
    GA_glCtx *gl,
    int xRes,
    int yRes,
    int bitsPerPixel,
    N_uint32 flags,
    int refreshRate,
    GA_CRTCInfo *crtc,
    N_uint32 planeMask,
    ibool force1bppShadow)
{
    int                     i,choice;
    ibool                   success = true,all = true;
    GA_videoFuncs           video;
    GA_videoCaptureFuncs    capture;
    GA_VideoCaptureInf      captureInfo;
    GA_captureInputTypes    inputs[ ] = { gaCaptureCompositeInput,
                                          gaCaptureSVideoInput,
                                          gaCaptureRGBInput,
                                          gaCaptureRS170Input };
#define NUM_INPUTS (sizeof(inputs) / sizeof(inputs[0]))

    /* Obtain the mode information before setting the mode */
    dc = gc->dc;
    virtualX = virtualY = bytesPerLine = -1;
    modeInfo.dwSize = sizeof(modeInfo);
    if (xRes == -1) {
        if (init.GetVideoModeInfo(flags,&modeInfo) != 0)
            return false;
        }
    else {
        if (init.GetCustomVideoModeInfo(xRes,yRes,-1,-1,bitsPerPixel,&modeInfo) != 0)
            return false;
        }

    /* Check mode for video acceleration capabilities */
    if (!(modeInfo.Attributes & gaHaveAccelVideo)) {
        GC_printf(gc,"Video acceleration not available!\n\n");
        return false;
        }

    /* Check mode for video capture format list */
    captureInfo.dwSize = sizeof(captureInfo);
    if (!(modeInfo.VideoWindows)) {
        GC_printf(gc,"Video capture format list not available!\n\n");
        return false;
        }
    else
        memcpy(&captureInfo,*modeInfo.VideoCapture,captureInfo.dwSize);

    for (;;) {
        /* Display video format menu while in graphics console mode */
        GC_clrscr(gc);
        GC_printf(gc,"Video Capture Test\n\n");

        /* Display menu of available video overlay formats */
        GC_printf(gc,"Select Video Capture input to test:\n\n");
        for (i = 0; i < NUM_INPUTS; i++) {
            if ((captureInfo.InputType & inputs[i]) != inputs[i])
                continue;
            GC_printf(gc,"  [%i] - %s\n",i,displayInput(inputs[i]));
            }
        GC_printf(gc,"  [Q] - Quit\n\n");
        GC_printf(gc,"Choice: ");
        for (;;) {
            choice = EVT_getch();
            if (tolower(choice) == 'q' || choice == 0x1B)
                return true;
            choice = (choice) - '0';
            if (choice >= 0 && choice < NUM_INPUTS) {
                if ((captureInfo.InputType & inputs[choice]) == inputs[choice])
                    break;
                }
            }

        /* Obtain the mode information and set the display mode */
        GC_leave(gc);
        dc = gc->dc;
        virtualX = virtualY = bytesPerLine = -1;
        modeInfo.dwSize = sizeof(modeInfo);
        if (xRes == -1) {
            if (init.GetVideoModeInfo(flags,&modeInfo) != 0)
                return false;
            if (init.SetVideoMode(flags,&virtualX,&virtualY,&bytesPerLine,&maxMem,refreshRate,crtc) != 0)
                return false;
            }
        else {
            if (init.GetCustomVideoModeInfo(xRes,yRes,-1,-1,bitsPerPixel,&modeInfo) != 0)
                return false;
            if (init.SetCustomVideoMode(xRes,yRes,bitsPerPixel,flags,&virtualX,&virtualY,&bytesPerLine,&maxMem,crtc) != 0)
                return false;
            }
        cntMode = flags;
        if (!InitSoftwareRasterizer(cntDevice,1,false))
            PM_fatalError("Unable to initialise software rasteriser!");

        /* Get the hardware video overlay functions */
        video.dwSize = sizeof(video);
        if (!REF2D_queryFunctions(ref2d,GA_GET_VIDEOFUNCS,&video)) {
            displayError("Video functions not available!");
            success = false;
            goto DoneTests;
            }
        capture.dwSize = sizeof(capture);
        if (!REF2D_queryFunctions(ref2d,GA_GET_VIDEOCAPTUREFUNCS,&capture)) {
            displayError("Video capture functions not available!");
            success = false;
            goto DoneTests;
            }

        /* Run the tests for the selected capture input */
        i = choice;
        all = (stricmp(accelTestName,"all") == 0);
        if (all || stricmp(accelTestName,"capture") == 0)
            if (staticTest(&video,&capture,inputs[i],gaCaptureStandardNTSC,&captureInfo) == 0x1B)
                goto DoneTests;

DoneTests:
        /* Return to text mode, restore the state of the console and reloop */
        ExitSoftwareRasterizer();
        GC_restore(gc);
        if (!success)
            break;
        }

    (void)gl;
    (void)planeMask;
    (void)force1bppShadow;
    return success;
}
Пример #2
0
int main() {
    staticTest();
    dynamicTest(1972);
}