player: detect forced subtitle tracks from the filename
Tier 2 medium c · local · real merged PR from mpv-player/mpv #16061
Ground-truth defects
The filename language guesser reuses one `checked_tag` latch for both the hearing-impaired (`sdh`/`hi`/`cc`) and the newly added `forced` suffix, so only the last dot-separated suffix is ever tested as a tag. For a subtitle named `movie.en.sdh.forced.srt` the parser strips `forced`, sets the latch, and then reads `sdh` as the language, returning language "sdh" with the hearing-impaired flag unset. With the suffixes the other way round, `movie.en.forced.sdh.srt`, the six-letter `forced` fails the primary-subtag length check, so no language is found and the forced flag is lost. The wrong language reaches real tracks through subtitle autoload and sub-reload.
The change under review
diff
new file mode 100644 @@ -0,0 +1 @@ +add `forced` flag to sub-add command @@ -673,6 +673,10 @@ Track Manipulation Marks the track as suitable for the visually impaired. + <forced> (only for ``sub-add``) + + Marks the track as forced. + <attached-picture> (only for ``video-add``) Marks the track as an attached picture, same as ``albumart`` argument @@ -297,7 +297,7 @@ done: return best_score; } -bstr mp_guess_lang_from_filename(bstr name, int *lang_start, bool *hearing_impaired) +bstr mp_guess_lang_from_filename(bstr name, int *lang_start, bool *hearing_impaired, bool *forced) { name = bstr_strip(bstr_strip_ext(name)); @@ -307,6 +307,9 @@ bstr mp_guess_lang_from_filename(bstr name, int *lang_start, bool *hearing_impai if (hearing_impaired) *hearing_impaired = false; + if (forced) + *forced = false; + if (name.len < 2) return (bstr){0}; @@ -325,7 +328,8 @@ bstr mp_guess_lang_from_filename(bstr name, int *lang_start, bool *hearing_impai } bool *hi = hearing_impaired ? hearing_impaired : &(bool){0}; - bool checked_hi = false; + bool *f = forced ? forced : &(bool){0}; + bool checked_tag = false; while (true) { while (i >= 0 && mp_isalpha(name.start[i])) { @@ -333,8 +337,8 @@ bstr mp_guess_lang_from_filename(bstr name, int *lang_start, bool *hearing_impai i--; } - if (i >= 0 && lang_length >= 2 && !checked_hi && name.start[i] == delimiter) { - checked_hi = true; + if (i >= 0 && lang_length >= 2 && !checked_tag && name.start[i] == delimiter) { + checked_tag = true; static const char *const suffixes[] = { "sdh", "hi", "cc" }; bstr tag = { name.start + i + 1, lang_length }; for (int n = 0; n < MP_ARRAY_SIZE(suffixes); n++) { @@ -343,7 +347,10 @@ bstr mp_guess_lang_from_filename(bstr name, int *lang_start, bool *hearing_impai break; } } - if (*hi) { + if (!bstrcasecmp0(tag, "forced")) { + *f = true; + } + if (*hi || *f) { lang_length = 0; i -= (delimiter != '.') ? 2 : 1; continue; @@ -25,6 +25,6 @@ // Result numerically higher => better match. 0 == no match. int mp_match_lang(char **langs, const char *lang); char **mp_get_user_langs(void); -bstr mp_guess_lang_from_filename(bstr name, int *lang_start, bool *hearing_impaired); +bstr mp_guess_lang_from_filename(bstr name, int *lang_start, bool *hearing_impaired, bool *forced); #endif /* MP_LANGUAGE_H */ @@ -6305,6 +6305,7 @@ static void cmd_track_reload(void *p) flags |= t->attached_picture ? TRACK_ATTACHED_PICTURE : 0; flags |= t->hearing_impaired_track ? TRACK_HEARING_IMPAIRED : 0; flags |= t->visual_impaired_track ? TRACK_VISUAL_IMPAIRED : 0; + flags |= t->forced_track ? TRACK_FORCED : 0; mp_remove_track(mpctx, t); nt_num = mp_add_external_file(mpctx, filename, type, cmd->abort->cancel, flags); @@ -6320,7 +6321,7 @@ static void cmd_track_reload(void *p) if (!nt->lang) { bstr lang = mp_guess_lang_from_filename(bstr0(nt->external_filename), NULL, - &nt->hearing_impaired_track); + &nt->hearing_impaired_track, &nt->forced_track); nt->lang = bstrto0(nt, lang); } @@ -7155,7 +7156,8 @@ const struct mp_cmd_def mp_cmds[] = { {"flags", OPT_FLAGS(v.i, {"select", 0}, {"auto", 1}, {"cached", 2}, {"hearing-impaired", TRACK_HEARING_IMPAIRED}, - {"visual-impaired", TRACK_VISUAL_IMPAIRED}), + {"visual-impaired", TRACK_VISUAL_IMPAIRED}, + {"forced", TRACK_FORCED}), .flags = MP_CMD_OPT_ARG}, {"title", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG}, {"lang", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG}, @@ -496,6 +496,7 @@ enum track_flags { TRACK_HEARING_IMPAIRED = 1 << 2, TRACK_VISUAL_IMPAIRED = 1 << 3, TRACK_ATTACHED_PICTURE = 1 << 4, + TRACK_FORCED = 1 << 5, }; // audio.c @@ -156,7 +156,8 @@ static void append_dir_subtitles(struct mpv_global *global, struct MPOpts *opts, bstr lang = {0}; int start = 0; bool hearing_impaired = false; - lang = mp_guess_lang_from_filename(dename, &start, &hearing_impaired); + bool forced = false; + lang = mp_guess_lang_from_filename(dename, &start, &hearing_impaired, &forced); if (bstr_case_startswith(tmp_fname_trim, f_fname_trim)) { if (lang.len && start == f_fname_trim.len) prio |= 16; // exact movie name + followed by lang @@ -202,6 +203,7 @@ static void append_dir_subtitles(struct mpv_global *global, struct MPOpts *opts, sub->fname = subpath; sub->lang = lang.len ? bstrdup0(*slist, lang) : NULL; sub->hearing_impaired = hearing_impaired; + sub->forced = forced; } else talloc_free(subpath); } @@ -26,6 +26,7 @@ struct subfn { char *fname; char *lang; bool hearing_impaired; + bool forced; }; struct mpv_global; @@ -917,6 +917,7 @@ int mp_add_external_file(struct MPContext *mpctx, char *filename, t->no_auto_select = t->no_default; t->hearing_impaired_track = flags & TRACK_HEARING_IMPAIRED; t->visual_impaired_track = flags & TRACK_VISUAL_IMPAIRED; + t->forced_track = flags & TRACK_FORCED; // if we found video, and we are loading cover art, flag as such. t->attached_picture = t->type == STREAM_VIDEO && (flags & TRACK_ATTACHED_PICTURE); if (first_num < 0 && (filter == STREAM_TYPE_COUNT || sh->type == filter)) @@ -989,6 +990,7 @@ void autoload_external_files(struct MPContext *mpctx, struct mp_cancel *cancel) enum track_flags flags = 0; flags |= e->hearing_impaired ? TRACK_HEARING_IMPAIRED : 0; + flags |= e->forced ? TRACK_FORCED : 0; // when given filter is set to video, we are loading up cover art flags |= e->type == STREAM_VIDEO ? TRACK_ATTACHED_PICTURE : 0; int first = mp_add_external_file(mpctx, e->fname, e->type, cancel, flags);
Leaderboard for this case
medium · 4 of 9 bots fully caught it (44% solve rate) · 44% avg coverage.
| # | Bot | Result | Caught | Coverage | Findings | False alarms |
|---|---|---|---|---|---|---|
| 1 | Claude Code (Opus 5.5) | solved | 1/1 | 100.0% | 3 | 0 |
| 2 | Drape (Deep Review) | solved | 1/1 | 100.0% | 3 | 0 |
| 3 | Drape (Review) | solved | 1/1 | 100.0% | 3 | 0 |
| 4 | greptile | solved | 1/1 | 100.0% | 3 | 0 |
| 5 | Cubic | miss | 0/1 | 0.0% | 2 | 0 |
| 6 | cursor | miss | 0/1 | 0.0% | 2 | 0 |
| 7 | Mjolnir (Opus 5.5) | miss | 0/1 | 0.0% | 6 | 0 |
| 8 | Mjolnir (Sonnet 5.5) | miss | 0/1 | 0.0% | 2 | 0 |
| 9 | qodo | miss | 0/1 | 0.0% | 2 | 0 |
Bot results
Claude Code (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | medium | ✓ | off by one |
add_stream_track copies `.forced_track = stream->forced_track`, and the new assignment overwrites it with the flag bit. External files with a container forced flag lose it unless the caller passes TRACK_FORCED, which is a regression from the previous behaviour. [grounded: diff] [consensus 3/3: valid=3]
mp_guess_lang_from_filename sets `*forced = false` unconditionally. When a lang-less track is reloaded, the forced flag carried over through TRACK_FORCED is cleared unless the filename has a forced tag. [grounded: diff] [consensus 3/3: valid=3]
raw comments (3)
`t->forced_track = flags & TRACK_FORCED;` always overwrites the value `add_stream_track()` already copied from the demuxer (`stream->forced_track`). Before this change, external files kept the container's forced flag: an MKV/MKS `FlagForced`, a lavf `AV_DISPOSITION_FORCED`, or an EDL `forced` track. Now any external file that is autoloaded or added without the new `forced` flag silently loses that flag. This breaks forced-subtitle selection (`subs-fallback-forced`, `subs-with-matching-audio`) for those tracks. Combine the two sources instead, e.g. `t->forced_track |= !!(flags & TRACK_FORCED);`.
In `cmd_track_reload`, when the reloaded track has no language, `mp_guess_lang_from_filename` is now passed `&nt->forced_track`, and that function unconditionally sets `*forced = false` at the start. So a track added with `sub-add ... forced` (or whose container marked it forced), and whose filename has no `.forced` tag, loses its forced flag on reload. This undoes the `TRACK_FORCED` flag this same change carries over a few lines earlier. Write the guessed value into a local variable and OR it into the track instead.
Detecting `hi` and `forced` still shares one `checked_tag` guard, so only the last tag in a filename is recognized. In `movie.en.forced.sdh.srt` the `sdh` tag is consumed, then `forced` is treated as the language candidate (6 letters, accepted as a language), so the result is lang=`forced` and the forced flag is never set. The same happens in reverse for `movie.en.sdh.forced.srt`, where lang becomes `sdh`.
Cubic · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | medium | ✗ | — |
add_stream_track sets forced_track from stream->forced_track; the new unconditional assignment overwrites it with only the explicit flag. Callers that don't pass TRACK_FORCED now lose a container-marked forced flag that previously survived. [grounded: diff] [consensus 5/5: valid=5]
mp_guess_lang_from_filename first runs `*forced = false` and only sets it again if the filename contains a forced tag. When lang is NULL, reload overwrites the forced_track that TRACK_FORCED just preserved, so forced tracks without a forced filename tag lose the flag. [grounded: diff] [consensus 5/5: valid=5]
raw comments (3)
<!-- cubic:v=ed7ed212-e7ee-4fa2-9db2-29b171ae3c83 -->
<!-- cubic:review-run=c2267d3b-75e7-5edb-a522-3c8032d53aae -->
<!-- metadata:{"confidence":6} -->
P2: `add_stream_track` already sets `t->forced_track = stream->forced_track` from the container (loadfile.c:416). The new line overwrites it unconditionally with `flags & TRACK_FORCED`, and every caller that does not pass TRACK_FORCED — `open_external_files` for `--sub-file`/`--audio-file` passes `0` or `TRACK_ATTACHED_PICTURE`, and autoload passes it only when the filename heuristic set `e->forced` — now zeroes out a container-marked forced flag that previously survived. An external `.mks`/`.mkv` loaded as a subtitle whose tracks are flagged forced in the container loses its forced status (and the `forced` track-list property and the forced-aware selection in `compare_track` at loadfile.c:489) unless the filename happens to contain "forced". Preserve the container value when no explicit flag was given, e.g. `t->forced_track = flags & TRACK_FORCED | stream->forced_track;`
<details>
<summary>Prompt for AI agents</summary>
```text
Check if this issue is valid — if so, understand the root cause and fix it. At player/loadfile.c, line 920:
<comment>`add_stream_track` already sets `t->forced_track = stream->forced_track` from the container (loadfile.c:416). The new line overwrites it unconditionally with `flags & TRACK_FORCED`, and every caller that does not pass TRACK_FORCED — `open_external_files` for `--sub-file`/`--audio-file` passes `0` or `TRACK_ATTACHED_PICTURE`, and autoload passes it only when the filename heuristic set `e->forced` — now zeroes out a container-marked forced flag that previously survived. An external `.mks`/`.mkv` loaded as a subtitle whose tracks are flagged forced in the container loses its forced status (and the `forced` track-list property and the forced-aware selection in `compare_track` at loadfile.c:489) unless the filename happens to contain "forced". Preserve the container value when no explicit flag was given, e.g. `t->forced_track = flags & TRACK_FORCED | stream->forced_track;`</comment>
<file context>
@@ -917,6 +917,7 @@ int mp_add_external_file(struct MPContext *mpctx, char *filename,
t->no_auto_select = t->no_default;
t->hearing_impaired_track = flags & TRACK_HEARING_IMPAIRED;
t->visual_impaired_track = flags & TRACK_VISUAL_IMPAIRED;
+ t->forced_track = flags & TRACK_FORCED;
// if we found video, and we are loading cover art, flag as such.
t->attached_picture = t->type == STREAM_VIDEO && (flags & TRACK_ATTACHED_PICTURE);
</file context>
```
</details>
```suggestion
t->forced_track = stream->forced_track | (flags & TRACK_FORCED);
```
<!-- cubic:v=ae080f34-989f-4db6-a4b2-679c3483a0b7 -->
<!-- cubic:review-run=c2267d3b-75e7-5edb-a522-3c8032d53aae -->
<!-- metadata:{"confidence":7} -->
P2: When `nt->lang` is NULL, the filename guess in `cmd_track_reload` clobbers the `forced_track` flag this PR just preserved. `mp_guess_lang_from_filename()` unconditionally executes `if (forced) *forced = false;` (misc/language.c) before parsing the filename, and here it is invoked after `mp_add_external_file()` already applied the preserved `TRACK_FORCED` flag (player/loadfile.c sets `t->forced_track = flags & TRACK_FORCED`). So for any external subtitle with no language tag and no "forced" keyword in its name that was explicitly flagged via `sub-add ... forced=yes`, `sub-reload` silently drops the forced property. The intent of line 6308 (`flags |= t->forced_track ? TRACK_FORCED : 0;`) and the new `forced` sub-add flag is defeated. Pass the guess result into a temporary and OR it with the preserved value instead of writing `&nt->forced_track` directly.
<details>
<summary>Prompt for AI agents</summary>
```text
Check if this issue is valid — if so, understand the root cause and fix it. At player/command.c, line 6324:
<comment>When `nt->lang` is NULL, the filename guess in `cmd_track_reload` clobbers the `forced_track` flag this PR just preserved. `mp_guess_lang_from_filename()` unconditionally executes `if (forced) *forced = false;` (misc/language.c) before parsing the filename, and here it is invoked after `mp_add_external_file()` already applied the preserved `TRACK_FORCED` flag (player/loadfile.c sets `t->forced_track = flags & TRACK_FORCED`). So for any external subtitle with no language tag and no "forced" keyword in its name that was explicitly flagged via `sub-add ... forced=yes`, `sub-reload` silently drops the forced property. The intent of line 6308 (`flags |= t->forced_track ? TRACK_FORCED : 0;`) and the new `forced` sub-add flag is defeated. Pass the guess result into a temporary and OR it with the preserved value instead of writing `&nt->forced_track` directly.</comment>
<file context>
@@ -6320,7 +6321,7 @@ static void cmd_track_reload(void *p)
if (!nt->lang) {
bstr lang = mp_guess_lang_from_filename(bstr0(nt->external_filename), NULL,
- &nt->hearing_impaired_track);
+ &nt->hearing_impaired_track, &nt->forced_track);
nt->lang = bstrto0(nt, lang);
}
</file context>
```
</details>
<!-- cubic:review-summary:start -->
**2 issues found** across 9 files
<!-- cubic:review-summary:end -->
<details>
<summary>Prompt for AI agents (unresolved issues)</summary>
```text
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="player/loadfile.c">
<violation number="1" location="player/loadfile.c:920">
P2: `add_stream_track` already sets `t->forced_track = stream->forced_track` from the container (loadfile.c:416). The new line overwrites it unconditionally with `flags & TRACK_FORCED`, and every caller that does not pass TRACK_FORCED — `open_external_files` for `--sub-file`/`--audio-file` passes `0` or `TRACK_ATTACHED_PICTURE`, and autoload passes it only when the filename heuristic set `e->forced` — now zeroes out a container-marked forced flag that previously survived. An external `.mks`/`.mkv` loaded as a subtitle whose tracks are flagged forced in the container loses its forced status (and the `forced` track-list property and the forced-aware selection in `compare_track` at loadfile.c:489) unless the filename happens to contain "forced". Preserve the container value when no explicit flag was given, e.g. `t->forced_track = flags & TRACK_FORCED | stream->forced_track;`</violation>
</file>
<file name="player/command.c">
<violation number="1" location="player/command.c:6324">
P2: When `nt->lang` is NULL, the filename guess in `cmd_track_reload` clobbers the `forced_track` flag this PR just preserved. `mp_guess_lang_from_filename()` unconditionally executes `if (forced) *forced = false;` (misc/language.c) before parsing the filename, and here it is invoked after `mp_add_external_file()` already applied the preserved `TRACK_FORCED` flag (player/loadfile.c sets `t->forced_track = flags & TRACK_FORCED`). So for any external subtitle with no language tag and no "forced" keyword in its name that was explicitly flagged via `sub-add ... forced=yes`, `sub-reload` silently drops the forced property. The intent of line 6308 (`flags |= t->forced_track ? TRACK_FORCED : 0;`) and the new `forced` sub-add flag is defeated. Pass the guess result into a temporary and OR it with the preserved value instead of writing `&nt->forced_track` directly.</violation>
</file>
```
</details>
<sub>Reply with feedback, questions, or to request a fix.<br /><br />[Re-trigger cubic](https://www.cubic.dev/action/re-review/pr/drape-io/crbench-cubic-2026-09/107/ai_pr_review_github_delivery_01e7b881721584744c9fd79001810c34be7cc48bf73a2f0df1c96f8cce36312e?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F107)</sub>
<!-- cubic:review-post:ai_pr_review_github_delivery_01e7b881721584744c9fd79001810c34be7cc48bf73a2f0df1c96f8cce36312e:624ae59d30b3a4c9fc38d9bed72b77b544b98e76:c2267d3b-75e7-5edb-a522-3c8032d53aae -->
cursor · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | medium | ✗ | — |
add_stream_track sets .forced_track = stream->forced_track, then the new line overwrites it with flags & TRACK_FORCED, so external containers with forced tracks lose the flag unless +forced is passed; previously preserved. [grounded: diff] [consensus 5/5: valid=5]
cmd_track_reload now passes &nt->forced_track to mp_guess_lang_from_filename, which unconditionally resets it to false, so reloading a track with no lang loses the forced flag set from flags (or the container) unless the filename has a .forced tag. [grounded: tree misc/language.c] [consensus 5/5: valid=5]
raw comments (3)
### Container forced flag overwritten
**Medium Severity**
<!-- DESCRIPTION START -->
`t->forced_track` is assigned from `flags` after `add_stream_track` already copied the container value. External files whose container marks a track forced (`.mks` / `sub-add` of an mkv) lose that flag unless `TRACK_FORCED` is also passed, so auto-selection can pick the wrong subtitle.
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: 565189ba-04ee-42a7-bf6a-54c89c0d5e59 -->
<!-- LOCATIONS START
player/loadfile.c#L919-L920
LOCATIONS END -->
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjhjM2I1MDNmLTYxYTktNDMwMS05ODdmLWZkZmQ0ZDEzNjcwZiIsImVuY3J5cHRpb25LZXkiOiJUTGJOaVZCVENHN1hHTEUtdXVWR2lZM3NweFZJZ09wc19HSEpVSFZLTmdnIiwiYnJhbmNoIjoicHItZjA2NzEyZjE1ZiIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjhjM2I1MDNmLTYxYTktNDMwMS05ODdmLWZkZmQ0ZDEzNjcwZiIsImVuY3J5cHRpb25LZXkiOiJUTGJOaVZCVENHN1hHTEUtdXVWR2lZM3NweFZJZ09wc19HSEpVSFZLTmdnIiwiYnJhbmNoIjoicHItZjA2NzEyZjE1ZiIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjEwNywiY29tbWl0U2hhIjoiNDU2ZDcwYzY1M2QyODYxNDAyNDlhM2FhOTU3NGU5N2JlNzIxZTAzYiIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>
<sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 456d70c653d286140249a3aa9574e97be721e03b. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
### Reload clears forced track flag
**Medium Severity**
<!-- DESCRIPTION START -->
`sub-reload` preserves `TRACK_FORCED` when re-adding the file, then `mp_guess_lang_from_filename` is given `&nt->forced_track`. That helper always writes `false` first, so a track marked forced only via `sub-add` `+forced` loses the flag whenever the file has no language (typical for `.srt`/`.ass`).
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: c9e146ee-bc05-44b4-9adf-29545bc4859a -->
<!-- LOCATIONS START
player/command.c#L6321-L6325
LOCATIONS END -->
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmVjNDVjMDZiLWIxZDctNDAzYi1hYmQ1LTNlNzY5Y2UxZTRjMSIsImVuY3J5cHRpb25LZXkiOiJEamJ1bGIyaEhOaDBYbm1KeEJDV2cwZFRrc3RtdU1DOHlEZmdlU1I5SzZVIiwiYnJhbmNoIjoicHItZjA2NzEyZjE1ZiIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmVjNDVjMDZiLWIxZDctNDAzYi1hYmQ1LTNlNzY5Y2UxZTRjMSIsImVuY3J5cHRpb25LZXkiOiJEamJ1bGIyaEhOaDBYbm1KeEJDV2cwZFRrc3RtdU1DOHlEZmdlU1I5SzZVIiwiYnJhbmNoIjoicHItZjA2NzEyZjE1ZiIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjEwNywiY29tbWl0U2hhIjoiNDU2ZDcwYzY1M2QyODYxNDAyNDlhM2FhOTU3NGU5N2JlNzIxZTAzYiIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>
<sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 456d70c653d286140249a3aa9574e97be721e03b. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- BUGBOT_REVIEW -->
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
<!-- BUGBOT_FIX_ALL -->
<a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTo0NjRiNGY1Mi05MWM2LTRlNDgtOTQ0OS03ODVmMGJhM2Y5OWEiLCJlbmNyeXB0aW9uS2V5IjoiY2JvLVNvSy1xRGNuRnN0cFBuTUhEQ3dYbE5ib19LVUZ4X1lZYlNPU0N6ZyIsImJyYW5jaCI6InByLWYwNjcxMmYxNWYiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>
<!-- /BUGBOT_FIX_ALL -->
<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN -->
<sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END -->
<sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 456d70c653d286140249a3aa9574e97be721e03b. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
Drape (Deep Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | medium | ✓ | off by one |
add_stream_track sets `.forced_track = stream->forced_track`. The new line in mp_add_external_file then overwrites it unconditionally. Before this change the container's forced flag survived. Now an external file whose container marks a track forced loses that flag whenever the caller doesn't pass TRACK_FORCED. [grounded: diff] [consensus 3/3: valid=3]
cmd_track_reload passes TRACK_FORCED to mp_add_external_file, so the new track starts out forced. If the track has no lang, the code then calls mp_guess_lang_from_filename, which sets `*forced = false` unless the filename ends in a forced tag. A track added with `sub-add ... forced` therefore loses the flag on reload. [grounded: diff] [consensus 3/3: valid=3]
raw comments (3)
**External files lose their container forced flag**
`add_stream_track` already copies the stream's forced flag, but this line overwrites it with `flags & TRACK_FORCED`. A forced track in an external .mks (or one lavf/EDL marks forced) becomes unforced unless the caller passes the flag. Only set it: `if (flags & TRACK_FORCED) t->forced_track = true;`.
```
player/loadfile.c:920 t->forced_track = flags & TRACK_FORCED;
player/loadfile.c:416 .forced_track = stream->forced_track,
demux/demux_mkv.c:1540 sh->forced_track = track->forced_track;
demux/demux_lavf.c:833 sh->forced_track = true;
player/loadfile.c:486 return t1->forced_track;
player/loadfile.c:487 if (t1->default_track != t2->default_track && !t2->forced_select)
player/loadfile.c:488 return t1->default_track;
player/loadfile.c:489 if (sub && !t2->forced_select && t2->forced_track)
player/loadfile.c:490 return !t1->forced_track;
player/loadfile.c:599 bool forced = track->forced_track && (opts->subs_fallback_forced == 2 ||
```
**Reload drops forced flag on tracks without lang**
When the reloaded track has no language, `mp_guess_lang_from_filename` resets `nt->forced_track` to false. A track added with `sub-add ... forced` loses the flag on reload unless its filename ends in `.forced`. Guess into a local bool and only set `nt->forced_track` when it is true.
```
player/command.c:6323 bstr lang = mp_guess_lang_from_filename(bstr0(nt->external_filename), NULL,
player/command.c:6324 &nt->hearing_impaired_track, &nt->forced_track);
misc/language.c:310 if (forced)
misc/language.c:311 *forced = false;
player/command.c:6308 flags |= t->forced_track ? TRACK_FORCED : 0;
```
**Combined sdh+forced tags give language "sdh"**
Only one tag is skipped because `checked_tag` is set after the first match. In a name like `movie.en.sdh.forced.srt`, `forced` is consumed and then `sdh` is taken as the language code. Let the hi tag and the forced tag each be checked once, rather than sharing a single `checked_tag`.
```
misc/language.c:340 if (i >= 0 && lang_length >= 2 && !checked_tag && name.start[i] == delimiter) {
misc/language.c:341 checked_tag = true;
misc/language.c:342 static const char *const suffixes[] = { "sdh", "hi", "cc" };
misc/language.c:343 bstr tag = { name.start + i + 1, lang_length };
misc/language.c:344 for (int n = 0; n < MP_ARRAY_SIZE(suffixes); n++) {
misc/language.c:345 if (!bstrcasecmp0(tag, suffixes[n])) {
misc/language.c:346 *hi = true;
misc/language.c:347 break;
misc/language.c:348 }
misc/language.c:349 }
```
Drape (Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | medium | ✓ | off by one |
mp_add_external_file sets nt->forced_track from the TRACK_FORCED flag. The language guess then resets *forced = false and only sets it again for a 'forced' tag, so the restored flag is erased when the track has no language and the filename has no forced tag. [grounded: diff] [consensus 3/3: valid=3]
Before this change, add_stream_track's .forced_track = stream->forced_track was kept for external files. Now it is overwritten by the flags, so a container-forced external stream loaded without the TRACK_FORCED flag loses its forced status. That is a behaviour change that affects automatic track selection. [grounded: diff] [consensus 3/3: valid=3]
raw comments (3)
**track-reload resets forced flag when no lang**
In `cmd_track_reload`, when the track has no `lang`, `mp_guess_lang_from_filename` always writes `false` into `nt->forced_track`. That erases the flag just restored, if the filename has no `.forced` tag. Guess into temporaries and OR them in, or pass NULL for the flag outputs.
```
player/command.c:6308 flags |= t->forced_track ? TRACK_FORCED : 0;
player/command.c:6323 bstr lang = mp_guess_lang_from_filename(bstr0(nt->external_filename), NULL,
player/command.c:6324 &nt->hearing_impaired_track, &nt->forced_track);
misc/language.c:310 if (forced)
```
**External file's own forced flag gets overwritten**
`mp_add_external_file` now assigns `t->forced_track = flags & TRACK_FORCED`, replacing the forced flag that `add_stream_track` copied from the container stream. An external subtitle file whose stream is already marked forced loses that flag unless the caller passes `forced`. Only set it when the flag is present: `t->forced_track |= flags & TRACK_FORCED;`.
```
player/loadfile.c:920 t->forced_track = flags & TRACK_FORCED;
player/loadfile.c:416 .forced_track = stream->forced_track,
player/loadfile.c:486 return t1->forced_track;
player/loadfile.c:487 if (t1->default_track != t2->default_track && !t2->forced_select)
player/loadfile.c:488 return t1->default_track;
player/loadfile.c:489 if (sub && !t2->forced_select && t2->forced_track)
player/loadfile.c:490 return !t1->forced_track;
```
**Second filename tag is read as language**
With two tags, as in `movie.en.sdh.forced.srt`, only the last one is stripped because `checked_tag` lets the tag check run once. The next tag (`sdh`) is then taken as the language and the hearing-impaired flag is dropped. Fix: loop the tag check so it strips every trailing sdh/hi/cc/forced tag.
```
misc/language.c:332 bool checked_tag = false;
misc/language.c:340 if (i >= 0 && lang_length >= 2 && !checked_tag && name.start[i] == delimiter) {
misc/language.c:341 checked_tag = true;
misc/language.c:350 if (!bstrcasecmp0(tag, "forced")) {
```
greptile · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | medium | ✓ | off by one |
The diff adds a fourth `forced` parameter to the function. The unchanged test macro still calls it with three arguments, so in C the language test no longer compiles (too few arguments). [grounded: tree test/language.c] [consensus 3/3: valid=3]
cmd_track_reload restores TRACK_FORCED, which sets nt->forced_track. When nt->lang is NULL, it then passes &nt->forced_track to mp_guess_lang_from_filename, which sets `*forced = false` unless the filename has a 'forced' tag. So a track added with the forced flag loses it on reload. [grounded: diff] [consensus 3/3: valid=3]
raw comments (4)
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Language Test No Longer Compiles**
`mp_guess_lang_from_filename` now requires a fourth `forced` argument, but the compiled language unit test still calls it with three arguments. The `language` test target therefore fails to compile with a “too few arguments” error.
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Reload Clears Forced Metadata**
When an external subtitle such as `movie.ass` has no embedded or filename-derived language, reloading first restores its `TRACK_FORCED` flag but then passes that field to `mp_guess_lang_from_filename`. The parser unconditionally resets it to false unless the filename contains `forced`, so `sub-reload` makes an explicitly forced track lose its forced-selection metadata.
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Combined Subtitle Tags Misparse**
The parser recognizes only one trailing metadata tag because `checked_tag` remains true after the first tag is removed. A forced SDH file such as `movie.en.sdh.forced.srt` is reported with language `sdh` and no hearing-impaired flag, while `movie.en.forced.sdh.srt` returns no language and misses the forced flag. Depending on tag order, this breaks language matching or forced-subtitle selection.
<!-- greptile_summary -->
<h2><a href="https://app.greptile.com/api/retrigger?id=66790245"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a>Confidence Score: 2/5</h2>
The PR is not safe to merge because it breaks the language test build and can lose or misparse forced-subtitle metadata in normal reload and filename-discovery paths.
<h2>Findings</h2>
1. <img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"> **Language Test No Longer Compiles** <a href="https://github.com/drape-io/crbench-greptile-2026-09/pull/107#discussion_r4059121523">▶</a>
2. <img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"> **Reload Clears Forced Metadata** <a href="https://github.com/drape-io/crbench-greptile-2026-09/pull/107#discussion_r4059121525">▶</a>
3. <img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"> **Combined Subtitle Tags Misparse** <a href="https://github.com/drape-io/crbench-greptile-2026-09/pull/107#discussion_r4059121528">▶</a>
<h3>Summary</h3>
This PR adds forced-subtitle metadata to explicit subtitle addition, filename-based external subtitle discovery, track reloads, and documentation.
- Adds the `forced` flag to `sub-add`.
- Detects `forced` in external subtitle filenames.
- Propagates forced metadata into track selection and reload paths.
- Currently leaves the language test target uncompilable and mishandles reload and multi-tag filename cases.
<details open><summary>Diagram</summary>
```mermaid
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Command["sub-add forced flag"] --> Flags["TRACK_FORCED"]
Filename["External subtitle filename"] --> Parser["Language/tag parser"]
Parser --> Flags
Flags --> Add["mp_add_external_file"]
Add --> Track["track.forced_track"]
Track --> Selection["Subtitle selection"]
Track --> Reload["sub-reload"]
Reload --> Parser
```
</details>
<sub>Reviews (1) · Last reviewed commit: ["Update DOCS/interface-changes/forced.txt..."](https://github.com/drape-io/crbench-greptile-2026-09/commit/8f345dc18efd2e80abfd9c36599bc4e6ddd24fa9)</sub>
Mjolnir (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | medium | ✗ | — |
The signature gained a fourth parameter, but the test macro still passes three arguments, so the test build fails to compile. [grounded: tree test/language.c] [consensus 3/3: valid=3]
add_stream_track sets forced_track from stream->forced_track. The new line overwrites that value unconditionally, so external files whose container marks them forced lose the flag. [grounded: diff] [consensus 3/3: valid=3]
mp_guess_lang_from_filename first sets *forced = false, so a reloaded track with no lang loses the forced flag that was just passed back in through TRACK_FORCED. [grounded: diff] [consensus 3/3: valid=3]
Duplicate of finding 0: the test caller still uses the old 3-argument signature, so the test build fails to compile. [grounded: tree test/language.c] [consensus 3/3: valid=3]
Duplicate of finding 1: the container's forced flag, set by add_stream_track, is overwritten. [grounded: diff] [consensus 3/3: valid=3]
Duplicate of finding 2: sub-reload clears the forced flag because the guess function resets *forced to false. [grounded: diff] [consensus 3/3: valid=3]
raw comments (6)
[P1] The test suite no longer compiles: test/language.c still calls the old 3-argument signature
`mp_guess_lang_from_filename` now takes a fourth `bool *forced` parameter, but the `TEST_LANG_GUESS` macro in `test/language.c:64-65` still calls `mp_guess_lang_from_filename(bstr0(filename), &start, &hearing_impaired)`. Any build with tests enabled (`-Dtests=true`) therefore fails with a "too few arguments" error. The change also adds no test coverage for the new `.forced` filename tag.
[P2] External tracks lose the forced flag their own container sets
`add_stream_track` already initializes `t-›forced_track` from `stream-›forced_track`, which demux_mkv and demux_lavf fill in from the container's forced flag or disposition. The new line `t-›forced_track = flags & TRACK_FORCED;` overwrites that value unconditionally. An external file marked forced inside its own container (for example an external .mks/.mkv subtitle with FlagForced set) is now reported as not forced unless the caller also passes `TRACK_FORCED`. Before this change that flag was kept, so this regresses forced-subtitle auto-selection (`subs_fallback_forced`, matching-audio logic) for such files. OR-ing the flag in (`t-›forced_track |= ...`) would preserve the container value.
[P3] sub-reload clears the user-supplied forced flag when the track has no language
`cmd_track_reload` correctly passes `TRACK_FORCED` to `mp_add_external_file`. However, when the reloaded track has no language, it then passes `&nt-›forced_track` to `mp_guess_lang_from_filename`, and that function's first step is `*forced = false`. A track added with `sub-add file.srt select title "" forced` and no language in its filename therefore loses the forced flag after `sub-reload`, even though the flag was just passed back in.
[P1] Test caller of `mp_guess_lang_from_filename` not updated to the new signature
The signature now takes a fourth `bool *forced` argument, but `test/language.c:64`, inside the `TEST_LANG_GUESS` macro, still calls it with three arguments (`&start, &hearing_impaired`). Builds with tests enabled will fail to compile. Because the test macro wasn't extended, the new `forced` filename detection also has no test coverage.
[P2] External tracks lose their container `forced` flag
`add_stream_track()` already sets `t-›forced_track = stream-›forced_track` from the demuxer, for example from the Matroska FlagForced or the lavf forced disposition. The new line `t-›forced_track = flags & TRACK_FORCED;` overwrites that value unconditionally. Before this change, an external .mks/.mkv or other subtitle file with a forced flag in its container still showed as forced and took part in forced-sub selection. Now it is reset to false unless the filename or a `sub-add` flag says it is forced, which is a regression. OR-ing the flag into the existing value would avoid this.
[P3] `sub-reload` can clear a forced flag set by the user
`cmd_track_reload` carries `TRACK_FORCED` over to the new track. But when the reloaded track has no `lang`, which is common for srt/ass files, it then calls `mp_guess_lang_from_filename(..., &nt-›forced_track)`, and that function sets `*forced = false` first. So after `sub-add file.srt select "" "" forced`, a `sub-reload` silently drops the forced flag whenever the filename has no `.forced` tag.
Mjolnir (Sonnet 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | medium | ✗ | — |
The change adds a fourth parameter to mp_guess_lang_from_filename, but the unchanged test/language.c macro still calls it with three arguments. That is a compile error in the test build. [grounded: tree test/language.c] [consensus 3/3: valid=3]
Same issue: the signature change in misc/language.h leaves TEST_LANG_GUESS passing too few arguments, so the test build breaks. [grounded: tree test/language.c] [consensus 3/3: valid=3]
raw comments (2)
[P2] Unit test still calls the old 3-argument signature
`mp_guess_lang_from_filename` now takes a fourth `bool *forced` parameter, but the `TEST_LANG_GUESS` macro in `test/language.c` still passes three arguments. This is a compile error whenever the tests are built (`-Dtests=true`), so the `language` unit test no longer compiles. The test also has no cases for the new `.forced.` filename detection.
[P1] Unit test still calls the old 3-argument signature
`mp_guess_lang_from_filename` now takes a fourth `bool *forced` argument, but the `TEST_LANG_GUESS` macro in `test/language.c` still passes three arguments (`bstr0(filename), &start, &hearing_impaired`). That file is not touched by this change. When mpv is configured with tests enabled (`-Dtests=true`), `test/language.c` fails to compile with "too few arguments to function call", which breaks the test build. The macro needs the extra argument. It would also be worth adding cases for the new `.forced` filename suffix.
qodo · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | medium | ✗ | — |
The diff adds a required fourth `bool *forced` parameter to mp_guess_lang_from_filename. test/language.c (unchanged) still calls it with only three arguments (name, &start, &hearing_impaired), so the test no longer compiles. The finding says "four" vs "five" arguments, but that miscount does not change the failure. [grounded: tree test/language.c] [consensus 3/3: valid=3]
Reload now carries TRACK_FORCED into the new track. But when nt->lang is unset, it passes &nt->forced_track to mp_guess_lang_from_filename, which first does `*forced = false` and sets it true only for a 'forced' filename tag. So a subtitle added with the forced flag loses that flag on reload if its filename has no forced suffix. [grounded: diff] [consensus 3/3: valid=3]
raw comments (4)
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required">
1\. Language tests no longer compile <code>🐞 Bug</code> <code>≡ Correctness</code>
<pre>
<b><i>mp_guess_lang_from_filename</i></b> now requires a fifth <b><i>forced</i></b> argument, but its test caller retains
the four-argument invocation. Meson builds <b><i>test/language.c</i></b> as the <b><i>language</i></b> test executable, so
compiling the test suite fails with too few arguments.
</pre>
<details>
<summary><strong>Agent Prompt</strong></summary>
```
## Issue description
The filename-language parser gained a required `forced` output argument, but the language test still calls it with the old signature and therefore cannot compile.
## Fix Focus Areas
- test/language.c[58-68]
- misc/language.h[28-28]
## Recommended Fix
Extend `TEST_LANG_GUESS` with an expected forced value, declare a `forced` boolean, pass its address to `mp_guess_lang_from_filename`, and assert the result. Update every test invocation and add forced-filename cases.
```
<code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>
</details>
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required">
2\. Reload clears explicit forced status <code>🐞 Bug</code> <code>≡ Correctness</code>
<pre>
<b><i>cmd_track_reload</i></b> passes <b><i>nt->forced_track</i></b> directly to <b><i>mp_guess_lang_from_filename</i></b>, whose
initialization unconditionally resets that output to false. Reloading a forced external subtitle
without a recognized forced filename suffix therefore discards the flag preserved through
<b><i>TRACK_FORCED</i></b>, affecting subsequent forced-track selection.
</pre>
<details>
<summary><strong>Agent Prompt</strong></summary>
```
## Issue description
Track reload preserves `TRACK_FORCED` while recreating the track, but subsequent filename inference overwrites the restored value with false when the filename lacks a forced suffix.
## Fix Focus Areas
- player/command.c[6303-6325]
- misc/language.c[307-311]
## Recommended Fix
Parse inferred hearing-impaired and forced values into temporary booleans, then OR those values into the recreated track fields instead of passing the fields directly as resettable parser outputs.
```
<code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>
</details>
<h3>PR Summary by Qodo</h3>
Detect and propagate forced external subtitle tracks
<code>✨ Enhancement</code> <code>📝 Documentation</code> <code>🕐 20-40 Minutes</code>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<details>
<summary>AI Description</summary>
<dl>
<dd>
<br/>
><pre>
>• Detect forced subtitle markers in external filenames during autoloading.
>• Propagate forced status through track creation, reload, and selection metadata.
>• Expose and document the forced flag for sub-add.
></pre>
</dd>
</dl>
</details>
<details>
<summary>Diagram</summary>
<dl>
<dd>
<br/>
```mermaid
graph TD
A["Subtitle filename"] --> B["Language parser"] --> C["External discovery"] --> D["Track flags"] --> E["Track metadata"] --> F["Subtitle selection"]
G["sub-add command"] --> D
H["Track reload"] --> D
```
</dd>
</dl>
</details>
<details>
<summary>High-Level Assessment</summary>
<dl>
<dd>
<br/>
>The following are alternative approaches to this PR:
<details>
<summary><b>1. Return parsed filename metadata struct</b></summary>
<dl>
<dd>
- ➕ Avoids continued growth of optional output parameters
- ➕ Groups language and subtitle attributes into one extensible result
- ➕ Makes parser expectations easier to express in tests
- ➖ Requires a broader API and caller refactor
- ➖ Adds unnecessary churn for one additional attribute
</dd>
</dl>
</details>
>**Recommendation:** The current centralized filename detection and track-flag propagation is the best low-churn approach and matches existing hearing-impaired handling. Before merging, update test/language.c for the new function signature and add forced-filename cases; a result struct is worth considering only if more filename-derived attributes are expected.
</dd>
</dl>
</details>
<details>
<summary> Files changed (9) <code> +29 / -9 </code> </summary>
<dl>
<dd>
<br/>
<details>
<summary>Enhancement (7) <code> +24 / -9 </code></summary>
<dl>
<dd>
<details>
<summary>language.c<code>Infer forced status from subtitle filenames</code> <code>+12/-5</code></summary>
<br/>
>Infer forced status from subtitle filenames
>
><pre>
>• Extends filename language inference with an optional forced-status output. A trailing forced marker is recognized and excluded before parsing the preceding language tag.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/107/files#diff-c59775d5293500ee2903ad4e6de40827b58abb9e5bf2b944ca406444d4300490'>misc/language.c</a>
</details>
<details>
<summary>language.h<code>Expose forced output from filename inference</code> <code>+1/-1</code></summary>
<br/>
>Expose forced output from filename inference
>
><pre>
>• Adds the optional forced-status output parameter to the filename language parser declaration.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/107/files#diff-24befdbf8452cc552465d265462312b1e11f8445f1fb83427d170a8006c8420f'>misc/language.h</a>
</details>
<details>
<summary>command.c<code>Support and preserve forced command flags</code> <code>+4/-2</code></summary>
<br/>
>Support and preserve forced command flags
>
><pre>
>• Adds forced to track-add command flags, preserves it during track reloads, and captures forced status inferred from reloaded filenames.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/107/files#diff-830516050a5bf883d9c265fa0cf3c5b59d23d8bc9e6dec63db3d3d9b9868bb6b'>player/command.c</a>
</details>
<details>
<summary>core.h<code>Define the forced track creation flag</code> <code>+1/-0</code></summary>
<br/>
>Define the forced track creation flag
>
><pre>
>• Adds TRACK_FORCED to the track flag bitmask used when creating external tracks.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/107/files#diff-b275878eaae7558635dd1accf26c2ecf23a94d32383f9c7f14f97b9f02ff1f4e'>player/core.h</a>
</details>
<details>
<summary>external_files.c<code>Capture forced metadata during subtitle discovery</code> <code>+3/-1</code></summary>
<br/>
>Capture forced metadata during subtitle discovery
>
><pre>
>• Requests forced-status inference while scanning external subtitle filenames and stores the result in each discovered subtitle record.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/107/files#diff-63b1932499d24180f56bfe6861d751bfdab05d80cab4024bad10ded210e862da'>player/external_files.c</a>
</details>
<details>
<summary>external_files.h<code>Store forced status on discovered subtitles</code> <code>+1/-0</code></summary>
<br/>
>Store forced status on discovered subtitles
>
><pre>
>• Extends external subtitle discovery records with a forced boolean.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/107/files#diff-7a01ea6faae19b50655dea25a8ef12d763e0a0bd548beaded0788c6ea8227493'>player/external_files.h</a>
</details>
<details>
<summary>loadfile.c<code>Apply forced metadata to loaded tracks</code> <code>+2/-0</code></summary>
<br/>
>Apply forced metadata to loaded tracks
>
><pre>
>• Maps TRACK_FORCED onto track metadata during external track creation. Autoloaded subtitle records now pass their inferred forced status into the creation flags.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/107/files#diff-4f48c8482f05d304fcb498577e82e4db5049cf650e20e7bc1493a0e84457960a'>player/loadfile.c</a>
</details>
</dd>
</dl>
</details>
<details>
<summary>Documentation (2) <code> +5 / -0 </code></summary>
<dl>
<dd>
<details>
<summary>forced.txt<code>Record the new sub-add forced flag</code> <code>+1/-0</code></summary>
<br/>
>Record the new sub-add forced flag
>
><pre>
>• Adds an interface-change entry announcing forced flag support for the sub-add command.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/107/files#diff-61ff81cc448044a918f389de196584a995c21f2d75ccddc36afc349f341bb0dd'>DOCS/interface-changes/forced.txt</a>
</details>
<details>
<summary>input.rst<code>Document forced subtitles in sub-add</code> <code>+4/-0</code></summary>
<br/>
>Document forced subtitles in sub-add
>
><pre>
>• Documents the forced track flag and limits its stated use to sub-add.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/107/files#diff-90bc0869e160b0aa66c4ffa2f6fe990f25f295275509058188749eaed873d280'>DOCS/man/input.rst</a>
</details>
</dd>
</dl>
</details>
</dd>
</dl>
</details>
<h3>Code Review by Qodo</h3>
<code>🐞 Bugs (2)</code> <code>📘 Rule violations (0)</code> <code>📜 Skill insights (0)</code>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<br/>
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required">
<details>
<summary> 1. Language tests no longer compile <code>🐞 Bug</code> <code>≡ Correctness</code></summary>
<br/>
> <details open>
><summary>Description</summary>
><br/>
>
><pre>
><b><i>mp_guess_lang_from_filename</i></b> now requires a fifth <b><i>forced</i></b> argument, but its test caller retains
>the four-argument invocation. Meson builds <b><i>test/language.c</i></b> as the <b><i>language</i></b> test executable, so
>compiling the test suite fails with too few arguments.
></pre>
></details>
> <details>
><summary>Code</summary>
><br/>
>
><code>[misc/language.h[28]](https://github.com/drape-io/crbench-qodo-2026-09/pull/107/files#diff-24befdbf8452cc552465d265462312b1e11f8445f1fb83427d170a8006c8420fR28-R28)</code>
>
>```diff
>+bstr mp_guess_lang_from_filename(bstr name, int *lang_start, bool *hearing_impaired, bool *forced);
>```
></details>
> <details>
><summary>Evidence</summary>
><br/>
>
><pre>
>The public declaration requires five arguments, while the test macro supplies only four; Meson
>unconditionally compiles that source into a test executable.
></pre>
>
> <code>[misc/language.h[28-28]](https://github.com/drape-io/crbench-qodo-2026-09/blob/b20fe1bde275bb7adc1a63254b3618ba4ab61ce5/misc/language.h/#L28-L28)</code>
> <code>[test/language.c[58-68]](https://github.com/drape-io/crbench-qodo-2026-09/blob/b20fe1bde275bb7adc1a63254b3618ba4ab61ce5/test/language.c/#L58-L68)</code>
> <code>[test/meson.build[105-106]](https://github.com/drape-io/crbench-qodo-2026-09/blob/b20fe1bde275bb7adc1a63254b3618ba4ab61ce5/test/meson.build/#L105-L106)</code>
></details>
> <details>
><summary>Agent prompt</summary>
><br/>
>
>```
>The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
>
>## Issue description
>The filename-language parser gained a required `forced` output argument, but the language test still calls it with the old signature and therefore cannot compile.
>
>## Fix Focus Areas
>- test/language.c[58-68]
>- misc/language.h[28-28]
>
>## Recommended Fix
>Extend `TEST_LANG_GUESS` with an expected forced value, declare a `forced` boolean, pass its address to `mp_guess_lang_from_filename`, and assert the result. Update every test invocation and add forced-filename cases.
>```
> <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>
></details>
<hr/>
</details>
<details>
<summary> 2. Reload clears explicit forced status <code>🐞 Bug</code> <code>≡ Correctness</code></summary>
<br/>
> <details open>
><summary>Description</summary>
><br/>
>
><pre>
><b><i>cmd_track_reload</i></b> passes <b><i>nt->forced_track</i></b> directly to <b><i>mp_guess_lang_from_filename</i></b>, whose
>initialization unconditionally resets that output to false. Reloading a forced external subtitle
>without a recognized forced filename suffix therefore discards the flag preserved through
><b><i>TRACK_FORCED</i></b>, affecting subsequent forced-track selection.
></pre>
></details>
> <details>
><summary>Code</summary>
><br/>
>
><code>[player/command.c[6324]](https://github.com/drape-io/crbench-qodo-2026-09/pull/107/files#diff-830516050a5bf883d9c265fa0cf3c5b59d23d8bc9e6dec63db3d3d9b9868bb6bR6324-R6324)</code>
>
>```diff
>+ &nt->hearing_impaired_track, &nt->forced_track);
>```
></details>
> <details>
><summary>Evidence</summary>
><br/>
>
><pre>
>Reload first copies the old forced state into <b><i>TRACK_FORCED</i></b>, and <b><i>mp_add_external_file</i></b> restores
>it, but the changed parser call then targets the restored field directly while the parser begins by
>assigning false to it.
></pre>
>
> <code>[player/command.c[6303-6324]](https://github.com/drape-io/crbench-qodo-2026-09/blob/b20fe1bde275bb7adc1a63254b3618ba4ab61ce5/player/command.c/#L6303-L6324)</code>
> <code>[player/loadfile.c[917-922]](https://github.com/drape-io/crbench-qodo-2026-09/blob/b20fe1bde275bb7adc1a63254b3618ba4ab61ce5/player/loadfile.c/#L917-L922)</code>
> <code>[misc/language.c[307-311]](https://github.com/drape-io/crbench-qodo-2026-09/blob/b20fe1bde275bb7adc1a63254b3618ba4ab61ce5/misc/language.c/#L307-L311)</code>
></details>
> <details>
><summary>Agent prompt</summary>
><br/>
>
>```
>The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
>
>## Issue description
>Track reload preserves `TRACK_FORCED` while recreating the track, but subsequent filename inference overwrites the restored value with false when the filename lacks a forced suffix.
>
>## Fix Focus Areas
>- player/command.c[6303-6325]
>- misc/language.c[307-311]
>
>## Recommended Fix
>Parse inferred hearing-impaired and forced values into temporary booleans, then OR those values into the recreated track fields instead of passing the fields directly as resettable parser outputs.
>```
> <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>
></details>
<hr/>
</details>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<!-- qodo-context:start -->
<details><summary><strong>Context sources</strong></summary>
<div>Review mode: <code>⚖️ Balanced</code>: This behavioral C change adds forced-subtitle parsing and propagates the flag across multiple track-loading and reload paths, warranting a complete single-pass review.</div>
<!-- qodo-context:end -->
</details>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<!-- qodo-daily-tip:start -->
<details>
<summary><strong>Tip of the day</strong></summary>
<br/>
<pre>💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR</pre>
<a href="https://docs.qodo.ai/tips-and-tricks">More tips ↗</a> | <a href="https://app.qodo.ai/configurations?tab=display-preferences">Customize Qodo ↗</a> | <a href="https://docs.qodo.ai">Qodo docs ↗</a>
</details>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<!-- qodo-daily-tip:end -->
<!-- https://github.com/drape-io/crbench-qodo-2026-09/commit/b20fe1bde275bb7adc1a63254b3618ba4ab61ce5 -->
<a href="https://www.qodo.ai"><img src="https://www.qodo.ai/wp-content/uploads/2025/03/qodo-logo.svg" width="80" alt="Qodo Logo"></a>