//-----------------------------------------------
void captureApp::handleDecode(){
	if( state == CAP_STATE_DECODING ){
	
		if( !ofxFileHelper::doesFileExist(currentDecodePath) ){
			ofLog(OF_LOG_ERROR, "handleDecode - decode folder not found - can't save files!\n");
		}
		
		float filterMin =  dAppPtr->filterMin;
		float filterMax =  dAppPtr->filterMax;
		float smoothAmnt=  dAppPtr->panel.getValueF("smooth_y_amnt");
		int   smoothDist=  dAppPtr->panel.getValueI("smooth_y_dist");
		bool smoothGaussian = dAppPtr->panel.getValueB("smooth_gaussian");
		int dilatePasses = dAppPtr->panel.getValueI("dilate_passes");
		
		printf("filter min %f filter max %f - smooth %f dist %i \n", filterMin, filterMax, smoothAmnt, smoothDist);
		
		//		float scale = dAppPtr->panel.getValueF("depthScale");
		//		if( panel.getValueB("bReverseModel") ){
		//			filterMin *= -1.0;
		//			filterMax *= -1.0;
		//		}		
		//		
		int numMissed	= 1+ panel.getValueI("decodeSkipFrame");
		
		//you can changed this to a higher number to decode more frames per app frame. 
		for(int k = 0; k < numMissed; k++){
			if( saveIndex < imageSaver.getSize() ){
				
				printf("decoding %i of %i\n", saveIndex, imageSaver.getSize());
				decoder.decodeFrameAndFilter(imageSaver.images[saveIndex], saveIndex, 3, filterMin, filterMax, smoothAmnt, smoothDist, smoothGaussian, dilatePasses);
				
				bool bSaveToDisk = ( panel.getValueI("postCapture") >= POST_CAPTURE_DECODE_EXPORT );
				
				//TODO: theo added saveIndex > 3 - to ignore this crazy boogy frame 
				//also lets the system get a good decode before export
				//TODO: really figure out why we get a frame from the previous capture
				if( saveIndex % ( numMissed ) == 0 && bSaveToDisk && saveIndex > 3 ){
					float t1 = ofGetElapsedTimef();
					decoder.exportFrameToTGA(currentDecodePath, FRAME_START_INDEX+saveIndex, filterMin, filterMax);
					timeToDecode += ofGetElapsedTimef()-t1;
					saveCount++;
				}
				saveIndex++;
			}else{
				endDecode();
				break;
			}
		}
		
	}
}
//--------------------------------------------------------------
void captureApp::keyPressed(int key) {
	if (key == '='){
		serial.writeByte(255);		// this will turn on led.
	}	
	
	if (key == '-') {
		serial.writeByte(0);		// this will turn off led.
	}
	
	if(key == 'f') {
		ofToggleFullscreen();
	}
	
	if(key == '\t') {
		if( state < CAP_STATE_FADEIN ){
			startFadeIn();
		}
		else if( state == CAP_STATE_FADEIN ){
			bNeedsToLeaveFrame = false;
			face.resetCounters();		
			state = CAP_STATE_WAITING;	
		}
		else if( state == CAP_STATE_CAPTURE ){
			endCapture(true); //force override and cancel - normally capture is timed. 
			bNeedsToLeaveFrame = false;
			face.resetCounters();				
		}else if( state == CAP_STATE_DECODING ){
			endDecode(true);
			bNeedsToLeaveFrame = false;
			face.resetCounters();
		}
	}
	
	if( key == 'h' ){
		if( debugState == CAP_DEBUG ){
			debugState = CAP_NORMAL;
		}else if( debugState == CAP_NORMAL ){
			debugState = CAP_DEBUG;
		}	
	}
	
	if( debugState == CAP_DEBUG ){
		if(panel.getValueB("frameByFrame") && key == OF_KEY_UP){
			patternFrame--;
		}
		
		if(panel.getValueB("frameByFrame") && key == OF_KEY_DOWN){
			patternFrame++;
		}
	}
}
예제 #3
0
int main()
{
    struct coreBuf *corebuf;
    III_scalefac_t III_scalefac;
    typedef short PCM[2][SSLIMIT][SBLIMIT];
    PCM *pcm_sample;
    pcm_sample = (PCM *) mem_alloc((long) sizeof(PCM), "PCM Samp");
    unsigned long sample_frames = 0;
    corebuf = (struct coreBuf *)getCoreBuf();
    struct frame_params fr_ps;
    struct III_side_info_t III_side_info;
    while (1)
    {
        printf(0, "decode\n");
        waitForDecode(&fr_ps, &III_side_info);
        int clip = 0, gr, ch, ss, sb;
        for (gr = 0; gr < 2; gr++)
        {
            double lr[2][SBLIMIT][SSLIMIT], ro[2][SBLIMIT][SSLIMIT];
            //Ö÷œâÂë
            int iii = 0;
            for (ch = 0; ch < fr_ps.stereo; ch++)
            {
                printf(1, "test %d\n", iii ++);
                long int is[SBLIMIT][SSLIMIT];   /*±£ŽæÁ¿»¯ÊýŸÝ*/
                int part2_start;
                part2_start = hsstell();
                //»ñÈ¡±ÈÀýÒò×Ó
                III_get_scale_factors(&III_scalefac, &(III_side_info), gr, ch, &(fr_ps));
                //HuffmanœâÂë
                III_hufman_decode(is, &(III_side_info), ch, gr, part2_start, &(fr_ps));
                //·ŽÁ¿»¯²ÉÑù
                III_dequantize_sample(is, ro[ch], &III_scalefac, &(III_side_info.ch[ch].gr[gr]), ch, &(fr_ps));
            }

            III_stereo(ro, lr, &III_scalefac, &(III_side_info.ch[0].gr[gr]), &(fr_ps));
            printf(0, "%d\n", fr_ps.stereo);
            for (ch = 0; ch < fr_ps.stereo; ch++)
            {
                printf(1, "test %d\n", iii --);

                double re[SBLIMIT][SSLIMIT];
                double hybridIn[SBLIMIT][SSLIMIT];/* Hybrid filter input */
                double hybridOut[SBLIMIT][SSLIMIT];/* Hybrid filter out */
                double polyPhaseIn[SBLIMIT];     /* PolyPhase Input. */
                III_reorder(lr[ch], re, &(III_side_info.ch[ch].gr[gr]), &(fr_ps));
                //¿¹Ÿâ³ÝŽŠÀí
                III_antialias(re, hybridIn, /* Antialias butterflies. */
                              & (III_side_info.ch[ch].gr[gr]), &(fr_ps));
                //IMDCT
                for (sb = 0; sb < SBLIMIT; sb++) /* Hybrid synthesis. */
                {
                    III_hybrid(hybridIn[sb], hybridOut[sb], sb, ch, &(III_side_info.ch[ch].gr[gr]), &(fr_ps));
                }
                for (ss = 0; ss < 18; ss++) //¶àÏàƵÂʵ¹ÖÃ
                    for (sb = 0; sb < SBLIMIT; sb++)
                        if ((ss % 2) && (sb % 2))
                            hybridOut[sb][ss] = -hybridOut[sb][ss];
                for (ss = 0; ss < 18; ss++) //¶àÏàºÏ³É
                {
                    for (sb = 0; sb < SBLIMIT; sb++)
                        polyPhaseIn[sb] = hybridOut[sb][ss];
                    //×ÓŽøºÏ³É
                    clip += SubBandSynthesis(polyPhaseIn, ch, &((*pcm_sample)[ch][ss][0]));
                }
            }
            //PCMÊä³ö
            /* Output PCM sample points for one granule(¿ÅÁ£). */
            out_fifo(*pcm_sample, 18, &(fr_ps), &sample_frames);
            endDecode();
        }
    }
    exit();
}