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

📄 vivot.c

📁 用于TM1300/PNX1300系列DSP(主要用于视频处理)的各种滤波器源码
💻 C
📖 第 1 页 / 共 3 页
字号:
    runningOverlay = True;

    viYUVAPI(viHALFRES, cifWidth, cifHeight, cifStride, 1,
         0xc,        /* x offset */
         0xc,        /* y offset */
         (Pointer) (cif422Buf[0].Y),
         (Pointer) (cif422Buf[0].U),
         (Pointer) (cif422Buf[0].V));


    voYUVAPI(vo422_COSITED_UNSCALED, fullWidth, fullHeight, fullWidth, 0, 0,
         (Pointer) fullResBuf[0].Y,
         (Pointer) fullResBuf[0].U,
         (Pointer) fullResBuf[0].V);

    voOverlayAPI(64, 128, 352, 120, 64, 64, 1408, (Pointer) cif422Buf[0].Y);

    for (voISRCount = 0; voISRCount < loopCount;) { 
        mmOvlyBufUpdate();
    }

    if (err = viStop(viInst))
        my_abort("viStop", err);
    if (err = voStop(voInst))
        my_abort("voStop", err);
}

void
vivoFreeFullRes()
{
    Int         i;

    for (i = 0; i < NUM_BUF_ENTRIES; i++) {
        _cache_free((Pointer) fullResBuf[i].Y);
        _cache_free((Pointer) fullResBuf[i].U);
        _cache_free((Pointer) fullResBuf[i].V);
    }
}

void
vivoRunFullRes()
{
    tmLibdevErr_t err;

    printf("Displaying Video-In to Video-Out in Full Resolution for several seconds. \n");

    cpGenBuf(fullResBuf, NUM_BUF_ENTRIES, VID_RDY_VI);
    viNum = mmNum = voNum = 0;

    yFieldStride = fullStride;
    uvFieldStride = (fullStride >> 1);
    overlayFieldStride = 0;
    capField = False;
    firstField = True;
    yScanWidth = fullStride;
    uvScanWidth = (fullStride >> 1);
    runningOverlay = False;

    viYUVAPI(viFULLRES, fullWidth, fullHeight, fullStride, 0, 0, 21,
         (Pointer) (fullResBuf[0].Y),
         (Pointer) (fullResBuf[0].U),
         (Pointer) (fullResBuf[0].V));

    voYUVAPI(vo422_COSITED_UNSCALED, fullWidth, fullHeight, fullStride, 0, 0,
         (Pointer) fullResBuf[0].Y,
         (Pointer) fullResBuf[0].U,
         (Pointer) fullResBuf[0].V);

#ifdef __TCS_nohost__
    endless = 1;        /* get stuck in here forever */
#endif

    if (endless) {
        while (1) {        /* get stuck in here forever */
            mmBufUpdate();
        }
    }
    else {
        for (voISRCount = 0; voISRCount < loopCount; ) {
            mmBufUpdate();
        }
    }

    if (err = viStop(viInst))
        my_abort("viStop", err);
    if (err = voStop(voInst))
        my_abort("voStop", err);
}

void
vivoFreeCif422()
{
    ;
}

void
vivoRunCIF()
{
    tmLibdevErr_t err;

    printf("Displaying Video-In to Video-Out in CIF resolution for several seconds.\n");

    cpGenBuf(cif422Buf, NUM_BUF_ENTRIES, VID_RDY_VI);
    viNum = mmNum = voNum = 0;

    yFieldStride = cifStride;
    uvFieldStride = (cifStride >> 1);
    overlayFieldStride = 0;
    capField = True;
    firstField = False;
    yScanWidth = 0;
    uvScanWidth = 0;
    runningOverlay = False;

    viYUVAPI(viHALFRES, cifWidth, cifHeight, cifStride, 1, 4, 11,
         (Pointer) (cif422Buf[0].Y),
         (Pointer) (cif422Buf[0].U),
         (Pointer) (cif422Buf[0].V));

    voYUVAPI(vo422_COSITED_UNSCALED, cifWidth, cifHeight, cifStride, 64, 128,
         (Pointer) cif422Buf[0].Y,
         (Pointer) cif422Buf[0].U,
         (Pointer) cif422Buf[0].V);

    for (voISRCount = 0; voISRCount < loopCount; ) {
        mmBufUpdate();
    }

    if (err = viStop(viInst))
        my_abort("viStop", err);
    if (err = voStop(voInst))
        my_abort("voStop", err);
}

