for(unsigned int mBlock = 0; mBlock < coords.size(); mBlock++)
{
WidgetType widgetType;
height = macBlockWidth + coords[mBlock].y;
width = macBlockHeight + coords[mBlock].x;
macBlockParent = new QWidget;
cooefsLink = new QPushButton(macBlockParent);
macBlock = new QWidget(macBlockParent);
widgetType.widget = macBlock;
widgetType.type = (macBlocks[mBlock][2] != 'S')
? (macBlocks[mBlock][0]) : (macBlocks[mBlock][2]);
blockWidgetTypes.push_back(widgetType);
connect(cooefsLink, SIGNAL(released()),
this, SLOT(showCoefficients()));
buttonSignals[cooefsLink] = mBlock;
constructMotionVector(mBlock);
macBlockLayout->addWidget(macBlockParent, height - 16, width - 16);
styleMacroBlocks(mBlock);
}
この for ループから関数を作成して、2 つの異なる for ループに分割することで操作を並列化できますか?両方とも同時にベクトルを操作します。1 つは前半の項目に取り組んでおり、2 番目のスレッドは後半を構築しています。たとえば
スレッド 1
for(unsigned int mBlock = 0; mBlock < coords.size() / 2; mBlock++)
{
WidgetType widgetType;
height = macBlockWidth + coords[mBlock].y;
width = macBlockHeight + coords[mBlock].x;
macBlockParent = new QWidget;
cooefsLink = new QPushButton(macBlockParent);
macBlock = new QWidget(macBlockParent);
widgetType.widget = macBlock;
widgetType.type = (macBlocks[mBlock][2] != 'S')
? (macBlocks[mBlock][0]) : (macBlocks[mBlock][2]);
blockWidgetTypes.push_back(widgetType);
connect(cooefsLink, SIGNAL(released()),
this, SLOT(showCoefficients()));
buttonSignals[cooefsLink] = mBlock;
constructMotionVector(mBlock);
macBlockLayout->addWidget(macBlockParent, height - 16, width - 16);
styleMacroBlocks(mBlock);
}
スレッド 2
for(unsigned int mBlock = coords.size() / 2; mBlock < coords.size(); mBlock++)
{
WidgetType widgetType;
height = macBlockWidth + coords[mBlock].y;
width = macBlockHeight + coords[mBlock].x;
macBlockParent = new QWidget;
cooefsLink = new QPushButton(macBlockParent);
macBlock = new QWidget(macBlockParent);
widgetType.widget = macBlock;
widgetType.type = (macBlocks[mBlock][2] != 'S')
? (macBlocks[mBlock][0]) : (macBlocks[mBlock][2]);
blockWidgetTypes.push_back(widgetType);
connect(cooefsLink, SIGNAL(released()),
this, SLOT(showCoefficients()));
buttonSignals[cooefsLink] = mBlock;
constructMotionVector(mBlock);
macBlockLayout->addWidget(macBlockParent, height - 16, width - 16);
styleMacroBlocks(mBlock);
}
それは私のシステムにとって本当のボトルネックであり、1 つの CPU しか使用していないことに気づき、その CPU を使い果たしているためです。どんな助けでも大歓迎です。