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

SampleToChunkBox

public class SampleToChunkBox extends com.googlecode.mp4parser.AbstractFullBox
Samples within the media data are grouped into chunks. Chunks can be of different sizes, and the samples within a chunk can have different sizes. This table can be used to find the chunk that contains a sample, its position, and the associated sample description. Defined in ISO/IEC 14496-12.

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


      
        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),
                    IsoTypeReader.readUInt32(content)));
        }
    
public long[]blowup(int chunkCount)
Decompresses the list of entries and returns the number of samples per chunk for every single chunk.

param
chunkCount overall number of chunks
return
number of samples per chunk

        long[] numberOfSamples = new long[chunkCount];
        int j = 0;
        List<SampleToChunkBox.Entry> sampleToChunkEntries = new LinkedList<Entry>(entries);
        Collections.reverse(sampleToChunkEntries);
        Iterator<Entry> iterator = sampleToChunkEntries.iterator();
        SampleToChunkBox.Entry currentEntry = iterator.next();

        for (int i = numberOfSamples.length; i > 1; i--) {
            numberOfSamples[i - 1] = currentEntry.getSamplesPerChunk();
            if (i == currentEntry.getFirstChunk()) {
                currentEntry = iterator.next();
            }
        }
        numberOfSamples[0] = currentEntry.getSamplesPerChunk();
        return numberOfSamples;
    
protected voidgetContent(java.nio.ByteBuffer byteBuffer)

        writeVersionAndFlags(byteBuffer);
        IsoTypeWriter.writeUInt32(byteBuffer, entries.size());
        for (Entry entry : entries) {
            IsoTypeWriter.writeUInt32(byteBuffer, entry.getFirstChunk());
            IsoTypeWriter.writeUInt32(byteBuffer, entry.getSamplesPerChunk());
            IsoTypeWriter.writeUInt32(byteBuffer, entry.getSampleDescriptionIndex());
        }
    
protected longgetContentSize()

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

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

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

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