public class H264Utils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
H264Utils.Mv
A collection of functions to work with a compact representation of a motion vector.
|
static class |
H264Utils.MvList
A collection of functions to work with a compact representation of a
motion vector list.
|
static class |
H264Utils.MvList2D |
static class |
H264Utils.SliceHeaderTweaker |
Constructor and Description |
---|
H264Utils() |
Modifier and Type | Method and Description |
---|---|
static ByteBuffer |
avcCToAnnexB(AvcCBox avcC) |
static AvcCBox |
createAvcC(SeqParameterSet sps,
PictureParameterSet pps,
int nalLengthSize) |
static AvcCBox |
createAvcCFromBytes(ByteBuffer codecPrivate)
Creates a MP4 sample entry given AVC/H.264 codec private.
|
static AvcCBox |
createAvcCFromList(List<SeqParameterSet> initSPS,
List<PictureParameterSet> initPPS,
int nalLengthSize) |
static AvcCBox |
createAvcCFromPS(List<ByteBuffer> spsList,
List<ByteBuffer> ppsList,
int nalLengthSize) |
static SampleEntry |
createMOVSampleEntryFromAvcC(AvcCBox avcC) |
static SampleEntry |
createMOVSampleEntryFromBuffer(ByteBuffer sps,
ByteBuffer pps,
int nalLengthSize) |
static SampleEntry |
createMOVSampleEntryFromBytes(ByteBuffer codecPrivate)
Creates a MP4 sample entry given AVC/H.264 codec private.
|
static SampleEntry |
createMOVSampleEntryFromSpsPps(SeqParameterSet initSPS,
PictureParameterSet initPPS,
int nalLengthSize) |
static SampleEntry |
createMOVSampleEntryFromSpsPpsList(List<ByteBuffer> spsList,
List<ByteBuffer> ppsList,
int nalLengthSize) |
static ByteBuffer |
decodeMOVPacket(ByteBuffer result,
AvcCBox avcC)
Decodes AVC packet in ISO BMF format into Annex B format.
|
static void |
decodeMOVPacketInplace(ByteBuffer result,
AvcCBox avcC)
Decodes AVC packet in ISO BMF format into Annex B format.
|
static void |
dumpFrame(FileChannelWrapper ch,
SeqParameterSet[] values,
PictureParameterSet[] values2,
List<ByteBuffer> nalUnits) |
static ByteBuffer |
encodeMOVPacket(ByteBuffer avcFrame)
Encodes AVC frame in ISO BMF format.
|
static void |
encodeMOVPacketInplace(ByteBuffer avcFrame)
Encodes AVC frame in ISO BMF format.
|
static void |
escapeNAL(ByteBuffer src,
ByteBuffer dst) |
static void |
escapeNALinplace(ByteBuffer src) |
static PictureParameterSet |
findPPS(List<PictureParameterSet> ppss,
int id) |
static SeqParameterSet |
findSPS(List<SeqParameterSet> spss,
int id) |
static ByteBuffer |
getAvcCData(AvcCBox avcC) |
static Size |
getPicSize(SeqParameterSet sps) |
static List<ByteBuffer> |
getRawNALUnitsOfType(ByteBuffer codecPrivate,
NALUnitType type) |
static List<ByteBuffer> |
getRawPPS(ByteBuffer codecPrivate)
Parses a list of SPS NAL units out of the codec private array.
|
static List<ByteBuffer> |
getRawSPS(ByteBuffer codecPrivate)
Parses a list of SPS NAL units out of the codec private array.
|
static ByteBuffer |
gotoNALUnit(ByteBuffer buf)
Finds next Nth H.264 bitstream NAL unit (0x00000001) and returns the data
that preceeds it as a ByteBuffer slice
Segment byte order is always little endian
TODO: emulation prevention
|
static ByteBuffer |
gotoNALUnitWithArray(ByteBuffer buf)
Finds next Nth H.264 bitstream NAL unit (0x00000001) and returns the data
that preceeds it as a ByteBuffer slice
Segment byte order is always little endian
|
static boolean |
idrSlice(List<ByteBuffer> _data) |
static boolean |
iFrame(ByteBuffer _data) |
static boolean |
isByteBufferIDRSlice(ByteBuffer _data) |
static ByteBuffer |
joinNALUnits(List<ByteBuffer> nalUnits)
Joins buffers containing individual NAL units into a single AnnexB
delimited buffer.
|
static void |
joinNALUnitsToBuffer(List<ByteBuffer> nalUnits,
ByteBuffer out)
Joins buffers containing individual NAL units into a single AnnexB
delimited buffer.
|
static ByteBuffer |
nextNALUnit(ByteBuffer buf) |
static AvcCBox |
parseAVCC(VideoSampleEntry vse) |
static AvcCBox |
parseAVCCFromBuffer(ByteBuffer bb) |
static PictureParameterSet |
readPPS(ByteBuffer data) |
static List<PictureParameterSet> |
readPPSFromBufferList(List<ByteBuffer> ppsList) |
static SeqParameterSet |
readSPS(ByteBuffer data) |
static List<SeqParameterSet> |
readSPSFromBufferList(List<ByteBuffer> spsList) |
static ByteBuffer |
saveCodecPrivate(List<ByteBuffer> spsList,
List<ByteBuffer> ppsList) |
static List<ByteBuffer> |
savePPS(List<PictureParameterSet> initPPS) |
static void |
saveRawFrame(ByteBuffer data,
AvcCBox avcC,
File f) |
static List<ByteBuffer> |
saveSPS(List<SeqParameterSet> initSPS) |
static void |
saveStreamParams(AvcCBox avcC,
SeekableByteChannel raw) |
static void |
skipToNALUnit(ByteBuffer buf) |
static List<ByteBuffer> |
splitFrame(ByteBuffer frame) |
static List<ByteBuffer> |
splitMOVPacket(ByteBuffer buf,
AvcCBox avcC) |
static void |
toNAL(ByteBuffer codecPrivate,
SeqParameterSet sps,
PictureParameterSet pps) |
static void |
toNALList(ByteBuffer codecPrivate,
List<ByteBuffer> spsList2,
List<ByteBuffer> ppsList2) |
static void |
unescapeNAL(ByteBuffer _buf) |
static void |
wipePS(ByteBuffer _in,
ByteBuffer out,
List<ByteBuffer> spsList,
List<ByteBuffer> ppsList)
Wipes AVC parameter sets ( SPS/PPS ) from the packet
|
static void |
wipePSinplace(ByteBuffer _in,
Collection<ByteBuffer> spsList,
Collection<ByteBuffer> ppsList)
Wipes AVC parameter sets ( SPS/PPS ) from the packet ( inplace operation
)
|
static ByteBuffer |
writePPS(PictureParameterSet pps,
int approxSize) |
static List<ByteBuffer> |
writePPSList(List<PictureParameterSet> allPps) |
static ByteBuffer |
writeSPS(SeqParameterSet sps,
int approxSize) |
static List<ByteBuffer> |
writeSPSList(List<SeqParameterSet> allSps) |
public static ByteBuffer nextNALUnit(ByteBuffer buf)
public static final void skipToNALUnit(ByteBuffer buf)
public static final ByteBuffer gotoNALUnit(ByteBuffer buf)
buf
- public static final ByteBuffer gotoNALUnitWithArray(ByteBuffer buf)
buf
- public static final void unescapeNAL(ByteBuffer _buf)
public static final void escapeNALinplace(ByteBuffer src)
public static final void escapeNAL(ByteBuffer src, ByteBuffer dst)
public static List<ByteBuffer> splitMOVPacket(ByteBuffer buf, AvcCBox avcC)
public static void encodeMOVPacketInplace(ByteBuffer avcFrame)
avcFrame
- AVC frame encoded in Annex B NAL unit formatpublic static ByteBuffer encodeMOVPacket(ByteBuffer avcFrame)
avcFrame
- AVC frame encoded in Annex B NAL unit formatpublic static ByteBuffer decodeMOVPacket(ByteBuffer result, AvcCBox avcC)
result
- public static void decodeMOVPacketInplace(ByteBuffer result, AvcCBox avcC)
result
- public static void wipePS(ByteBuffer _in, ByteBuffer out, List<ByteBuffer> spsList, List<ByteBuffer> ppsList)
in
- AVC frame encoded in Annex B NAL unit formatout
- Buffer where packet without PS will be putspsList
- Storage for leading SPS structures ( can be null, then all
leading SPSs are discarded ).ppsList
- Storage for leading PPS structures ( can be null, then all
leading PPSs are discarded ).public static void wipePSinplace(ByteBuffer _in, Collection<ByteBuffer> spsList, Collection<ByteBuffer> ppsList)
in
- AVC frame encoded in Annex B NAL unit formatspsList
- Storage for leading SPS structures ( can be null, then all
leading SPSs are discarded ).ppsList
- Storage for leading PPS structures ( can be null, then all
leading PPSs are discarded ).public static AvcCBox createAvcC(SeqParameterSet sps, PictureParameterSet pps, int nalLengthSize)
public static AvcCBox createAvcCFromList(List<SeqParameterSet> initSPS, List<PictureParameterSet> initPPS, int nalLengthSize)
public static List<ByteBuffer> savePPS(List<PictureParameterSet> initPPS)
initPPS
- public static List<ByteBuffer> saveSPS(List<SeqParameterSet> initSPS)
initSPS
- public static SampleEntry createMOVSampleEntryFromBytes(ByteBuffer codecPrivate)
codecPrivate
- Array containing AnnexB delimited (00 00 00 01) SPS/PPS NAL
units.public static SampleEntry createMOVSampleEntryFromSpsPpsList(List<ByteBuffer> spsList, List<ByteBuffer> ppsList, int nalLengthSize)
public static AvcCBox createAvcCFromBytes(ByteBuffer codecPrivate)
codecPrivate
- Array containing AnnexB delimited (00 00 00 01) SPS/PPS NAL
units.public static AvcCBox createAvcCFromPS(List<ByteBuffer> spsList, List<ByteBuffer> ppsList, int nalLengthSize)
public static SampleEntry createMOVSampleEntryFromAvcC(AvcCBox avcC)
public static SampleEntry createMOVSampleEntryFromSpsPps(SeqParameterSet initSPS, PictureParameterSet initPPS, int nalLengthSize)
public static SampleEntry createMOVSampleEntryFromBuffer(ByteBuffer sps, ByteBuffer pps, int nalLengthSize)
public static boolean iFrame(ByteBuffer _data)
public static boolean isByteBufferIDRSlice(ByteBuffer _data)
public static boolean idrSlice(List<ByteBuffer> _data)
public static void saveRawFrame(ByteBuffer data, AvcCBox avcC, File f) throws IOException
IOException
public static void saveStreamParams(AvcCBox avcC, SeekableByteChannel raw) throws IOException
IOException
public static List<ByteBuffer> splitFrame(ByteBuffer frame)
public static ByteBuffer joinNALUnits(List<ByteBuffer> nalUnits)
nalUnits
- out
- public static void joinNALUnitsToBuffer(List<ByteBuffer> nalUnits, ByteBuffer out)
nalUnits
- out
- public static ByteBuffer getAvcCData(AvcCBox avcC)
public static AvcCBox parseAVCC(VideoSampleEntry vse)
public static ByteBuffer saveCodecPrivate(List<ByteBuffer> spsList, List<ByteBuffer> ppsList)
public static ByteBuffer avcCToAnnexB(AvcCBox avcC)
public static AvcCBox parseAVCCFromBuffer(ByteBuffer bb)
public static ByteBuffer writeSPS(SeqParameterSet sps, int approxSize)
public static SeqParameterSet readSPS(ByteBuffer data)
public static ByteBuffer writePPS(PictureParameterSet pps, int approxSize)
public static PictureParameterSet readPPS(ByteBuffer data)
public static PictureParameterSet findPPS(List<PictureParameterSet> ppss, int id)
public static SeqParameterSet findSPS(List<SeqParameterSet> spss, int id)
public static Size getPicSize(SeqParameterSet sps)
public static List<SeqParameterSet> readSPSFromBufferList(List<ByteBuffer> spsList)
public static List<PictureParameterSet> readPPSFromBufferList(List<ByteBuffer> ppsList)
public static List<ByteBuffer> writePPSList(List<PictureParameterSet> allPps)
public static List<ByteBuffer> writeSPSList(List<SeqParameterSet> allSps)
public static void dumpFrame(FileChannelWrapper ch, SeqParameterSet[] values, PictureParameterSet[] values2, List<ByteBuffer> nalUnits) throws IOException
IOException
public static void toNAL(ByteBuffer codecPrivate, SeqParameterSet sps, PictureParameterSet pps)
public static void toNALList(ByteBuffer codecPrivate, List<ByteBuffer> spsList2, List<ByteBuffer> ppsList2)
public static List<ByteBuffer> getRawPPS(ByteBuffer codecPrivate)
codecPrivate
- An AnnexB formatted set of SPS/PPS NAL units.public static List<ByteBuffer> getRawSPS(ByteBuffer codecPrivate)
codecPrivate
- An AnnexB formatted set of SPS/PPS NAL units.public static List<ByteBuffer> getRawNALUnitsOfType(ByteBuffer codecPrivate, NALUnitType type)
Copyright © 2019. All rights reserved.