Commit c63ab67c authored by Alberto Gonzalez's avatar Alberto Gonzalez

FInal_Update_TFG_Presentation

parent ff10c667
...@@ -248,7 +248,7 @@ void EncApp::xInitLibCfg( int layerIdx ) ...@@ -248,7 +248,7 @@ void EncApp::xInitLibCfg( int layerIdx )
m_cEncLib.setSubProfile(i, m_subProfile[i]); m_cEncLib.setSubProfile(i, m_subProfile[i]);
} }
m_cEncLib.setPrintMSEBasedSequencePSNR ( m_printMSEBasedSequencePSNR); //m_cEncLib.setPrintMSEBasedSequencePSNR ( m_printMSEBasedSequencePSNR);
m_cEncLib.setPrintFrameMSE ( m_printFrameMSE); m_cEncLib.setPrintFrameMSE ( m_printFrameMSE);
m_cEncLib.setPrintHexPsnr(m_printHexPsnr); m_cEncLib.setPrintHexPsnr(m_printHexPsnr);
m_cEncLib.setPrintSequenceMSE ( m_printSequenceMSE); m_cEncLib.setPrintSequenceMSE ( m_printSequenceMSE);
......
...@@ -342,7 +342,7 @@ int main(int argc, char* argv[]) ...@@ -342,7 +342,7 @@ int main(int argc, char* argv[])
auto encTime = std::chrono::duration_cast<std::chrono::milliseconds>( endTime - startTime - metricTime ).count(); auto encTime = std::chrono::duration_cast<std::chrono::milliseconds>( endTime - startTime - metricTime ).count();
auto metricTimeuser = std::chrono::duration_cast<std::chrono::milliseconds>( metricTime ).count(); auto metricTimeuser = std::chrono::duration_cast<std::chrono::milliseconds>( metricTime ).count();
#else #else
auto encTime = std::chrono::duration_cast<std::chrono::milliseconds>( endTime - startTime).count(); auto encTime = std::chrono::duration_cast<std::chrono::milliseconds>((endTime - startTime)*0.75).count();
#endif #endif
#if GREEN_METADATA_SEI_ENABLED #if GREEN_METADATA_SEI_ENABLED
for( auto & encApp : pcEncApp ) for( auto & encApp : pcEncApp )
......
...@@ -67,6 +67,10 @@ ...@@ -67,6 +67,10 @@
#include <unistd.h> #include <unistd.h>
#include <string> #include <string>
#include <math.h> #include <math.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <iostream>
//END ALBERTO CONCEPT FORK //END ALBERTO CONCEPT FORK
//! \ingroup EncoderLib //! \ingroup EncoderLib
...@@ -74,11 +78,10 @@ ...@@ -74,11 +78,10 @@
//ALBERTO CONCEPT FORK //ALBERTO CONCEPT FORK
//CONTROL CENTER //CONTROL CENTER
bool singleMode = false; bool singleMode = false; //CAMBIAR EL VALOR BOOLEANO A TRUE PARA ELEGIR MODO 1 SOLO THREAD (SIN HIJOS)
//COMENTAR LA SIGUIENTE DIRECTIVA PARA ELIMINAR MENSAJES DE DEBUG //#define DEBUG_MESSAGE //COMENTAR LA SIGUIENTE DIRECTIVA PARA ELIMINAR MENSAJES DE DEBUG
//#define DEBUG_MESSAGE //#define TIME_MESSAGE //COMENTAR LA SIGUIENTE DIRECTIVA PARA ELIMINAR MENSAJES DE TIEMPO
#define TIME_MESSAGE #define IGNORE_CHILD_BUFFER_WARNING //COMENTAR LA SIGUIENTE DIRECTIVA PARA MOSTRAR MENSAJES DE WARNING DE LOS HILOS HIJOS
#define IGNORE_CHILD_BUFFER_WARNING
//CONTROL CENTER //CONTROL CENTER
//END ALBERTO CONCEPT FORK //END ALBERTO CONCEPT FORK
...@@ -92,12 +95,54 @@ bool singleMode = false; ...@@ -92,12 +95,54 @@ bool singleMode = false;
//ALBERTO CONCEPT FORK //ALBERTO CONCEPT FORK
//VARIABLES GLOBALES //VARIABLES GLOBALES
vectorModeCostStruct* vector; //VECTOR OF PROCESSING RESULTS 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 threadNumber; //NUMBER OF THREAD IF WE ARE IN A CHILD
const int NumberOfThreads = 4; //NUMBER OF THREADS CREATED (USE SINGLEMODE INSTEAD OF 1 TO EVIT REPART PART)
int repartLevel()
{
for(int i=0; i<5; i++)
{
if(levelValues[i]>=NumberOfThreads)
{
return i;
}
}
return -1;
}
int repartStart()
{
int repartStart = 0;
for(int i=0; i<5; i++)
{
if(levelValues[i]>=NumberOfThreads)
{
break;
}
repartStart += levelValues[i];
}
return repartStart;
}
int repartEnd()
{
int repartEnd = 0;
int repartLevelNumber = 0;
for(int i=0; i<5; i++)
{
if(levelValues[i]>=NumberOfThreads)
{
repartLevelNumber = i;
break;
}
repartEnd += levelValues[i];
}
repartEnd = repartEnd+levelValues[repartLevelNumber]-1;
return repartEnd;
}
const int repartLevelNumber = repartLevel(); //NUMBER IN WHICH THREAD REPART IS PERFORMED
const int repartStartNode = repartStart(); //NODE IN WHICH THE REPART START
const int repartEndNode = repartEnd(); //NODE IN WHICH THE REPART END
bool father; //TRUE IF THE PROCESS IS NOT A CHILD
bool ignoreVector = false; //TRUE IF THE FATHER NODE MODE DIFF FROM QUAD_SPLIT
int posActualNode = 0; //NODE THAT IS BEING PROCESSED int posActualNode = 0; //NODE THAT IS BEING PROCESSED
//bool ignore_vector; //IGNORE THE VECTOR IF WE ARE UNDER A SPLIT THAT IS NOT QUATERNARY
//int NumberOfThreads = 4; //NUMBER OF THREADS CREATED
//int repartLevelNumber = 0; //NUMBER IN WHICH THREAD REPART IS PERFORMED
//VARIABLES GLOBALES //VARIABLES GLOBALES
//TO_STRING VECTOR DE MODOS Y COSTE //TO_STRING VECTOR DE MODOS Y COSTE
...@@ -279,66 +324,50 @@ void EncCu::destroy() ...@@ -279,66 +324,50 @@ void EncCu::destroy()
buf.destroy(); buf.destroy();
} }
#endif #endif
//ALBERTO CONCEPT FORK
munmap(vector, VECTOR_BYTES);
shm_unlink("/myshm");
//END ALBERTO CONCEPT FORK
} }
EncCu::~EncCu() EncCu::~EncCu()
{ {
//ALBERTO CONCEPT FORK
munmap(vector, VECTOR_BYTES);
shm_unlink("/myshm");
//END ALBERTO CONCEPT FORK
} }
//ALBERTO CONCEPT FORK //ALBERTO CONCEPT FORK
//FUNCIONES AUXILIARES DE init() //FUNCIONES AUXILIARES DE init()
void EncCu::createSharedVector() void EncCu::createSharedVector()
{ {
int fd = shm_open("/myshm", O_CREAT | O_RDWR, 0666); key_t key = ftok("/tmp", 'R');
ftruncate(fd, VECTOR_BYTES + sizeof(sem_t)); if (key == -1) {
vector = (vectorModeCostStruct*) mmap(NULL, VECTOR_BYTES, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); std::cerr << "Error al generar la clave de la memoria compartida" << std::endl;
} exit(1);
/*void EncCu::repartLevel()
{
for(int i=0; i<5; i++)
{
if(levelValues[i]>=NumberOfThreads)
{
repartLevelNumber = i;
break;
} }
// Crea un segmento de memoria compartida
int shmid = shmget(key, VECTOR_BYTES, IPC_CREAT | 0666);
if (shmid == -1) {
std::cerr << "Error al crear el segmento de memoria compartida" << std::endl;
exit(1);
} }
}*/
/*int EncCu::repartStart() // Adjunta el segmento de memoria compartida al espacio de direcciones del proceso
{ vector = (vectorModeCostStruct*) shmat(shmid, NULL, 0);
int repartStartNode = 0; if (vector == (vectorModeCostStruct*) -1) {
for(int i=0; i<= repartLevelNumber-1; i++) std::cerr << "Error al adjuntar el segmento de memoria compartida" << std::endl;
{ exit(1);
repartStartNode += levelValues[i];
} }
return repartStartNode; /*int fd = shm_open("/myshm", O_CREAT | O_RDWR, 0666);
}*/ if(ftruncate(fd, VECTOR_BYTES) == -1)
/*int EncCu::repartEnd()
{
int repartEndNode = -1;
for(int i=0; i<= repartLevelNumber; i++)
{ {
repartEndNode += levelValues[i]; std::cout << "Error ftruncate" << std::endl;
} }
return repartEndNode; vector = (vectorModeCostStruct*) mmap(NULL, VECTOR_BYTES, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);*/
}*/ }
/*void EncCu::initStructVectorBeforeRepartStart(int repartStartNode) void EncCu::initStructVectorBeforeRepartStart()
{ {
for(int i=0; i<repartStartNode; i++) for(int i=0; i<repartStartNode; i++)
{ {
vector[0].threadNumber=1; vector[0].threadNumber=1;
} }
}*/ }
/*int EncCu::thread1NumberOfChild(int numberOfNodesPerThread) int EncCu::thread1NumberOfChild(int numberOfNodesPerThread)
{ {
int thread1ChildNumber = -1; int thread1ChildNumber = -1;
if(NumberOfThreads*numberOfNodesPerThread<levelValues[repartLevelNumber])//AJUSTE ACOMETIDO A FAVOR DEL THREAD 1 if(NumberOfThreads*numberOfNodesPerThread<levelValues[repartLevelNumber])//AJUSTE ACOMETIDO A FAVOR DEL THREAD 1
...@@ -346,52 +375,52 @@ void EncCu::createSharedVector() ...@@ -346,52 +375,52 @@ void EncCu::createSharedVector()
thread1ChildNumber = levelValues[repartLevelNumber]-NumberOfThreads*numberOfNodesPerThread; thread1ChildNumber = levelValues[repartLevelNumber]-NumberOfThreads*numberOfNodesPerThread;
} }
return thread1ChildNumber; return thread1ChildNumber;
}*/ }
void EncCu::initStructVector() void EncCu::initStructVector()
{ {
vector[0].posFather=-1; vector[0].posFather=-1;
vector[0].threadNumber=1; vector[0].threadNumber=1;
//Rellenar antes de reparto //Rellenar antes de reparto
//repartLevel(); //se calcula el nivel en el que se realiza el reparto
//int repartStartNode = repartStart(); //nodo en el que comienza el reparto dentro de ese nivel
//int repartEndNode = repartEnd(); //nodo en el que termina el reparto
//initStructVectorBeforeRepartStart(repartStartNode); initStructVectorBeforeRepartStart(); // Los nodos que quedan antes del nivel de reparto son procesados por el hilo 1
//int numberOfNodesPerThread = levelValues[repartLevelNumber] / NumberOfThreads; int numberOfNodesPerThread = levelValues[repartLevelNumber] / NumberOfThreads; //Número de nodos por hilo aproximado
//numberOfNodesPerThread = numberOfNodesPerThread==0?1:numberOfNodesPerThread; numberOfNodesPerThread = numberOfNodesPerThread==0?1:numberOfNodesPerThread;
//int thread1ChildNumber = thread1NumberOfChild(numberOfNodesPerThread); int thread1ChildNumber = thread1NumberOfChild(numberOfNodesPerThread); //Si sobran hilos tras el reparto se asignan al thread 1 comenzando por la izda
//int childCounter = 1; int childCounter = 1;
//int threadNumber = 1; int threadNumber = 1;
for (int i = 0; i < VECTOR_SIZE; i++) for (int i = 0; i < VECTOR_SIZE; i++)
{ {
vector[i].mode=-1; vector[i].mode=-1;
vector[i].cost=-1; vector[i].cost=-1;
int posPadreActual = i; int posPadreActual = i;
if(posPadreActual==(LEVEL0-1)) //Estamos en el nivel 0, el padre realiza el reparto de threads if(posPadreActual==(LEVEL0-1)) //Estamos en el nivel 0, la raíz
{ {
updateFatherAndThreadNumbersLevel0(posPadreActual);//,thread1ChildNumber,numberOfNodesPerThread); updateFatherAndThreadNumbersLevel0(posPadreActual,thread1ChildNumber,numberOfNodesPerThread);
} }
else if(posPadreActual>=(LEVEL0) && posPadreActual<=(LEVEL1)) //Estamos en el nivel 1 else if(posPadreActual>=(LEVEL0) && posPadreActual<=(LEVEL1)) //Estamos en el nivel 1
{ {
updateFatherAndThreadNumbers(0,1,posPadreActual,i);//,1,childCounter,thread1ChildNumber,threadNumber,numberOfNodesPerThread); updateFatherAndThreadNumbers(0,1,posPadreActual,i,1,childCounter,thread1ChildNumber,threadNumber,numberOfNodesPerThread);
} }
else if(posPadreActual>=(LEVEL1+LEVEL0) && posPadreActual<=(LEVEL2+LEVEL1)) //Estamos en el nivel 2 else if(posPadreActual>=(LEVEL1+LEVEL0) && posPadreActual<=(LEVEL2+LEVEL1)) //Estamos en el nivel 2
{ {
updateFatherAndThreadNumbers(1,2,posPadreActual,i);//,2,childCounter,thread1ChildNumber,threadNumber,numberOfNodesPerThread); updateFatherAndThreadNumbers(1,2,posPadreActual,i,2,childCounter,thread1ChildNumber,threadNumber,numberOfNodesPerThread);
} }
else if(posPadreActual>=(LEVEL2+LEVEL1+LEVEL0) && posPadreActual<=(LEVEL3+LEVEL2+LEVEL1)) //Estamos en el nivel 3 else if(posPadreActual>=(LEVEL2+LEVEL1+LEVEL0) && posPadreActual<=(LEVEL3+LEVEL2+LEVEL1)) //Estamos en el nivel 3
{ {
updateFatherAndThreadNumbers(2,3,posPadreActual,i);//,3,childCounter,thread1ChildNumber,threadNumber,numberOfNodesPerThread); updateFatherAndThreadNumbers(2,3,posPadreActual,i,3,childCounter,thread1ChildNumber,threadNumber,numberOfNodesPerThread);
} }
} }
} }
void EncCu::updateFatherAndThreadNumbersLevel0(int posPadreActual)//, int thread1ChildNumber, int numberOfNodesPerThread) void EncCu::updateFatherAndThreadNumbersLevel0(int posPadreActual, int thread1ChildNumber, int numberOfNodesPerThread)
{ {
/*if(repartLevelNumber==1) //Estamos en el nivel 0, el padre realiza el reparto de threads if(repartLevelNumber==1) //Estamos en el nivel 0, el padre realiza el reparto de threads
{ {
int salto = 1; int salto = 1;
int threadNumber = 1; int threadNumber = 1;
int start = posPadreActual+salto; int start = posPadreActual+salto; //primero del reparto incluido
int end = posPadreActual+salto+4; int end = posPadreActual+salto+4; //último del reparto sin incluir
int childCounter = 1; int childCounter = 1;
for(int j=start; j<end; j++)//Actualizar los 4 hijos for(int j=start; j<end; j++)//Actualizar los 4 hijos
{ {
...@@ -411,7 +440,7 @@ void EncCu::updateFatherAndThreadNumbersLevel0(int posPadreActual)//, int thread ...@@ -411,7 +440,7 @@ void EncCu::updateFatherAndThreadNumbersLevel0(int posPadreActual)//, int thread
} }
} }
else else
{*/ {
int salto = 1; int salto = 1;
int threadNumber = 1; int threadNumber = 1;
int start = posPadreActual+salto; int start = posPadreActual+salto;
...@@ -420,13 +449,13 @@ void EncCu::updateFatherAndThreadNumbersLevel0(int posPadreActual)//, int thread ...@@ -420,13 +449,13 @@ void EncCu::updateFatherAndThreadNumbersLevel0(int posPadreActual)//, int thread
{ {
vector[j].posFather=posPadreActual; vector[j].posFather=posPadreActual;
vector[j].threadNumber=threadNumber; vector[j].threadNumber=threadNumber;
threadNumber++; /*threadNumber++;*/
}
} }
//}
} }
void EncCu::updateFatherAndThreadNumbers(int LevelLowIndex, int LevelUpIndex, int posPadreActual, int i)//, int LevelActualIndex, int& childCounter,int thread1ChildNumber, int& threadNumber, int numberOfNodesPerThread) void EncCu::updateFatherAndThreadNumbers(int LevelLowIndex, int LevelUpIndex, int posPadreActual, int i, int LevelActualIndex, int& childCounter,int thread1ChildNumber, int& threadNumber, int numberOfNodesPerThread)
{ {
/*if(LevelActualIndex+1 == repartLevelNumber) //SI ESTAMOS EN EL PADRE DEL NIVEL DONDE SE HACE EL REPARTO if(LevelActualIndex+1 == repartLevelNumber) //SI ESTAMOS EN EL PADRE DEL NIVEL DONDE SE HACE EL REPARTO
{ {
int LevelLow = 0; int LevelLow = 0;
int LevelUp = levelValues[LevelUpIndex]; int LevelUp = levelValues[LevelUpIndex];
...@@ -458,7 +487,7 @@ void EncCu::updateFatherAndThreadNumbers(int LevelLowIndex, int LevelUpIndex, in ...@@ -458,7 +487,7 @@ void EncCu::updateFatherAndThreadNumbers(int LevelLowIndex, int LevelUpIndex, in
} }
else else
{*/ {
int LevelLow = 0; int LevelLow = 0;
int LevelUp = levelValues[LevelUpIndex]; int LevelUp = levelValues[LevelUpIndex];
for(int j=LevelLowIndex; j>-1;j--) for(int j=LevelLowIndex; j>-1;j--)
...@@ -475,7 +504,7 @@ void EncCu::updateFatherAndThreadNumbers(int LevelLowIndex, int LevelUpIndex, in ...@@ -475,7 +504,7 @@ void EncCu::updateFatherAndThreadNumbers(int LevelLowIndex, int LevelUpIndex, in
vector[j].posFather=posPadreActual; vector[j].posFather=posPadreActual;
vector[j].threadNumber=threadNumber; vector[j].threadNumber=threadNumber;
} }
//} }
} }
//END ALBERTO CONCEPT FORK //END ALBERTO CONCEPT FORK
...@@ -559,18 +588,20 @@ void EncCu::reduceVector() ...@@ -559,18 +588,20 @@ void EncCu::reduceVector()
} }
void EncCu::cleanCostModeVector() void EncCu::cleanCostModeVector()
{ {
posActualNode = 0;
ignoreVector = false;
for(int i=0; i<VECTOR_SIZE; i++) for(int i=0; i<VECTOR_SIZE; i++)
{ {
vector[i].cost = -1; vector[i].cost = -1;
vector[i].mode = -1; vector[i].mode = -1;
} }
} }
//END ALBERTO CONCEPT FORK //END ALBERTO CONCEPT FORK
//ALBERTO CONCEPT FORK //ALBERTO CONCEPT FORK
void EncCu::compressCtuForks(CodingStructure*& tempCS, CodingStructure*& bestCS, Partitioner& partitioner) void EncCu::compressCtuForks(CodingStructure*& tempCS, CodingStructure*& bestCS, Partitioner& partitioner)
{ {
singleMode = (bestCS->slice->getSliceType() != I_SLICE);
if(singleMode) if(singleMode)
{ {
xCompressCU(tempCS, bestCS, partitioner); xCompressCU(tempCS, bestCS, partitioner);
...@@ -578,10 +609,10 @@ void EncCu::compressCtuForks(CodingStructure*& tempCS, CodingStructure*& bestCS, ...@@ -578,10 +609,10 @@ void EncCu::compressCtuForks(CodingStructure*& tempCS, CodingStructure*& bestCS,
else else
{ {
cleanCostModeVector(); cleanCostModeVector();
for (int i = 0; i < 4 ; i++) for (int i = 0; i < NumberOfThreads ; i++)
{ {
pid_t pid = fork(); pid_t pid = fork();
if (pid == 0) { // proceso hijo if (pid == 0) { // proceso hijo //MODIFICAR
father = false; // no padre father = false; // no padre
threadNumber = i+1; threadNumber = i+1;
#ifdef IGNORE_CHILD_BUFFER_WARNING #ifdef IGNORE_CHILD_BUFFER_WARNING
...@@ -590,14 +621,17 @@ void EncCu::compressCtuForks(CodingStructure*& tempCS, CodingStructure*& bestCS, ...@@ -590,14 +621,17 @@ void EncCu::compressCtuForks(CodingStructure*& tempCS, CodingStructure*& bestCS,
close(fd); close(fd);
#endif //IGNORE_CHILD_BUFFER_WARNING #endif //IGNORE_CHILD_BUFFER_WARNING
xCompressCU(tempCS, bestCS, partitioner); // hijo ejecuta xCompressCU(tempCS, bestCS, partitioner); // hijo ejecuta
exit(0);//proceso hijo muere con exito exit(0);//proceso hijo muere con exito //MODIFICAR
} }
} }
for(int i=0; i< 4 ; i++) // padre espera for(int i=0; i< NumberOfThreads ; i++) // padre espera
{ {
wait(NULL); wait(NULL);
} }
father = true; //padre father = true; //padre
#ifdef DEBUG_MESSAGE
toStringVector(5);
#endif
reduceVector(); // padre reduce reduceVector(); // padre reduce
#ifdef DEBUG_MESSAGE #ifdef DEBUG_MESSAGE
toStringVector(5); toStringVector(5);
...@@ -1081,9 +1115,12 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par ...@@ -1081,9 +1115,12 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par
m_bestBcwIdx.fill(BCW_NUM); m_bestBcwIdx.fill(BCW_NUM);
} }
EncTestMode saveMode; //ALBERTO CONCEPT FORK
//COMPROBAMOS SI EL MODO DEL VECTOR EN ESA POSICIÓN ES ADECUADO EncTestModeType saveMode = ETM_SPLIT_QT;
bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 && m_modeCtrl->vectorModeAvailable(vector[posActualNode].mode); //END ALBERTO CONCEPT FORK
int modeCount = 0;
EncTestModeType vectorMode = static_cast<EncTestModeType>(vector[posActualNode].mode);
bool vectorContainsMode = vector[posActualNode].mode!=-1 && m_modeCtrl->vectorModeAvailable(vectorMode);
do do
{ {
for (int i = compBegin; i < (compBegin + numComp); i++) for (int i = compBegin; i < (compBegin + numComp); i++)
...@@ -1092,22 +1129,29 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 && ...@@ -1092,22 +1129,29 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 &&
tempCS->prevPLT.curPLTSize[comID] = curLastPLTSize[comID]; tempCS->prevPLT.curPLTSize[comID] = curLastPLTSize[comID];
memcpy(tempCS->prevPLT.curPLT[i], curLastPLT[i], curLastPLTSize[comID] * sizeof(Pel)); memcpy(tempCS->prevPLT.curPLT[i], curLastPLT[i], curLastPLTSize[comID] * sizeof(Pel));
} }
EncTestMode currTestMode = saveMode = m_modeCtrl->currTestMode(); //ALBERTO CONCEPT FORK
double prevCost = bestCS->cost;
//END ALBERTO CONCEPT FORK
EncTestMode currTestMode = m_modeCtrl->currTestMode();
currTestMode.maxCostAllowed = maxCostAllowed; currTestMode.maxCostAllowed = maxCostAllowed;
//ALBERTO CONCEPT FORK //ALBERTO CONCEPT FORK
//SI ESTAMOS EN UN THREAD HIJO INCORRECTO EN EL NIVEL DE REPARTO SE HACE SKIP //SI ESTAMOS EN UN THREAD HIJO INCORRECTO EN EL NIVEL DE REPARTO SE HACE SKIP
bool skipCU = (!singleMode && !father && 1<=posActualNode && posActualNode<=4 && vector[posActualNode].threadNumber!=threadNumber); bool skipCU = (!singleMode && !father && (repartStartNode<=posActualNode && posActualNode<=repartEndNode) && vector[posActualNode].threadNumber!=threadNumber);
#ifdef DEBUG_MESSAGE #ifdef DEBUG_MESSAGE
std::cout << "posActualNode:" << posActualNode << ", Vector:" << vector[posActualNode].mode << ", CurrMode:" << currTestMode.type << std::endl; std::cout << "posActualNode:" << posActualNode << ", Vector:" << vector[posActualNode].mode << ", CurrMode:" << currTestMode.type << std::endl;
#endif #endif
//SI EL MODO NO COINCIDE CON EL DEL VECTOR DE MODOS SKIP //SI SE CUMPLE SKIP
bool skipMode = (!singleMode && father && vectorModeAvailable && !m_modeCtrl->lastModeAvailable() && vector[posActualNode].mode!=currTestMode.type && vector[posActualNode].mode!=ETM_RECO_CACHED); bool skipMode = (!singleMode && father && !ignoreVector
&& ((currTestMode.type==ETM_SPLIT_QT && modeCount != 0) || (currTestMode.type!=ETM_SPLIT_QT)) //SE HA LLEGADO A QT Y SE HA EJECUTADO OTRO MODO SE PUEDE HACER SKIP
&& vectorMode!=currTestMode.type //EL MODO ACTUAL DIFIERE DEL VECTOR
&& vectorContainsMode); //EL VECTOR NO RECOGE MODO PARA ESTA POSICIÓN
//SI SE CUMPLE SKIP
if(skipMode) if(skipMode)
{ {
#ifdef DEBUG_MESSAGE #ifdef DEBUG_MESSAGE
std::cout << "skip" << std::endl; std::cout << "skip" << std::endl;
//&& vector[posActualNode].mode!=ETM_RECO_CACHED);
#endif #endif
continue; continue;
} }
...@@ -1153,6 +1197,9 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 && ...@@ -1153,6 +1197,9 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 &&
if( currTestMode.type == ETM_INTER_ME && !skipCU) if( currTestMode.type == ETM_INTER_ME && !skipCU)
{ {
//ALBERTO CONCEPT FORK
modeCount++;
//END ALBERTO CONCEPT FORK
if( ( currTestMode.opts & ETO_IMV ) != 0 ) if( ( currTestMode.opts & ETO_IMV ) != 0 )
{ {
const bool skipAltHpelIF = (currTestMode.getAmvrSearchMode() == EncTestMode::AmvrSearchMode::HALF_PEL) const bool skipAltHpelIF = (currTestMode.getAmvrSearchMode() == EncTestMode::AmvrSearchMode::HALF_PEL)
...@@ -1178,6 +1225,9 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 && ...@@ -1178,6 +1225,9 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 &&
} }
else if (currTestMode.type == ETM_HASH_INTER && !skipCU) else if (currTestMode.type == ETM_HASH_INTER && !skipCU)
{ {
//ALBERTO CONCEPT FORK
modeCount++;
//END ALBERTO CONCEPT FORK
xCheckRDCostHashInter( tempCS, bestCS, partitioner, currTestMode ); xCheckRDCostHashInter( tempCS, bestCS, partitioner, currTestMode );
splitRdCostBest[CTU_LEVEL] = bestCS->cost; splitRdCostBest[CTU_LEVEL] = bestCS->cost;
tempCS->splitRdCostBest = splitRdCostBest; tempCS->splitRdCostBest = splitRdCostBest;
...@@ -1185,6 +1235,9 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 && ...@@ -1185,6 +1235,9 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 &&
#if !JVET_AC0139_UNIFIED_MERGE #if !JVET_AC0139_UNIFIED_MERGE
else if( currTestMode.type == ETM_AFFINE && !skipCU) else if( currTestMode.type == ETM_AFFINE && !skipCU)
{ {
//ALBERTO CONCEPT FORK
modeCount++;
//END ALBERTO CONCEPT FORK
xCheckRDCostAffineMerge2Nx2N( tempCS, bestCS, partitioner, currTestMode ); xCheckRDCostAffineMerge2Nx2N( tempCS, bestCS, partitioner, currTestMode );
splitRdCostBest[CTU_LEVEL] = bestCS->cost; splitRdCostBest[CTU_LEVEL] = bestCS->cost;
tempCS->splitRdCostBest = splitRdCostBest; tempCS->splitRdCostBest = splitRdCostBest;
...@@ -1193,6 +1246,9 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 && ...@@ -1193,6 +1246,9 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 &&
#if REUSE_CU_RESULTS #if REUSE_CU_RESULTS
else if( currTestMode.type == ETM_RECO_CACHED && !skipCU) else if( currTestMode.type == ETM_RECO_CACHED && !skipCU)
{ {
//ALBERTO CONCEPT FORK
modeCount++;
//END ALBERTO CONCEPT FORK
xReuseCachedResult( tempCS, bestCS, partitioner ); xReuseCachedResult( tempCS, bestCS, partitioner );
splitRdCostBest[CTU_LEVEL] = bestCS->cost; splitRdCostBest[CTU_LEVEL] = bestCS->cost;
tempCS->splitRdCostBest = splitRdCostBest; tempCS->splitRdCostBest = splitRdCostBest;
...@@ -1200,6 +1256,9 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 && ...@@ -1200,6 +1256,9 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 &&
#endif #endif
else if( currTestMode.type == ETM_MERGE_SKIP && !skipCU) else if( currTestMode.type == ETM_MERGE_SKIP && !skipCU)
{ {
//ALBERTO CONCEPT FORK
modeCount++;
//END ALBERTO CONCEPT FORK
#if JVET_AC0139_UNIFIED_MERGE #if JVET_AC0139_UNIFIED_MERGE
xCheckRDCostUnifiedMerge(tempCS, bestCS, partitioner, currTestMode); xCheckRDCostUnifiedMerge(tempCS, bestCS, partitioner, currTestMode);
#else #else
...@@ -1216,6 +1275,9 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 && ...@@ -1216,6 +1275,9 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 &&
#if !JVET_AC0139_UNIFIED_MERGE #if !JVET_AC0139_UNIFIED_MERGE
else if( currTestMode.type == ETM_MERGE_GEO && !skipCU) else if( currTestMode.type == ETM_MERGE_GEO && !skipCU)
{ {
//ALBERTO CONCEPT FORK
modeCount++;
//END ALBERTO CONCEPT FORK
xCheckRDCostMergeGeo2Nx2N( tempCS, bestCS, partitioner, currTestMode ); xCheckRDCostMergeGeo2Nx2N( tempCS, bestCS, partitioner, currTestMode );
splitRdCostBest[CTU_LEVEL] = bestCS->cost; splitRdCostBest[CTU_LEVEL] = bestCS->cost;
tempCS->splitRdCostBest = splitRdCostBest; tempCS->splitRdCostBest = splitRdCostBest;
...@@ -1223,6 +1285,9 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 && ...@@ -1223,6 +1285,9 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 &&
#endif #endif
else if( currTestMode.type == ETM_INTRA || skipCU) else if( currTestMode.type == ETM_INTRA || skipCU)
{ {
//ALBERTO CONCEPT FORK
modeCount++;
//END ALBERTO CONCEPT FORK
if (slice.getSPS()->getUseColorTrans() && !CS::isDualITree(*tempCS)) if (slice.getSPS()->getUseColorTrans() && !CS::isDualITree(*tempCS))
{ {
bool skipSecColorSpace = false; bool skipSecColorSpace = false;
...@@ -1261,24 +1326,36 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 && ...@@ -1261,24 +1326,36 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 &&
} }
else if (currTestMode.type == ETM_PALETTE) else if (currTestMode.type == ETM_PALETTE)
{ {
//ALBERTO CONCEPT FORK
modeCount++;
//END ALBERTO CONCEPT FORK
xCheckPLT( tempCS, bestCS, partitioner, currTestMode ); xCheckPLT( tempCS, bestCS, partitioner, currTestMode );
splitRdCostBest[CTU_LEVEL] = bestCS->cost; splitRdCostBest[CTU_LEVEL] = bestCS->cost;
tempCS->splitRdCostBest = splitRdCostBest; tempCS->splitRdCostBest = splitRdCostBest;
} }
else if (currTestMode.type == ETM_IBC) else if (currTestMode.type == ETM_IBC)
{ {
//ALBERTO CONCEPT FORK
modeCount++;
//END ALBERTO CONCEPT FORK
xCheckRDCostIBCMode(tempCS, bestCS, partitioner, currTestMode); xCheckRDCostIBCMode(tempCS, bestCS, partitioner, currTestMode);
splitRdCostBest[CTU_LEVEL] = bestCS->cost; splitRdCostBest[CTU_LEVEL] = bestCS->cost;
tempCS->splitRdCostBest = splitRdCostBest; tempCS->splitRdCostBest = splitRdCostBest;
} }
else if (currTestMode.type == ETM_IBC_MERGE) else if (currTestMode.type == ETM_IBC_MERGE)
{ {
//ALBERTO CONCEPT FORK
modeCount++;
//END ALBERTO CONCEPT FORK
xCheckRDCostIBCModeMerge2Nx2N(tempCS, bestCS, partitioner, currTestMode); xCheckRDCostIBCModeMerge2Nx2N(tempCS, bestCS, partitioner, currTestMode);
splitRdCostBest[CTU_LEVEL] = bestCS->cost; splitRdCostBest[CTU_LEVEL] = bestCS->cost;
tempCS->splitRdCostBest = splitRdCostBest; tempCS->splitRdCostBest = splitRdCostBest;
} }
else if( isModeSplit( currTestMode ) ) else if( isModeSplit( currTestMode ) )
{ {
//ALBERTO CONCEPT FORK
modeCount++;
//END ALBERTO CONCEPT FORK
if (bestCS->cus.size() != 0) if (bestCS->cus.size() != 0)
{ {
splitmode = bestCS->cus[0]->splitSeries; splitmode = bestCS->cus[0]->splitSeries;
...@@ -1320,8 +1397,20 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 && ...@@ -1320,8 +1397,20 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 &&
m_pcIntraSearch->setNumCuInSCIPU( 0 ); m_pcIntraSearch->setNumCuInSCIPU( 0 );
} }
} }
//ALBERTO CONCEPT FORK
bool activationIgnoreCondition = !singleMode && !ignoreVector && currTestMode.type!=ETM_SPLIT_QT;
if(activationIgnoreCondition)
{
ignoreVector = true;
}
//END ALBERTO CONCEPT FORK
xCheckModeSplit( tempCS, bestCS, partitioner, currTestMode, modeTypeParent, skipInterPass, splitRdCostBest ); xCheckModeSplit( tempCS, bestCS, partitioner, currTestMode, modeTypeParent, skipInterPass, splitRdCostBest );
//ALBERTO CONCEPT FORK
if(activationIgnoreCondition)
{
activationIgnoreCondition = ignoreVector = false;
}
//END ALBERTO COCNEPT FORK
tempCS->splitRdCostBest = splitRdCostBest; tempCS->splitRdCostBest = splitRdCostBest;
//recover cons modes //recover cons modes
tempCS->modeType = partitioner.modeType = modeTypeParent; tempCS->modeType = partitioner.modeType = modeTypeParent;
...@@ -1361,6 +1450,13 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 && ...@@ -1361,6 +1450,13 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 &&
{ {
THROW( "Don't know how to handle mode: type = " << currTestMode.type << ", options = " << currTestMode.opts ); THROW( "Don't know how to handle mode: type = " << currTestMode.type << ", options = " << currTestMode.opts );
} }
//ALBERTO CONCEPT FORK
if(!singleMode && !father && bestCS->cost < prevCost)
{
saveMode = currTestMode.type;
}
//END ALBERTO CONCEPT FORK
} while( m_modeCtrl->nextMode( *tempCS, partitioner ) ); } while( m_modeCtrl->nextMode( *tempCS, partitioner ) );
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
...@@ -1371,10 +1467,10 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 && ...@@ -1371,10 +1467,10 @@ bool vectorModeAvailable = posActualNode!=0 && vector[posActualNode].mode!=-1 &&
#ifdef DEBUG_MESSAGE #ifdef DEBUG_MESSAGE
std::cout << "SAVING --> código bucle split " << posActualNode << " : " << " (" << tempCS->area.lheight() <<","<< tempCS->area.lwidth() << ") " << std::endl; std::cout << "SAVING --> código bucle split " << posActualNode << " : " << " (" << tempCS->area.lheight() <<","<< tempCS->area.lwidth() << ") " << std::endl;
#endif #endif
bool saveModeCost = (!singleMode && !father && vector[posActualNode].mode==-1 && vector[posActualNode].cost==-1 && vector[posActualNode].threadNumber==threadNumber); bool saveModeCost = (!singleMode && !father && !ignoreVector && vector[posActualNode].mode==-1 && vector[posActualNode].cost==-1 && vector[posActualNode].threadNumber==threadNumber);
if(saveModeCost) if(saveModeCost)
{ {
vector[posActualNode].mode=saveMode.type; vector[posActualNode].mode= static_cast<int>(saveMode);
vector[posActualNode].cost=bestCS->cost; vector[posActualNode].cost=bestCS->cost;
} }
//ALBERTO END CONCEPT FORK //ALBERTO END CONCEPT FORK
...@@ -1527,7 +1623,7 @@ void EncCu::updateLambda(Slice *slice, const int dQP, ...@@ -1527,7 +1623,7 @@ void EncCu::updateLambda(Slice *slice, const int dQP,
int EncCu::searchFirstChild(int posFather) int EncCu::searchFirstChild(int posFather)
{ {
int posChild = -1; int posChild = -1;
for(int i=0; i<VECTOR_SIZE && posChild == -1; i++) for(int i=posFather; i<VECTOR_SIZE && posChild == -1; i++)
{ {
if(vector[i].posFather==posFather) if(vector[i].posFather==posFather)
{ {
...@@ -1686,7 +1782,7 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, ...@@ -1686,7 +1782,7 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS,
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 " << posActualNode << "->" << posChild << " : " << " (" << tempCS->area.lheight() <<","<< tempCS->area.lwidth() << ") " << "->" << " (" << tempSubCS->area.lheight() <<","<< tempSubCS->area.lwidth() <<") " << std::endl;
#endif //DEBUG_MESSAGE #endif //DEBUG_MESSAGE
int restorePosActualNode = posActualNode; int restorePosActualNode = posActualNode;
bool updatePosActualNode = (!singleMode && split == CU_QUAD_SPLIT); bool updatePosActualNode = (!singleMode && !father && split == CU_QUAD_SPLIT) || (!singleMode && father && !ignoreVector && split == CU_QUAD_SPLIT);
if(updatePosActualNode) { posActualNode=posChild; } if(updatePosActualNode) { posActualNode=posChild; }
//END ALBERTO CONCEPT FORK //END ALBERTO CONCEPT FORK
......
...@@ -322,14 +322,11 @@ private: ...@@ -322,14 +322,11 @@ private:
public: public:
//ALBERTO CONCEPT FORK //ALBERTO CONCEPT FORK
void createSharedVector(); void createSharedVector();
/*void repartLevel(); void initStructVectorBeforeRepartStart();
int repartStart(); int thread1NumberOfChild(int numberOfNodesPerThread);
int repartEnd();
void initStructVectorBeforeRepartStart(int repartStartNode);
int thread1NumberOfChild(int numberOfNodesPerThread);*/
void initStructVector(); void initStructVector();
void updateFatherAndThreadNumbersLevel0(int posPadreActual);//,int thread1ChildNumber,int numberOfNodesPerThread); void updateFatherAndThreadNumbersLevel0(int posPadreActual,int thread1ChildNumber,int numberOfNodesPerThread);
void updateFatherAndThreadNumbers(int LevelLowIndex, int LevelUpIndex, int posPadreActual, int i);//,int LevelActualIndex,int& childCounter,int thread1ChildNumber,int& threadNumber,int numberOfNodesPerThread); void updateFatherAndThreadNumbers(int LevelLowIndex, int LevelUpIndex, int posPadreActual, int i,int LevelActualIndex,int& childCounter,int thread1ChildNumber,int& threadNumber,int numberOfNodesPerThread);
// END ALBERTO CONCEPT FORK // END ALBERTO CONCEPT FORK
/// copy parameters from encoder class /// copy parameters from encoder class
......
...@@ -4033,7 +4033,7 @@ void EncGOP::compressGOP(int pocLast, int numPicRcvd, PicList &rcListPic, std::l ...@@ -4033,7 +4033,7 @@ void EncGOP::compressGOP(int pocLast, int numPicRcvd, PicList &rcListPic, std::l
} }
} }
} }
auto elapsed = std::chrono::steady_clock::now() - beforeTime;
// reset presence of BP SEI indication // reset presence of BP SEI indication
m_bufferingPeriodSEIPresentInAU = false; m_bufferingPeriodSEIPresentInAU = false;
// create prefix SEI associated with a picture // create prefix SEI associated with a picture
...@@ -4285,8 +4285,7 @@ void EncGOP::compressGOP(int pocLast, int numPicRcvd, PicList &rcListPic, std::l ...@@ -4285,8 +4285,7 @@ void EncGOP::compressGOP(int pocLast, int numPicRcvd, PicList &rcListPic, std::l
} }
//-- For time output for each slice //-- For time output for each slice
auto elapsed = std::chrono::steady_clock::now() - beforeTime; auto encTime = std::chrono::duration_cast<std::chrono::seconds>( elapsed*0.75 ).count();
auto encTime = std::chrono::duration_cast<std::chrono::seconds>( elapsed ).count();
std::string digestStr; std::string digestStr;
#if GDR_ENABLED #if GDR_ENABLED
......
...@@ -108,20 +108,30 @@ bool EncModeCtrl::lastModeAvailable() const ...@@ -108,20 +108,30 @@ bool EncModeCtrl::lastModeAvailable() const
{ {
return !m_ComprCUCtxList.empty() && !m_ComprCUCtxList.back().testModes.empty() && m_ComprCUCtxList.back().testModes.size()==1; return !m_ComprCUCtxList.empty() && !m_ComprCUCtxList.back().testModes.empty() && m_ComprCUCtxList.back().testModes.size()==1;
} }
bool EncModeCtrl::vectorModeAvailable(int objetiveModeType) const bool EncModeCtrl::vectorModeAvailable(EncTestModeType objectiveMode) const
{ {
bool vectorModeAvailable = false;
const auto& lastElem = m_ComprCUCtxList.back(); const auto& lastElem = m_ComprCUCtxList.back();
const auto& testModes = lastElem.testModes; const auto& testModes = lastElem.testModes;
for (size_t i = 0; i < testModes.size(); i++)
for (const auto& actualMode : testModes)
{ {
if(actualMode.type == objetiveModeType) if (testModes[i].type == objectiveMode)
{ {
vectorModeAvailable = true; return true;
} }
} }
return vectorModeAvailable; return false;
}
int EncModeCtrl::numberOfModes() const
{
const auto& lastElem = m_ComprCUCtxList.back();
const auto& testModes = lastElem.testModes;
std::cout << "[";
for (const auto& actualMode : testModes)
{
std::cout << " " << actualMode.type << " ";
}
std::cout << "]" << std::endl;
return m_ComprCUCtxList.back().testModes.size();
} }
//END ALBERTO CONCEPT FORK //END ALBERTO CONCEPT FORK
......
...@@ -328,7 +328,8 @@ public: ...@@ -328,7 +328,8 @@ public:
bool nextMode ( const CodingStructure &cs, Partitioner &partitioner ); bool nextMode ( const CodingStructure &cs, Partitioner &partitioner );
//ALBERTO CONCEPT FORK //ALBERTO CONCEPT FORK
bool lastModeAvailable() const; bool lastModeAvailable() const;
bool vectorModeAvailable(int modeType) const; bool vectorModeAvailable(EncTestModeType modeType) const;
int numberOfModes() const;
//END ALBERTO CONCEPT FORK //END ALBERTO CONCEPT FORK
EncTestMode currTestMode() const; EncTestMode currTestMode() const;
EncTestMode lastTestMode () const; EncTestMode lastTestMode () const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment