FastBitVector BytecodeLivenessAnalysis::getLivenessInfoAtBytecodeOffset(unsigned bytecodeOffset)
{
    FastBitVector temp;
    FastBitVector result;

    getLivenessInfoForNonCapturedVarsAtBytecodeOffset(bytecodeOffset, temp);

    unsigned numCapturedVars = numberOfCapturedVariables(m_codeBlock);
    if (numCapturedVars) {
        int firstCapturedLocal = VirtualRegister(captureStart(m_codeBlock)).toLocal();
        result.resize(temp.numBits() + numCapturedVars);
        for (unsigned i = 0; i < numCapturedVars; ++i)
            result.set(firstCapturedLocal + i);
    } else
        result.resize(temp.numBits());

    int tempLength = temp.numBits();
    ASSERT(tempLength >= 0);
    for (int i = 0; i < tempLength; i++) {
        if (!temp.get(i))
            continue;

        if (!numCapturedVars) {
            result.set(i);
            continue;
        }

        if (virtualRegisterForLocal(i).offset() > captureStart(m_codeBlock))
            result.set(i);
        else 
            result.set(numCapturedVars + i);
    }
    return result;
}
Example #2
0
void MagRead::toggleRead() {
	QString backStr;

	if( captureAudio ) {
		captureStop();
		if( onMainPage )
			backStr = "Start";
		else
			backStr = "Back";
		captureAudio = false;
	} else if( onMainPage ) {
		captureStart();
		backStr = "Stop";
		captureAudio = true;
	} else {
		card.clear();
		backStr = "Start";
		mainPage();
	}

#ifdef Q_OS_SYMBIAN
			backSoftKey->setText( backStr );
#else
			mainBackBtn->setText( backStr );
#endif
}
static bool isValidRegisterForLiveness(CodeBlock* codeBlock, int operand)
{
    VirtualRegister virtualReg(operand);
    return !codeBlock->isConstantRegisterIndex(operand) // Don't care about constants.
        && virtualReg.isLocal() // Don't care about arguments.
        && (!numberOfCapturedVariables(codeBlock) // If we have no captured variables, we're good to go.
            || (virtualReg.offset() > captureStart(codeBlock) || (virtualReg.offset() <= captureEnd(codeBlock))));
}
static void setForOperand(CodeBlock* codeBlock, FastBitVector& bits, int operand)
{
    ASSERT(isValidRegisterForLiveness(codeBlock, operand));
    VirtualRegister virtualReg(operand);
    if (virtualReg.offset() > captureStart(codeBlock))
        bits.set(virtualReg.toLocal());
    else
        bits.set(virtualReg.toLocal() - numberOfCapturedVariables(codeBlock));
}
bool BytecodeLivenessAnalysis::operandIsLiveAtBytecodeOffset(int operand, unsigned bytecodeOffset)
{
    int numCapturedVars = numberOfCapturedVariables(m_codeBlock);
    if (VirtualRegister(operand).isArgument())
        return true;
    if (operand <= captureStart(m_codeBlock) && operand > captureEnd(m_codeBlock))
        return true;
    FastBitVector result;
    getLivenessInfoForNonCapturedVarsAtBytecodeOffset(bytecodeOffset, result);
    return result.get(operand - numCapturedVars);
}
Example #6
0
void startCapture(int delay)
{
	if (g_bPause)
	{
		displayMessage("Cannot record when paused!");
	}
	else
	{
		captureStart(delay);
	}
}
Example #7
0
void SWipe::mainBtn_clicked() {
	if( captureAudio ) {
		captureStop();
		statusLabel.setText( "Stopped.  Press Start to capture" );
	} else {
		captureStart();
		statusLabel.setText( "Capturing audio.  Press Stop to stop" );
	}

	captureAudio = !captureAudio;
}
Example #8
0
int main(int argc, char* argv)
{   
 
    fb_init();
    
    printf("after fb_init\n");
    deviceOpen();
    printf("after deviceOpen\n");
    if(!deviceInit())
    {
        return 0;
    }
    printf("after deviceInit\n");
    captureStart();
    printf("after captureStart\n");
    while(1)
    {
	mainLoop();
        printf("in mainLoop\n");
    }

    printf("*****quit\n");
}
Example #9
0
FREObject toggleCapturing(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[])
{
    int32_t _id, _opt;
    FREGetObjectAsInt32(argv[0], &_id);
    FREGetObjectAsInt32(argv[1], &_opt);

    CCapture* cap;
    cap = active_cams[_id];

    if(cap)
    {
        if(_opt == 0)
        {
            captureStop(cap);
        }
        else if(_opt == 1)
        {
            // TODO can fail when starting after stop so we need to handle result
            captureStart(cap);
        }
    }

    return NULL;
}
Example #10
0
void captureRestart(int)
{
    captureStop(0);
    captureStart(0);
}
Example #11
0
void captureRestart(int)
{
	captureCloseWriteDevice();
	if (captureOpenWriteDevice())
		captureStart(0);
}
Example #12
0
FREObject getCapture(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[])
{
    int32_t w, h;
    int32_t frameRate = 0;
    uint32_t name_size = 0;
    const uint8_t* name_val = NULL;

    FREGetObjectAsUTF8(argv[0], &name_size, &name_val);

    FREGetObjectAsInt32(argv[1], &w);
    FREGetObjectAsInt32(argv[2], &h);
    FREGetObjectAsInt32(argv[3], &frameRate);

    FREObject objectBA = argv[4];
    FREByteArray baData;
    FREAcquireByteArray(objectBA, &baData);
    uint8_t *ba = baData.bytes;


    int32_t emptySlot = -1;
    size_t i;
    // search empty slot
    for(i = 0; i < MAX_ACTIVE_CAMS; i++)
    {
        if(!active_cams[i])
        {
            emptySlot = i;
            break;
        }
    }

    if(emptySlot == -1)
    {
        ba += ba_write_int(ba, -1);
        FREReleaseByteArray(objectBA);
        return NULL;
    }

    CCapture* cap = NULL;

    cap = createCameraCapture(w, h, (char *)name_val, frameRate );
    
    if(!cap)
    {
        ba += ba_write_int(ba, -1);
        FREReleaseByteArray(objectBA);
        return NULL;
    }

    // start if not running
    if( captureIsCapturing(cap) == 0 )
    {
        captureStart(cap);
    }

    active_cams[emptySlot] = cap;
    active_cams_count++;

    captureGetSize( cap, &w, &h );

    // write result
    ba += ba_write_int(ba, emptySlot);
    ba += ba_write_int(ba, w);
    ba += ba_write_int(ba, h);

    FREReleaseByteArray(objectBA);

    return NULL;
}
Example #13
0
int main(int argc, char **argv)
{

    for (;;) {
        int index, c = 0;

        c = getopt_long(argc, argv, short_options, long_options, &index);

        if (-1 == c)
            break;

        switch (c) {
        case 0: /* getopt_long() flag */
            break;

        case 'd':
            deviceName = optarg;
            break;

        case 'h':
            // print help
            usage(stdout, argc, argv);
            exit(EXIT_SUCCESS);

        case 'o':
            // set jpeg filename
            jpegFilename = optarg;
            break;

        case 'q':
            // set jpeg quality
            jpegQuality = atoi(optarg);
            break;

        case 'm':
#ifdef IO_MMAP
            io = IO_METHOD_MMAP;
#else
            fprintf(stderr, "You didn't compile for mmap support.\n");
            exit(EXIT_FAILURE);
#endif
            break;

        case 'r':
#ifdef IO_READ
            io = IO_METHOD_READ;
#else
            fprintf(stderr, "You didn't compile for read support.\n");
            exit(EXIT_FAILURE);
#endif
            break;

        case 'u':
#ifdef IO_USERPTR
            io = IO_METHOD_USERPTR;
#else
            fprintf(stderr, "You didn't compile for userptr support.\n");
            exit(EXIT_FAILURE);
#endif
            break;

        case 'W':
            // set width
            width = atoi(optarg);
            break;

        case 'H':
            // set height
            height = atoi(optarg);
            break;

        case 'I':
            // set fps
            fps = atoi(optarg);
            break;

        case 'c':
            // set flag for continuous capture, interuptible by sigint
            continuous = 1;
            InstallSIGINTHandler();
            break;


        case 'v':
            printf("Version: %s\n", VERSION);
            exit(EXIT_SUCCESS);
            break;

        default:
            usage(stderr, argc, argv);
            exit(EXIT_FAILURE);
        }
    }

    // check for need parameters
    if (!jpegFilename) {
        fprintf(stderr, "You have to specify JPEG output filename!\n\n");
        usage(stdout, argc, argv);
        exit(EXIT_FAILURE);
    }

    if(continuous == 1) {
        int max_name_len = snprintf(NULL,0,continuousFilenameFmt,jpegFilename,UINT32_MAX,INT64_MAX);
        jpegFilenamePart = jpegFilename;
        jpegFilename = calloc(max_name_len+1,sizeof(char));
        strcpy(jpegFilename,jpegFilenamePart);
    }


    // open and initialize device
    deviceOpen();
    deviceInit();

    // start capturing
    captureStart();

    // process frames
    mainLoop();

    // stop capturing
    captureStop();

    // close device
    deviceUninit();
    deviceClose();

    if(jpegFilenamePart != 0) {
        free(jpegFilename);
    }

    exit(EXIT_SUCCESS);

    return 0;
}
/*
 *  ======== encode_decode ========
 */
