function discardEPB(data) {
  var length = data.byteLength;
  var EPBPositions = [];
  var i = 1; // Find all `Emulation Prevention Bytes`

  while (i < length - 2) {
    if (data[i] === 0 && data[i + 1] === 0 && data[i + 2] === 0x03) {
      EPBPositions.push(i + 2);
      i += 2;
    } else {
      i++;
    }
  } // If no Emulation Prevention Bytes were found just return the original
  // array


  if (EPBPositions.length === 0) {
    return data;
  } // Create a new array to hold the NAL unit data


  var newLength = length - EPBPositions.length;
  var newData = new Uint8Array(newLength);
  var sourceIndex = 0;

  for (i = 0; i < newLength; sourceIndex++, i++) {
    if (sourceIndex === EPBPositions[0]) {
      // Skip this byte
      sourceIndex++; // Remove this position index

      EPBPositions.shift();
    }

    newData[i] = data[sourceIndex];
  }

  return newData;
}
remove Emulation Prevention bytes from a RBSP