1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
std::vector<int> Multigrid::methodeMultigrid16x16(unsigned char* I_Y, unsigned char* P_Y, unsigned char* prediction, unsigned char* predictionBlocks, unsigned char* blocksMap, int step, int width,int height, int precision, unsigned int* complexity, unsigned char* prediction4x4)
{
int num128x128Blocks = width/128*height/128;
int numLevels = log10(double(128/(precision)))/log10(2.0)+1;
int maxNumBlocks = num128x128Blocks;
int add = num128x128Blocks;
for (int i=0; i<numLevels-1; i++)
{
add = 4*add;
maxNumBlocks = maxNumBlocks + add;
}
int count=0;
std::vector<Block*> blocks;
blocks.reserve(maxNumBlocks);
for (int i=0; i<maxNumBlocks; i++)
{
Block* block = new Block(); //------->ENDROIT DU CRASH
blocks.push_back(block);
}
Block::process(I_Y, P_Y, &count, step, width, height, &numLevels, complexity, blocks);
// Block vector for mapping
std::vector<Block*> blocks4x4;
std::vector<int> mvRef;
int num4x4Blocks = width/4*height/4;
blocks4x4.reserve(num4x4Blocks);
mvRef.reserve(2*num4x4Blocks);
for (int i=0; i<num4x4Blocks; i++)
{
Block* block = new Block();
blocks4x4.push_back(block);
}
//Mapping multigrid Blocks to 4x4 blocks
Block::mappingBlocks4x4(&count,blocks4x4, blocks);
Multigrid::constructMultigridPrediction(I_Y, prediction,count, predictionBlocks, blocksMap,blocks);
Multigrid::constructPrediction4x4(I_Y, prediction4x4, num4x4Blocks, blocks4x4);
for ( std::vector<Block*>::iterator it = blocks.begin() ; it != blocks.end(); ++it)
{
delete *it;
}
blocks.clear();
//Inserting motion vectors in the motion Vector list
for (int i=0; i<num4x4Blocks; i++)
{
int v0 = blocks4x4[i]->motionVector[0];
int v1 = blocks4x4[i]->motionVector[1];
mvRef.push_back(v0);
mvRef.push_back(v1);
}
for ( std::vector<Block*>::iterator it = blocks4x4.begin() ; it != blocks4x4.end(); ++it)
{
delete *it;
}
blocks4x4.clear();
return mvRef;
} |
Partager