1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! PCR-discontinuity "honor" repair (#562).
//!
//! Unlike [`super::pcr_restamp`] (which rewrites PCR values onto a continuous
//! timeline), honor mode leaves every timestamp byte untouched and instead
//! **marks** a genuine, unflagged PCR break by setting
//! `discontinuity_indicator` in the adaptation-field flags byte
//! (ISO/IEC 13818-1 §2.4.3.5) — turning an unsignalled defect into a legally
//! signalled system-time-base change. All other bytes — including the PCR
//! field itself — are passed through byte-identical.
//!
//! # Detection
//!
//! "Genuine, unflagged break" is determined by
//! [`super::pcr_conformance::PcrDiscDetector`], which reuses
//! `dvb_conformance::ConformanceMonitor`'s ETSI TR 101 290 §5.2.2 indicator
//! 2.3b (`PCR_discontinuity_indicator_error`) check verbatim — the 100 ms
//! threshold is never re-derived here. A packet that already carries
//! `discontinuity_indicator == 1` never raises 2.3b (it is a legal break), so
//! honor mode never touches an already-flagged packet.
//!
//! # Why this is always byte-safe
//!
//! Indicator 2.3b can only fire on a packet that itself carries a PCR (the
//! delta is computed between consecutive PCR values), so the flagged packet
//! always already has an adaptation field with a valid flags byte at offset
//! 5 — setting bit `0x80` there never changes `adaptation_field_length` or
//! shifts any other byte.
//!
//! # Spec
//!
//! ISO/IEC 13818-1 (= ITU-T H.222.0) §2.4.3.5 (`discontinuity_indicator`);
//! ETSI TR 101 290 v1.4.1 §5.2.2, Table 5.0b, indicator 2.3b.
use TS_PACKET_SIZE;
use cratePcrDiscDetector;
use crate;
/// Bit mask for `discontinuity_indicator` in the adaptation field flags byte
/// (ISO/IEC 13818-1 §2.4.3.5), at byte offset 5 of the 188-byte packet.
const AF_DISCONTINUITY: u8 = 0x80;
/// PCR-discontinuity honor operation — flags genuine unflagged breaks without
/// rewriting any timestamp.
pub