diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index 0e407ac568480ed26b9b567015a72d0d69ee999c..6bb9480f1efaf50a041da82b2386ec6e3edc0887 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -78,36 +78,55 @@ //END ALBERTO //ALBERTO CONCEPT FORK -//bool debugModeForTesting = true; -//const int THREADS_NUMBER = 4; -//int nodeId = 0; - -sem_t* sem; -vectorModeCostStruct* vector; -std::string posNode; -bool father; -int threadNumber; - +//CONTROL CENTER +bool singleMode = false; +bool debugMessage = false; +//CONTROL CENTER + +//GLOBAL VARIABLES +vectorModeCostStruct* vector; //VECTOR OF PROCESSING RESULTS +bool father; //TRUE IF THE PROCESS IS NOT A CHILD +int threadNumber; //NUMBER OF THREAD IF WE ARE IN A CHILD +int posActualNode = 0; //NODE THAT IS BEING PROCESSED +bool ignore_vector; //IGNORE THE VECTOR IF WE ARE UNDER A SPLIT THAT IS NOT QUATERNARY +//GLOBAL VARIABLES + +//TOSTRING_VECTOR void toStringVector() { - for (int i = 0; i < VECTOR_SIZE; i++) { - std::cout << vector[i].mode; + for (int i = 0; i < VECTOR_SIZE && debugMessage; i++) { + std::cout << vector[i].mode << ", "; + std::cout << vector[i].cost << std::endl; + } +} +void toStringVector(double Level) +{ + int end = 0; + for(int i=Level-1; i>-1 && debugMessage; i--) + { + end += pow(4,i); + } + for (int i = 0; i < end && debugMessage; i++) { + std::cout << vector[i].posFather << ", "; + std::cout << vector[i].threadNumber << ", "; + std::cout << vector[i].mode << ", "; std::cout << vector[i].cost << std::endl; } } void toStringVector(int Level) { int end = 0; - for(int i=Level-1; i>-1; i--) + for(int i=Level-1; i>-1 && debugMessage; i--) { end += pow(4,i); } - for (int i = 0; i < end; i++) { - std::cout << vector[i].posPadre << ", "; + for (int i = 0; i < end && debugMessage; i++) { + std::cout << vector[i].posFather << ", "; std::cout << vector[i].threadNumber << std::endl; } } +//TOSTRING_VECTOR //END ALBERTO CONCEPT FORK @@ -264,7 +283,7 @@ void EncCu::destroy() } #endif //ALBERTO CONCEPT FORK - sem_destroy(sem); + //sem_destroy(sem); munmap(vector, VECTOR_BYTES); shm_unlink("/myshm"); //END ALBERTO CONCEPT FORK @@ -273,7 +292,7 @@ void EncCu::destroy() EncCu::~EncCu() { //ALBERTO CONCEPT FORK - sem_destroy(sem); + //sem_destroy(sem); munmap(vector, VECTOR_BYTES); shm_unlink("/myshm"); //END ALBERTO CONCEPT FORK @@ -310,31 +329,24 @@ void EncCu::init( EncLib* pcEncLib, const SPS& sps ) m_pcGOPEncoder->setModeCtrl( m_modeCtrl ); //ALBERTO CONCEPT FORK - // Crear memoria compartida para el vector y el semáforo - createAndInitSemaphore(); - - // Inicializar vector de estructuras con valores iniciales de -1 - //Estamos en el nivel 0 + // Crear memoria compartida para el vector + createSharedVector(); + //Rellenar el vector initStructVector(); - - toStringVector(5); //IMPRIMIR 5 NIVELES - - //Comenzamos en el nodo 0 (único) del nivel 0 de 4 - posNode.append("0"); + toStringVector(5); //IMPRIMIR 5 (TODOS) LOS NIVELES + //END ALBERTO CONCEPT } -void EncCu::createAndInitSemaphore() +//ALBERTO CONCEPT FORK +void EncCu::createSharedVector() { int fd = shm_open("/myshm", O_CREAT | O_RDWR, 0666); ftruncate(fd, VECTOR_BYTES + sizeof(sem_t)); vector = (vectorModeCostStruct*) mmap(NULL, VECTOR_BYTES, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - sem = (sem_t*) (vector + VECTOR_SIZE); - sem_init(sem,1,1); } - void EncCu::initStructVector() { - vector[0].posPadre=-1; + vector[0].posFather=-1; vector[0].threadNumber=1; for (int i = 0; i < VECTOR_SIZE; i++) { @@ -349,7 +361,7 @@ void EncCu::initStructVector() int end = posPadreActual+salto+4; for(int j=start; j &prevQP, const EnumArray &currQP) +void EncCu::compressCtuForks(CodingStructure*& tempCS, CodingStructure*& bestCS, Partitioner& partitioner) +{ + if(singleMode) + { + xCompressCU(tempCS, bestCS, partitioner); + } + else + { + cleanCostModeVector(); + for (int i = 0; i < 4 ; i++) + { + pid_t pid = fork(); + if (pid == 0) { // proceso hijo + father = false; + threadNumber = i+1; + xCompressCU(tempCS, bestCS, partitioner); + exit(0);//proceso hijo muere + } + } + for(int i=0; i<4 ; i++) + { + wait(NULL); + } + father = true; + reduceVector(); + toStringVector(5.00); + xCompressCU(tempCS, bestCS, partitioner); + } + +} +//END ALBERTO CONCEPT FORK + +void EncCu::compressCtu(CodingStructure &cs, const UnitArea &area, const unsigned ctuRsAddr, const EnumArray &prevQP, const EnumArray &currQP) { m_modeCtrl->initCTUEncoding( *cs.slice ); cs.treeType = TREE_D; @@ -449,7 +500,10 @@ void EncCu::compressCtuForks(CodingStructure &cs, const UnitArea &area, const un currQP[ChannelType::LUMA]; tempCS->prevQP[ChannelType::LUMA] = bestCS->prevQP[ChannelType::LUMA] = prevQP[ChannelType::LUMA]; - xCompressCU(tempCS, bestCS, partitioner); + //ALBERTO CONCEPT FORK + compressCtuForks(tempCS,bestCS,partitioner); + //END ALBERTO CONCEPT FORK + cs.slice->m_mapPltCost[0].clear(); cs.slice->m_mapPltCost[1].clear(); // all signals were already copied during compression if the CTU was split - at this point only the structures are copied to the top level CS @@ -469,7 +523,18 @@ void EncCu::compressCtuForks(CodingStructure &cs, const UnitArea &area, const un currQP[ChannelType::CHROMA]; tempCS->prevQP[ChannelType::CHROMA] = bestCS->prevQP[ChannelType::CHROMA] = prevQP[ChannelType::CHROMA]; - xCompressCU(tempCS, bestCS, partitioner); + //ALBERTO CONCEPT FORK + bool activation = false; + if(!singleMode) + { + activation = singleMode = true; + } + compressCtuForks(tempCS,bestCS,partitioner); + if(activation) + { + activation = singleMode = false; + } + //END ALBERTO CONCEPT FORK const bool copyUnsplitCTUSignals = bestCS->cus.size() == 1; cs.useSubStructure(*bestCS, partitioner.chType, CS::getArea(*bestCS, area, partitioner.chType), @@ -491,36 +556,6 @@ void EncCu::compressCtuForks(CodingStructure &cs, const UnitArea &area, const un CHECK( bestCS->cus[0]->predMode == NUMBER_OF_PREDICTION_MODES, "No possible encoding found" ); CHECK( bestCS->cost == MAX_DOUBLE , "No possible encoding found" ); } -//END ALBERTO CONCEPT FORK - -void EncCu::compressCtu(CodingStructure &cs, const UnitArea &area, const unsigned ctuRsAddr, const EnumArray &prevQP, const EnumArray &currQP) -{ - /*if(debugModeForTesting) - { - debugModeForTesting = false; - vector[4].mode=1; - vector[4].cost=6; - } - else - { - std::cout << vector[4].mode << "== 1?, " << vector[4].cost << "==6?" << std::endl; - }*/ - //ALBERTO CONCEPT FORK - for (int i = 0; i < 1; i++) { - pid_t pid = fork(); - if (pid != 0) { // proceso hijo - father = false; - threadNumber = i+1; - compressCtuForks(cs,area,ctuRsAddr,prevQP,currQP); - exit(0);//proceso hijo muere - } - } - wait(NULL); - father = true; - compressCtuForks(cs,area,ctuRsAddr,prevQP,currQP); - - //END ALBERTO CONCEPT FORK -} // ==================================================================================================================== // Protected member functions @@ -898,33 +933,8 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par m_bestBcwIdx.fill(BCW_NUM); } - //ALBERTO CONCEPT FORK - /*std::cout << "-----------------------------------------------------" << std::endl; - int mode = 5; - int lastMode = m_modeCtrl->currTestMode().type; - Se avanza hasta el modo actual requerido por el proceso - while (lastMode != mode) - { - std::cout << "Avanzando modo: " << lastMode << ", buscando modo: " << mode << std::endl; - if (lastMode == mode || !(m_modeCtrl->nextMode(*tempCS, partitioner))) //Si se encuntra mode o no hay mas modes salimos del bucle - { - std::cout << "No otros modos" << ", modo reciente: <" << lastMode << ">" << std::endl; - break; - } - lastMode = m_modeCtrl->currTestMode().type; - } - if (lastMode != mode) - { - std::cout << "El proceso que busca el modo " << mode << " NO ha resultado satisfactorio, no se puede aplicar ese modo para CU" << std::endl; - return; //NO SE PUEDE APLICAR MODO PARA ESTA CU - } - else - { - std::cout << "El proceso que busca el modo " << mode << " SI ha resultado satisfactorio" << std::endl; - } - std::cout << "-----------------------------------------------------" << std::endl;*/ - //END ALBERTO CONCEPT FORK - +EncTestMode savedEncMode; +bool activeIgnoreVector = false; do { for (int i = compBegin; i < (compBegin + numComp); i++) @@ -933,8 +943,18 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par tempCS->prevPLT.curPLTSize[comID] = curLastPLTSize[comID]; memcpy(tempCS->prevPLT.curPLT[i], curLastPLT[i], curLastPLTSize[comID] * sizeof(Pel)); } - EncTestMode currTestMode = m_modeCtrl->currTestMode(); - //continue; + EncTestMode currTestMode = savedEncMode = m_modeCtrl->currTestMode(); + //ALBERTO CONCEPT FORK + bool lastModeAvailable = (!singleMode && father && m_modeCtrl->lastModeAvailable(*tempCS, partitioner) && tempCS->cost == MAX_DOUBLE); //SI SOLO QUEDA UN MODO Y EL COSTE ES MÁXIMO, NO PODEMOS SKIPEAR + bool skipMode = (!singleMode && father && vector[posActualNode].mode!=-1 && vector[posActualNode].mode!=currTestMode.type && !ignore_vector && vector[posActualNode].mode!=ETM_RECO_CACHED && !lastModeAvailable); + bool skipCU = (!singleMode && !father && 1<=posActualNode && posActualNode<=4 && vector[posActualNode].threadNumber!=threadNumber);//SI ESTAMOS EN UN THREAD INCORRECTO SE HACE SKIP + if(debugMessage) { std::cout << "posActualNode:" << posActualNode << ", Vector:" << vector[posActualNode].mode << ", CurrMode:" << currTestMode.type << std::endl;} + if(skipMode) + { + if(debugMessage) { std::cout << "skip" << std::endl; } + continue; + } + //END ALBERTO CONCEPT FORK currTestMode.maxCostAllowed = maxCostAllowed; if (pps.getUseDQP() && partitioner.isSepTree(*tempCS) && isChroma( partitioner.chType )) @@ -974,7 +994,7 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par } } #endif - + if( currTestMode.type == ETM_INTER_ME ) { if( ( currTestMode.opts & ETO_IMV ) != 0 ) @@ -1022,7 +1042,7 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par tempCS->splitRdCostBest = splitRdCostBest; } #endif - else if( currTestMode.type == ETM_MERGE_SKIP ) + else if( currTestMode.type == ETM_MERGE_SKIP) { #if JVET_AC0139_UNIFIED_MERGE xCheckRDCostUnifiedMerge(tempCS, bestCS, partitioner, currTestMode); @@ -1045,7 +1065,7 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par tempCS->splitRdCostBest = splitRdCostBest; } #endif - else if( currTestMode.type == ETM_INTRA ) + else if( currTestMode.type == ETM_INTRA || skipCU) { if (slice.getSPS()->getUseColorTrans() && !CS::isDualITree(*tempCS)) { @@ -1103,6 +1123,10 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par } else if( isModeSplit( currTestMode ) ) { + //ALBERTO CONCEPT FORK + if(!ignore_vector && currTestMode.type!=ETM_SPLIT_QT) { activeIgnoreVector = ignore_vector = true; }//SI ES LA PRIMERA VEZ QUE NOS ENCONTRAMOS CON UN SPLIT NO QT IGNORAMOS AL VECTOR + //END ALBERTO CONCEPT FORK + if (bestCS->cus.size() != 0) { splitmode = bestCS->cus[0]->splitSeries; @@ -1180,6 +1204,9 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par memcpy(bestLastPLT[i], bestCS->cus[0]->cs->prevPLT.curPLT[i], bestCS->cus[0]->cs->prevPLT.curPLTSize[comID] * sizeof(Pel)); } } + //ALBERTO CONCEPT FORK + if(activeIgnoreVector) { activeIgnoreVector = ignore_vector = false; }//SI SE MARCÓ EN ESTA ITERACIÓN EL IGNORAR AL VECTOR, AL REGRESAR DE DEVUELVE EL VALOR FALSO + //END ALBERTO CONCEPT FORK } else { @@ -1187,9 +1214,20 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par } } while( m_modeCtrl->nextMode( *tempCS, partitioner ) ); - ////////////////////////////////////////////////////////////////////////// // Finishing CU + + //ALBERTO CONCEPT FORK + //PASO 5 -> AL TERMINAR EL BUCLE SE GUARDA EN EL PADRE EL VALOR DEL COSTE Y SE RETORNA + if(debugMessage) { std::cout << "SAVING --> código bucle split " << posActualNode << " : " << " (" << tempCS->area.lheight() <<","<< tempCS->area.lwidth() << ") " << std::endl; } + bool saveModeCost = (!singleMode && !father && vector[posActualNode].mode==-1 && vector[posActualNode].cost==-1 && vector[posActualNode].threadNumber==threadNumber); + if(saveModeCost) + { + vector[posActualNode].mode=savedEncMode.type; + vector[posActualNode].cost=bestCS->cost; + } + //ALBERTO END CONCEPT FORK + if( tempCS->cost == MAX_DOUBLE && bestCS->cost == MAX_DOUBLE ) { //although some coding modes were planned to be tried in RDO, no coding mode actually finished encoding due to early termination @@ -1280,7 +1318,6 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par iter = 0; } //END ALBERTO - } #if SHARP_LUMA_DELTA_QP || ENABLE_QPA_SUB_CTU @@ -1341,7 +1378,7 @@ int EncCu::determinePosNodeInVector(std::string posNode) if(i==posNode.length()-1 && posNode.length()>1) { bool childToSum = true; - for(int j=i; j-1>0; j--) + for(int j=i; j-1>-1; j--) { int codeParent = posNode[j-1] - '0'; int codeChild = posNode[j] - '0'; @@ -1363,6 +1400,49 @@ int EncCu::determinePosNodeInVector(std::string posNode) } return index; } +int EncCu::searchFirstChild(int posFather) +{ + int posChild = -1; + for(int i=0; i=0 ; i=i-4) + { + int valueChild_1 = vector[i-3].cost; + int valueChild_2 = vector[i-2].cost; + int valueChild_3 = vector[i-1].cost; + int valueChild_4 = vector[i].cost; + if(valueChild_1==-1 || valueChild_2==-1 || valueChild_3==-1 || valueChild_4==-1) + { + continue; + } + else + { + int childSum = valueChild_1 + valueChild_2 + valueChild_3 + valueChild_4; + int posFather = vector[i].posFather; + int costFather = vector[posFather].cost; + int modeFather = vector[posFather].mode; + if(costFather <= childSum && modeFather!=ETM_SPLIT_QT) + { + vector[i-3].cost = vector[i-2].cost = vector[i-1].cost = vector[i].cost = -1; + vector[i-3].mode = vector[i-2].mode = vector[i-1].mode = vector[i].mode = -1; + } + else if(costFather > childSum && modeFather!=ETM_SPLIT_QT) + { + vector[posFather].cost = childSum; + vector[posFather].mode = ETM_SPLIT_QT; + } + } + } +} //END ALBERTO CONCEPT FORK void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &partitioner, const EncTestMode& encTestMode, const ModeType modeTypeParent, bool &skipInterPass, double *splitRdCostBest ) @@ -1484,10 +1564,12 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, { m_pcInterSearch->savePrevUniMvInfo(tempCS->area.Y(), tmpUniMvInfo, isUniMvInfoSaved); } + //ALBERTO CONCEPT FORK - int actualNodeId = 0; //CU COUNTER - std::string original = posNode; + //PASO 1 -> OBTENEMOS EL PRIMER HIJO DEL NODO ACTUAL + int posChild = searchFirstChild(posActualNode); //END ALBERTO CONCEPT FORK + do { const auto &subCUArea = partitioner.currArea(); @@ -1504,32 +1586,25 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, tempSubCS->bestParent = bestSubCS->bestParent = bestCS; double newMaxCostAllowed = isLuma(partitioner.chType) ? std::min(encTestMode.maxCostAllowed, bestCS->cost - m_pcRdCost->calcRdCost(tempCS->fracBits, tempCS->dist)) : MAX_DOUBLE; newMaxCostAllowed = std::max(0.0, newMaxCostAllowed); + //ALBERTO CONCEPT FORK - posNode.append(std::to_string(actualNodeId)); //INTRODUCIMOS SU ID DENTRO DEL PADRE - //ELEGIMOS EL THREAD EN EL NIVEL 1 (CONTANDO DESDE 0). - if(!father && posNode.length() == 2 && vector[determinePosNodeInVector(posNode)].threadNumber!=threadNumber) + //PASO 2 -> SI EL SPLIT ES QUAD SE ACTUALIZA NODO ACTUAL + if(debugMessage) { - continue; + std::cout << "CONTROL --> código bucle split " << posActualNode << "->" << posChild << " : " << " (" << tempCS->area.lheight() <<","<< tempCS->area.lwidth() << ") " << "->" << " (" << tempSubCS->area.lheight() <<","<< tempSubCS->area.lwidth() <<") " << std::endl; } - std::cout << "CONTROL --> código bucle split" << posNode << " : (" << tempSubCS->area.lheight() <<","<< tempSubCS->area.lwidth() <<") " << std::endl; - /*if(posNode == "0311") - { - toStringVector(); - }*/ - //END ALBERTO CONCEPT FORK - xCompressCU(tempSubCS, bestSubCS, partitioner, newMaxCostAllowed);//LLAMADA RECURSIVA + int restorePosActualNode = posActualNode; + bool fatherUpdate = ((!singleMode && !father && split == CU_QUAD_SPLIT) || (!singleMode && father && split == CU_QUAD_SPLIT && !ignore_vector)); + if(fatherUpdate) { posActualNode=posChild; } + + //PASO 3 -> LLAMADA RECURSIVA CON EL HIJO QUE AHORA ES EL PADRE + xCompressCU(tempSubCS, bestSubCS, partitioner, newMaxCostAllowed); + tempSubCS->bestParent = bestSubCS->bestParent = nullptr; + //ALBERTO CONCEPT FORK - if(tempCS->area.lheight()>=8 && tempCS->area.lwidth()>= 8) - { - int idexPosNode = determinePosNodeInVector(posNode); - if(vector[idexPosNode].mode==-1 && vector[idexPosNode].cost == -1) - { - vector[idexPosNode].mode=encTestMode.type; - vector[idexPosNode].cost=tempSubCS->cost; - } - } + //PASO 4 -> AL REGRESAR DE LA LLAMADA SI SE HA MODIFICADO EL PADRE SE RESTAURA EL PADRE Y SE AVANZA AL SIGUIENTE HIJO DE LOS 4 + if(fatherUpdate) { posActualNode=restorePosActualNode; posChild++;} //END ALBERTO CONCEPT FORK - tempSubCS->bestParent = bestSubCS->bestParent = nullptr; if( bestSubCS->cost == MAX_DOUBLE ) { @@ -1544,14 +1619,10 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, { tempCS->motionLut = oldMotionLut; } - posNode = original; - actualNodeId = 0; return; } - bool keepResi = KEEP_PRED_AND_RESI_SIGNALS; tempCS->useSubStructure( *bestSubCS, partitioner.chType, CS::getArea( *tempCS, subCUArea, partitioner.chType ), KEEP_PRED_AND_RESI_SIGNALS, true, keepResi, keepResi, true ); - if( partitioner.currQgEnable() ) { tempCS->prevQP[partitioner.chType] = bestSubCS->prevQP[partitioner.chType]; @@ -1570,7 +1641,6 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, CHECK(CU::isInter(*bestSubCS->cus[i]), "all CUs must not be inter mode in an Intra coding region (SCIPU)"); } } - tempSubCS->releaseIntermediateData(); bestSubCS->releaseIntermediateData(); if( !tempCS->slice->isIntra() && partitioner.isConsIntra() ) @@ -1587,28 +1657,15 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, { tempCS->motionLut = oldMotionLut; } - posNode = original; - actualNodeId = 0; return; } } } - - //ALBERTO CONCEPT FORK - actualNodeId++;//NOS PONEMOS EN EL PRIMER NODO DE LA PARTICIÓN (AVANZAMOS NODO) - posNode.pop_back(); //LIMPIAMOS NODO ACTUAL DEL VECTOR DEL CÓDIGO (STRING) - //END ALBERTO CONCEPT FORK - } while( partitioner.nextPart( *tempCS ) );//AVANZAMOS A LA SIGIENTE CU GENERADA EN TEMPCS - //ALBERTO CONCEPT FORK - posNode = original; - actualNodeId = 0; - //END ALBERTO CONCEPT FORK partitioner.exitCurrSplit(); - m_CurrCtx--; if( chromaNotSplit ) diff --git a/source/Lib/EncoderLib/EncCu.h b/source/Lib/EncoderLib/EncCu.h index 5e37be280feab7cff355e947a2a8ea0d1fbeaef4..18334e96a63249c6d5ab834e82b90f5c9f5e5e75 100644 --- a/source/Lib/EncoderLib/EncCu.h +++ b/source/Lib/EncoderLib/EncCu.h @@ -232,7 +232,7 @@ struct vectorModeCostStruct { int mode; double cost; int threadNumber; - int posPadre; + int posFather; }; //ALBERTO CONCEPT FORK const int VECTOR_SIZE = 341; // TREE NODES @@ -325,12 +325,11 @@ public: //ALBERTO CONCEPT FORK - void createAndInitSemaphore(); - + void createSharedVector(); void initStructVector(); - void updateFatherAndThreadNumbers(int LevelLowIndex, int LevelUpIndex, int posPadreActual, int i); - //END ALBERTO CONCEPT FORK + void cleanCostModeVector(); + // END ALBERTO CONCEPT FORK void setDecCuReshaperInEncCU(EncReshape* pcReshape, ChromaFormat chromaFormatIdc) { @@ -344,7 +343,7 @@ public: //ALBERTO CONCEPT FORK - void compressCtuForks(CodingStructure &cs, const UnitArea &area, const unsigned ctuRsAddr, const EnumArray &prevQP, const EnumArray &currQP); + void compressCtuForks(CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &partitioner); //END ALBERTO CONCEPT FORK /// CTU analysis function @@ -380,7 +379,10 @@ protected: bool digits_below_or_equal(std::string a, std::string b); int determinePosNodeInVectorRec(std::string posNode, std::string posSearch, int index, int counter); int determinePosNodeInVector(std::string posNode); - //END ALBERTO CONCEPT FORK + int searchFirstChildEmpty(int posFather); + int searchFirstChild(int posFather); + void reduceVector(); + // END ALBERTO CONCEPT FORK void xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &pm, const EncTestMode &encTestMode, const ModeType modeTypeParent, bool &skipInterPass, double *splitRdCostBest); diff --git a/source/Lib/EncoderLib/EncModeCtrl.cpp b/source/Lib/EncoderLib/EncModeCtrl.cpp index 5443c382c8d92f7de54df4a382a882d51b615646..089345c6241e085d421266f8a36d164affb38bb6 100644 --- a/source/Lib/EncoderLib/EncModeCtrl.cpp +++ b/source/Lib/EncoderLib/EncModeCtrl.cpp @@ -103,6 +103,13 @@ bool EncModeCtrl::nextMode( const CodingStructure &cs, Partitioner &partitioner return !m_ComprCUCtxList.back().testModes.empty(); } +//ALBERTO CONCEPT FORK +bool EncModeCtrl::lastModeAvailable( const CodingStructure &cs, Partitioner &partitioner ) +{ + return !m_ComprCUCtxList.empty() && !m_ComprCUCtxList.back().testModes.empty() && m_ComprCUCtxList.back().testModes.size()==1; +} +//END ALBERTO CONCEPT FORK + EncTestMode EncModeCtrl::currTestMode() const { return m_ComprCUCtxList.back().testModes.back(); diff --git a/source/Lib/EncoderLib/EncModeCtrl.h b/source/Lib/EncoderLib/EncModeCtrl.h index 3aaac954b764b2bd60d411d144162f3d3e524606..0eedb8b33b4bc931e3523b898d4b676866862aae 100644 --- a/source/Lib/EncoderLib/EncModeCtrl.h +++ b/source/Lib/EncoderLib/EncModeCtrl.h @@ -326,7 +326,10 @@ public: void init ( EncCfg *pCfg, RateCtrl *pRateCtrl, RdCost *pRdCost ); bool tryModeMaster ( const EncTestMode& encTestmode, const CodingStructure &cs, Partitioner& partitioner ); bool nextMode ( const CodingStructure &cs, Partitioner &partitioner ); - EncTestMode currTestMode () const; + //ALBERTO CONCEPT FORK + bool lastModeAvailable(const CodingStructure &cs, Partitioner &partitioner); + //END ALBERTO CONCEPT FORK + EncTestMode currTestMode() const; EncTestMode lastTestMode () const; void setEarlySkipDetected (); void setIsHashPerfectMatch( bool b ) { m_ComprCUCtxList.back().isHashPerfectMatch = b; }