javazoom.jl.decoder.Bitstream.readBytes()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(167)

本文整理了Java中javazoom.jl.decoder.Bitstream.readBytes()方法的一些代码示例,展示了Bitstream.readBytes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bitstream.readBytes()方法的具体详情如下:
包路径:javazoom.jl.decoder.Bitstream
类名称:Bitstream
方法名:readBytes

Bitstream.readBytes介绍

[英]Simlar to readFully, but doesn't throw exception when EOF is reached.
[中]Simlar已准备就绪,但在达到EOF时不会引发异常。

代码示例

代码示例来源:origin: tulskiy/musique

  1. /**
  2. * Determines if the next 4 bytes of the stream represent a
  3. * frame header.
  4. */
  5. public boolean isSyncCurrentPosition(int syncmode) throws BitstreamException {
  6. int read = readBytes(syncbuf, 0, 4);
  7. int headerstring = ((syncbuf[0] << 24) & 0xFF000000) | ((syncbuf[1] << 16) & 0x00FF0000) | ((syncbuf[2] << 8) & 0x0000FF00) | ((syncbuf[3]) & 0x000000FF);
  8. try {
  9. source.unread(syncbuf, 0, 4);
  10. } catch (IOException e) {
  11. e.printStackTrace();
  12. }
  13. switch (read) {
  14. case 0:
  15. return true;
  16. case 4:
  17. return isSyncMark(headerstring, syncmode, syncword);
  18. default:
  19. return false;
  20. }
  21. }

代码示例来源:origin: com.badlogicgames.jlayer/jlayer

  1. /**
  2. * Determines if the next 4 bytes of the stream represent a frame header.
  3. */
  4. public boolean isSyncCurrentPosition (int syncmode) throws BitstreamException {
  5. int read = readBytes(syncbuf, 0, 4);
  6. int headerstring = syncbuf[0] << 24 & 0xFF000000 | syncbuf[1] << 16 & 0x00FF0000 | syncbuf[2] << 8 & 0x0000FF00
  7. | syncbuf[3] << 0 & 0x000000FF;
  8. try {
  9. source.unread(syncbuf, 0, read);
  10. } catch (IOException ex) {
  11. }
  12. boolean sync = false;
  13. switch (read) {
  14. case 0:
  15. sync = true;
  16. break;
  17. case 4:
  18. sync = isSyncMark(headerstring, syncmode, syncword);
  19. break;
  20. }
  21. return sync;
  22. }

代码示例来源:origin: com.googlecode.soundlibs/jlayer

  1. /**
  2. * Determines if the next 4 bytes of the stream represent a
  3. * frame header.
  4. */
  5. public boolean isSyncCurrentPosition(int syncmode) throws BitstreamException
  6. {
  7. int read = readBytes(syncbuf, 0, 4);
  8. int headerstring = ((syncbuf[0] << 24) & 0xFF000000) | ((syncbuf[1] << 16) & 0x00FF0000) | ((syncbuf[2] << 8) & 0x0000FF00) | ((syncbuf[3] << 0) & 0x000000FF);
  9. try
  10. {
  11. source.unread(syncbuf, 0, read);
  12. }
  13. catch (IOException ex)
  14. {
  15. }
  16. boolean sync = false;
  17. switch (read)
  18. {
  19. case 0:
  20. sync = true;
  21. break;
  22. case 4:
  23. sync = isSyncMark(headerstring, syncmode, syncword);
  24. break;
  25. }
  26. return sync;
  27. }