void
vivoOpenAPI()
{
    voOpenAPI();
    viOpenAPI();
}

void
vivoCloseAPI()
{
    vivoFreeCif422();
    vivoFreeFullRes();
    vivoFreeOverlay();
}

void
vivoAlloc()
{
    Int         err;

    allocFullRes();
    allocCif422();
    allocBkBuf();

#ifndef __TCS_nohost__
    err = readYUVFiles("tmlogo", 720, 480,
               bkBuf[0].Y, bkBuf[0].U, bkBuf[0].V);
    if (err)
        fprintf(stderr, "Warning: Missing overlay files \"tmlogo\"\n");
#endif
}

void
vivoRun()
{
    pprocCapabilities_t procCap;
    tmLibdevErr_t       err;

    err = procGetCapabilities(&procCap);
    if (err) 
    {
        fprintf(stderr, "Could not get procCaps\n");
        exit(1);
    }
    vivoAlloc();

    switch(procCap->deviceID)
    {
    case PROC_DEVICE_TM1000: 
    case PROC_DEVICE_TM1100:
    case PROC_DEVICE_TM1300:
        if (videoInUnit != unit0) 
        {
            fprintf(stderr, "Default to unit0 (VI1). VI2 is not availabled on this chip\n");
            videoInUnit = unit0;
        }
        break;
    default:
        /* we suppose that in other cases, that s ok */
        break;
    }

    vivoOpenAPI();

#if TBC==1
    tbcInit(videoStandard, tbcGain, 0, 0);
    if (tbcPhase)
      tbcSetPhase(tbcPhase);
#endif

    vivoRunCIF();
    DP(("Done vivoRunCif\n"));

#if TBC==1
    if (tbcPhase)
      tbcSetPhase(tbcPhase);
#endif

    vivoRunFullRes();
    DP(("Done vivoRunFullRes\n"));

#ifndef __TCS_nohost__
    switch(procCap->deviceID)
    {
    case PROC_DEVICE_TM1000: 
    case PROC_DEVICE_TM1100:
    case PROC_DEVICE_TM1300:
        SetupICP();
#if	TBC==1
	if (tbcPhase)
	  tbcSetPhase(tbcPhase);
#endif
        vivoRunOverlay();
	DP(("Done vivoRunOverlay\n"));
        break;
    default:
        fprintf(stderr, "Overlay test is disabled : ICP is not available on this chip\n");
        break;
    }
#endif

    vivoCloseAPI();
}

void
SetDP()
{   
    DPsize(32000);  /* for debugging */
}

void
vivoDetectworkarounds(void)
{
    tmLibdevErr_t err;
    pprocCapabilities_t cap;

    if (err = procGetCapabilities(&cap))
        my_abort("procGetCapabilities", err);

    if (cap->revisionID <= PROC_REVISION_1_0S && cap->deviceID <= PROC_DEVICE_TM1000) {
    fprintf(stderr, "Detected tm1s1.0 or older version of chip. "
        "They are no longer supported.\n" 
        "Please contact Philips TriMedia to exchange to "
        "a newer version of chip.\n");
    exit(-1);
    }
}

void 
vivoUsage(void)
{
    printf("usage: vivot [ntsc|pal] [cvbs|s-video] [-in cvbs|s-video] [-out cvbs|s-video] [-vi 1|2] -endless\n");
    printf("Example : vivot -in s-video -out cvbs ntsc -vi 2\n");
    printf("\tWill open the VI2 (unit1), and will expect a s-video signal, and will output a cvbs output\n");
}

