mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Cleanup
This commit is contained in:
parent
184761f79e
commit
5e3b817b81
2 changed files with 4 additions and 24 deletions
|
|
@ -157,11 +157,6 @@ public final class ParsableByteArray {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resets the current byte offset. */
|
|
||||||
public void resetPosition() {
|
|
||||||
this.position = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the underlying array.
|
* Returns the underlying array.
|
||||||
*
|
*
|
||||||
|
|
@ -572,8 +567,7 @@ public final class ParsableByteArray {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isLittleEndian = charset.equals(Charsets.UTF_16LE);
|
int lineLimit = calculateLineLimitForUtf16(charset.equals(Charsets.UTF_16LE));
|
||||||
int lineLimit = calculateLineLimitForUtf16(isLittleEndian);
|
|
||||||
|
|
||||||
if (lineLimit - position >= 2 && isUtf16BOM(peekChar())) {
|
if (lineLimit - position >= 2 && isUtf16BOM(peekChar())) {
|
||||||
// There's a UTF-16 byte order mark at the start of the line. Discard it.
|
// There's a UTF-16 byte order mark at the start of the line. Discard it.
|
||||||
|
|
@ -586,27 +580,14 @@ public final class ParsableByteArray {
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
char currentChar;
|
if (peekLittleEndianChar() == '\r' || peekChar() == '\r') {
|
||||||
if(isLittleEndian) {
|
|
||||||
currentChar = peekLittleEndianChar();
|
|
||||||
} else {
|
|
||||||
currentChar = peekChar();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentChar == '\r') {
|
|
||||||
position += 2;
|
position += 2;
|
||||||
if (position == limit) {
|
if (position == limit) {
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isLittleEndian) {
|
if (peekLittleEndianChar() == '\n' || peekChar() == '\n') {
|
||||||
currentChar = peekLittleEndianChar();
|
|
||||||
} else {
|
|
||||||
currentChar = peekChar();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentChar == '\n') {
|
|
||||||
position += 2;
|
position += 2;
|
||||||
}
|
}
|
||||||
return line;
|
return line;
|
||||||
|
|
|
||||||
|
|
@ -144,10 +144,9 @@ public final class SubripDecoder extends SimpleSubtitleDecoder {
|
||||||
/**
|
/**
|
||||||
* Determine UTF encoding of the byte array. It can be UTF-16LE/UTF-16BE
|
* Determine UTF encoding of the byte array. It can be UTF-16LE/UTF-16BE
|
||||||
* if the byte array contains BOM, or UTF-8 otherwise as the default behavior.
|
* if the byte array contains BOM, or UTF-8 otherwise as the default behavior.
|
||||||
* After it resets the offset in ParsableByteArray
|
|
||||||
*
|
*
|
||||||
* @param data byte array to determinate UTF encoding.
|
* @param data byte array to determinate UTF encoding.
|
||||||
* @return Determined encoding
|
* @return determined encoding
|
||||||
*/
|
*/
|
||||||
private Charset detectUtfCharset(ParsableByteArray data) {
|
private Charset detectUtfCharset(ParsableByteArray data) {
|
||||||
if(data.limit() < 2) {
|
if(data.limit() < 2) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue