コード例 #1
0
ファイル: mxfdump.cpp プロジェクト: Dheeraj-B/mxflib
//! Dump an object and any physical or logical children
void DumpObject(MDObjectPtr Object, std::string Prefix)
{
	if(DumpLocation) printf("0x%s : ", Int64toHexString(Object->GetLocation(),8).c_str());

	if(Object->IsModified()) printf("%s%s is *MODIFIED*\n", Object->FullName().c_str(), Prefix.c_str() );

#ifdef OPTION3ENABLED
	if(ShowBaseline)
	{
		if(!Object->IsBaseline())
		{
			if(Object->GetBaselineUL())
			{
				MDOTypePtr BaselineClass = MDOType::Find(Object->GetBaselineUL());
				if(BaselineClass)
				{
					printf("%sBaseline: %s\n", Prefix.c_str(), BaselineClass->Name().c_str());
				}
				else
				{
					printf("%sNote: Current dictionary does not contain a set with the baseline UL used to wrap this non-baseline class\n", Prefix.c_str());
					printf("%sBaseline: %s\n", Prefix.c_str(), Object->GetBaselineUL()->GetString().c_str());
				}
				Prefix += "  ";
			}
			else
			{
				printf("%sNote: Current dictionary flags this class as non-baseline, but it is not wrapped in a baseline class\n", Prefix.c_str());
			}
		}
		else
		{
			if(Object->GetBaselineUL())
			{
				printf("%sNote: Current dictionary flags this class as baseline, but it is wrapped as a non-baseline class\n", Prefix.c_str());

				MDOTypePtr BaselineClass = MDOType::Find(Object->GetBaselineUL());
				if(BaselineClass)
				{
					printf("%sBaseline: %s\n", Prefix.c_str(), BaselineClass->Name().c_str());
				}
				else
				{
					printf("%sNote: Current dictionary does not contain a set with the baseline UL used to wrap this non-baseline class\n", Prefix.c_str());
					printf("%sBaseline: %s\n", Prefix.c_str(), Object->GetBaselineUL()->GetString().c_str());
				}
				Prefix += "  ";
			}
		}
	}
#endif // OPTION3ENABLED

	if(Object->GetLink())
	{
		if(Object->GetRefType() == ClassRefStrong)
		{
			printf("%s%s = %s\n", Prefix.c_str(), Object->Name().c_str(), Object->GetString().c_str());

			if(DumpLocation) printf("0x%s : ", Int64toHexString(Object->GetLocation(),8).c_str());
			printf("%s%s -> Strong Reference to %s\n", Prefix.c_str(), Object->Name().c_str(), Object->GetLink()->Name().c_str());

			DumpObject(Object->GetLink(), Prefix + "  ");
		}
		else if(Object->GetRefType() == ClassRefGlobal)
		{
			if(FollowGlobals)
			{
				printf("%s%s = %s\n", Prefix.c_str(), Object->Name().c_str(), Object->GetString().c_str());

				if(DumpLocation) printf("0x%s : ", Int64toHexString(Object->GetLocation(),8).c_str());
				printf("%s%s -> Global Reference to %s\n", Prefix.c_str(), Object->Name().c_str(), Object->GetLink()->Name().c_str());

				DumpObject(Object->GetLink(), Prefix + "  ");
			}
			else
			{
				printf("%s%s -> Global Reference to %s, %s\n", Prefix.c_str(), Object->Name().c_str(), Object->GetLink()->Name().c_str(), Object->GetString().c_str());
			}
		}
		else if(Object->GetRefType() == ClassRefMeta)
		{
			std::string TargetName = Object->GetLink()->GetString(MetaDefinitionName_UL, Object->GetLink()->Name());
			printf("%s%s -> MetaDictionary Reference to %s %s\n", Prefix.c_str(), Object->Name().c_str(), TargetName.c_str(), Object->GetString().c_str());
		}
		else if(Object->GetRefType() == ClassRefDict)
		{
			std::string TargetName = Object->GetLink()->GetString(DefinitionObjectName_UL, Object->GetLink()->Name());
			printf("%s%s -> Dictionary Reference to %s %s\n", Prefix.c_str(), Object->Name().c_str(), TargetName.c_str(), Object->GetString().c_str());
		}
		else
		{
			printf("%s%s -> Weak Reference to %s %s\n", Prefix.c_str(), Object->Name().c_str(), Object->GetLink()->Name().c_str(), Object->GetString().c_str());
		}
	}
	else
	{
		if(Object->IsDValue())
		{
			printf("%s%s = <Unknown>\n", Prefix.c_str(), Object->Name().c_str());
		}
		else
		{
			// Check first for values that are not reference batches
			if(Object->IsAValue())
			{
//if(Object->Name().find("Unknown") == std::string::npos)
				printf("%s%s = %s\n", Prefix.c_str(), Object->Name().c_str(), Object->GetString().c_str());
//else			printf("%s%s\n", Prefix.c_str(), Object->Name().c_str());
if(Object->GetRefType() == ClassRefMeta)
	printf("%s%s is an unsatisfied MetaRef\n", Prefix.c_str(), Object->Name().c_str());
else if(Object->GetRefType() == ClassRefDict)
	printf("%s%s is an unsatisfied DictRef\n", Prefix.c_str(), Object->Name().c_str());
			}
			else
			{
				printf("%s%s\n", Prefix.c_str(), Object->Name().c_str());
				MDObjectULList::iterator it = Object->begin();

				if(!SortedDump)
				{
					/* Dump Objects in the order stored */
					while(it != Object->end())
					{
						DumpObject((*it).second, Prefix + "  ");
						it++;
					}
				}
				else
				{
					/* Dump Objects in alphabetical order - to allow easier file comparisons */
					std::multimap<std::string, MDObjectPtr> ChildMap;
					std::multimap<std::string, MDObjectPtr>::iterator CM_Iter;

					while(it != Object->end())
					{
						ChildMap.insert(std::multimap<std::string, MDObjectPtr>::value_type((*it).second->Name(), (*it).second));
						it++;
					}

					CM_Iter = ChildMap.begin();
					while(CM_Iter != ChildMap.end())
					{
						DumpObject((*CM_Iter).second, Prefix + "  ");
						CM_Iter++;
					}
				}
			}
		}
	}

	return;
}
コード例 #2
0
ファイル: vbi.cpp プロジェクト: Dheeraj-B/mxflib
//! Get the offset to add to lines in field 2
int ANCVBISource::Field2Offset(void)
{
	if(F2Offset >= 0) return F2Offset;

	MDObjectPtr Descriptor = MasterSource->GetDescriptor();
	if(!Descriptor)
	{
		error("EssenceDescriptor not defined for master source of ANCVBISource before calling Field2Offset()\n");
		F2Offset = 0;
		return F2Offset;
	}

	// If this is a multpile descriptor, locate the video
	// DRAGONS: If we can't find a picture descriptor we will drop through with the MultipleDescriptor and give a "does not have a VideoLineMap" error
	if(Descriptor->IsA(MultipleDescriptor_UL))
	{
		MDObject::iterator it = Descriptor->begin();
		while(it != Descriptor->end())
		{
			if((*it).second->IsA(GenericPictureEssenceDescriptor_UL))
			{
				Descriptor = (*it).second;
				break;
			}
			it++;
		}
	}


	/* Check if this is interlaced essence */

	if(Descriptor->IsDValue(FrameLayout_UL))
	{
		warning("EssenceDescriptor for ANCVBISource does not have a valid FrameLayout\n");
		F2Offset = 0;
		return F2Offset;
	}

	if(Descriptor->GetInt(FrameLayout_UL) != 1)
	{
		F2Offset = 0;
		return F2Offset;
	}

	
	/* Calculate F1 to F2 distance from Video Line Map */

	MDObjectPtr VideoLineMap = Descriptor->Child(VideoLineMap_UL);
	if(!VideoLineMap)
	{
		error("EssenceDescriptor for ANCVBISource does not have a valid VideoLineMap\n");
		F2Offset = 0;
		return F2Offset;
	}

	MDObjectPtr F1Entry = VideoLineMap->Child(0);
	MDObjectPtr F2Entry = VideoLineMap->Child(1);
	if((!F1Entry) || (!F2Entry))
	{
		error("EssenceDescriptor for ANCVBISource does not have a valid VideoLineMap\n");
		F2Offset = 0;
		return F2Offset;
	}

	F2Offset = static_cast<int>(F2Entry->GetInt() - F1Entry->GetInt());
	return F2Offset;
}