コード例 #1
0
ファイル: movsettings.cpp プロジェクト: walkerka/opentoonz
void visitAtoms(const QTAtomContainer &atoms, const QTAtom &parent,
                TPropertyGroup &pg) {
  QTAtom curr = 0;

  do {
    if (QTNextChildAnyType(atoms, parent, curr, &curr) != noErr) assert(false);

    if (curr == 0) break;
    QTAtomType atomType;
    QTAtomID id;

    QTGetAtomTypeAndID(atoms, curr, &atomType, &id);
    int sonCount = QTCountChildrenOfType(atoms, curr, 0);

    char buffer[1024];
    sprintf(buffer, "%d %d %d", (int)atomType, (int)id, sonCount);
    string str(buffer);

    if (sonCount > 0) {
      pg.add(new TStringProperty(str, TString()));
      visitAtoms(atoms, curr, pg);
    }

    else {
      long size;
      UCHAR *atomData;
      if (QTGetAtomDataPtr(atoms, curr, &size, (char **)&atomData) != noErr)
        assert(false);

      string strapp;
      for (int i = 0; i < size; i++) {
        string num;
        if (atomData[i] == 0) {
          int count = 1;
          while ((i + 1) < size && atomData[i + 1] == 0) i++, count++;
          if (count > 1) {
            num    = std::to_string(count);
            strapp = strapp + "z " + num + " ";
            continue;
          }
        }
        num = std::to_string(atomData[i]);

        strapp = strapp + string(num) + " ";
      }

      // unsigned short*buffer = new unsigned short[size];
      // buffer[size]=0;
      // for (i=0; i<size; i++)
      //  buffer[i] = atomData[i]+1;

      wstring data = ::to_wstring(strapp);

      pg.add(new TStringProperty(str, data));
    }
  } while (curr != 0);
}
コード例 #2
0
ファイル: movsettings.cpp プロジェクト: CroW-CZ/opentoonz
//------------------------------------------------
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);
		}
	}
}
コード例 #3
0
ファイル: t323gpmsg.cpp プロジェクト: walkerka/opentoonz
void InitLW3gpParser::operator()(Message &msg) {
  unsigned int id;
  QString fp, propsFp;
  msg >> id >> fp >> propsFp >> clr;

  TFilePath tfp(fp.toStdWString()), propsTFp(propsFp.toStdWString());

  try {
    TPropertyGroup *props = 0;
    if (!propsTFp.isEmpty()) {
      props = new TPropertyGroup;

      TIStream is(propsTFp);
      props->loadData(is);
    }

    writers.insert(id, TLevelWriterP(tfp, props));

    msg << QString("ok");
  } catch (...) {
    msg << QString("err");
  }
}
コード例 #4
0
//!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();
}
コード例 #5
0
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();
}
コード例 #6
0
ファイル: movsettings.cpp プロジェクト: CroW-CZ/opentoonz
void fromAtomsToProperties(const QTAtomContainer &atoms, TPropertyGroup &pg)
{
	pg.clear();
	visitAtoms(atoms, kParentAtomIsContainer, pg);
}
コード例 #7
0
ファイル: sceneproperties.cpp プロジェクト: CroW-CZ/opentoonz
void TSceneProperties::saveData(TOStream &os) const
{
	if (!m_hGuides.empty()) {
		os.openChild("hGuides");
		for (int i = 0; i < (int)m_hGuides.size(); i++)
			os << m_hGuides[i];
		os.closeChild();
	}
	if (!m_vGuides.empty()) {
		os.openChild("vGuides");
		for (int i = 0; i < (int)m_vGuides.size(); i++)
			os << m_vGuides[i];
		os.closeChild();
	}

	int i;
	if (!m_cameras.empty()) {
		os.openChild("cameras");
		for (i = 0; i < (int)m_cameras.size(); i++) {
			os.openChild("camera");
			m_cameras[i]->saveData(os);
			os.closeChild();
		}
		os.closeChild();
	}

	os.openChild("outputs");
	std::vector<TOutputProperties *> outputs;
	outputs.push_back(getOutputProperties());
	outputs.push_back(getPreviewProperties());
	for (i = 0; i < (int)outputs.size(); i++) {
		TOutputProperties &out = *outputs[i];
		const TRenderSettings &rs = out.getRenderSettings();
		std::map<std::string, std::string> attr;
		attr["name"] = i == 0 ? "main" : "preview";
		os.openChild("output", attr);

		TFilePath outPath = out.getPath();
		int from, to, step;
		out.getRange(from, to, step);
		os.child("range") << from << to;
		os.child("step") << step;
		os.child("shrink") << rs.m_shrinkX;
		os.child("applyShrinkToViewer") << (rs.m_applyShrinkToViewer ? 1 : 0);
		os.child("fps") << out.getFrameRate();
		os.child("path") << outPath;
		os.child("bpp") << rs.m_bpp;
		os.child("multimedia") << out.getMultimediaRendering();
		os.child("threadsIndex") << out.getThreadIndex();
		os.child("maxTileSizeIndex") << out.getMaxTileSizeIndex();
		os.child("subcameraPrev") << (out.isSubcameraPreview() ? 1 : 0);
		os.child("stereoscopic") << (rs.m_stereoscopic ? 1 : 0) << rs.m_stereoscopicShift;

		switch (rs.m_quality) {
		case TRenderSettings::StandardResampleQuality:
			os.child("resquality") << (int)0;
			break;
		case TRenderSettings::ImprovedResampleQuality:
			os.child("resquality") << (int)1;
			break;
		case TRenderSettings::HighResampleQuality:
			os.child("resquality") << (int)2;

		case TRenderSettings::Triangle_FilterResampleQuality:
			os.child("resquality") << (int)100;
			break;
		case TRenderSettings::Mitchell_FilterResampleQuality:
			os.child("resquality") << (int)101;
			break;
		case TRenderSettings::Cubic5_FilterResampleQuality:
			os.child("resquality") << (int)102;
			break;
		case TRenderSettings::Cubic75_FilterResampleQuality:
			os.child("resquality") << (int)103;
			break;
		case TRenderSettings::Cubic1_FilterResampleQuality:
			os.child("resquality") << (int)104;
			break;
		case TRenderSettings::Hann2_FilterResampleQuality:
			os.child("resquality") << (int)105;
			break;
		case TRenderSettings::Hann3_FilterResampleQuality:
			os.child("resquality") << (int)106;
			break;
		case TRenderSettings::Hamming2_FilterResampleQuality:
			os.child("resquality") << (int)107;
			break;
		case TRenderSettings::Hamming3_FilterResampleQuality:
			os.child("resquality") << (int)108;
			break;
		case TRenderSettings::Lanczos2_FilterResampleQuality:
			os.child("resquality") << (int)109;
			break;
		case TRenderSettings::Lanczos3_FilterResampleQuality:
			os.child("resquality") << (int)110;
			break;
		case TRenderSettings::Gauss_FilterResampleQuality:
			os.child("resquality") << (int)111;
			break;
		case TRenderSettings::ClosestPixel_FilterResampleQuality:
			os.child("resquality") << (int)112;
			break;
		case TRenderSettings::Bilinear_FilterResampleQuality:
			os.child("resquality") << (int)113;
			break;
			break;
		DEFAULT:
			assert(false);
		}
		switch (rs.m_fieldPrevalence) {
		case TRenderSettings::NoField:
			os.child("fieldprevalence") << (int)0;
			break;
		case TRenderSettings::EvenField:
			os.child("fieldprevalence") << (int)1;
			break;
		case TRenderSettings::OddField:
			os.child("fieldprevalence") << (int)2;
			break;
		DEFAULT:
			assert(false);
		}
		os.child("gamma") << rs.m_gamma;
		os.child("timestretch") << rs.m_timeStretchFrom << rs.m_timeStretchTo;

		if (out.getOffset() != 0)
			os.child("offset") << out.getOffset();

		os.openChild("formatsProperties");
		std::vector<std::string> fileExtensions;
		out.getFileFormatPropertiesExtensions(fileExtensions);
		for (int i = 0; i < (int)fileExtensions.size(); i++) {
			std::string ext = fileExtensions[i];
			TPropertyGroup *pg = out.getFileFormatProperties(ext);
			assert(pg);
			std::map<std::string, std::string> attr;
			attr["ext"] = ext;
			os.openChild("formatProperties", attr);
			pg->saveData(os);
			os.closeChild();
		}
		os.closeChild();

		os.closeChild(); // </output>
	}
	os.closeChild();
	os.openChild("cleanupParameters");
	m_cleanupParameters->saveData(os);
	os.closeChild();
	os.openChild("scanParameters");
	m_scanParameters->saveData(os);
	os.closeChild();
	os.openChild("vectorizerParameters");
	m_vectorizerParameters->saveData(os);
	os.closeChild();
	os.child("bgColor") << m_bgColor;
	os.child("markers") << m_markerDistance << m_markerOffset;
	os.child("subsampling") << m_fullcolorSubsampling << m_tlvSubsampling;
	os.child("fieldguide") << m_fieldGuideSize << m_fieldGuideAspectRatio;

	os.openChild("noteColors");
	for (i = 0; i < m_notesColor.size(); i++)
		os << m_notesColor.at(i);
	os.closeChild();
}
コード例 #8
0
ファイル: tiio.cpp プロジェクト: janisozaur/opentoonz
TPropertyGroup *Tiio::makeWriterProperties(std::string ext) {
  TPropertyGroup *prop = TiioTable::instance()->findWriterProperties(ext);
  if (!prop) return new TPropertyGroup();
  return prop->clone();
}