123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #include "mp4common.h"
- MP4StscAtom::MP4StscAtom()
- : MP4Atom("stsc")
- {
- AddVersionAndFlags();
- MP4Integer32Property* pCount =
- new MP4Integer32Property("entryCount");
- AddProperty(pCount);
- MP4TableProperty* pTable = new MP4TableProperty("entries", pCount);
- AddProperty(pTable);
- pTable->AddProperty(
- new MP4Integer32Property("firstChunk"));
- pTable->AddProperty(
- new MP4Integer32Property("samplesPerChunk"));
- pTable->AddProperty(
- new MP4Integer32Property("sampleDescriptionIndex"));
-
-
- MP4Integer32Property* pSample =
- new MP4Integer32Property("firstSample");
- pSample->SetImplicit();
- pTable->AddProperty(pSample);
- }
- void MP4StscAtom::Read()
- {
-
- MP4Atom::Read();
-
- u_int32_t count =
- ((MP4Integer32Property*)m_pProperties[2])->GetValue();
- MP4Integer32Property* pFirstChunk = (MP4Integer32Property*)
- ((MP4TableProperty*)m_pProperties[3])->GetProperty(0);
- MP4Integer32Property* pSamplesPerChunk = (MP4Integer32Property*)
- ((MP4TableProperty*)m_pProperties[3])->GetProperty(1);
- MP4Integer32Property* pFirstSample = (MP4Integer32Property*)
- ((MP4TableProperty*)m_pProperties[3])->GetProperty(3);
- MP4SampleId sampleId = 1;
- for (u_int32_t i = 0; i < count; i++) {
- pFirstSample->SetValue(sampleId, i);
- if (i < count - 1) {
- sampleId +=
- (pFirstChunk->GetValue(i+1) - pFirstChunk->GetValue(i))
- * pSamplesPerChunk->GetValue(i);
- }
- }
- }
|