Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRefactors DVD descramble/validation to per-frame APIs: DataFrame gains ID::valid(), valid(optional key) and descramble(optional key); Scrambler exposes a public get()/descramble(span,psn,key); constants and namespace moved under Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Drive as SPTD/Drive
participant Dump as dvd_dump
participant RF as RecordingFrame
participant DF as dvd::DataFrame
participant Nin as nintendo::get_key
participant Scr as dvd::Scrambler::get()
Note over Drive,Dump: Raw sector read and per-LBA validation/descramble
Dump->>Drive: cmd_read_omnidrive(lba)
Drive-->>Dump: sector bytes
Dump->>RF: parse bytes -> RecordingFrame
RF-->>Dump: RecordingFrame
Dump->>DF: RecordingFrame_to_DataFrame(RF)
DF-->>Dump: DataFrame
Dump->>Nin: get_key(key_lba0, lba, DF)
Nin-->>Dump: optional<nintendo_key>
Dump->>DF: DF.ID::valid()
alt ID valid
Dump->>DF: DF.valid(optional_key)
alt DF valid
Dump->>DF: DF.descramble(optional_key)
DF-->>Dump: main_data (descrambled)
Dump->>Scr: Scr.descramble(span, psn, optional_key)
Scr-->>Dump: span modified (if applicable)
Dump->>Dump: write main_data span to ISO
else DF invalid
Dump-->>Dump: record invalid_data_frames / continue
end
else ID invalid
Dump-->>Dump: record invalid_data_frames / continue
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~55 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
dvd/dvd.ixx (1)
186-220: Remove stale commented implementation block.The large commented-out
descramblecode path (Line [186] onward) is obsolete noise now thatDataFrame::valid/DataFrame::descrambleare the active API.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@dvd/dvd.ixx` around lines 186 - 220, Remove the stale commented-out implementation of descramble by deleting the entire commented block that contains the old bool descramble(DataFrame &df, std::optional<uint8_t> nintendo_key) implementation; keep the file focused on the active API (DataFrame::valid / DataFrame::descramble) and ensure no remaining references to the old free-function descramble or its helper logic remain in the file so the codebase only uses the current DataFrame methods.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@dvd/dvd_dump.ixx`:
- Around line 1056-1057: The current condition calls
df.valid(nintendo::get_key(nintendo_key, l, df)) unconditionally, causing
expensive per-sector validation even when options.verbose is false; change the
branch to check options.verbose first (e.g., if (options.verbose &&
!df.valid(nintendo::get_key(nintendo_key, l, df))) ...) so df.valid and
nintendo::get_key are only invoked when verbose logging is enabled, preserving
existing LOG_R behavior.
In `@dvd/dvd_split.ixx`:
- Around line 191-199: The code calls df.descramble(key) before checking
validity, so invalid frames get altered even when options.leave_unchanged is
true; move the descramble call to occur only after validating the frame (i.e.,
call nintendo::get_key(...), then bool valid = df.valid(key) and if valid then
call df.descramble(key), otherwise honor options.leave_unchanged and possibly
zero the buffer), updating the logic around get_key, df.valid, df.descramble and
options.leave_unchanged to ensure descramble is conditional on valid.
In `@dvd/nintendo.ixx`:
- Around line 34-37: The current std::span(std::span(df.cpr_mai, df.cpr_mai +
8)) in the Nintendo key derivation is invoking pointer arithmetic past the
6-element array df.cpr_mai; change derive_key usage to build a safe 8-byte
buffer explicitly after df.descramble: allocate a local 8-byte temporary (e.g.,
uint8_t tmp[8]), copy the 6 bytes from df.cpr_mai into tmp[0..5] and then copy
the remaining 2 bytes from the adjacent df.main_data start into tmp[6..7], and
then call derive_key(std::span(tmp, 8)) (references: data_frame, df.descramble,
df.cpr_mai, df.main_data, derive_key, key_lba0).
---
Nitpick comments:
In `@dvd/dvd.ixx`:
- Around line 186-220: Remove the stale commented-out implementation of
descramble by deleting the entire commented block that contains the old bool
descramble(DataFrame &df, std::optional<uint8_t> nintendo_key) implementation;
keep the file focused on the active API (DataFrame::valid /
DataFrame::descramble) and ensure no remaining references to the old
free-function descramble or its helper logic remain in the file so the codebase
only uses the current DataFrame methods.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
dvd/dvd.ixxdvd/dvd_dump.ixxdvd/dvd_scrambler.ixxdvd/dvd_split.ixxdvd/nintendo.ixxdvd/xbox.ixx
There was a problem hiding this comment.
🧹 Nitpick comments (1)
dvd/dvd_dump.ixx (1)
1047-1060: Remove redundant verbose check inside verbose-only block.
options.verboseis already guaranteed true in the outer scope, so the inner&& options.verboseis unnecessary noise.♻️ Proposed cleanup
- if(!df.valid(nintendo::get_key(nintendo_key, l, df)) && options.verbose) + if(!df.valid(nintendo::get_key(nintendo_key, l, df))) LOG_R("[LBA: {}] invalid data frame", l);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@dvd/dvd_dump.ixx` around lines 1047 - 1060, Inside the verbose-only block (guarded by options.verbose) remove the redundant inner check by deleting the "&& options.verbose" from the if that logs invalid frames; specifically update the inner loop that checks if(!df.valid(nintendo::get_key(nintendo_key, l, df)) && options.verbose) to simply if(!df.valid(nintendo::get_key(nintendo_key, l, df))) so the logging via LOG_R("[LBA: {}] invalid data frame", l) still occurs when ctx.disc_type == DiscType::DVD, raw is true, and the data frame is invalid.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@dvd/dvd_dump.ixx`:
- Around line 1047-1060: Inside the verbose-only block (guarded by
options.verbose) remove the redundant inner check by deleting the "&&
options.verbose" from the if that logs invalid frames; specifically update the
inner loop that checks if(!df.valid(nintendo::get_key(nintendo_key, l, df)) &&
options.verbose) to simply if(!df.valid(nintendo::get_key(nintendo_key, l, df)))
so the logging via LOG_R("[LBA: {}] invalid data frame", l) still occurs when
ctx.disc_type == DiscType::DVD, raw is true, and the data frame is invalid.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary by CodeRabbit
Refactor
New Features
Bug Fixes