235 final short big2littleShort(short i) {
236
237 short high, low;
238
239 high = (short)(( i & 0xFF ) << 8) ;
240 low = (short)(( i & 0xFF00 ) >>> 8);
241
242 i = (short)( high | low );
243
244 return i;
245 }
246
247 /** Calculates the frame size for PCM frames.
248 * Note that this method is appropriate for non-packed samples.
249 * For instance, 12 bit, 2 channels will return 4 bytes, not 3.
250 * @param sampleSizeInBits the size of a single sample in bits
251 * @param channels the number of channels
252 * @return the size of a PCM frame in bytes.
253 */
254 static final int calculatePCMFrameSize(int sampleSizeInBits, int channels) {
255 return ((sampleSizeInBits + 7) / 8) * channels;
256 }
257 }
|
235 final short big2littleShort(short i) {
236
237 short high, low;
238
239 high = (short)(( i & 0xFF ) << 8) ;
240 low = (short)(( i & 0xFF00 ) >>> 8);
241
242 i = (short)( high | low );
243
244 return i;
245 }
246
247 /** Calculates the frame size for PCM frames.
248 * Note that this method is appropriate for non-packed samples.
249 * For instance, 12 bit, 2 channels will return 4 bytes, not 3.
250 * @param sampleSizeInBits the size of a single sample in bits
251 * @param channels the number of channels
252 * @return the size of a PCM frame in bytes.
253 */
254 static final int calculatePCMFrameSize(int sampleSizeInBits, int channels) {
255 try {
256 return Math.multiplyExact((sampleSizeInBits + 7) / 8, channels);
257 } catch (final ArithmeticException ignored) {
258 return 0;
259 }
260 }
261 }
|