com.google.android.exoplayer2.audio.DtsUtil Java Examples

The following examples show how to use com.google.android.exoplayer2.audio.DtsUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DtsReader.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Locates the next SYNC value in the buffer, advancing the position to the byte that immediately
 * follows it. If SYNC was not located, the position is advanced to the limit.
 *
 * @param pesBuffer The buffer whose position should be advanced.
 * @return Whether SYNC was found.
 */
private boolean skipToNextSync(ParsableByteArray pesBuffer) {
  while (pesBuffer.bytesLeft() > 0) {
    syncBytes <<= 8;
    syncBytes |= pesBuffer.readUnsignedByte();
    if (DtsUtil.isSyncWord(syncBytes)) {
      headerScratchBytes.data[0] = (byte) ((syncBytes >> 24) & 0xFF);
      headerScratchBytes.data[1] = (byte) ((syncBytes >> 16) & 0xFF);
      headerScratchBytes.data[2] = (byte) ((syncBytes >> 8) & 0xFF);
      headerScratchBytes.data[3] = (byte) (syncBytes & 0xFF);
      bytesRead = 4;
      syncBytes = 0;
      return true;
    }
  }
  return false;
}
 
Example #2
Source File: DtsReader.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Locates the next SYNC value in the buffer, advancing the position to the byte that immediately
 * follows it. If SYNC was not located, the position is advanced to the limit.
 *
 * @param pesBuffer The buffer whose position should be advanced.
 * @return Whether SYNC was found.
 */
private boolean skipToNextSync(ParsableByteArray pesBuffer) {
  while (pesBuffer.bytesLeft() > 0) {
    syncBytes <<= 8;
    syncBytes |= pesBuffer.readUnsignedByte();
    if (DtsUtil.isSyncWord(syncBytes)) {
      headerScratchBytes.data[0] = (byte) ((syncBytes >> 24) & 0xFF);
      headerScratchBytes.data[1] = (byte) ((syncBytes >> 16) & 0xFF);
      headerScratchBytes.data[2] = (byte) ((syncBytes >> 8) & 0xFF);
      headerScratchBytes.data[3] = (byte) (syncBytes & 0xFF);
      bytesRead = 4;
      syncBytes = 0;
      return true;
    }
  }
  return false;
}
 
Example #3
Source File: DtsReader.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Locates the next SYNC value in the buffer, advancing the position to the byte that immediately
 * follows it. If SYNC was not located, the position is advanced to the limit.
 *
 * @param pesBuffer The buffer whose position should be advanced.
 * @return Whether SYNC was found.
 */
private boolean skipToNextSync(ParsableByteArray pesBuffer) {
  while (pesBuffer.bytesLeft() > 0) {
    syncBytes <<= 8;
    syncBytes |= pesBuffer.readUnsignedByte();
    if (DtsUtil.isSyncWord(syncBytes)) {
      headerScratchBytes.data[0] = (byte) ((syncBytes >> 24) & 0xFF);
      headerScratchBytes.data[1] = (byte) ((syncBytes >> 16) & 0xFF);
      headerScratchBytes.data[2] = (byte) ((syncBytes >> 8) & 0xFF);
      headerScratchBytes.data[3] = (byte) (syncBytes & 0xFF);
      bytesRead = 4;
      syncBytes = 0;
      return true;
    }
  }
  return false;
}
 
Example #4
Source File: DtsReader.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Locates the next SYNC value in the buffer, advancing the position to the byte that immediately
 * follows it. If SYNC was not located, the position is advanced to the limit.
 *
 * @param pesBuffer The buffer whose position should be advanced.
 * @return Whether SYNC was found.
 */
private boolean skipToNextSync(ParsableByteArray pesBuffer) {
  while (pesBuffer.bytesLeft() > 0) {
    syncBytes <<= 8;
    syncBytes |= pesBuffer.readUnsignedByte();
    if (DtsUtil.isSyncWord(syncBytes)) {
      headerScratchBytes.data[0] = (byte) ((syncBytes >> 24) & 0xFF);
      headerScratchBytes.data[1] = (byte) ((syncBytes >> 16) & 0xFF);
      headerScratchBytes.data[2] = (byte) ((syncBytes >> 8) & 0xFF);
      headerScratchBytes.data[3] = (byte) (syncBytes & 0xFF);
      bytesRead = 4;
      syncBytes = 0;
      return true;
    }
  }
  return false;
}
 
Example #5
Source File: DtsReader.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Locates the next SYNC value in the buffer, advancing the position to the byte that immediately
 * follows it. If SYNC was not located, the position is advanced to the limit.
 *
 * @param pesBuffer The buffer whose position should be advanced.
 * @return Whether SYNC was found.
 */
