Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR introduces Blu-ray disc support to redumper by adding BD-specific data structures, a descrambling algorithm, and integrated raw read and extraction workflows alongside existing DVD functionality. Changes
Sequence Diagram(s)sequenceDiagram
participant Reader as Disc Reader
participant Dumper as DVD Dumper
participant Scrambler as BD Scrambler
participant EDC as EDC Validator
participant Output as Output Buffer
Reader->>Dumper: read_dvd_sectors(BD disc, raw mode)
Dumper->>Reader: read OmniDriveDataFrame
Reader-->>Dumper: frame data
Dumper->>Scrambler: descramble(df, psn)
Scrambler->>Scrambler: process(data span, psn)
Scrambler->>EDC: validate EDC
EDC-->>Scrambler: match/mismatch
alt EDC Valid
Scrambler-->>Dumper: return true
else EDC Invalid
Scrambler->>Scrambler: revert via process()
Scrambler-->>Dumper: return false, mark error
end
Dumper->>Output: copy decrypted frame data
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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.
🧹 Nitpick comments (1)
dvd/bd_scrambler.ixx (1)
34-34: Operator precedence is correct but fragile-looking — consider adding parentheses for clarity.The expression relies on
&binding tighter than^binding tighter than|, which is correct in C++. However, the chain of|,^, and&without explicit grouping is easy to misread during future maintenance.♻️ Suggested clarification
- shift_register = (shift_register << 1) | (shift_register >> 15 & 1) ^ (shift_register >> 14 & 1) ^ (shift_register >> 12 & 1) ^ (shift_register >> 3 & 1); + shift_register = (shift_register << 1) | ((shift_register >> 15 & 1) ^ (shift_register >> 14 & 1) ^ (shift_register >> 12 & 1) ^ (shift_register >> 3 & 1));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@dvd/bd_scrambler.ixx` at line 34, The bitwise expression assigning to shift_register is correct but hard to read; update the assignment in the scrambler where shift_register is computed so each operation is explicitly grouped: parenthesize each (shift_register >> N & 1) term and then group the XORs together (e.g. ((t1) ^ (t2) ^ (t3) ^ (t4))) before ORing with (shift_register << 1), so the final statement makes the intended precedence obvious while preserving existing behaviour.
🤖 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/bd_scrambler.ixx`:
- Line 34: The bitwise expression assigning to shift_register is correct but
hard to read; update the assignment in the scrambler where shift_register is
computed so each operation is explicitly grouped: parenthesize each
(shift_register >> N & 1) term and then group the XORs together (e.g. ((t1) ^
(t2) ^ (t3) ^ (t4))) before ORing with (shift_register << 1), so the final
statement makes the intended precedence obvious while preserving existing
behaviour.
|
@coderabbitai stop suggesting brackets for operations where operator precedence is correct. |
|
Tip For best results, initiate chat on the files or code changes.
✏️ Learnings added
|
superg
left a comment
There was a problem hiding this comment.
Looks ok.
There is some code duplication but please just address what I asked and let's get that merged and I'll deduplicate later.
dvd/bd.ixx
Outdated
| namespace gpsxre | ||
| { | ||
|
|
||
| export constexpr int32_t BD_LBA_START = -0x100000; | ||
| export constexpr int32_t BD_LBA_IZ = -0x2000; | ||
| export constexpr uint32_t BD_ECC_FRAMES = 0x20; |
There was a problem hiding this comment.
let's namespace it to gpsxre::bd, strip BD_ prefix from constants and use it as bd::LBA_START etc, will look more tidy.
There was a problem hiding this comment.
There is already CD_LBA_START and DVD_LBA_START, do you want me to prefix the DVD one too, dvd::LBA_START
There was a problem hiding this comment.
Just do bd:: and I'll handle dvd and cd separately.
|
|
||
| namespace gpsxre::bd | ||
| { | ||
|
|
There was a problem hiding this comment.
I'd prefer to have it as a class with process in private: section
scrambler.descramble() looks more consistant with already existing CD/DVD code vs just bd::descramble().
options.ixx
Outdated
| else if(key == "--dvd-raw") | ||
| dvd_raw = true; | ||
| else if(key == "--bd-raw") | ||
| dvd_raw = true; |
There was a problem hiding this comment.
I understand the intent here but let's make another variable bd_raw.
It's not immediately clear for the user to use --dvd-raw but get bluray raw if disc is bluray.
dvd/dvd_split.ixx
Outdated
| bd_extract_iso(ctx, options); | ||
| dvd_extract_iso(ctx, options); |
There was a problem hiding this comment.
Flow is not obvious here.
Can you change:
void bd_extract_iso(Context &ctx, Options &options)
to:
void bd_extract_iso(Context &ctx, std::string image_path, Options &options)
and:
void dvd_extract_iso(Context &ctx, Options &options)
to:
void dvd_extract_iso(Context &ctx, std::string image_path, Options &options)
and move out decision logic on this level?
Something like:
auto image_prefix = (std::filesystem::path(options.image_path) / options.image_name).string();
std::filesystem::path sdram_path(image_prefix + ".sdram");
std::filesystem::path sbram_path(image_prefix + ".sbram");
if(std::filesystem::exists(sdram_path)
dvd_extract_iso(ctx, sdram_path, options);
else if(std::filesystem::exists(sbram_path)
bd_extract_iso(ctx, sbram_path, options);
(and remove those checks from dvd_extract_iso and bd_extract_iso)
dvd/dvd_dump.ixx
Outdated
| @@ -506,6 +508,10 @@ DumpConfig dump_get_config(DiscType disc_type, bool raw) | |||
| { | |||
| config = DumpConfig{ ".sdram", sizeof(RecordingFrame), DVD_LBA_START, DVD_LBA_RCZ - (int32_t)OVERREAD_COUNT, 0 }; | |||
| } | |||
| else if((disc_type == DiscType::BLURAY || disc_type == DiscType::BLURAY_R) && raw) | |||
There was a problem hiding this comment.
if(raw)
{
if(disc_type == DiscType::DVD)
// ...
else if(disc_type == DiscType::BLURAY || disc_type == DiscType::BLURAY_R)
// ...
}
dvd/dvd_dump.ixx
Outdated
There was a problem hiding this comment.
Same as previous comment, add if(raw) above.
|
Thanks - I'm aware of the code duplication in dvd_split but it would lead to a much harder piece of code to review, and I prefer you do that part. |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 895-899: The raw-mode flag is currently enabled if either
options.dvd_raw or options.bd_raw is set regardless of the loaded media; change
the logic that sets raw so it only enables when the option matches the current
disc type and omnidrive_firmware is present (e.g., set raw = options.dvd_raw &&
is_dvd_disc && omnidrive_firmware OR raw = options.bd_raw && is_bd_disc &&
omnidrive_firmware), and update the warning checks so they only warn when the
user requested a raw mode that does not match the loaded media (use the
disc-type predicate used elsewhere in this module such as is_bd_disc/is_dvd_disc
or the existing disc_type variable while keeping the existing omnidrive_firmware
condition).
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
dvd/bd.ixxdvd/bd_scrambler.ixxdvd/dvd_dump.ixxdvd/dvd_split.ixxoptions.ixx
🚧 Files skipped from review as they are similar to previous changes (2)
- options.ixx
- dvd/bd_scrambler.ixx
| bool raw = (options.dvd_raw || options.bd_raw || nintendo_key) && omnidrive_firmware; | ||
| if(options.dvd_raw && !omnidrive_firmware) | ||
| LOG("warning: drive not compatible with raw DVD dumping"); | ||
| if(options.bd_raw && !omnidrive_firmware) | ||
| LOG("warning: drive not compatible with raw BD dumping"); |
There was a problem hiding this comment.
Scope raw-mode enablement by current disc type.
Line 895 currently enables raw when either options.dvd_raw or options.bd_raw is set, regardless of the loaded media type. That can trigger the wrong raw path/extension unexpectedly (e.g., dvd_raw on BD).
💡 Proposed fix
- bool raw = (options.dvd_raw || options.bd_raw || nintendo_key) && omnidrive_firmware;
- if(options.dvd_raw && !omnidrive_firmware)
+ bool dvd_raw_requested = (ctx.disc_type == DiscType::DVD) && options.dvd_raw;
+ bool bd_raw_requested = (ctx.disc_type == DiscType::BLURAY || ctx.disc_type == DiscType::BLURAY_R) && options.bd_raw;
+ bool raw = (dvd_raw_requested || bd_raw_requested || nintendo_key) && omnidrive_firmware;
+ if(dvd_raw_requested && !omnidrive_firmware)
LOG("warning: drive not compatible with raw DVD dumping");
- if(options.bd_raw && !omnidrive_firmware)
+ if(bd_raw_requested && !omnidrive_firmware)
LOG("warning: drive not compatible with raw BD dumping");🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@dvd/dvd_dump.ixx` around lines 895 - 899, The raw-mode flag is currently
enabled if either options.dvd_raw or options.bd_raw is set regardless of the
loaded media; change the logic that sets raw so it only enables when the option
matches the current disc type and omnidrive_firmware is present (e.g., set raw =
options.dvd_raw && is_dvd_disc && omnidrive_firmware OR raw = options.bd_raw &&
is_bd_disc && omnidrive_firmware), and update the warning checks so they only
warn when the user requested a raw mode that does not match the loaded media
(use the disc-type predicate used elsewhere in this module such as
is_bd_disc/is_dvd_disc or the existing disc_type variable while keeping the
existing omnidrive_firmware condition).
* Raw BD read (#355) * Raw BD read * code review * fix * fix build * Fix bd scrambler * currently only works with dump size 1 * OmniDrive bluray data frame is 2070 bytes --------- Co-authored-by: Hennadiy Brych <gennadiy.brich@gmail.com> * compilation fixes * nintendo book type * structure padding fix * bluray support refactored, split progress output * raw by type, CR review addressed * CR review --------- Co-authored-by: Deterous <138427222+Deterous@users.noreply.github.com>
Summary by CodeRabbit
Release Notes
New Features
Chores