代码示例来源:origin: javazoom/jlayer

  1. /**
  2. * Determines if the next 4 bytes of the stream represent a
  3. * frame header.
  4. */
  5. public boolean isSyncCurrentPosition(int syncmode) throws BitstreamException
  6. {
  7. int read = readBytes(syncbuf, 0, 4);
  8. int headerstring = ((syncbuf[0] << 24) & 0xFF000000) | ((syncbuf[1] << 16) & 0x00FF0000) | ((syncbuf[2] << 8) & 0x0000FF00) | ((syncbuf[3] << 0) & 0x000000FF);
  9. try
  10. {
  11. source.unread(syncbuf, 0, read);
  12. }
  13. catch (IOException ex)
  14. {
  15. }
  16. boolean sync = false;
  17. switch (read)
  18. {
  19. case 0:
  20. sync = true;
  21. break;
  22. case 4:
  23. sync = isSyncMark(headerstring, syncmode, syncword);
  24. break;
  25. }
  26. return sync;
  27. }

代码示例来源:origin: pdudits/soundlibs

  1. /**
  2. * Determines if the next 4 bytes of the stream represent a
  3. * frame header.
  4. */
  5. public boolean isSyncCurrentPosition(int syncmode) throws BitstreamException
  6. {
  7. int read = readBytes(syncbuf, 0, 4);
  8. int headerstring = ((syncbuf[0] << 24) & 0xFF000000) | ((syncbuf[1] << 16) & 0x00FF0000) | ((syncbuf[2] << 8) & 0x0000FF00) | ((syncbuf[3] << 0) & 0x000000FF);
  9. try
  10. {
  11. source.unread(syncbuf, 0, read);
  12. }
  13. catch (IOException ex)
  14. {
  15. }
  16. boolean sync = false;
  17. switch (read)
  18. {
  19. case 0:
  20. sync = true;
  21. break;
  22. case 4:
  23. sync = isSyncMark(headerstring, syncmode, syncword);
  24. break;
  25. }
  26. return sync;
  27. }

代码示例来源:origin: com.badlogicgames.jlayer/jlayer

  1. /**
  2. * Get next 32 bits from bitstream. They are stored in the headerstring. syncmod allows Synchro flag ID The returned value is
  3. * False at the end of stream.
  4. */
  5. int syncHeader (byte syncmode) throws BitstreamException {
  6. boolean sync;
  7. int headerstring;
  8. // read additional 2 bytes
  9. int bytesRead = readBytes(syncbuf, 0, 3);
  10. if (bytesRead != 3) throw newBitstreamException(STREAM_EOF, null);
  11. headerstring = syncbuf[0] << 16 & 0x00FF0000 | syncbuf[1] << 8 & 0x0000FF00 | syncbuf[2] << 0 & 0x000000FF;
  12. do {
  13. headerstring <<= 8;
  14. if (readBytes(syncbuf, 3, 1) != 1) throw newBitstreamException(STREAM_EOF, null);
  15. headerstring |= syncbuf[3] & 0x000000FF;
  16. sync = isSyncMark(headerstring, syncmode, syncword);
  17. } while (!sync);
  18. // current_frame_number++;
  19. // if (last_frame_number < current_frame_number) last_frame_number = current_frame_number;
  20. return headerstring;
  21. }

代码示例来源:origin: tulskiy/musique

  1. /**
  2. * Get next 32 bits from bitstream.
  3. * They are stored in the headerstring.
  4. * syncmod allows Synchro flag ID
  5. * The returned value is False at the end of stream.
  6. */
  7. public int syncHeader(byte syncmode) throws BitstreamException {
  8. boolean sync;
  9. int headerstring;
  10. // read additional 2 bytes
  11. int bytesRead = readBytes(syncbuf, 0, 3);
  12. if (bytesRead != 3) throw new BitstreamException(STREAM_EOF, null);
  13. headerstring = ((syncbuf[0] << 16) & 0x00FF0000) | ((syncbuf[1] << 8) & 0x0000FF00) | ((syncbuf[2]) & 0x000000FF);
  14. do {
  15. headerstring <<= 8;
  16. if (readBytes(syncbuf, 3, 1) != 1)
  17. throw new BitstreamException(STREAM_EOF, null);
  18. headerstring |= (syncbuf[3] & 0x000000FF);
  19. sync = isSyncMark(headerstring, syncmode, syncword);
  20. }
  21. while (!sync);
  22. return headerstring;
  23. }

