public static String lookupFourcc(AudioFormat format) { if (format.getSampleSizeInBits() == 16 && !format.isBigEndian()) return "sowt"; else if (format.getSampleSizeInBits() == 24) return "in24"; else throw new IllegalArgumentException("Audio format " + format + " is not supported."); }
public static String lookupFourcc(AudioFormat format) { if (format.getSampleSizeInBits() == 16 && !format.isBigEndian()) return "sowt"; else if (format.getSampleSizeInBits() == 24) return "in24"; else throw new IllegalArgumentException("Audio format " + format + " is not supported."); }
public static String lookupFourcc(AudioFormat format) { if (format.getSampleSizeInBits() == 16 && !format.isBigEndian()) return "sowt"; else if (format.getSampleSizeInBits() == 24) return "in24"; else throw new NotSupportedException("Audio format " + format + " is not supported."); }
public static AudioCodecMeta createAudioCodecMeta3(String fourcc, ByteBuffer codecPrivate, AudioFormat format, boolean pcm, Label[] labels) { AudioCodecMeta self = new AudioCodecMeta(fourcc, codecPrivate); self.sampleSize = format.getSampleSizeInBits() >> 3; self.channelCount = format.getChannels(); self.sampleRate = format.getSampleRate(); self.endian = format.isBigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN; self.pcm = pcm; self.labels = labels; return self; }
public static AudioCodecMeta fromAudioFormat(AudioFormat format) { AudioCodecMeta self = new AudioCodecMeta(null, null); self.sampleSize = format.getSampleSizeInBits() >> 3; self.channelCount = format.getChannels(); self.sampleRate = format.getSampleRate(); self.endian = format.isBigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN; self.pcm = false; return self; } }
public static AudioSampleEntry audioSampleEntryPCM(AudioFormat format) { return audioSampleEntry(AudioSampleEntry.lookupFourcc(format), 1, format.getSampleSizeInBits() >> 3, format.getChannels(), (int) format.getSampleRate(), format.isBigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN); }
public static AudioSampleEntry audioSampleEntry(AudioFormat format) { return MP4Muxer.audioSampleEntry(lookupFourcc(format), 1, format.getSampleSizeInBits() >> 3, format.getChannels(), (int) format.getSampleRate(), format.isBigEndian() ? Endian.BIG_ENDIAN : Endian.LITTLE_ENDIAN); }
public static AudioSampleEntry audioSampleEntry(AudioFormat format) { return MP4Muxer.audioSampleEntry(lookupFourcc(format), 1, format.getSampleSizeInBits() >> 3, format.getChannels(), (int) format.getSampleRate(), format.isBigEndian() ? Endian.BIG_ENDIAN : Endian.LITTLE_ENDIAN); }
public static int fromInt(int[] data, int len, AudioFormat format, ByteBuffer buf) { if (!format.isSigned()) throw new NotSupportedException("Unsigned PCM is not supported ( yet? )."); if (format.getSampleSizeInBits() != 16 && format.getSampleSizeInBits() != 24) throw new NotSupportedException(format.getSampleSizeInBits() + " bit PCM is not supported ( yet? )."); if (format.isBigEndian()) { if (format.getSampleSizeInBits() == 16) { return fromInt16BE(buf, data, len); } else { return fromInt24BE(buf, data, len); } } else { if (format.getSampleSizeInBits() == 16) { return fromInt16LE(buf, data, len); } else { return fromInt24LE(buf, data, len); } } }
public static int toInt(AudioFormat format, ByteBuffer buf, int[] samples) { if (!format.isSigned()) throw new NotSupportedException("Unsigned PCM is not supported ( yet? )."); if (format.getSampleSizeInBits() != 16 && format.getSampleSizeInBits() != 24) throw new NotSupportedException(format.getSampleSizeInBits() + " bit PCM is not supported ( yet? )."); if (format.isBigEndian()) { if (format.getSampleSizeInBits() == 16) { return toInt16BE(buf, samples); } else { return toInt24BE(buf, samples); } } else { if (format.getSampleSizeInBits() == 16) { return toInt16LE(buf, samples); } else { return toInt24LE(buf, samples); } } }
/** * Converts PCM samples stored in buf and described with format to float * array representation * * @param format * Supported formats - *_*_S16_LE, *_*_S24_LE, *_*_S16_BE, * *_*_S24_LE * @param buf * @param floatBuf * @return Total number of samples read from the buffer */ public static void toFloat(AudioFormat format, ByteBuffer buf, FloatBuffer floatBuf) { if (!format.isSigned()) throw new NotSupportedException("Unsigned PCM is not supported ( yet? )."); if (format.getSampleSizeInBits() != 16 && format.getSampleSizeInBits() != 24) throw new NotSupportedException(format.getSampleSizeInBits() + " bit PCM is not supported ( yet? )."); if (format.isBigEndian()) { if (format.getSampleSizeInBits() == 16) { toFloat16BE(buf, floatBuf); } else { toFloat24BE(buf, floatBuf); } } else { if (format.getSampleSizeInBits() == 16) { toFloat16LE(buf, floatBuf); } else { toFloat24LE(buf, floatBuf); } } }
/** * Converts float PCM samples stored in floatBuf to integer representation * according to format and stores them in buf * * @param format * Supported formats - *_*_S16_LE, *_*_S24_LE, *_*_S16_BE, * *_*_S24_LE * @param buf * @param floatBuf * @return Total number of samples written to the buffer */ public static void fromFloat(FloatBuffer floatBuf, AudioFormat format, ByteBuffer buf) { if (!format.isSigned()) throw new NotSupportedException("Unsigned PCM is not supported ( yet? )."); if (format.getSampleSizeInBits() != 16 && format.getSampleSizeInBits() != 24) throw new NotSupportedException(format.getSampleSizeInBits() + " bit PCM is not supported ( yet? )."); if (format.isBigEndian()) { if (format.getSampleSizeInBits() == 16) { fromFloat16BE(buf, floatBuf); } else { fromFloat24BE(buf, floatBuf); } } else { if (format.getSampleSizeInBits() == 16) { fromFloat16LE(buf, floatBuf); } else { fromFloat24LE(buf, floatBuf); } } }