Skip to content

refactor: Replace picojpeg with jpegdec#2

Open
jpirnay wants to merge 16 commits intopablohc:feat/home-cover-settingsfrom
jpirnay:refactor/remove-picojpeg
Open

refactor: Replace picojpeg with jpegdec#2
jpirnay wants to merge 16 commits intopablohc:feat/home-cover-settingsfrom
jpirnay:refactor/remove-picojpeg

Conversation

@jpirnay
Copy link
Copy Markdown

@jpirnay jpirnay commented Mar 28, 2026

Summary

  • What is the goal of this PR? Replace the in-tree picojpeg library with the JPEGDEC library (already a declared dependency) to align this branch with the main repo's refactor-remove-picojpeg refactor.
  • What changes are included?
    • Delete lib/picojpeg/ (picojpeg.c + picojpeg.h, ~2200 lines)
    • Rewrite JpegToBmpConverter to use JPEGDEC's callback-based decoder instead of picojpeg
    • Adds progressive JPEG support (via patch_jpegdec.py, already present in this branch)
    • Preserves the deadline parameter introduced in this branch: stored in BmpConvertCtx and checked inside the JPEGDEC draw callback — equivalent to the per-MCU-row check in the picojpeg version

Additional Context

This is a mechanical port of jpirnay/crosspoint-reader#refactor-remove-picojpeg on top of this branch. The deadline behaviour is functionally identical to the picojpeg version; only the check site moves from an explicit for (mcuY...) loop to the JPEGDEC draw callback.


AI Usage

Did you use AI tools to help write this code? YES — Claude Code was used to apply the refactoring and adapt the deadline check to JPEGDEC's callback architecture.

pablohc and others added 16 commits March 26, 2026 14:19
- Settings > Display > Cover: Enabled / Timeout (3s) / Disabled enum
- Cover generation only triggers on return from Reader (pendingCoverGeneration flag)
- ZIP/JPEG/PNG deadline propagated through full stack to prevent WDT resets
- Lyra/Lyra3Covers: show placeholder icon when BMP file is missing
- addBook() preserves cleared coverBmpPath to prevent timeout retry on reopen
- ReaderActivity shows loading popup before epub/xtc/txt load
- RecentBook.coverDisabled field added with JSON serialization (Paso 4)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- HomeActivity: isForcedBook bypasses coverDisabled guard and DISABLED
  global mode; DISABLED early return now allows force renders; add
  setCoverDisabled(false) on successful generation
- BaseTheme/LyraTheme/Lyra3CoversTheme: skipCover now uses only
  coverDisabled (no global mode check), enabling per-book ENABLED to
  override global DISABLED
- EpubReaderActivity/XtcReaderActivity: set coverDisabled=true on exit
  when global mode is DISABLED
- EpubReaderMenuActivity: add COVER_ACTION to menu; TIMEOUT shows
  "Generate cover", ENABLED/DISABLED toggle "Enable/Disable cover"
- EpubReaderActivity: pass bookCoverDisabled to menu, handle
  COVER_ACTION (force render or toggle per-book state + delete BMP)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ove bookmark to spine

- Hide title + author text overlay when hasCoverImage is true; cover
  speaks for itself without redundant text on top of the art
- Update "Continue Reading" box condition from coverRendered to
  hasCoverImage for consistency (also covers edge case where buffer
  store fails but BMP is already drawn)
- Move bookmark ribbon from top-right to top-left (spine side), flush
  with top edge, 20px margin from the spine

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…flash churn

- Use wrap-safe deadline check in JPEG/PNG/ZipFile deadline pipeline:
  `static_cast<int32_t>(millis() - deadline) >= 0`
- Remove COVER_DISABLED_MODE write-back from EpubReaderActivity::onExit()
  to preserve per-book cover enables set via Reader Menu
- Revert XtcReaderActivity::onExit() to master state (no changes from this PR)
- Guard RecentBooksStore::setCoverDisabled() to skip flash write when value unchanged

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
isForcedBook now skips both the outer Storage.exists guard and deletes
the stale BMP before calling generateThumbBmp (which has its own
internal exists-check that would otherwise return early). Only applies
to EPUB — XTC cover generation is unaffected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
If the user enables then disables cover in the same reader session,
forceRenderCoverPath could still be set when HOME runs, causing it to
regenerate the BMP the user just deleted. Clear the flag on disable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Close archive on early returns when this function opened it
  (loadFileStatSlim failure and negative fileOffset)
- Check out.write() return in stored-entry path, matching the
  existing check in the deflated path (line 614)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract repeated find_if over RECENT_BOOKS into a findRecentBook() helper
in EpubReaderActivity.cpp; hoist the single GUI.drawPopup call in
ReaderActivity::onEnter to cover all non-BMP branches.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…n no-cover books

coverRendered is now set immediately after drawing, before storeCoverBuffer().
A failed cache write no longer causes re-rendering every frame.

When bufferRestored && !hasCoverImage in BaseTheme, the full rect is cleared
so prior full-width cover pixels don't leak behind the narrower placeholder.

Applied to BaseTheme, LyraTheme, and Lyra3CoversTheme.
…bled persistence until HOME confirms success
- Delete lib/picojpeg/ (picojpeg.c + picojpeg.h)
- Rewrite JpegToBmpConverter to use JPEGDEC (callback-based decoder)
  instead of picojpeg; adds progressive JPEG support via patch_jpegdec.py
- Preserve the deadline parameter introduced in this branch:
  store it in BmpConvertCtx and check it in the JPEGDEC draw callback
  (equivalent to the per-MCU-row check in the picojpeg version)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jpirnay jpirnay changed the title Replace picojpeg with jpegdec refactor: Replace picojpeg with jpegdec Mar 28, 2026
@pablohc pablohc force-pushed the feat/home-cover-settings branch 2 times, most recently from 5fcc5ea to f385cbf Compare March 28, 2026 21:03
@pablohc
Copy link
Copy Markdown
Owner

pablohc commented Mar 30, 2026

I just saw this PR! Thank you very much @jpirnay

@pablohc pablohc force-pushed the feat/home-cover-settings branch from f385cbf to 1562c1f Compare April 5, 2026 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants