forked from PaulWoitaschek/Voice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved package size parsing to a separate class
- Loading branch information
1 parent
f76b60c
commit 3914c04
Showing
3 changed files
with
22 additions
and
12 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
...rc/main/java/de/ph1b/audiobook/features/chapterReader/ogg/oggReading/PackageSizeParser.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package de.ph1b.audiobook.features.chapterReader.ogg.oggReading | ||
|
||
import de.ph1b.audiobook.features.chapterReader.toUInt | ||
|
||
|
||
object PackageSizeParser { | ||
|
||
fun fromSegmentTable(segmentTable: ByteArray): List<Int> = segmentTable | ||
.map { it.toUInt() } | ||
.fold(mutableListOf(0), { acc, e -> | ||
acc[acc.lastIndex] += e | ||
if (e != 255) { | ||
acc.add(0) | ||
} | ||
acc | ||
}) | ||
.filter { it != 0 } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters