public static byte[][] splitNalUnits(byte[] data){
  if (!isNalStartCode(data,0)) {
    return null;
  }
  List<Integer> starts=new ArrayList<>();
  int nalUnitIndex=0;
  do {
    starts.add(nalUnitIndex);
    nalUnitIndex=findNalStartCode(data,nalUnitIndex + NAL_START_CODE.length);
  }
 while (nalUnitIndex != -1);
  byte[][] split=new byte[starts.size()][];
  for (int i=0; i < starts.size(); i++) {
    int startIndex=starts.get(i);
    int endIndex=i < starts.size() - 1 ? starts.get(i + 1) : data.length;
    byte[] nal=new byte[endIndex - startIndex];
    System.arraycopy(data,startIndex,nal,0,nal.length);
    split[i]=nal;
  }
  return split;
}

public static byte [ ] [ ] splitNalUnits ( byte [ ] data ) { if ( ! isNalStartCode ( data , 0 ) ) { return null ; } List < Integer > starts = new ArrayList < > ( ) ; int nalUnitIndex = 0 ; do { starts . add ( nalUnitIndex ) ; nalUnitIndex = findNalStartCode ( data , nalUnitIndex + NAL_START_CODE . length ) ; } while ( nalUnitIndex != - 1 ) ; byte [ ] [ ] split = new byte [ starts . size ( ) ] [ ] ; for ( int i = 0 ; i < starts . size ( ) ; i ++ ) { int startIndex = starts . get ( i ) ; int endIndex = i < starts . size ( ) - 1 ? starts . get ( i + 1 ) : data . length ; byte [ ] nal = new byte [ endIndex - startIndex ] ; System . arraycopy ( data , startIndex , nal , 0 , nal . length ) ; split [ i ] = nal ; } return split ; }
splits an array of nal units . < p > if the input consists of nal start code delimited units , then the returned array consists of the split nal units , each of which is still prefixed with the nal start code . for any other input , null is returned .
