Skip to content

feat(dynamicrange)!: replace HDR with a sorted DynamicRange set - #81

Open
zze0s wants to merge 1 commit into
feat/anime-cjkfrom
feat/dynamic-range
Open

zze0s wants to merge 1 commit into
feat/anime-cjkfrom
feat/dynamic-range

Conversation

@zze0s

@zze0s zze0s commented Nov 18, 2026

Copy link
Copy Markdown

Description

Stacked on #80. Step 4 of the stack: decision 5, HDR printed sorted and the field renamed.

Release.HDR was a []string in the order of the name, so HDR.DV and DV.HDR were two different values to anything that compared them. Release.DynamicRange is a set:

type DynamicRange uint8

const (
    DV DynamicRange = 1 << iota
    HDR
    HDRPlus
    HDR10
    HDR10Plus
    HLG
    SDR
)

func (d DynamicRange) Has(f DynamicRange) bool
func (d DynamicRange) Strings() []string   // DV, HDR, HDR+, HDR10, HDR10+, HLG, SDR, in that order
func (d DynamicRange) String() string      // "DV,HDR"
func ParseDynamicRange(s string) DynamicRange
// MarshalJSON and UnmarshalJSON: a list of spellings, ["DV","HDR"]

This is the shape you approved. The seven formats are the tags of the hdr rows of taginfo.csv, and a test holds that the two lists agree.

What changes

name HDR before DynamicRange.Strings()
22.Bahnen.2025.GERMAN.2160p.HDR.DV.WEB.H265-MGE HDR, DV DV, HDR
Movie.2020.2160p.UHD.BluRay.HDR10.DoVi.x265-GRP HDR10, DV DV, HDR10
Show.S01E01.2160p.WEB-DL.DV.HDR.H.265-GRP DV, HDR DV, HDR
any name with one format unchanged

Against #80, over every set:

set names changed
real scene names 54,766 24
nyaa.txt 13,215 1
tests.yaml, sports.txt, the three probe sets 3,938 0

All 25 are the first row of the table: HDR, DV becomes DV, HDR. The set of formats is the same in every one, and no other field of any name changes.

No spelling changes. The fixed order equals sort.Strings of the seven spellings.

tests.yaml renames its key hdr: to dynamicRange:. None of its 45 values changes order. cmd/rls keeps its dynamic_range key, and the list it prints is sorted.

Downstream impact on autobrr and qui

qui: 8 files, +22 −37 in a local port, not pushed. Reads of r.HDR become r.DynamicRange.Strings(), and simplifySeasonPackHDRTags becomes a set operation that is 17 lines shorter. Nothing qui stores or compares changes: every path that reads the list sorts it or compares it as a set already. With the port, qui builds and its 11 packages that use rls pass against this commit.

autobrr: one line, r.HDR = rel.DynamicRange.Strings(). domain.Release.HDR stays autobrr's own []string. With it, autobrr builds and fails only the two tests that fail against master.

But the order reaches stored values in autobrr, for a name that lists two formats in another order than the fixed one:

name hdr column before after normalized_hash
The.Best.Show.2020.S04E10.1080p.AMZN.WEB-DL.DDP.5.1.HDR.DV.H.264-GROUP HDR,DV DV,HDR changes
the same name with DV.HDR DV,HDR DV,HDR same as the row above, after the change
  • Duplicate checks. A release stored before the upgrade as HDR,DV keeps its old hash and its old hdr text. The same name announced after the upgrade is not found as its duplicate, by the hash check (CheckIsDuplicateRelease) or by the DynamicRange duplicate profile. That lasts as long as the old rows are kept. Removing the gap takes a migration that sorts release.hdr and recomputes normalized_hash, and the hash needs Go's title normalisation, not SQL. I did not write one. Say if you want it.
  • After the upgrade HDR.DV and DV.HDR versions of one release hash the same, which is the point of decision 5.
  • Filters compare as sets already, so no filter outcome changes. The reject text, the {{.HDR}} macro, the notification payload and the API list show the new order.

For you to decide

  1. Other encoders. DynamicRange marshals to JSON as a list of spellings. yaml.v3 and anything else that does not use the JSON methods sees an integer. Adding MarshalText would cover those and would change the JSON to one string, "DV,HDR". Neither app encodes a Release today.
  2. One rule for enums. Type, Scheme and EpKind marshal as integers, and this type as a list of spellings. I would settle all of them in step 7 (Q7f).

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How has this been tested?

  • TestDynamicRange*: the set, its order, parsing in any case, JSON both ways, and the hdr rows of taginfo.csv against the constants.
  • The differential over every name set with a dump of every field.
  • An independent review. It found that a caller's hdr row spelled in another case was not read, and that a decoded null panicked. Both are fixed here.
  • go vet ./..., gofmt -l . with Go 1.26 and 1.27, go test ./... with the corpus present, go test -race ./..., the cmd/rls checks.

Benchmarks, #80 against the last of the three typed PRs (#83), 8 rounds in alternating order: Parse, Build, ParseNyaa, ParseSports and ParseLong are within noise, and allocations are identical on every benchmark. ParseClaims (Web. repeated 4,000 times) reads between +1.4% and +3.3% across runs. A profile gives none of the changed functions a sample there, and the extra time is in lexer code that no step touches, so I read it as code layout and could not pin it further.

Checklist

  • I ran go fmt and the test suite passes locally
  • I added cases to tests.yaml for any parsing change
  • If this adds or renames a normalized value (source, codec, HDR, etc.), I noted the downstream impact on autobrr/qui
  • I have linked any related issue (none)

AI disclosure

Yes, all of it. Claude Code (Claude Fable 5.2) wrote it, a second model run reviewed it, and a third ported both apps in local worktrees.

BREAKING CHANGE: Release.HDR ([]string) is removed. Use Release.DynamicRange, whose Strings method gives the spellings in the fixed order DV, HDR, HDR+, HDR10, HDR10+, HLG, SDR and not in the order of the name.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 77d71bec-9519-4ed6-b514-953d53daa7c8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

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

Release.DynamicRange is a set of the seven formats of the hdr rows of
taginfo.csv (DV, HDR, HDR+, HDR10, HDR10+, HLG, SDR). Strings gives them
in that order whatever order the name writes them in, so
'HDR.Dolby.Vision' and 'DV.HDR' read the same. ParseDynamicRange reads
the one spelling of a format in any case, and the set marshals to JSON
as a list of spellings. A bit outside the seven is nothing to the set.

A caller's hdr row whose tag is a format in another case counts as that
format; a row with any other tag gives no format, and its tag stays in
Tags.

When unset gives a hdr tag of another release type back to the text, its
format is cleared only when no other hdr tag left in the name gives it.
With a caller's hdr rows that are exclusive to a type, every tag of
those rows in a name of another type now goes back to the text, where
before only the first tag of a value did: removing the value from HDR
made the next tag with it no longer match. The built-in hdr rows are
exclusive to no type, so the built-in vocabulary is not affected.

The tests.yaml key hdr is now dynamicRange. cmd/rls keeps its
dynamic_range key; the list is now sorted.

BREAKING CHANGE: Release.HDR ([]string) is removed. Use
Release.DynamicRange, whose Strings method gives the spellings in the
fixed order DV, HDR, HDR+, HDR10, HDR10+, HLG, SDR instead of the order
of the name.
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.

1 participant