代码示例来源:origin: javazoom/jlayer

  1. /**
  2. * Get next 32 bits from bitstream.
  3. * They are stored in the headerstring.
  4. * syncmod allows Synchro flag ID
  5. * The returned value is False at the end of stream.
  6. */
  7. int syncHeader(byte syncmode) throws BitstreamException
  8. {
  9. boolean sync;
  10. int headerstring;
  11. // read additional 2 bytes
  12. int bytesRead = readBytes(syncbuf, 0, 3);
  13. if (bytesRead!=3) throw newBitstreamException(STREAM_EOF, null);
  14. headerstring = ((syncbuf[0] << 16) & 0x00FF0000) | ((syncbuf[1] << 8) & 0x0000FF00) | ((syncbuf[2] << 0) & 0x000000FF);
  15. do
  16. {
  17. headerstring <<= 8;
  18. if (readBytes(syncbuf, 3, 1)!=1)
  19. throw newBitstreamException(STREAM_EOF, null);
  20. headerstring |= (syncbuf[3] & 0x000000FF);
  21. sync = isSyncMark(headerstring, syncmode, syncword);
  22. }
  23. while (!sync);
  24. //current_frame_number++;
  25. //if (last_frame_number < current_frame_number) last_frame_number = current_frame_number;
  26. return headerstring;
  27. }

代码示例来源:origin: com.googlecode.soundlibs/jlayer

  1. /**
  2. * Get next 32 bits from bitstream.
  3. * They are stored in the headerstring.
  4. * syncmod allows Synchro flag ID
  5. * The returned value is False at the end of stream.
  6. */
  7. int syncHeader(byte syncmode) throws BitstreamException
  8. {
  9. boolean sync;
  10. int headerstring;
  11. // read additional 2 bytes
  12. int bytesRead = readBytes(syncbuf, 0, 3);
  13. if (bytesRead!=3) throw newBitstreamException(STREAM_EOF, null);
  14. headerstring = ((syncbuf[0] << 16) & 0x00FF0000) | ((syncbuf[1] << 8) & 0x0000FF00) | ((syncbuf[2] << 0) & 0x000000FF);
  15. do
  16. {
  17. headerstring <<= 8;
  18. if (readBytes(syncbuf, 3, 1)!=1)
  19. throw newBitstreamException(STREAM_EOF, null);
  20. headerstring |= (syncbuf[3] & 0x000000FF);
  21. sync = isSyncMark(headerstring, syncmode, syncword);
  22. }
  23. while (!sync);
  24. //current_frame_number++;
  25. //if (last_frame_number < current_frame_number) last_frame_number = current_frame_number;
  26. return headerstring;
  27. }

代码示例来源:origin: pdudits/soundlibs

  1. /**
  2. * Get next 32 bits from bitstream.
  3. * They are stored in the headerstring.
  4. * syncmod allows Synchro flag ID
  5. * The returned value is False at the end of stream.
  6. */
  7. int syncHeader(byte syncmode) throws BitstreamException
  8. {
  9. boolean sync;
  10. int headerstring;
  11. // read additional 2 bytes
  12. int bytesRead = readBytes(syncbuf, 0, 3);
  13. if (bytesRead!=3) throw newBitstreamException(STREAM_EOF, null);
  14. headerstring = ((syncbuf[0] << 16) & 0x00FF0000) | ((syncbuf[1] << 8) & 0x0000FF00) | ((syncbuf[2] << 0) & 0x000000FF);
  15. do
  16. {
  17. headerstring <<= 8;
  18. if (readBytes(syncbuf, 3, 1)!=1)
  19. throw newBitstreamException(STREAM_EOF, null);
  20. headerstring |= (syncbuf[3] & 0x000000FF);
  21. sync = isSyncMark(headerstring, syncmode, syncword);
  22. }
  23. while (!sync);
  24. //current_frame_number++;
  25. //if (last_frame_number < current_frame_number) last_frame_number = current_frame_number;
  26. return headerstring;
  27. }

相关文章