From 11e6481b58b7b23685f84707f72ec58bf5168e84 Mon Sep 17 00:00:00 2001 From: Chandragupt Singh Date: Fri, 24 Jul 2026 14:03:22 +0530 Subject: [PATCH 1/2] fix(report): probe both EIA-608 fields in --out report so CC3/CC4 are reported accurately (#2177) Issue: `--out report` reported CC3/CC4 as "No" even when the stream carried captions on EIA-608 field 2 (CC3/CC4 live on field 2), so the report was inaccurate for field-2 sources. Root cause: options->extract defaults to 1 (field 1 only, ccx_common_option.c:28). The report path never changed it, so the decoder's field gate (ccx_decoders_608.c, field 2 processed only when extract == 2 || extract == 12) skipped field 2 and CC3/CC4 presence was never probed. Fix: Set extract = 12 (both fields) in the OutFormat::Report arm (parser.rs). Kept scoped by two details: - Explicit --output-field still wins: the report arm runs during set_output_format, and --output-field is parsed afterwards and overwrites extract, so field selection is honoured regardless of CLI flag order. - The "both fields to stdout" broadcast-mode guard is bypassed only for report mode (added `&& !print_file_reports`). Report uses write_format = Null, so there is no real caption stream to stdout; normal extraction is unaffected. 13 lines, Rust-only (src/rust/src/parser.rs). extract is not changed for any non-report invocation. Before (cc3.ts): CC3: No -> After: CC3: Yes (CC1/CC2/CC4 unchanged) Reproduce: ffmpeg -i "https://weather.horse/samples/cc3.mkv" -c copy cc3.ts -y ccextractor --out report cc3.ts Testing: - report -> CC3 Yes; --output-field 1 override -> CC3 No; both -> Yes. - --out report --stdout and --out report --output-field both --stdout: report printed, no fatal. Normal --output-field both --stdout still rejected (exit 4). - Flag order irrelevant (`-1 --out report` == `--out report -1`). - Normal / -1 / -2 / both extraction unchanged (exit 0, expected output files). - C-side extract==12 encoder branches are inert in report mode: generates_file=0 for CCX_OF_NULL (verified: `--out report -o out.srt` creates no files) and encode_sub has no CCX_OF_NULL case. - parser:: unit tests 204/204, incl. test_out_report_enables_file_reports (asserts extract == 12) and test_out_report_explicit_field_overrides_both. --- src/rust/src/parser.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/rust/src/parser.rs b/src/rust/src/parser.rs index 0f7898d15..a7639de2f 100644 --- a/src/rust/src/parser.rs +++ b/src/rust/src/parser.rs @@ -204,6 +204,9 @@ impl OptionsExt for Options { self.messages_target = OutputTarget::Quiet; self.print_file_reports = true; self.demux_cfg.ts_allprogram = true; + // Probe both EIA-608 fields so CC3/CC4 presence is reported accurately (issue #2177). + // Runs before --output-field parsing, so an explicit field choice still overrides this. + self.extract = 12; } OutFormat::Raw => self.write_format = OutputFormat::Raw, OutFormat::Smptett => self.write_format = OutputFormat::SmpteTt, @@ -1573,6 +1576,7 @@ impl OptionsExt for Options { && self.cc_to_stdout && self.extract != 0 && self.extract == 12 + && !self.print_file_reports { fatal!( cause = ExitCause::IncompatibleParameters; @@ -1918,6 +1922,15 @@ pub mod tests { assert_eq!(options.write_format, OutputFormat::Null); assert!(options.print_file_reports); assert!(options.demux_cfg.ts_allprogram); + // issue #2177: report mode probes both fields by default + assert_eq!(options.extract, 12); + } + + #[test] + fn test_out_report_explicit_field_overrides_both() { + let (options, _) = parse_args(&["--out", "report", "--output-field", "1"]); + assert!(options.print_file_reports); + assert_eq!(options.extract, 1); } // ========================================================================= From e7815ac094021c1f97c444dc50e753763242e5a4 Mon Sep 17 00:00:00 2001 From: Chandragupt Singh Date: Sat, 25 Jul 2026 03:38:57 +0530 Subject: [PATCH 2/2] style(rust): use byte-string literals to satisfy clippy byte_char_slices --- src/rust/src/demuxer/stream_functions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rust/src/demuxer/stream_functions.rs b/src/rust/src/demuxer/stream_functions.rs index 59422725e..e561d1552 100644 --- a/src/rust/src/demuxer/stream_functions.rs +++ b/src/rust/src/demuxer/stream_functions.rs @@ -392,7 +392,7 @@ pub fn detect_myth(ctx: &mut CcxDemuxer) -> i32 { uc.copy_from_slice(&ctx.startbytes[..3]); for &byte in &ctx.startbytes[3..ctx.startbytes_avail as usize] { - if (uc == [b't', b'v', b'0']) || (uc == [b'T', b'V', b'0']) { + if (uc == *b"tv0") || (uc == *b"TV0") { vbi_blocks += 1; }