//------------------------------------------------ void visitprops(TPropertyGroup &pg, int &index, QTAtomContainer &atoms, QTAtom parent) { int count = pg.getPropertyCount(); while (index < count) { TStringProperty *p = (TStringProperty *)pg.getProperty(index++); string str0 = p->getName(); const char *buf = str0.c_str(); int atomType, id, sonCount; sscanf(buf, "%d %d %d", &atomType, &id, &sonCount); QTAtom newAtom; if (sonCount == 0) { wstring appow = p->getValue(); string appo = toString(appow); const char *str = appo.c_str(); vector<UCHAR> buf; while (strlen(str) > 0) { if (str[0] == 'z') { int count = atoi(str + 1); str += (count < 10) ? 4 : ((count < 100) ? 5 : 6); while (count--) buf.push_back(0); } else { int val = atoi(str); assert(val >= 0 && val < 256); str += (val < 10) ? 2 : ((val < 100) ? 3 : 4); buf.push_back(val); } } //const unsigned short*bufs = str1.c_str(); //UCHAR *bufc = new UCHAR[size]; //for (int i=0; i<size; i++) // { // assert(bufs[i]<257); // bufc[i] = (UCHAR)(bufs[i]-1); // } void *ptr = 0; if (buf.size() != 0) { ptr = &(buf[0]); } QTInsertChild(atoms, parent, (QTAtomType)atomType, (QTAtomID)id, 0, buf.size(), (void *)ptr, 0); } else { QTInsertChild(atoms, parent, (QTAtomType)atomType, (QTAtomID)id, 0, 0, 0, &newAtom); visitprops(pg, index, atoms, newAtom); } } }
//!Specialized render invocation for multimedia rendering. Flash rendering //!is currently not supported in this mode. void RenderCommand::multimediaRender() { ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); string ext = m_fp.getType(); #ifdef WIN32 if (ext == "avi") { TPropertyGroup *props = scene->getProperties()->getOutputProperties()->getFileFormatProperties(ext); string codecName = props->getProperty(0)->getValueAsString(); TDimension res = scene->getCurrentCamera()->getRes(); if (!AviCodecRestrictions::canWriteMovie(toWideString(codecName), res)) { QString msg(QObject::tr("The resolution of the output camera does not fit with the options chosen for the output file format.")); MsgBox(WARNING, msg); return; } } #endif; TOutputProperties *prop = scene->getProperties()->getOutputProperties(); //Build thread count int index = prop->getThreadIndex(); const int procCount = TSystem::getProcessorCount(); const int threadCounts[3] = {1, procCount / 2, procCount}; int threadCount = threadCounts[index]; //Build raster granularity size index = prop->getMaxTileSizeIndex(); const int maxTileSizes[4] = { (std::numeric_limits<int>::max)(), TOutputProperties::LargeVal, TOutputProperties::MediumVal, TOutputProperties::SmallVal}; TRenderSettings rs = prop->getRenderSettings(); rs.m_maxTileSize = maxTileSizes[index]; MultimediaRenderer multimediaRenderer(scene, m_fp, prop->getMultimediaRendering(), threadCount); multimediaRenderer.setRenderSettings(rs); #ifdef BRAVODEMO rs.m_mark = loadBravo(scene->getCurrentCamera()->getRes()); #endif TPointD cameraDpi = scene->getCurrentCamera()->getDpi(); multimediaRenderer.setDpi(cameraDpi.x, cameraDpi.y); multimediaRenderer.enablePrecomputing(true); for (int i = 0; i < m_numFrames; ++i, m_r += m_stepd) multimediaRenderer.addFrame(m_r); MultimediaProgressBar *listener = new MultimediaProgressBar(&multimediaRenderer); QObject::connect(listener, SIGNAL(canceled()), &multimediaRenderer, SLOT(onCanceled())); multimediaRenderer.addListener(listener); multimediaRenderer.start(); }
void RenderCommand::rasterRender(bool isPreview) { ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); if (isPreview) { //Let the PreviewFxManager own the rest. Just pass him the current output node. PreviewFxManager::instance()->showNewPreview((TFx *)scene->getXsheet()->getFxDag()->getCurrentOutputFx()); return; } string ext = m_fp.getType(); #ifdef WIN32 if (ext == "avi" && !isPreview) { TPropertyGroup *props = scene->getProperties()->getOutputProperties()->getFileFormatProperties(ext); string codecName = props->getProperty(0)->getValueAsString(); TDimension res = scene->getCurrentCamera()->getRes(); if (!AviCodecRestrictions::canWriteMovie(toWideString(codecName), res)) { QString msg(QObject::tr("The resolution of the output camera does not fit with the options chosen for the output file format.")); MsgBox(WARNING, msg); return; } } #endif; //Extract output properties TOutputProperties *prop = isPreview ? scene->getProperties()->getPreviewProperties() : scene->getProperties()->getOutputProperties(); //Build thread count /*-- Dedicated CPUs のコンボボックス (Single, Half, All) --*/ int index = prop->getThreadIndex(); const int procCount = TSystem::getProcessorCount(); const int threadCounts[3] = {1, procCount / 2, procCount}; int threadCount = threadCounts[index]; /*-- MovieRendererを作る。Previewの場合はファイルパスは空 --*/ MovieRenderer movieRenderer(scene, isPreview ? TFilePath() : m_fp, threadCount, isPreview); TRenderSettings rs = prop->getRenderSettings(); //Build raster granularity size index = prop->getMaxTileSizeIndex(); const int maxTileSizes[4] = { (std::numeric_limits<int>::max)(), TOutputProperties::LargeVal, TOutputProperties::MediumVal, TOutputProperties::SmallVal}; rs.m_maxTileSize = maxTileSizes[index]; //Build #ifdef BRAVODEMO rs.m_mark = loadBravo(scene->getCurrentCamera()->getRes()); #endif /*-- RenderSettingsをセット --*/ movieRenderer.setRenderSettings(rs); /*-- カメラDPIの取得、セット --*/ TPointD cameraDpi = isPreview ? scene->getCurrentPreviewCamera()->getDpi() : scene->getCurrentCamera()->getDpi(); movieRenderer.setDpi(cameraDpi.x, cameraDpi.y); movieRenderer.enablePrecomputing(true); /*-- プログレス ダイアログの作成 --*/ RenderListener *listener = new RenderListener(movieRenderer.getTRenderer(), m_fp, ((m_numFrames - 1) / m_step) + 1, isPreview); QObject::connect(listener, SIGNAL(canceled()), &movieRenderer, SLOT(onCanceled())); movieRenderer.addListener(listener); bool fieldRendering = rs.m_fieldPrevalence != TRenderSettings::NoField; /*-- buildSceneFxの進行状況を表示するプログレスバー --*/ QProgressBar *buildSceneProgressBar = new QProgressBar(TApp::instance()->getMainWindow()); buildSceneProgressBar->setAttribute(Qt::WA_DeleteOnClose); buildSceneProgressBar->setWindowFlags(Qt::SubWindow | Qt::Dialog | Qt::WindowStaysOnTopHint); buildSceneProgressBar->setMinimum(0); buildSceneProgressBar->setMaximum(m_numFrames - 1); buildSceneProgressBar->setValue(0); buildSceneProgressBar->move(600, 500); buildSceneProgressBar->setWindowTitle("Building Schematic..."); buildSceneProgressBar->show(); for (int i = 0; i < m_numFrames; ++i, m_r += m_stepd) { buildSceneProgressBar->setValue(i); if (rs.m_stereoscopic) scene->shiftCameraX(-rs.m_stereoscopicShift / 2); TFxPair fx; fx.m_frameA = buildSceneFx(scene, m_r, rs.m_shrinkX, isPreview); if (fieldRendering && !isPreview) fx.m_frameB = buildSceneFx(scene, m_r + 0.5 / m_timeStretchFactor, rs.m_shrinkX, isPreview); else if (rs.m_stereoscopic) { scene->shiftCameraX(rs.m_stereoscopicShift); fx.m_frameB = buildSceneFx(scene, m_r + 0.5 / m_timeStretchFactor, rs.m_shrinkX, isPreview); scene->shiftCameraX(-rs.m_stereoscopicShift / 2); } else fx.m_frameB = TRasterFxP(); /*-- movieRendererにフレーム毎のFxを登録 --*/ movieRenderer.addFrame(m_r, fx); } /*-- プログレスバーを閉じる --*/ buildSceneProgressBar->close(); //resetViewer(); //TODO cancella le immagini dell'eventuale render precedente //FileViewerPopupPool::instance()->getCurrent()->onClose(); movieRenderer.start(); }