Mempal New Frame

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
21 kB
4
Indexable
Never
void Application::RenderNewFrame(void){


	//GenerateColorLUT(void);
	//ColorizeFrame(t_pix* src, t_pix* dst, uint32_t num_pixels);

	uint32_t prevWarpCnt = m_warpCnt;
	if(m_parameters[kFreezeMode]->get()==0&&m_parameters[kFrozen]->get()^m_parameters[kFreeze]->get()){
		m_warpCnt = m_warpCnt;
	} else {
		m_warpCnt = (m_warpCnt+1)%LONG_NUM_FRAMES;
	}


	switch(m_parameters[kAuxMode]->get()){
	case 0: // Opacity

		//Aux to Alpha
		m_hardware.alphaDecoder.WriteReg(0x52, 0x0); //B to U
		m_hardware.alphaDecoder.WriteReg(0x53, 0x0);//B to U
		m_hardware.alphaDecoder.WriteReg(0x58, 0xAA); //B to V
		m_hardware.alphaDecoder.WriteReg(0x59, 0x1A);//B to V

		//Alpha to Alpha
		m_hardware.alphaDecoder.WriteReg(0x54, 0x0); //R to U
		m_hardware.alphaDecoder.WriteReg(0x55, 0x0); //R to U
		m_hardware.alphaDecoder.WriteReg(0x5A, 0xAA); //R to V
		m_hardware.alphaDecoder.WriteReg(0x5B, 0x1A); //R to V
		m_parameters[kMaskModeX]->set(0);
		m_parameters[kMaskModeY]->set(0);
		break;
	case 1: // Mesh
		//Aux to Aux
		m_hardware.alphaDecoder.WriteReg(0x52, 0xAA); //B to U
		m_hardware.alphaDecoder.WriteReg(0x53, 0x1A); //B to U
		m_hardware.alphaDecoder.WriteReg(0x58, 0x0); //B to V
		m_hardware.alphaDecoder.WriteReg(0x59, 0x0); //B to V

		//Alpha to Alpha
		m_hardware.alphaDecoder.WriteReg(0x54, 0x0); //R to U
		m_hardware.alphaDecoder.WriteReg(0x55, 0x0); //R to U
		m_hardware.alphaDecoder.WriteReg(0x5A, 0xAA); //R to V
		m_hardware.alphaDecoder.WriteReg(0x5B, 0x1A); //R to V
		m_parameters[kMaskModeX]->set(0);
		m_parameters[kMaskModeY]->set(0);
		break;
	case 2: // Mask
		//Aux to Aux
		m_hardware.alphaDecoder.WriteReg(0x52, 0xAA); //B to U
		m_hardware.alphaDecoder.WriteReg(0x53, 0x1A); //B to U
		m_hardware.alphaDecoder.WriteReg(0x58, 0x0); //B to V
		m_hardware.alphaDecoder.WriteReg(0x59, 0x0); //B to V

		//Alpha to Alpha
		m_hardware.alphaDecoder.WriteReg(0x54, 0x0); //R to U
		m_hardware.alphaDecoder.WriteReg(0x55, 0x0); //R to U
		m_hardware.alphaDecoder.WriteReg(0x5A, 0xAA); //R to V
		m_hardware.alphaDecoder.WriteReg(0x5B, 0x1A); //R to V


		m_parameters[kMaskModeX]->set(ParamScale(m_parameters[kAux]->get(),m_parameters[kAux]->getMin(),m_parameters[kAux]->getMax(),0,15));
		m_parameters[kMaskModeY]->set(ParamScale(m_parameters[kAux]->get(),m_parameters[kAux]->getMin(),m_parameters[kAux]->getMax(),0,15));
		break;
	}

	m_dmaWrAnalogDecoderBase = 0;
	m_dmaWrKeyerBase = SHORT_NUM_FRAMES;
	m_mediaLoaderBase = SHORT_NUM_FRAMES*2;
	m_warpBase = (SHORT_NUM_FRAMES*2)+MAX_MEDIA_LOADER_FRAMES;
	m_warpBase++; // Reserve a frame for blanking
	m_dmaWrAlphaAuxBase = 4;


	uint32_t KeyerAddr = (uint32_t)m_framebuffers[m_dmaWrKeyerBase+m_dmaWrKeyerLastBuffer];
	uint32_t KeyerPaintAddr = (uint32_t)m_framebuffers[m_dmaWrKeyerBase+(m_dmaWrKeyerLastBuffer+1)%SHORT_NUM_FRAMES];
	uint32_t CaptureAddr = (uint32_t)m_framebuffers[m_dmaWrAnalogDecoderBase+m_dmaWrAnalogDecoder.GetLastBuffer()];
	uint32_t MediaAddr = (uint32_t)m_framebuffers[m_mediaLoaderBase+m_parameters[kStillImage]->get()];
	uint32_t WarpAddr = (uint32_t)m_framebuffers[m_warpCnt+m_warpBase];
	uint32_t PrevWarpAddr = (uint32_t)m_framebuffers[prevWarpCnt+m_warpBase];
	uint32_t KeyerDelayAddr = (uint32_t)m_solitaryframe;

	uint32_t WarpDelayOffset = ((m_parameters[kDelay]->get()*LONG_NUM_FRAMES)/(kParameterConfigs[kDelay].max+1));
	uint32_t MediaDelayOffset = ((m_parameters[kDelay]->get()*m_curMediaLoaderNumFrames)/(kParameterConfigs[kDelay].max+1));

	uint32_t WarpDelayAddr;
	uint32_t MediaDelayAddr;


	switch(m_parameters[kPatch]->get()){
	case 0: // PATCH: WARP
		m_parameters[kDelayMode]->set(0);
		m_parameters[kFreezeMode]->set(0);
		m_parameters[kRecursionMode]->set(0); //1);
		m_parameters[kScanMode]->set(0);

		m_parameters[kMirrorModeX]->set(0);
		m_parameters[kMirrorModeY]->set(0);
		m_parameters[kColorMode]->set(0);
		m_parameters[kScaleMode]->set(0);
		m_parameters[kThresholdMode]->set(0);
		m_parameters[kPositionMode]->set(0);

		switch(m_parameters[kAB]->get()){
		case 0: // AB: A
			m_parameters[kDelayMotionEnable]->set(0);
			break;
		case 1: // AB: B
			m_parameters[kDelayMotionEnable]->set(1);
			break;
		}
		switch(m_parameters[kRoute]->get()){
		case 0: // ROUTE: ARGB ONLY
			m_parameters[kForegroundSourceMode]->set(0); // ARGB Capture
			m_parameters[kKeySourceMode]->set(0); // ARGB Capture
			break;
		case 1: // ROUTE: MEDIA ONLY
			m_parameters[kForegroundSourceMode]->set(1); // Media Base Frame
			m_parameters[kKeySourceMode]->set(1); // Media Base Frame
			break;
		case 2: // ROUTE: ARGB TEXTURE + MEDIA KEY
			m_parameters[kForegroundSourceMode]->set(0); // ARGB Capture
			m_parameters[kKeySourceMode]->set(1); // Media Base Frame
			break;
		case 3: // ROUTE: MEDIA KEY + ARGB TEXTURE
			m_parameters[kForegroundSourceMode]->set(1); // Media Base Frame
			m_parameters[kKeySourceMode]->set(0); // ARGB Capture
			break;
		}
		m_parameters[kBackgroundSourceMode]->set(4); // Warp Delayed Frame
		if(m_parameters[kFrozen]->get()^m_parameters[kFreeze]->get()){
			m_parameters[kEncoderOutMode]->set(4); // Warp Delay Out
			m_parameters[kDviOutMode]->set(4); // Warp Delay Out
		} else {
			m_parameters[kEncoderOutMode]->set(3); // Warp Out
			m_parameters[kDviOutMode]->set(3); // Warp Out
		}
		m_parameters[kWarpSourceMode]->set(5); // Keyer Out

		break;
		case 1: // PATCH: PAINT
			if(m_parameters[kFreeze]->get()){
				memcpy((void*)KeyerDelayAddr,(void*)KeyerAddr,MAX_FRAME_SIZE*sizeof(t_pix));
				Xil_DCacheFlushRange(KeyerDelayAddr, MAX_FRAME_SIZE*sizeof(t_pix));
			}
			if (m_clearScreen) {
				memset((void*)KeyerDelayAddr,0,MAX_FRAME_SIZE*sizeof(t_pix));
				Xil_DCacheFlushRange(KeyerDelayAddr, MAX_FRAME_SIZE*sizeof(t_pix));
			}

			if((m_parameters[kFrozen]->get())||(m_clearScreen)){
				m_parameters[kBackgroundSourceMode]->set(6); // Keyer Delay
			} else {
				m_parameters[kBackgroundSourceMode]->set(5); // Keyer Delay
			}

			m_parameters[kFreezeMode]->set(1);
			m_parameters[kRecursionMode]->set(0);
			m_parameters[kScanMode]->set(0);

			m_parameters[kMirrorModeX]->set(0);
			m_parameters[kMirrorModeY]->set(0);
			m_parameters[kColorMode]->set(0);
			m_parameters[kScaleMode]->set(0);
			m_parameters[kThresholdMode]->set(0);
			m_parameters[kPositionMode]->set(1); //Graphics

			switch(m_parameters[kAB]->get()){
			case 0: // AB: A
				m_parameters[kDelayMotionEnable]->set(0);
				break;
			case 1: // AB: B
				m_parameters[kDelayMotionEnable]->set(1);
				break;
			}
			switch(m_parameters[kRoute]->get()){
			case 0: // ROUTE: ARGB ONLY
				m_parameters[kWarpSourceMode]->set(0); // ARGB Capture
				m_parameters[kKeySourceMode]->set(4);  // Warp
				m_parameters[kDelayMode]->set(0); 	   //Media Select
				break;
			case 1: // ROUTE: MEDIA ONLY
				m_parameters[kWarpSourceMode]->set(2); // Media Select
				m_parameters[kKeySourceMode]->set(4);  // Warp
				m_parameters[kDelayMode]->set(1); 	   //Media Select
				break;
			case 2: // ROUTE: ARGB TEXTURE + MEDIA KEY
				m_parameters[kWarpSourceMode]->set(0); // ARGB Capture
				m_parameters[kKeySourceMode]->set(1);  // Media
				m_parameters[kDelayMode]->set(0); 	   //Media Select
				break;
			case 3: // ROUTE: ARGB KEY + MEDIA TEXTURE
				m_parameters[kWarpSourceMode]->set(2); // Media Select
				m_parameters[kKeySourceMode]->set(0);  // Warp
				m_parameters[kDelayMode]->set(1); 	   //Media Select
				break;
			}

			m_parameters[kForegroundSourceMode]->set(4); // Warp Out

			m_parameters[kEncoderOutMode]->set(5); // Keyer
			m_parameters[kDviOutMode]->set(5); // Keyer Delay

			break;

			case 2: // PATCH: SCENE
				if(m_parameters[kFrozen]->get()^m_parameters[kFreeze]->get()){
					m_parameters[kDelayMode]->set(0); //Delay Select
				} else {
					m_parameters[kDelayMode]->set(1); //Media Select
				}

				m_parameters[kFreezeMode]->set(0);
				m_parameters[kRecursionMode]->set(0);
				m_parameters[kScanMode]->set(0);

				m_parameters[kMirrorModeX]->set(0);
				m_parameters[kMirrorModeY]->set(0);
				m_parameters[kColorMode]->set(0);
				m_parameters[kScaleMode]->set(0);
				m_parameters[kThresholdMode]->set(0);
				m_parameters[kPositionMode]->set(0); //Graphics

				switch(m_parameters[kAB]->get()){
				case 0: // AB: A
					m_parameters[kDelayMotionEnable]->set(0);
					break;
				case 1: // AB: B
					m_parameters[kDelayMotionEnable]->set(1);
					break;
				}
				switch(m_parameters[kRoute]->get()){
				case 0: // ROUTE: ARGB ONLY
					m_parameters[kWarpSourceMode]->set(0); // ARGB Capture
					m_parameters[kBackgroundSourceMode]->set(0); // ARGB Capture
					break;
				case 1: // ROUTE: MEDIA ONLY
					m_parameters[kWarpSourceMode]->set(2);  // Media Select
					m_parameters[kBackgroundSourceMode]->set(2);  // Media Select
					break;
				case 2: // ROUTE: ARGB TEXTURE + MEDIA KEY
					m_parameters[kWarpSourceMode]->set(0); // ARGB Capture
					m_parameters[kBackgroundSourceMode]->set(2); // Media Select
					break;
				case 3: // ROUTE: ARGB KEY + MEDIA TEXTURE
					m_parameters[kWarpSourceMode]->set(2); // Media Select
					m_parameters[kBackgroundSourceMode]->set(0);  // ARGB Capture
					break;
				}

				m_parameters[kKeySourceMode]->set(4);  // Warp
				m_parameters[kForegroundSourceMode]->set(4); // Warp Out
				m_parameters[kEncoderOutMode]->set(5); // Keyer
				m_parameters[kDviOutMode]->set(5); // Keyer

				break;

			case 3: // PATCH: GHOST
//				if(m_parameters[kFrozen]->get()^m_parameters[kFreeze]->get()){
					m_parameters[kDelayMode]->set(0); //Delay Select
//				} else {
//					m_parameters[kDelayMode]->set(1); //Media Select
//				}

				m_parameters[kFreezeMode]->set(0);
				m_parameters[kRecursionMode]->set(0);
				m_parameters[kScanMode]->set(0);

				m_parameters[kMirrorModeX]->set(0);
				m_parameters[kMirrorModeY]->set(0);
				m_parameters[kColorMode]->set(0);
				m_parameters[kScaleMode]->set(0);
				m_parameters[kThresholdMode]->set(0);
				m_parameters[kPositionMode]->set(0); //Graphics

				switch(m_parameters[kAB]->get()){
				case 0: // AB: A
					m_parameters[kDelayMotionEnable]->set(0);
					break;
				case 1: // AB: B
					m_parameters[kDelayMotionEnable]->set(1);
					break;
				}
				switch(m_parameters[kRoute]->get()){
				case 0: // ROUTE: ARGB ONLY
					m_parameters[kWarpSourceMode]->set(0); // ARGB Capture
					m_parameters[kKeySourceMode]->set(3);  // Warp Out
					break;
				case 1: // ROUTE: MEDIA ONLY
					m_parameters[kWarpSourceMode]->set(2); // Media Select
					m_parameters[kKeySourceMode]->set(3);  // Warp Out
					break;
				case 2: // ROUTE: ARGB TEXTURE + MEDIA KEY
					m_parameters[kWarpSourceMode]->set(0); // ARGB Capture
					m_parameters[kKeySourceMode]->set(2);   // Media Select
					break;
				case 3: // ROUTE: ARGB KEY + MEDIA TEXTURE
					m_parameters[kWarpSourceMode]->set(2); // Media Select
					m_parameters[kKeySourceMode]->set(0);  // ARGB Capture
					break;
				}

				m_parameters[kForegroundSourceMode]->set(3); // Warp Out
				m_parameters[kBackgroundSourceMode]->set(4); // Warp Out Delay

				m_parameters[kEncoderOutMode]->set(5); // Keyer
				m_parameters[kDviOutMode]->set(5); // Keyer

				break;
	}

	//m_parameters[kDiagT2]->set(COMM_T0);
	//m_parameters[kDiagT3]->set(COMM_T1);



	if(m_parameters[kDelayMode]->get()==0){
		if(m_parameters[kMIDIFrameSequenceEnable]->get()==0){
			WarpDelayAddr = (uint32_t)m_framebuffers[m_warpBase+((LONG_NUM_FRAMES+m_warpCnt-WarpDelayOffset)%LONG_NUM_FRAMES)];
		} else {
			WarpDelayAddr = (uint32_t)m_framebuffers[m_warpBase+((LONG_NUM_FRAMES+m_warpCnt-WarpDelayOffset+m_parameters[kLastMIDINoteOn]->get())%LONG_NUM_FRAMES)];
		}

		MediaDelayAddr = MediaAddr;
	} else {
		if (m_curMediaLoaderNumFrames > 0) {
			if(m_parameters[kMIDIFrameSequenceEnable]->get()==0){
				MediaDelayAddr = (uint32_t)m_framebuffers[m_mediaLoaderBase+((m_parameters[kStillImage]->get()+MediaDelayOffset)%m_curMediaLoaderNumFrames)];
			} else {
				MediaDelayAddr = (uint32_t)m_framebuffers[m_mediaLoaderBase+((m_parameters[kStillImage]->get()+MediaDelayOffset+m_parameters[kLastMIDINoteOn]->get())%m_curMediaLoaderNumFrames)];
			}
		} else {
			//No Stills - Should display black frame
			MediaDelayAddr = (uint32_t)m_framebuffers[m_mediaLoaderBase];
		}

		WarpDelayAddr = WarpAddr;
	}

	//DMA Path Assignment
	//uint32_t DispAddr;
	uint32_t WarpSrcAddr;

	//Analog encoder
	uint32_t fieldOffset;
	fieldOffset = (kVideoFormats[m_curAnalogFormat].field_order == kBottomFieldFirst) ? MAX_FRAME_STRIDE : 0;
	switch(m_parameters[kEncoderOutMode]->get()){
	case 0:	//Capture
		m_dmaRdAnalogEncoder.SetAddress(CaptureAddr+fieldOffset);
		break;
	case 1: //Media
		m_dmaRdAnalogEncoder.SetAddress(MediaAddr+fieldOffset);
		break;
	case 2: //MediaDelay
		m_dmaRdAnalogEncoder.SetAddress(MediaDelayAddr+fieldOffset);
		break;
	case 3: //Warp
		m_dmaRdAnalogEncoder.SetAddress(WarpAddr+fieldOffset);
		break;
	case 4: //Warp Delay
		m_dmaRdAnalogEncoder.SetAddress(WarpDelayAddr+fieldOffset);
		break;
	case 5: //Keyer
		m_dmaRdAnalogEncoder.SetAddress(KeyerAddr+fieldOffset);
		break;
	case 6: //Keyer Delay
		m_dmaRdAnalogEncoder.SetAddress(KeyerDelayAddr+fieldOffset);
		break;
	}

	//DviTx
	switch(m_parameters[kDviOutMode]->get()){
	case 0:	//Capture
		m_dmaRdDviTx.SetAddress(CaptureAddr);
		break;
	case 1: //Media
		m_dmaRdDviTx.SetAddress(MediaAddr);
		break;
	case 2: //MediaDelay
		m_dmaRdDviTx.SetAddress(MediaDelayAddr);
		break;
	case 3: //Warp
		m_dmaRdDviTx.SetAddress(PrevWarpAddr);
		break;
	case 4: //Warp Delay
		m_dmaRdDviTx.SetAddress(WarpDelayAddr);
		break;
	case 5: //Keyer
		m_dmaRdDviTx.SetAddress(KeyerAddr);
		break;
	case 6: //Keyer Delay
		m_dmaRdDviTx.SetAddress(KeyerDelayAddr);
		break;
	}

	//KeyerFg
	switch(m_parameters[kForegroundSourceMode]->get()){
	case 0:	//Capture
		m_dmaRdKeyerFg.SetAddress(CaptureAddr);
		break;
	case 1: //Media
		m_dmaRdKeyerFg.SetAddress(MediaAddr);
		break;
	case 2: //MediaDelay
		m_dmaRdKeyerFg.SetAddress(MediaDelayAddr);
		break;
	case 3: //Warp
		m_dmaRdKeyerFg.SetAddress(WarpAddr);
		break;
	case 4: //Warp Delay
		m_dmaRdKeyerFg.SetAddress(WarpDelayAddr);
		break;
	case 5: //Keyer
		m_dmaRdKeyerFg.SetAddress(KeyerAddr);
		break;
	case 6: //Keyer Delay
		m_dmaRdKeyerFg.SetAddress(KeyerDelayAddr);
		break;
	}

	//KeyerBg
	switch(m_parameters[kBackgroundSourceMode]->get()){
	case 0:	//Capture
		m_dmaRdKeyerBg.SetAddress(CaptureAddr);
		break;
	case 1: //Media
		m_dmaRdKeyerBg.SetAddress(MediaAddr);
		break;
	case 2: //MediaDelay
		m_dmaRdKeyerBg.SetAddress(MediaDelayAddr);
		break;
	case 3: //Warp
		m_dmaRdKeyerBg.SetAddress(WarpAddr);
		break;
	case 4: //Warp Delay
		m_dmaRdKeyerBg.SetAddress(WarpDelayAddr);
		break;
	case 5: //Keyer
		m_dmaRdKeyerBg.SetAddress(KeyerPaintAddr);
		break;
	case 6: //Keyer Delay
		m_dmaRdKeyerBg.SetAddress(KeyerDelayAddr);
		break;
	}

	//KeyerKey
	switch(m_parameters[kKeySourceMode]->get()){
	case 0:	//Capture
		m_dmaRdKeyerKey.SetAddress(CaptureAddr);
		break;
	case 1: //Media
		m_dmaRdKeyerKey.SetAddress(MediaAddr);
		break;
	case 2: //MediaDelay
		m_dmaRdKeyerKey.SetAddress(MediaDelayAddr);
		break;
	case 3: //Warp
		m_dmaRdKeyerKey.SetAddress(WarpAddr);
		break;
	case 4: //Warp Delay
		m_dmaRdKeyerKey.SetAddress(WarpDelayAddr);
		break;
	case 5: //Keyer
		m_dmaRdKeyerKey.SetAddress(KeyerAddr);
		break;
	case 6: //Keyer Delay
		m_dmaRdKeyerKey.SetAddress(KeyerDelayAddr);
		break;
	}

	//WarpSrc
	COMM_TEX_WIDTH  = kVideoFormats[m_curAnalogFormat].width;
	if (m_parameters[kProgressive]->get() == 0) {
	COMM_TEX_HEIGHT = kVideoFormats[m_curAnalogFormat].height;
	} else {
		COMM_TEX_HEIGHT = kVideoFormats[m_curAnalogFormat].height << 1;
	}
	switch(m_parameters[kWarpSourceMode]->get()){
	case 0:	//Capture
		WarpSrcAddr = CaptureAddr;
		break;
	case 1: //Media
		WarpSrcAddr = MediaAddr;
		break;
	case 2: //MediaDelay
		WarpSrcAddr = MediaDelayAddr;
		break;
	case 3: //Warp
		WarpSrcAddr = WarpAddr;
		break;
	case 4: //Warp Delay
		WarpSrcAddr = WarpDelayAddr;
		break;
	case 5: //Keyer
		WarpSrcAddr = KeyerAddr;
		break;
	case 6: //Keyer Delay
	default:
		WarpSrcAddr = KeyerDelayAddr;
		break;
	}

	COMM_WARP_F1_TEXTURE_ADDR = WarpSrcAddr;

	if (m_parameters[kFreezeMode]->get()==0&&m_parameters[kFrozen]->get()^m_parameters[kFreeze]->get()) {
		COMM_WARP_F1_DST_ADDR = (uint32_t)m_framebuffers[m_warpBase-1]; //Blanking frame
	} else {
		COMM_WARP_F1_DST_ADDR = WarpAddr;
	}

	m_dmaWrKeyer.Configure(MAX_FIELD_STRIDE, MAX_FRAME_SIZE * sizeof(t_pix), MAX_FRAME_STRIDE, kVideoFormats[m_curAnalogFormat].interlaced, SHORT_NUM_FRAMES);
	m_dmaWrKeyer.SetAddress(		(uint32_t)m_framebuffers[m_dmaWrKeyerBase]			);
	m_dmaWrKeyer.Start();

//	if (m_parameters[kFrozen]->get()) {
//		m_dmaWrAnalogDecoder.m_driver.WriteReg(kAxiDMAWrInterlacedAddr, 0x00030000 | (SHORT_NUM_FRAMES - 1));
//		if (m_parameters[kFreeze]->get()) {
//			m_dmaWrAnalogDecoder.m_driver.WriteReg(kAxiDMAWrStartAddr, 0x1);
//		}
//	} else {
//		m_dmaWrAnalogDecoder.m_driver.WriteReg(kAxiDMAWrInterlacedAddr, 0x00010000 | (SHORT_NUM_FRAMES - 1));
//		m_dmaWrAnalogDecoder.m_driver.WriteReg(kAxiDMAWrStartAddr, 0x1);
//	}

	COMM_ALPHAAUX_LAST_BUFFER = (uint32_t)m_dmaWrAlphaAux.GetLastBuffer();
	if(m_parameters[kAuxMode]->get()==1){
		COMM_MESH_MODE 				= 1;
	} else {
		COMM_MESH_MODE 				= 0;
	}

	COMM_X_POSITION 			= ParamScale(m_parameters[kXPosition]->get(),kParameterConfigs[kXPosition].min,kParameterConfigs[kXPosition].max,0,4095);
	COMM_Y_POSITION 			= ParamScale(m_parameters[kYPosition]->get(),kParameterConfigs[kYPosition].min,kParameterConfigs[kYPosition].max,0,4095);
	COMM_ZOOM 					= ParamScale(m_parameters[kZoom]->get(),kParameterConfigs[kZoom].min,kParameterConfigs[kZoom].max,4095,0);
	COMM_ASPECT 				= ParamScale(m_parameters[kAspect]->get(),kParameterConfigs[kAspect].min,kParameterConfigs[kAspect].max,0,4095);
	COMM_ROTATION 				= ParamScale(m_parameters[kRotation]->get(),kParameterConfigs[kRotation].min,kParameterConfigs[kRotation].max,0,4095);

	switch(m_parameters[kMirrorModeX]->get()){
	case 0: if(m_parameters[kMirrorX]->get()==true){
				COMM_MIRROR_X = 1;
				COMM_FLIP_X = 0;
			} else {
				COMM_MIRROR_X = 0;
				COMM_FLIP_X = 0;
			}
		break;
	case 1: if(m_parameters[kMirrorX]->get()==true){
				COMM_MIRROR_X = 0;
				COMM_FLIP_X = 1;
			} else {
				COMM_MIRROR_X = 0;
				COMM_FLIP_X = 0;
			}
		break;
	case 2: if(m_parameters[kMirrorX]->get()==true){
				COMM_MIRROR_X = 1;
				COMM_FLIP_X = 1;
			} else {
				COMM_MIRROR_X = 0;
				COMM_FLIP_X = 0;
			}
		break;
	}

	switch(m_parameters[kMirrorModeY]->get()){
	case 0: if(m_parameters[kMirrorY]->get()==true){
				COMM_MIRROR_Y = 1;
				COMM_FLIP_Y = 0;
			} else {
				COMM_MIRROR_Y = 0;
				COMM_FLIP_Y = 0;
			}
		break;
	case 1: if(m_parameters[kMirrorY]->get()==true){
				COMM_MIRROR_Y = 0;
				COMM_FLIP_Y = 1;
			} else {
				COMM_MIRROR_Y = 0;
				COMM_FLIP_Y = 0;
			}
		break;
	case 2: if(m_parameters[kMirrorY]->get()==true){
				COMM_MIRROR_Y = 1;
				COMM_FLIP_Y = 1;
			} else {
				COMM_MIRROR_Y = 0;
				COMM_FLIP_Y = 0;
			}
		break;
	}

	COMM_KEY_INVERT				= m_parameters[kInvert]->get();
	COMM_KEY_MODE    			= m_parameters[kKeyMode]->get();
	COMM_UPPER_THRESHOLD		= m_parameters[kUpperThreshold]->get();
	COMM_LOWER_THRESHOLD		= m_parameters[kLowerThreshold]->get();
	COMM_UPPER_CR_THRESHOLD		= m_parameters[kUpperCrThreshold]->get();
	COMM_LOWER_CR_THRESHOLD		= m_parameters[kLowerCrThreshold]->get();
	COMM_SOFTNESS				= ParamScale(m_parameters[kSoftness]->get(),kParameterConfigs[kSoftness].min,kParameterConfigs[kSoftness].max,0,255);
	COMM_CSC_COLORSPACE			= m_parameters[kColorMode]->get();
	COMM_HUE					= ParamScale(m_parameters[kHue]->get(),kParameterConfigs[kHue].min,kParameterConfigs[kHue].max,0,4095);
	COMM_SATURATION				= ParamScale(m_parameters[kSaturation]->get(),kParameterConfigs[kSaturation].min,kParameterConfigs[kSaturation].max,0,4095);
	COMM_CONTRAST				= ParamScale(m_parameters[kContrast]->get(),kParameterConfigs[kContrast].min,kParameterConfigs[kContrast].max,0,4095);
	COMM_MASK_X					= m_parameters[kMaskModeX]->get();
	COMM_MASK_Y					= m_parameters[kMaskModeY]->get();
	COMM_TILE					= m_parameters[kTile]->get();
	COMM_REFLECT				= m_parameters[kReflect]->get();
	COMM_SCALE_MODE				= m_parameters[kScaleMode]->get();
	COMM_POSITION_MODE			= m_parameters[kPositionMode]->get();
	COMM_ASPECT_RATIO			= m_parameters[kAspectMode]->get();
	COMM_PROGRESSIVE			= m_parameters[kProgressive]->get();
	COMM_MESH_RENDER_STATE = 0;
	COMM_ALPHAAUX_START = 1;



}