Skip to content

Commit 5b51aec

Browse files
committed
Merge branch 'main' of https://github.com/ef1500/libbbf
2 parents 3f0fe49 + fbc5e78 commit 5b51aec

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

readme.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# libbbf: Bound Book Format
22

33
![alt text](https://img.shields.io/badge/Format-BBF1-blue.svg)
4-
5-
64
![alt text](https://img.shields.io/badge/License-MIT-green.svg)
75

86
Bound Book Format (.bbf) is a high-performance binary container designed specifically for digital comic books and manga. Unlike CBR/CBZ, BBF is built for DirectSotrage/mmap, easy integrity checks, and mixed-codec containerization.
@@ -26,6 +24,8 @@ Windows
2624
g++ -std=c++17 bbfenc.cpp libbbf.cpp xxhash.c -o bbfmux -municode
2725
```
2826

27+
Alternatively, if you need python support, use [libbbf-python](https://github.com/ef1500/libbbf-python).
28+
2929
---
3030

3131
## Technical Details
@@ -36,7 +36,7 @@ BBF is designed as a Footer-indexed binary format. This allows for rapid append-
3636
The `bbfmux` reference implementation utilizes **Memory Mapping (mmap/MapViewOfFile)**. Instead of reading file data into intermediate buffers, the tool maps the container directly into the process address space. This allows the CPU to access image data at the speed of your NVMe drive's hardware limit.
3737

3838
### High-Speed Parallel Verification
39-
Integrity checks now utilize **Parallel XXH3**. On multi-core systems, the verifier splits the asset table into chunks and validates multiple pages simultaneously. This makes BBF verification up to **10x faster** than ZIP/RAR CRC checks.
39+
Integrity checks utilize **Parallel XXH3**. On multi-core systems, the verifier splits the asset table into chunks and validates multiple pages simultaneously. This makes BBF verification up to **10x faster** than ZIP/RAR CRC checks.
4040

4141
### 4KB Alignment
4242
Every asset in a BBF file starts on a **4096-byte boundary**. This alignment is critical for modern hardware, allowing for DirectStorage transfers directly from disk to GPU memory, bypassing CPU bottlenecks entirely.
@@ -45,12 +45,14 @@ Every asset in a BBF file starts on a **4096-byte boundary**. This alignment is
4545
### Binary Layout
4646
1. **Header (13 bytes)**: Magic `BBF1`, versioning, and initial padding.
4747
2. **Page Data**: The raw image payloads (AVIF, PNG, etc.), each padded to **4096-byte boundaries**.
48-
3. **String Pool**: A deduplicated pool of null-terminated strings for metadata and section titles.
49-
4. **Asset Table**: A registry of physical data blobs with XXH3 hashes.
50-
5. **Page Table**: The logical reading order, mapping logical pages to assets.
51-
6. **Section Table**: Markers for chapters, volumes, or gallery sections.
52-
7. **Metadata Table**: Key-Value pairs for archival data (Author, Scanlation team, etc.).
53-
8. **Footer (76 bytes)**: Table offsets and a final integrity hash.
48+
4. **String Pool**: A deduplicated pool of null-terminated strings for metadata and section titles.
49+
5. **Asset Table**: A registry of physical data blobs with XXH3 hashes.
50+
6. **Page Table**: The logical reading order, mapping logical pages to assets.
51+
7. **Section Table**: Markers for chapters, volumes, or gallery sections.
52+
8. **Metadata Table**: Key-Value pairs for archival data (Author, Scanlation team, etc.).
53+
9. **Footer (76 bytes)**: Table offsets and a final integrity hash.
54+
55+
NOTE: `libbbf.h` includes a `flags` field, as well as extra padding for each asset entry. This is so that in the future `libbbf` can accomodate future technical advancements in both readers and image storage.
5456

5557
### Feature Comparison: Digital Comic & Archival Formats
5658

@@ -103,14 +105,14 @@ The included `bbfmux` tool is a reference implementation for creating and managi
103105
The `bbfmux` utility provides a powerful interface for managing Bound Book files:
104106

105107
* **Flexible Ingestion**: Create books by passing individual files, entire directories, or a mix of both.
106-
* **Logical Structuring**: Add named **Sections** (Chapters, Volumes, Galleries) to define the internal hierarchy of the book.
108+
* **Logical Structuring**: Add named **Sections** (Chapters, Volumes, Extras, Galleries) to define the internal hierarchy of the book.
107109
* **Custom Metadata**: Embed arbitrary Key:Value pairs into the global string pool for archival indexing.
108110
* **Content-Aware Extraction**: Extract the entire book or target specific sections by name.
109111

110112
## Usage Examples
111113

112114
### Create a new BBF
113-
You can mix individual images and folders. `bbfmux` sorts inputs alphabetically, deduplicates identical assets, and aligns data to 4096-byte boundaries.
115+
You can mix individual images and folders. `bbfmux` sorts inputs alphabetically, deduplicates identical assets, and aligns data to 4096-byte boundaries. See [Advanced CLI Usage](https://github.com/ef1500/libbbf?tab=readme-ov-file#advanced-cli-features) for how to specify your own custom page orders.
114116

115117
```bash
116118
# Basic creation with metadata
@@ -159,13 +161,15 @@ bbfmux input.bbf --extract --outdir="./unpacked_book"
159161
### View Metadata & Structure
160162
View the version, page count, deduplication stats, hierarchical sections, and all embedded metadata.
161163
```bash
162-
bbfmux input.bbf --info
164+
bbfmux input_book.bbf --info
163165
```
164166

165167
---
166168

167169
## Advanced CLI Features
168170

171+
`bbfmux` also supports more advanced options, allowing full-control over your `.bbf` files.
172+
169173
### Custom Page Ordering (`--order`)
170174
You can precisely control the reading order using a text file or inline arguments.
171175
* **Positive Integers**: Fixed 1-based index (e.g., `cover.png:1`).
@@ -219,7 +223,7 @@ The `--rangekey` option allows you to extract a range of sections. The extractor
219223
bbfmux manga.bbf --extract --section="Chapter 2" --rangekey="Chapter 4" --outdir="./Ch2_to_Ch4"
220224

221225
# Extract Volume 2 until it encounters the string "Chapter 60"
222-
bbfmux manga.bbf --extract --section="Volume 2" --rangekey="Chapter 60"
226+
bbfmux manga.bbf --extract --section="Volume 2" --rangekey="Chapter 60" --outdir="./Volume_2_to_Chapter_60"
223227
```
224228

225229
---

0 commit comments

Comments
 (0)