FileDocCategorySizeDatePackage
TimeToSampleBox.javaAPI Docmp4parser 1.0-RC-174719Wed Dec 19 20:10:38 GMT 2012com.coremedia.iso.boxes

TimeToSampleBox

public class TimeToSampleBox extends com.googlecode.mp4parser.AbstractFullBox
This box contains a compact version of a table that allows indexing from decoding time to sample number. Other tables give sample sizes and pointers, from the sample number. Each entry in the table gives the number of consecutive samples with the same time delta, and the delta of those samples. By adding the deltas a complete time-to-sample map may be built.
The Decoding Time to Sample Box contains decode time delta's: DT(n+1) = DT(n) + STTS(n) where STTS(n) is the (uncompressed) table entry for sample n.
The sample entries are ordered by decoding time stamps; therefore the deltas are all non-negative.
The DT axis has a zero origin; DT(i) = SUM(for j=0 to i-1 of delta(j)), and the sum of all deltas gives the length of the media in the track (not mapped to the overall timescale, and not considering any edit list).
The Edit List Box provides the initial CT value if it is non-empty (non-zero).

Fields Summary
public static final String
TYPE
List
entries
Constructors Summary
public TimeToSampleBox()



      
        super(TYPE);
    
Methods Summary
public void_parseDetails(java.nio.ByteBuffer content)

        parseVersionAndFlags(content);
        int entryCount = l2i(IsoTypeReader.readUInt32(content));
        entries = new ArrayList<Entry>(entryCount);

        for (int i = 0; i < entryCount; i++) {
            entries.add(new Entry(IsoTypeReader.readUInt32(content), IsoTypeReader.readUInt32(content)));
        }

    
public static long[]blowupTimeToSamples(java.util.List entries)
Decompresses the list of entries and returns the list of decoding times.

return
decoding time per sample

        long numOfSamples = 0;
        for (TimeToSampleBox.Entry entry : entries) {
            numOfSamples += entry.getCount();
        }
        assert numOfSamples <= Integer.MAX_VALUE;
        long[] decodingTime = new long[(int) numOfSamples];

        int current = 0;


        for (TimeToSampleBox.Entry entry : entries) {
            for (int i = 0; i < entry.getCount(); i++) {
                decodingTime[current++] = entry.getDelta();
            }
        }

        return decodingTime;
    
protected voidgetContent(java.nio.ByteBuffer byteBuffer)

        writeVersionAndFlags(byteBuffer);
        IsoTypeWriter.writeUInt32(byteBuffer, entries.size());
        for (Entry entry : entries) {
            IsoTypeWriter.writeUInt32(byteBuffer, entry.getCount());
            IsoTypeWriter.writeUInt32(byteBuffer, entry.getDelta());
        }
    
protected longgetContentSize()

        return 8 + entries.size() * 8;
    
public java.util.ListgetEntries()

        return entries;
    
public voidsetEntries(java.util.List entries)

        this.entries = entries;
    
public java.lang.StringtoString()

        return "TimeToSampleBox[entryCount=" + entries.size() + "]";