private boolean skipToNextSync(ParsableByteArray pesBuffer) {
  while (pesBuffer.bytesLeft() > 0) {
    syncBytes <<= 8;
    syncBytes |= pesBuffer.readUnsignedByte();
    if (DtsUtil.isSyncWord(syncBytes)) {
      headerScratchBytes.data[0] = (byte) ((syncBytes >> 24) & 0xFF);
      headerScratchBytes.data[1] = (byte) ((syncBytes >> 16) & 0xFF);
      headerScratchBytes.data[2] = (byte) ((syncBytes >> 8) & 0xFF);
      headerScratchBytes.data[3] = (byte) (syncBytes & 0xFF);
      bytesRead = 4;
      syncBytes = 0;
      return true;
    }
  }
  return false;
}
 
Example #6
Source File: DtsReader.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Parses the sample header.
 */
private void parseHeader() {
  byte[] frameData = headerScratchBytes.data;
  if (format == null) {
    format = DtsUtil.parseDtsFormat(frameData, formatId, language, null);
    output.format(format);
  }
  sampleSize = DtsUtil.getDtsFrameSize(frameData);
  // In this class a sample is an access unit (frame in DTS), but the format's sample rate
  // specifies the number of PCM audio samples per second.
  sampleDurationUs = (int) (C.MICROS_PER_SECOND
      * DtsUtil.parseDtsAudioSampleCount(frameData) / format.sampleRate);
}
 
Example #7
Source File: DtsReader.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the sample header.
 */
private void parseHeader() {
  byte[] frameData = headerScratchBytes.data;
  if (format == null) {
    format = DtsUtil.parseDtsFormat(frameData, formatId, language, null);
    output.format(format);
  }
  sampleSize = DtsUtil.getDtsFrameSize(frameData);
  // In this class a sample is an access unit (frame in DTS), but the format's sample rate
  // specifies the number of PCM audio samples per second.
  sampleDurationUs = (int) (C.MICROS_PER_SECOND
      * DtsUtil.parseDtsAudioSampleCount(frameData) / format.sampleRate);
}
 
Example #8
Source File: DtsReader.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the sample header.
 */
private void parseHeader() {
  byte[] frameData = headerScratchBytes.data;
  if (format == null) {
    format = DtsUtil.parseDtsFormat(frameData, formatId, language, null);
    output.format(format);
  }
  sampleSize = DtsUtil.getDtsFrameSize(frameData);
  // In this class a sample is an access unit (frame in DTS), but the format's sample rate
  // specifies the number of PCM audio samples per second.
  sampleDurationUs = (int) (C.MICROS_PER_SECOND
      * DtsUtil.parseDtsAudioSampleCount(frameData) / format.sampleRate);
}
 
Example #9
Source File: DtsReader.java    From K-Sonic with MIT License 5 votes vote down vote up
/**
 * Parses the sample header.
 */
private void parseHeader() {
  byte[] frameData = headerScratchBytes.data;
  if (format == null) {
    format = DtsUtil.parseDtsFormat(frameData, formatId, language, null);
    output.format(format);
  }
  sampleSize = DtsUtil.getDtsFrameSize(frameData);
  // In this class a sample is an access unit (frame in DTS), but the format's sample rate
  // specifies the number of PCM audio samples per second.
  sampleDurationUs = (int) (C.MICROS_PER_SECOND
      * DtsUtil.parseDtsAudioSampleCount(frameData) / format.sampleRate);
}
 
Example #10
Source File: DtsReader.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the sample header.
 */
private void parseHeader() {
  byte[] frameData = headerScratchBytes.data;
  if (format == null) {
    format = DtsUtil.parseDtsFormat(frameData, formatId, language, null);
    output.format(format);
  }
  sampleSize = DtsUtil.getDtsFrameSize(frameData);
  // In this class a sample is an access unit (frame in DTS), but the format's sample rate
  // specifies the number of PCM audio samples per second.
  sampleDurationUs = (int) (C.MICROS_PER_SECOND
      * DtsUtil.parseDtsAudioSampleCount(frameData) / format.sampleRate);
}
 
Example #11
Source File: DtsReader.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the sample header.
 */
private void parseHeader() {
  byte[] frameData = headerScratchBytes.data;
  if (format == null) {
    format = DtsUtil.parseDtsFormat(frameData, formatId, language, null);
    output.format(format);
  }
  sampleSize = DtsUtil.getDtsFrameSize(frameData);
  // In this class a sample is an access unit (frame in DTS), but the format's sample rate
  // specifies the number of PCM audio samples per second.
  sampleDurationUs = (int) (C.MICROS_PER_SECOND
      * DtsUtil.parseDtsAudioSampleCount(frameData) / format.sampleRate);
}