code: public static int calculateEncodeSize(int[] values, int inputOffset,
        int inputStep, int inputCount, int bitParam) {
      //Pack int version of encode partition
      if(DEBUG_LEV > 0) {
        System.err.println("RiceEncoder::calculateEncodeSize : Begin");
        System.err.println("-- bitParam: " + bitParam);
      }
      int totalEncodeLength = inputCount*(bitParam+1);
      int index = inputOffset-inputStep;
      for(int i = 0; i < inputCount; i++) {
        index += inputStep;
        int value = values[index];
        value = (value < 0) ? -2*value-1:2*value;
        int upperBits = value >> bitParam;
        totalEncodeLength += upperBits;
      }
      if(bitParam > 14)
        totalEncodeLength += 5+6;
      else
        totalEncodeLength += 4+6;
      return totalEncodeLength;
    }
docs: Calculate how large a given set of values will be once it has been
  rice-encoded. While this method duplicates much of the process of
  rice-encoding, it is faster than an actual encode since the data is not
  actually written to the flac bitstream format(a rather costly write).
  
  @param values array of integer values to save
  @param inputOffset start index in input array
  @param inputStep number of values to skip between target values(for
  interleaved data.
  @param inputCount    number of total values to encode
  @param bitParam rice-parameter to use. This value should be based upon
  the distribution of the input data(roughly speeking, each value
  will require at least bitParam+1 bits to save, so this value
  should reflect the average magnitude of input values.
  @return total encoded-size with given data and rice-parameter.