/*
-Copyright (c) 2007-2008, John Hurst
+Copyright (c) 2007-2009, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
if ( InstanceList.empty() )
{
- DefaultLogSink(). Error("XML document contains no Subtitle elements!\n");
+ DefaultLogSink(). Error("XML document contains no Subtitle elements.\n");
return RESULT_FORMAT;
}
// assumes 24/1 or 48/1 as constrained above
- S12MTimecode beginTC(InstanceList.front()->GetAttrWithName("TimeIn"), m_TDesc.EditRate.Numerator);
+ assert(m_TDesc.EditRate.Denominator == 1);
+
+ S12MTimecode beginTC;
+ beginTC.SetFPS(m_TDesc.EditRate.Numerator);
+ XMLElement* StartTime = m_Root.GetChildWithName("StartTime");
+
+ if ( StartTime != 0 )
+ beginTC.DecodeString(StartTime->GetBody());
for ( ei = InstanceList.begin(); ei != InstanceList.end(); ei++ )
{
end_count = tmpTC.GetFrames();
}
- assert( end_count > beginTC.GetFrames() );
+ if ( end_count <= beginTC.GetFrames() )
+ {
+ DefaultLogSink(). Error("Timed Text file has zero-length timeline.\n");
+ return RESULT_FORMAT;
+ }
+
m_TDesc.ContainerDuration = end_count - beginTC.GetFrames();
return RESULT_OK;