/* * scene.cpp * * Created on: 2025Äê7ÔÂ21ÈÕ * Author: 86189 */ #include #include #include #include "config.h" #include "ModuleExport.h" #include "f2f.h" #include "scene.h" #include "protocol_internal.h" #include "moduleexport.h" #include "crc.h" s32 Scene::str_delim(const s8* str, u16 logic_channel[]) { s8 pstr[32]; s8 * ptr; s32 i = 0; strcpy(pstr, str); ptr = strtok(pstr, "|"); if (strcmp(ptr, str) == 0) { s8 start, end; ptr = strtok(pstr, "-"); start = atoi(ptr); ptr = strtok(NULL, "-"); end = atoi(ptr); if(start==end) return 0; while (start <= end) { logic_channel[i++] = start++; } return i; } else { while (ptr) { logic_channel[i++] = atoi(ptr); ptr = strtok(NULL, "|"); } return i; } } s32 Scene::convert_to_bin(u8* bin) { s32 i ,j; struct FlowChartHead* flowchart = (struct FlowChartHead*)bin; u32 size = sizeof(struct FlowChartHead); s32 ninports,noutports; u16 rxBufID[64],txBufID[64]; u16 dsp_input_num[2] ={0,0}; u16 dsp_output_num[2] ={0,0}; s32 crc = 0xFFFFFFFF; if (!bin) return 0; struct Module *m = (struct Module *)(bin + size); printf("proc list size %d\n", proc_list.size()); for (i=0; i< proc_list.size(); i++) { Module *m = (struct Module *)(bin + size); proc_field * p = &proc_list[i]; ninports = str_delim(p->inportstr, rxBufID) ; noutports = str_delim(p->outportstr , txBufID) ; if(p->proc_type == ModuleType::PROC_NONE){ continue; } //ducker & spl. if(p->proc_type == PROC_DUCKER || p->proc_type == PROC_CONTINUNOUS_SPL) { //insert a mixer. struct Module *mixer = (struct Module *)(bin + size); u16 channelID[64]; mixer->mDsp = 0; mixer->mID = p->proc_id + 320; mixer->mType = ModuleType::PROC_MIXER; mixer->mTag = 0; mixer->mPhyModule = 0; mixer->mParamaddr = (s32)get_module_param_ptr(p->parameters,p->fixed); size += sizeof(struct Module); mixer->mRxNum = str_delim(proc_list[1].inportstr, channelID) ; memcpy(bin + size , channelID, mixer->mRxNum*sizeof(u16)); size += mixer->mRxNum*sizeof(u16); mixer->mTxNum = 1; memcpy(bin + size , &rxBufID[1], mixer->mTxNum*sizeof(u16)); size += mixer->mTxNum*sizeof(u16); } m = (struct Module *)(bin + size); for(j = 0 ; j< ninports ;j ++) { if(rxBufID[j] > dsp_input_num[p->dsp_index]) { dsp_input_num[p->dsp_index] = rxBufID[j]; } } for(j = 0 ; j< noutports ;j ++) { if(txBufID[j] > dsp_output_num[p->dsp_index]) { dsp_output_num[p->dsp_index] = txBufID[j]; } } m->mDsp = hw_adapter->get_system_is_dual_dsp()?p->dsp_index:0; m->mID = p->proc_id; m->mType = p->proc_type; m->mTag = p->tag; m->mPhyModule = p->physic_type; m->mParamaddr = (s32)get_module_param_ptr(p->parameters,p->fixed); size += sizeof(struct Module); m->mRxNum = ninports; memcpy(bin + size , rxBufID, m->mRxNum*sizeof(u16)); size += m->mRxNum*sizeof(u16); m->mTxNum = noutports; memcpy(bin + size , txBufID, m->mTxNum*sizeof(u16)); size += m->mTxNum*sizeof(u16); if(p->physic_type == ModuleInterfaceType::PHY_INPUT) { PhyPort* phy_id = (PhyPort*)(bin + size); for(j = 0 ; j< ninports ;j ++, phy_id++) { phy_id->mIntType = 0; phy_id->mPhyID = hw_adapter->get_physical_channel(1, j); } size += ninports*sizeof(PhyPort); } else if(p->physic_type == ModuleInterfaceType::PHY_OUTPUT){ PhyPort* phy_id = (PhyPort*)(bin + size); for(j = 0 ; j< noutports ;j ++, phy_id++) { phy_id->mIntType = 0; phy_id->mPhyID = hw_adapter->get_physical_channel(0, j); } size += noutports*sizeof(PhyPort); } } //dual_dsp for 2 DSP,else 1 DSP. for (i =0 ;i < hw_adapter->get_system_is_dual_dsp() + 1 ;i ++) { flowchart->dsp_buffer_num[i] = std::max(dsp_input_num[i], dsp_output_num[i]); } flowchart->module_num = proc_list.size(); flowchart->compress = 0; flowchart->version = 1; flowchart->crc = 0; crc = CRC::crc32((const u8*)bin, size); flowchart->crc = crc; return size; }