static Void encode_decode(VIDENC_Handle enc, VIDDEC_Handle dec, FILE *in,
    FILE *out)
{
    Int                         n;
    Int32                       status;

    VIDDEC_InArgs               decInArgs;
    VIDDEC_OutArgs              decOutArgs;
    VIDDEC_DynamicParams        decDynParams;
    VIDDEC_Status               decStatus;

    VIDENC_InArgs               encInArgs;
    VIDENC_OutArgs              encOutArgs;
    VIDENC_DynamicParams        encDynParams;
    VIDENC_Status               encStatus;

    XDM_BufDesc                 inBufDesc;
    XDAS_Int8                  *src[XDM_MAX_IO_BUFFERS];
    XDAS_Int32                  inBufSizes[XDM_MAX_IO_BUFFERS];

    XDM_BufDesc                 encodedBufDesc;
    XDAS_Int8                  *encoded[XDM_MAX_IO_BUFFERS];
    XDAS_Int32                  encBufSizes[XDM_MAX_IO_BUFFERS];

    XDM_BufDesc                 outBufDesc;
    XDAS_Int8                  *dst[XDM_MAX_IO_BUFFERS];
    XDAS_Int32                  outBufSizes[XDM_MAX_IO_BUFFERS];

    /* clear and initialize the buffer descriptors */
    memset(src,     0, sizeof(src[0])     * XDM_MAX_IO_BUFFERS);
    memset(encoded, 0, sizeof(encoded[0]) * XDM_MAX_IO_BUFFERS);
    memset(dst,     0, sizeof(dst[0])     * XDM_MAX_IO_BUFFERS);

    src[0]     = inBuf;
    encoded[0] = encodedBuf;
    dst[0]     = outBuf;

    inBufDesc.numBufs = encodedBufDesc.numBufs = outBufDesc.numBufs = 1;
   


    inBufDesc.bufSizes      = inBufSizes;
    encodedBufDesc.bufSizes = encBufSizes;
    outBufDesc.bufSizes     = outBufSizes;

    //Note , this declaration is tell the memtab how much need to  allocate the buf sizes  
    inBufSizes[0] = IFRAMESIZE;
    encBufSizes[0] = EFRAMESIZE;
    outBufSizes[0] = OFRAMESIZE;

    inBufDesc.bufs      = src;
    encodedBufDesc.bufs = encoded;
    outBufDesc.bufs     = dst;

    /* initialize all "sized" fields */
    encInArgs.size    = sizeof(encInArgs);
    decInArgs.size    = sizeof(decInArgs);
    encOutArgs.size   = sizeof(encOutArgs);
    decOutArgs.size   = sizeof(decOutArgs);
    encDynParams.size = sizeof(encDynParams);
    decDynParams.size = sizeof(decDynParams);
    encStatus.size    = sizeof(encStatus);
    decStatus.size    = sizeof(decStatus);

    /*
     * Query the encoder and decoder.
     * This app expects the encoder to provide 1 buf in and get 1 buf out,
     * and the buf sizes of the in and out buffer must be able to handle
     * NSAMPLES bytes of data.
     */
    status = VIDENC_control(enc, XDM_GETSTATUS, &encDynParams, &encStatus);
    if (status != VIDENC_EOK) {
        /* failure, report error and exit */
        GT_1trace(curMask, GT_7CLASS, "encode control status = 0x%x\n", status);
        return;
    }

    /* Validate this encoder codec will meet our buffer requirements */
    if ((inBufDesc.numBufs < encStatus.bufInfo.minNumInBufs) ||
        (IFRAMESIZE < encStatus.bufInfo.minInBufSize[0]) ||
        (encodedBufDesc.numBufs < encStatus.bufInfo.minNumOutBufs) ||
        (EFRAMESIZE < encStatus.bufInfo.minOutBufSize[0])) {

        /* failure, report error and exit */
        GT_0trace(curMask, GT_7CLASS,
            "Error:  encoder codec feature conflict\n");
        return;
    }


//#if 0
    status = VIDDEC_control(dec, XDM_GETSTATUS, &decDynParams, &decStatus);
    if (status != VIDDEC_EOK) {
        /* failure, report error and exit */
        GT_1trace(curMask, GT_7CLASS, "decode control status = 0x%x\n", status);
        return;
    }
//#endif


    /* Validate this decoder codec will meet our buffer requirements */
    if ((encodedBufDesc.numBufs < decStatus.bufInfo.minNumInBufs) ||
        (EFRAMESIZE < decStatus.bufInfo.minInBufSize[0]) ||
        (outBufDesc.numBufs < decStatus.bufInfo.minNumOutBufs) ||
        (OFRAMESIZE < decStatus.bufInfo.minOutBufSize[0])) {

        /* failure, report error and exit */
        GT_0trace(curMask, GT_7CLASS,
            "App-> ERROR: decoder does not meet buffer requirements.\n");
        return;
    }



    /*
     * Read complete frames from in, encode, decode, and write to out.
     */


    /* opencv create init image */
#ifdef USE_OPENCV_DISPLAY
    cvNamedWindow("sobel",CV_WINDOW_AUTOSIZE);
    cvResizeWindow("sobel",320,240);//怕畫面太大讓人看不完,所以顯示視窗設小一點
#endif
    CvSize size=cvSize(320,240);
    frame=cvCreateImage(size,IPL_DEPTH_8U,3);
    frame_gray=cvCreateImage(size,IPL_DEPTH_8U,1);
    frame_Smooth=cvCreateImage(size,IPL_DEPTH_8U,1);
    frame_sobel=cvCreateImage(size,IPL_DEPTH_16S,1);
    frame_sobel_8U=cvCreateImage(size,IPL_DEPTH_8U,1);

    /* v4l2 init */
     int count=0;

     deviceOpen();
     deviceInit();
     /*start capturing*/
     captureStart();


    /*===============v4l2 grab frame by Camera======================*/
    while(1){
        mainLoop(); /*this is the v4l2grab frame*/
        memcpy(inBuf,buffers[0].start,IFRAMESIZE);

#ifdef CACHE_ENABLED
#ifdef xdc_target__isaCompatible_64P
        /*
         *  fread() on this processor is implemented using CCS's stdio, which
         *  is known to write into the cache, not physical memory.  To meet
         *  xDAIS DMA Rule 7, we must writeback the cache into physical
         *  memory.  Also, per DMA Rule 7, we must invalidate the buffer's
         *  cache before providing it to any xDAIS algorithm.
         */
        Memory_cacheWbInv(inBuf, IFRAMESIZE);
#else
#error Unvalidated config - add appropriate fread-related cache maintenance
#endif
        /* Per DMA Rule 7, our output buffer cache lines must be cleaned */
        Memory_cacheInv(encodedBuf, EFRAMESIZE);
#endif

        GT_1trace(curMask, GT_1CLASS, "App-> Processing frame %d...\n", count);

        /* encode the frame */
        status = VIDENC_process(enc, &inBufDesc, &encodedBufDesc, &encInArgs,
            &encOutArgs);

        GT_2trace(curMask, GT_2CLASS,
            "App-> Encoder frame %d process returned - 0x%x)\n",
            count, status);

#ifdef CACHE_ENABLED
        /* Writeback this outBuf from the previous call.  Also, as encodedBuf
         * is an inBuf to the next process call, we must invalidate it also, to
         * clean buffer lines.
         */
        Memory_cacheWbInv(encodedBuf, EFRAMESIZE);

        /* Per DMA Rule 7, our output buffer cache lines must be cleaned */
        Memory_cacheInv(outBuf, OFRAMESIZE);
#endif

        if (status != VIDENC_EOK) {
            GT_3trace(curMask, GT_7CLASS,
                "App-> Encoder frame %d processing FAILED, status = 0x%x, "
                "extendedError = 0x%x\n", count, status, encOutArgs.extendedError);
            break;
        }


/***************************decode part (Unuse)***********************************/
/************************** decode the frame**************************************/
        status = VIDDEC_process(dec, &encodedBufDesc, &outBufDesc, &decInArgs,
           &decOutArgs);

        GT_2trace(curMask, GT_2CLASS,
            "App-> Decoder frame %d process returned - 0x%x)\n",
            n, status);

        if (status != VIDDEC_EOK) {
            GT_3trace(curMask, GT_7CLASS,
                "App-> Decoder frame %d processing FAILED, status = 0x%x, "
                "extendedError = 0x%x\n", n, status, decOutArgs.extendedError);
            break;
        }


#ifdef CACHE_ENABLED
        /* Writeback the outBuf. */
        Memory_cacheWb(outBuf, OFRAMESIZE);
#endif

        /* write to file */
        //fwrite(encodedBuf, EFRAMESIZE, 1, out);

        frame->imageData =  encoded[0];
        frame_gray->imageData = dst[0];
        //cvCvtColor(frame,frame_gray,CV_BGR2GRAY);

#ifdef USE_OPENCV_DISPLAY
        cvShowImage("sobel",frame_gray);
        int key=cvWaitKey(33);
#endif 
        //cvSaveImage("22.bmp",frame_gray,0);
        printf("the %d frame are completed \n",count);
        count++;

    }/*end while*/

#ifdef USE_OPENCV_DISPLAY
    cvDestroyWindow("sobel"); 
#endif 
    cvReleaseImage(&frame);
    cvReleaseImage(&frame_gray);
    cvReleaseImage(&frame_Smooth);
    cvReleaseImage(&frame_sobel);
    cvReleaseImage(&frame_sobel_8U);

    GT_1trace(curMask, GT_1CLASS, "%d frames encoded/decoded\n", n);
}
Example #15
0
int main(int argc, char **argv)
{

	for (;;) {
		int index, c = 0;

		c = getopt_long(argc, argv, short_options, long_options, &index);

		if (-1 == c)
			break;

		switch (c) {
			case 0: /* getopt_long() flag */
				break;

			case 'd':
				deviceName = optarg;
				break;

			case 'h':
				// print help
				usage(stdout, argc, argv);
				exit(EXIT_SUCCESS);

			case 'o':
				// set jpeg filename
				jpegFilename = optarg;
				break;

			case 'q':
				// set jpeg quality
				jpegQuality = atoi(optarg);
				break;

			case 'm':
#ifdef IO_MMAP
				io = IO_METHOD_MMAP;
#else
				fprintf(stderr, "You didn't compile for mmap support.\n");
				exit(EXIT_FAILURE);
#endif
				break;

			case 'r':
#ifdef IO_READ
				io = IO_METHOD_READ;
#else
				fprintf(stderr, "You didn't compile for read support.\n");
				exit(EXIT_FAILURE);
#endif
				break;

			case 'u':
#ifdef IO_USERPTR
				io = IO_METHOD_USERPTR;
#else
				fprintf(stderr, "You didn't compile for userptr support.\n");
				exit(EXIT_FAILURE);
#endif
				break;

			case 'W':
				// set width
				width = atoi(optarg);
				break;

			case 'H':
				// set height
				height = atoi(optarg);
				break;
				
			case 'I':
				// set fps
				fps = atoi(optarg);
				break;

			case 'v':
				printf("Version: %s\n", VERSION);
				exit(EXIT_SUCCESS);
				break;

			default:
				usage(stderr, argc, argv);
				exit(EXIT_FAILURE);
		}
	}

	// check for need parameters
	if (!jpegFilename) {
		fprintf(stderr, "You have to specify JPEG output filename!\n\n");
		usage(stdout, argc, argv);
		exit(EXIT_FAILURE);
	}

	// open and initialize device
	deviceOpen();
	deviceInit();

	// start capturing
	captureStart();

	// process frames
	mainLoop();

	// stop capturing
	captureStop();

	// close device
	deviceUninit();
	deviceClose();

	exit(EXIT_SUCCESS);

	return 0;
}