if (src.remaining() < 5) {
return null;
}
long nalLength;
if (src.remaining() >= nalLengthSize) {
if (nalLengthSize == 1) {
nalLength = IsoTypeReader.readUInt8(src);
} else if (nalLengthSize == 2) {
nalLength = IsoTypeReader.readUInt16(src);
} else if (nalLengthSize == 3) {
nalLength = IsoTypeReader.readUInt24(src);
} else if (nalLengthSize == 4) {
nalLength = IsoTypeReader.readUInt32(src);
} else {
throw new IOException("Unknown NAL Length isze ");
}
if (nalLength == 0) {
return null;
}
ByteBuffer nal = src.slice();
nal.limit(l2i(nalLength));
src.position(src.position() + l2i(nalLength));
return nal;
} else {
throw new RuntimeException("remaining bytes less than nalLengthSize found in sample. should not be here.");
}