void 
vivoCheckArgcv(int argc, char **argv)
{
    Int         mark = 1;
    Int         viUnit;
    
    argc--;
    while (argc > 0) {
        if (strcmp(argv[mark], "-vi") == 0) {
            mark++;
            argc--;
            if (1 == sscanf(argv[mark], "%d", &viUnit)) {
                switch(viUnit) {
                case 1:
                    videoInUnit = unit0;
                    break; 
                case 2:
                    videoInUnit = unit1;
                    break;
                default:
                    fprintf(stderr, "Valid values for -vi are 1 or 2\n");
                    break;
                }
                mark++;
                argc--;
            }
        } else if (strcmp(argv[mark], "ntsc") == 0) {           /* NTSC */
            videoStandard = vasNTSC;
            argc--;
            mark++;
        }
        else if (strcmp(argv[mark], "pal") == 0) {        /* PAL */
            videoStandard = vasPAL;
            fullHeight = 576;
            argc--;
            mark++;
        }
        else if (strcmp(argv[mark], "cvbs") == 0) {       /* CVBS */
            inAdapterType = outAdapterType = vaaCVBS;
            argc--;
            mark++;
        }
        else if (strcmp(argv[mark], "s-video") == 0) {    /* S-Video */
            inAdapterType = outAdapterType = vaaSvideo;
            argc--;
            mark++;
        }
#if	TBC==1 						/* COD 3.21.2000 */
        else if (strcmp(argv[mark], "-gain") == 0 && argc>1){
	    tbcGain = atof(argv[mark+1]);	 
	    argc -= 2;
	    mark += 2;	
        } else if (strcmp(argv[mark], "-debug") == 0 && argc>1){
	    tbcDebug = atoi(argv[mark+1]);	 
	    argc -= 2;
	    mark += 2;	
        } else if (strcmp(argv[mark], "-degrees") == 0 && argc>1) {
	    tbcPhase = atof(argv[mark+1]) ;
	    argc -= 2;
	    mark += 2;	
        }
#endif						      /* *end* COD 3.21.2000 */
        else if (strcmp(argv[mark], "-in") == 0) {
            mark++;
            argc--;
            if (strcmp(argv[mark], "cvbs") == 0) {       /* CVBS */
                inAdapterType = vaaCVBS;
                argc--;
                mark++;
            }
            else if (strcmp(argv[mark], "s-video") == 0) {    /* S-Video */
                inAdapterType = vaaSvideo;
                argc--;
                mark++;
            }
            else {
                vivoUsage();
                exit(-1);
            }
        }
        else if (strcmp(argv[mark], "-out") == 0) {
            mark++;
            argc--;
            if (strcmp(argv[mark], "cvbs") == 0) {       /* CVBS */
                outAdapterType = vaaCVBS;
                argc--;
                mark++;
            }
            else if (strcmp(argv[mark], "s-video") == 0) {    /* S-Video */
                outAdapterType = vaaSvideo;
                argc--;
                mark++;
            }
            else {
                vivoUsage();
                exit(-1);
            }
        }
        else if (strcmp(argv[mark], "-endless") == 0) {
            mark++;
            argc--;
            endless = True;
        }
        else {
            vivoUsage();
            argc--;
            mark++;
            exit(-1);
        }
    }
}

/***************************************************************************/

int
main(int argc, char **argv)
{
    SetDP();
    DP((Header));
    printf(Header);

    DP(("Running on ")); tmHelpReportSystem(Null);
    printf("Running on "); tmHelpReportSystem(stdout);

    vivoDetectworkarounds();

#ifndef __TCS_nohost__
    vivoCheckArgcv(argc, argv);
#endif

    vivoRun();

    exit(0);
}

⌨️ 快捷键说明

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