public VLC getVLC() { final VLCBuilder self = this; return new VLC(codes.toArray(), codesSizes.toArray()) { public int readVLC(BitReader _in) { return self.inverse.get(super.readVLC(_in)); } public int readVLC16(BitReader _in) { return self.inverse.get(super.readVLC16(_in)); } public void writeVLC(BitWriter out, int code) { super.writeVLC(out, self.forward.get(code)); } }; } }
public int[] getCounts() { finish(); return counts.toArray(); }
public int[] getCounts() { finish(); return counts.toArray(); }
public int[] getValues() { finish(); return values.toArray(); }
private int[] parseSystem(ByteBuffer pesBuffer) { NIOUtils.skip(pesBuffer, 12); IntArrayList result = IntArrayList.createIntArrayList(); while (pesBuffer.remaining() >= 3 && (pesBuffer.get(pesBuffer.position()) & 0x80) == 0x80) { result.add(pesBuffer.get() & 0xff); pesBuffer.getShort(); } return result.toArray(); }
private static int[] searchEscapeLocations(ByteBuffer src) { IntArrayList points = IntArrayList.createIntArrayList(); ByteBuffer search = src.duplicate(); short p = search.getShort(); while (search.hasRemaining()) { byte b = search.get(); if (p == 0 && (b & ~3) == 0) { points.add(search.position() - 1); p = 3; } p <<= 8; p |= b & 0xff; } int[] array = points.toArray(); return array; }
/** * @param arguments * vlc codes * @return */ public static VLC createVLC(String... arguments) { IntArrayList _codes = IntArrayList.createIntArrayList(); IntArrayList _codeSizes = IntArrayList.createIntArrayList(); for (int i = 0; i < arguments.length; i++) { String string = arguments[i]; _codes.add(Integer.parseInt(string, 2) << (32 - string.length())); _codeSizes.add(string.length()); } VLC vlc = new VLC(_codes.toArray(), _codeSizes.toArray()); return vlc; }
private static int[][] readReorderingEntries(BitReader _in) { IntArrayList ops = IntArrayList.createIntArrayList(); IntArrayList args = IntArrayList.createIntArrayList(); do { int idc = readUEtrace(_in, "SH: reordering_of_pic_nums_idc"); if (idc == 3) break; ops.add(idc); args.add(readUEtrace(_in, "SH: abs_diff_pic_num_minus1")); } while (true); return new int[][] { ops.toArray(), args.toArray() }; } }
public static PATSection parsePAT(ByteBuffer data) { PSISection psi = PSISection.parsePSI(data); IntArrayList networkPids = IntArrayList.createIntArrayList(); IntIntMap programs = new IntIntMap(); while (data.remaining() > 4) { int programNum = data.getShort() & 0xffff; int w = data.getShort(); int pid = w & 0x1fff; if (programNum == 0) networkPids.add(pid); else programs.put(programNum, pid); } return new PATSection(psi, networkPids.toArray(), programs); } }
private void cacheSamples(SampleToChunkEntry[] sampleToChunks, long[] chunkOffsets) throws IOException { synchronized (input) { int stscInd = 0; IntArrayList ss = IntArrayList.createIntArrayList(); for (int chunkNo = 0; chunkNo < chunkOffsets.length; chunkNo++) { int nSamples = sampleToChunks[stscInd].getCount(); if (stscInd < sampleToChunks.length - 1 && chunkNo + 1 >= sampleToChunks[stscInd + 1].getFirst()) stscInd++; long offset = chunkOffsets[chunkNo]; input.setPosition(offset); ByteBuffer buf = NIOUtils.fetchFromChannel(input, nSamples * 4); for (int i = 0; i < nSamples; i++) { ss.add(buf.getInt()); } } sampleCache = ss.toArray(); } }
private void cacheSamples(SampleToChunkEntry[] sampleToChunks, long[] chunkOffsets) throws IOException { synchronized (input) { int stscInd = 0; IntArrayList ss = new IntArrayList(); for (int chunkNo = 0; chunkNo < chunkOffsets.length; chunkNo++) { int nSamples = sampleToChunks[stscInd].getCount(); if (stscInd < sampleToChunks.length - 1 && chunkNo + 1 >= sampleToChunks[stscInd + 1].getFirst()) stscInd++; long offset = chunkOffsets[chunkNo]; input.position(offset); ByteBuffer buf = NIOUtils.fetchFrom(input, nSamples * 4); for (int i = 0; i < nSamples; i++) { ss.add(buf.getInt()); } } sampleCache = ss.toArray(); } }
private void cacheSamples(SampleToChunkEntry[] sampleToChunks, long[] chunkOffsets) throws IOException { synchronized (input) { int stscInd = 0; IntArrayList ss = new IntArrayList(); for (int chunkNo = 0; chunkNo < chunkOffsets.length; chunkNo++) { int nSamples = sampleToChunks[stscInd].getCount(); if (stscInd < sampleToChunks.length - 1 && chunkNo + 1 >= sampleToChunks[stscInd + 1].getFirst()) stscInd++; long offset = chunkOffsets[chunkNo]; input.position(offset); ByteBuffer buf = NIOUtils.fetchFrom(input, nSamples * 4); for (int i = 0; i < nSamples; i++) { ss.add(buf.getInt()); } } sampleCache = ss.toArray(); } }
private static int[] filterMediaPids(PMTStream[] programs) { IntArrayList result = IntArrayList.createIntArrayList(); for (PMTStream stream : programs) { if (stream.getStreamType().isVideo() || stream.getStreamType().isAudio()) result.add(stream.getPid()); } return result.toArray(); } }
stbl.add(SampleSizesBox.createSampleSizesBox2(sampleSizes.toArray())); stbl.add(TimeToSampleBox.createTimeToSampleBox(sampleDurations.toArray(new TimeToSampleEntry[] {}))); stbl.add(ChunkOffsets64Box.createChunkOffsets64Box(chunkOffsets.toArray())); if (!allIframes && iframes.size() > 0) stbl.add(SyncSamplesBox.createSyncSamplesBox(iframes.toArray()));