Skip to content

fix(text): match official bit rate units and precision - #37

Merged
s0up4200 merged 1 commit into
mainfrom
fix/text-bitrate-units
Aug 10, 2026
Merged

fix(text): match official bit rate units and precision#37
s0up4200 merged 1 commit into
mainfrom
fix/text-bitrate-units

Conversation

@s0up4200

@s0up4200 s0up4200 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

This continues the default-text parity work in #32, #33, #35, and #36, and fixes the first of the two defects left on the list in AGENTS.md.

The three bit rate formatters each used a different rule and none matched official MediaInfo. They are now one function that follows MediaInfoLib Kilo_Kilo123: each unit tier keeps one decimal until the source value passes ten times the tier, and every boundary is a strict "greater than", so 10 000 000 b/s still prints as 10 000 kb/s. Measured against official v23.04 on 32 real files: 2 better, 30 same, 0 worse, with JSON and --language=raw output byte-identical on every file.

Summary by CodeRabbit

  • Bug Fixes
    • Improved bitrate formatting across DVD, Matroska, and MPEG media details.
    • Bitrates now display consistently with appropriate units and decimal precision.
    • Corrected 96 kb/s audio displays to show as 96.0 kb/s.
    • Standardized formatting at bitrate unit boundaries, including b/s, kb/s, Mb/s, and Gb/s.

The three bit rate formatters each used a different rule, and none
matched official MediaInfo. Rates below 10 kb/s printed as a rounded
"0 kb/s" instead of b/s, rates between 10 and 100 kb/s lost their
decimal, and every rate above 10 Mb/s kept a decimal that official drops
past 100 Mb/s.

Replace all three with one function that follows MediaInfoLib
Kilo_Kilo123 (File__Analyze_Streams.cpp): each unit tier keeps one
decimal until the source value passes ten times the tier, the division
is done in float32, and every boundary is a strict "greater than", so
10 000 000 b/s still prints as "10 000 kb/s". Verified against official
v23.04 on 32 real files: 2 better, 30 same, 0 worse, with JSON and
--language=raw output byte-identical on every file, including the BDAV
and DVD controls.
@s0up4200 s0up4200 added bug Something isn't working go Pull requests that update go code labels Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 55854675-15a1-4f24-a5ef-388cef1d348f

📥 Commits

Reviewing files that changed from the base of the PR and between 90292ea and 984c91c.

⛔ Files ignored due to path filters (1)
  • internal/mediainfo/testdata/golden/sample.mp4.csv is excluded by !**/*.csv
📒 Files selected for processing (7)
  • internal/mediainfo/dvd.go
  • internal/mediainfo/format_duration.go
  • internal/mediainfo/format_duration_test.go
  • internal/mediainfo/matroska_scan.go
  • internal/mediainfo/mpeg_ps.go
  • internal/mediainfo/testdata/golden/sample.mp4.html
  • internal/mediainfo/testdata/golden/sample.mp4.txt

📝 Walkthrough

Walkthrough

The shared bitrate formatter now uses MediaInfo-compatible unit tiers, scaling, rounding, and precision. DVD, Matroska, and MPEG-PS reporting paths use it. Unit tests and golden fixtures cover the updated output.

Changes

Bitrate formatting

Layer / File(s) Summary
MediaInfo-compatible bitrate formatter
internal/mediainfo/format_duration.go, internal/mediainfo/format_duration_test.go
The formatter now supports tiered b/s, kb/s, Mb/s, and Gb/s output with MediaInfo-compatible scaling and precision. Tests cover units, boundaries, rounding, and kb/s precision.
Parser bitrate display integration
internal/mediainfo/dvd.go, internal/mediainfo/matroska_scan.go, internal/mediainfo/mpeg_ps.go, internal/mediainfo/testdata/golden/*
DVD, Matroska, and MPEG-PS display paths now use formatBitrate. Golden outputs change 96 kb/s to 96.0 kb/s.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: audionut

Poem

A rabbit formats bits with care,
From b/s to gigabits in air.
Tiers align and tests now see
Each decimal precisely.
Golden pages match the tune—
Hop, review, and merge soon!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: aligning bit rate units and precision with official MediaInfo behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/text-bitrate-units

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@s0up4200
s0up4200 merged commit 87d1a4e into main Aug 10, 2026
2 checks passed
@s0up4200
s0up4200 deleted the fix/text-bitrate-units branch August 10, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant