Merge branch 'worktree-agent-ace5d5ae90b1dabcc'
Browse files at this commit6 changed files +242 -6
- crates/app/src/export_ui.rs +47 -2
- crates/app/src/player/export.rs +27 -0
- crates/app/src/tests/cards.rs +24 -0
- crates/app/src/ui/cards.rs +13 -4
- crates/engine/src/export.rs +61 -0
- crates/engine/tests/video_copy.rs +70 -0
crates/app/src/export_ui.rsmodified+47 -2
| @@ -72,6 +72,7 @@ pub(crate) fn sample_rate_choices(current: Option<u32>) -> Vec<ChoiceRow> { | |||
| 72 | /// them. | 72 | /// them. |
| 73 | #[derive(Clone, Copy, PartialEq, Debug)] | 73 | #[derive(Clone, Copy, PartialEq, Debug)] |
| 74 | pub(crate) enum Quality { | 74 | pub(crate) enum Quality { |
| 75 | + Exact, | ||
| 75 | Auto, | 76 | Auto, |
| 76 | Low, | 77 | Low, |
| 77 | Medium, | 78 | Medium, |
| @@ -80,7 +81,8 @@ pub(crate) enum Quality { | |||
| 80 | } | 81 | } |
| 81 | 82 | ||
| 82 | impl Quality { | 83 | impl Quality { |
| 83 | - pub(crate) const ALL: [Quality; 5] = [ | 84 | + pub(crate) const ALL: [Quality; 6] = [ |
| 85 | + Quality::Exact, | ||
| 84 | Quality::Auto, | 86 | Quality::Auto, |
| 85 | Quality::Low, | 87 | Quality::Low, |
| 86 | Quality::Medium, | 88 | Quality::Medium, |
| @@ -90,6 +92,7 @@ impl Quality { | |||
| 90 | 92 | ||
| 91 | pub(crate) fn label(self) -> &'static str { | 93 | pub(crate) fn label(self) -> &'static str { |
| 92 | match self { | 94 | match self { |
| 95 | + Quality::Exact => "Exact", | ||
| 93 | Quality::Auto => "Auto", | 96 | Quality::Auto => "Auto", |
| 94 | Quality::Low => "Low", | 97 | Quality::Low => "Low", |
| 95 | Quality::Medium => "Medium", | 98 | Quality::Medium => "Medium", |
| @@ -101,6 +104,12 @@ impl Quality { | |||
| 101 | /// The figure the row stands for, said in the units the row is chosen by. | 104 | /// The figure the row stands for, said in the units the row is chosen by. |
| 102 | pub(crate) fn detail(self, custom_mbps: u32) -> String { | 105 | pub(crate) fn detail(self, custom_mbps: u32) -> String { |
| 103 | match self { | 106 | match self { |
| 107 | + // corner-cut: worded without naming the mechanism (which codec, | ||
| 108 | + // which container) -- DESIGN.md §8 keeps a card's detail line a | ||
| 109 | + // fact about the *output*, not an instruction about how to get | ||
| 110 | + // there; [`exact_refusal`] is where the mechanism's own limits | ||
| 111 | + // are said, once the row has actually been picked. | ||
| 112 | + Quality::Exact => "input quality — copy where cuts allow".to_string(), | ||
| 104 | Quality::Auto => "from the picture size and frame rate".to_string(), | 113 | Quality::Auto => "from the picture size and frame rate".to_string(), |
| 105 | Quality::Custom => { | 114 | Quality::Custom => { |
| 106 | format!("{custom_mbps} Mbps — wheel or ± steps, n types one, {MBPS_MIN}–{MBPS_MAX}") | 115 | format!("{custom_mbps} Mbps — wheel or ± steps, n types one, {MBPS_MIN}–{MBPS_MAX}") |
| @@ -858,12 +867,17 @@ pub(crate) fn export_settings( | |||
| 858 | // has dimmed cannot have been changed. | 867 | // has dimmed cannot have been changed. |
| 859 | audio_kbps: Some(audio_kbps), | 868 | audio_kbps: Some(audio_kbps), |
| 860 | bitrate: match quality { | 869 | bitrate: match quality { |
| 861 | - Quality::Auto => None, | 870 | + // A copied span carries its source's own bits, and a fallback |
| 871 | + // re-encode -- the only case `bitrate` reaches an encoder under | ||
| 872 | + // Exact -- is the automatic figure ([`engine::export::run`]), | ||
| 873 | + // not a preset's, so this asks for neither. | ||
| 874 | + Quality::Exact | Quality::Auto => None, | ||
| 862 | Quality::Low => Some(2_000_000), | 875 | Quality::Low => Some(2_000_000), |
| 863 | Quality::Medium => Some(6_000_000), | 876 | Quality::Medium => Some(6_000_000), |
| 864 | Quality::High => Some(12_000_000), | 877 | Quality::High => Some(12_000_000), |
| 865 | Quality::Custom => Some(u64::from(custom_mbps) * 1_000_000), | 878 | Quality::Custom => Some(u64::from(custom_mbps) * 1_000_000), |
| 866 | }, | 879 | }, |
| 880 | + exact: quality == Quality::Exact, | ||
| 867 | // The card's own row now ([`encoder_choices`]), kept with the project: | 881 | // The card's own row now ([`encoder_choices`]), kept with the project: |
| 868 | // it was a `VE_SW_ENC` env pin and nothing else, which is a switch | 882 | // it was a `VE_SW_ENC` env pin and nothing else, which is a switch |
| 869 | // nobody exporting a film would ever find. | 883 | // nobody exporting a film would ever find. |
| @@ -918,6 +932,37 @@ pub(crate) const MBPS_DIGITS: usize = 3; | |||
| 918 | /// cannot say what the timeline says (`export::copy_audio`), so none of them is | 932 | /// cannot say what the timeline says (`export::copy_audio`), so none of them is |
| 919 | /// a refusal any more -- and every video format carries the sound, so there is | 933 | /// a refusal any more -- and every video format carries the sound, so there is |
| 920 | /// nothing here that is one format's alone. | 934 | /// nothing here that is one format's alone. |
| 935 | +/// Why the Exact row would refuse this project's own picked format right | ||
| 936 | +/// now, asked before the button is pressed rather than minutes into a | ||
| 937 | +/// worker -- [`engine::export::exact_refusal`] is the same gate `start` | ||
| 938 | +/// checks again, so a caller here and the worker can never disagree about | ||
| 939 | +/// whether Exact is honoured. `None` for every quality but `Exact` itself, | ||
| 940 | +/// since nothing else has anything to refuse. | ||
| 941 | +pub(crate) fn exact_refusal(session: &PlaybackSession, format: Format, quality: Quality) -> Option<String> { | ||
| 942 | + if quality != Quality::Exact { | ||
| 943 | + return None; | ||
| 944 | + } | ||
| 945 | + let (project, meta) = session.export_snapshot(); | ||
| 946 | + let settings = export_settings(quality, 0, format, DEFAULT_AUDIO_KBPS, EncoderSeat::Auto); | ||
| 947 | + engine::export::exact_refusal(&project, &meta, &settings) | ||
| 948 | +} | ||
| 949 | + | ||
| 950 | +/// Which format picking Exact should set, from the source's own codec -- | ||
| 951 | +/// "the input's own quality" means the input's own codec, so this is what | ||
| 952 | +/// `Player::pick_quality` derives the format from rather than leaving | ||
| 953 | +/// whatever format a previous pick left behind. `None` for a codec Exact has | ||
| 954 | +/// no copy path for at all (h264); the row itself still refuses through | ||
| 955 | +/// [`exact_refusal`] in that case, since a mixed-source project can fail the | ||
| 956 | +/// same way after the format is set. | ||
| 957 | +pub(crate) fn exact_format(session: &PlaybackSession) -> Option<Format> { | ||
| 958 | + let (_, meta) = session.export_snapshot(); | ||
| 959 | + match meta.codec { | ||
| 960 | + engine::demux::Codec::Hevc => Some(Format::Hevc), | ||
| 961 | + engine::demux::Codec::Av1 => Some(Format::Av1), | ||
| 962 | + _ => None, | ||
| 963 | + } | ||
| 964 | +} | ||
| 965 | + | ||
| 921 | pub(crate) fn format_refusal(session: &PlaybackSession, format: Format) -> Option<String> { | 966 | pub(crate) fn format_refusal(session: &PlaybackSession, format: Format) -> Option<String> { |
| 922 | if !format.has_video() { | 967 | if !format.has_video() { |
| 923 | return None; | 968 | return None; |
crates/app/src/player/export.rsmodified+27 -0
| @@ -502,6 +502,25 @@ impl Player { | |||
| 502 | } | 502 | } |
| 503 | } | 503 | } |
| 504 | 504 | ||
| 505 | + /// A quality row, by click or by its own key (`Custom` goes through | ||
| 506 | + /// [`Self::edit_mbps`] instead). Exact is the one row that is also a | ||
| 507 | + /// format decision -- "the input's own quality" means the input's own | ||
| 508 | + /// codec, so picking it derives the container from the source rather | ||
| 509 | + /// than leaving whatever format a previous pick left behind for | ||
| 510 | + /// [`exact_refusal`] to refuse minutes later. A source this cannot copy | ||
| 511 | + /// (h264, mixed sources) leaves the format alone; the row itself | ||
| 512 | + /// ([`crate::ui::cards`]'s quality list) already says why. | ||
| 513 | + pub(crate) fn pick_quality(&mut self, quality: Quality) { | ||
| 514 | + self.quality = quality; | ||
| 515 | + if quality != Quality::Exact { | ||
| 516 | + return; | ||
| 517 | + } | ||
| 518 | + let Some(format) = self.session.as_ref().and_then(exact_format) else { | ||
| 519 | + return; | ||
| 520 | + }; | ||
| 521 | + self.set_format(format); | ||
| 522 | + } | ||
| 523 | + | ||
| 505 | /// The container row: the same codec in the other box, which retargets the | 524 | /// The container row: the same codec in the other box, which retargets the |
| 506 | /// destination exactly as picking a codec does -- and does nothing at all | 525 | /// destination exactly as picking a codec does -- and does nothing at all |
| 507 | /// for a codec with only one box, so the stroke cannot invent a choice the | 526 | /// for a codec with only one box, so the stroke cannot invent a choice the |
| @@ -726,6 +745,14 @@ impl Player { | |||
| 726 | cx.notify(); | 745 | cx.notify(); |
| 727 | return; | 746 | return; |
| 728 | } | 747 | } |
| 748 | + // Exact asks the same question format_refusal just did, for the same | ||
| 749 | + // reason: the row can be picked, then the cut or the format changed | ||
| 750 | + // under it, and this is the fence with a keystroke to blame. | ||
| 751 | + if let Some(why) = exact_refusal(session, self.format, self.quality) { | ||
| 752 | + self.notify_user(format!("NOT EXPORTED — {why}").into()); | ||
| 753 | + cx.notify(); | ||
| 754 | + return; | ||
| 755 | + } | ||
| 729 | session.pause(); | 756 | session.pause(); |
| 730 | self.export = Some(session.export_to_with(&self.export_path, &settings)); | 757 | self.export = Some(session.export_to_with(&self.export_path, &settings)); |
| 731 | // The clock starts with the worker, not with the first repaint that | 758 | // The clock starts with the worker, not with the first repaint that |
crates/app/src/tests/cards.rsmodified+24 -0
| @@ -1727,6 +1727,30 @@ fn a_preset_over_a_picture_this_timeline_has_none_of_carries_the_codec_refusal() | |||
| 1727 | assert_eq!(format_refusal(&session, audio_format), None); | 1727 | assert_eq!(format_refusal(&session, audio_format), None); |
| 1728 | } | 1728 | } |
| 1729 | 1729 | ||
| 1730 | +/// Picking Exact must derive the container from the source's own codec | ||
| 1731 | +/// rather than leave whatever format was already picked -- an HEVC or AV1 | ||
| 1732 | +/// source lands on its own copy-capable Matroska format, and a source Exact | ||
| 1733 | +/// has no copy path for at all (h264) leaves `exact_format` with nothing to | ||
| 1734 | +/// set, so the row's own [`exact_refusal`] is what a click on it would see. | ||
| 1735 | +#[test] | ||
| 1736 | +fn exact_derives_its_format_from_the_source_codec() { | ||
| 1737 | + let hevc = PlaybackSession::open(asset("test_hevc.mkv")).expect("an hevc fixture"); | ||
| 1738 | + assert_eq!(crate::exact_format(&hevc), Some(Format::Hevc)); | ||
| 1739 | + | ||
| 1740 | + let av1 = PlaybackSession::open(asset("test_av1.mkv")).expect("an av1 fixture"); | ||
| 1741 | + assert_eq!(crate::exact_format(&av1), Some(Format::Av1)); | ||
| 1742 | + | ||
| 1743 | + let h264 = PlaybackSession::open(asset("test_h264.mkv")).expect("an h264 fixture"); | ||
| 1744 | + assert_eq!(h264.export_snapshot().1.codec, engine::demux::Codec::H264); | ||
| 1745 | + assert_eq!(crate::exact_format(&h264), None); | ||
| 1746 | + // No copy path for h264 at any format -- the row's own refusal is what a | ||
| 1747 | + // click on Exact would still show, since `exact_format` sets nothing and | ||
| 1748 | + // the format is left at whatever it already was (Mp4's own refusal, or | ||
| 1749 | + // Hevc's if the pane was left there from an earlier pick). | ||
| 1750 | + assert!(crate::exact_refusal(&h264, Format::Mp4, Quality::Exact).is_some()); | ||
| 1751 | + assert!(crate::exact_refusal(&h264, Format::Hevc, Quality::Exact).is_some()); | ||
| 1752 | +} | ||
| 1753 | + | ||
| 1730 | /// The stacking-scrims bug: opening the speed card while the colour card was | 1754 | /// The stacking-scrims bug: opening the speed card while the colour card was |
| 1731 | /// up left both up at once, because each `open_*` cleared a different | 1755 | /// up left both up at once, because each `open_*` cleared a different |
| 1732 | /// hand-picked subset of the other flags rather than all of them. The fix is | 1756 | /// hand-picked subset of the other flags rather than all of them. The fix is |
crates/app/src/ui/cards.rsmodified+13 -4
| @@ -604,6 +604,14 @@ impl Player { | |||
| 604 | .mbps_edit | 604 | .mbps_edit |
| 605 | .as_ref() | 605 | .as_ref() |
| 606 | .filter(|_| quality == Quality::Custom); | 606 | .filter(|_| quality == Quality::Custom); |
| 607 | + // Exact's own row carries whatever [`exact_refusal`] says of | ||
| 608 | + // the format currently picked, whether or not Exact is the | ||
| 609 | + // row in force -- the same reason `start_export` would give, | ||
| 610 | + // said here instead of only after the button is pressed. | ||
| 611 | + let exact_why = (quality == Quality::Exact) | ||
| 612 | + .then(|| self.session.as_ref()) | ||
| 613 | + .flatten() | ||
| 614 | + .and_then(|s| exact_refusal(s, self.format, quality)); | ||
| 607 | let mut r = entry( | 615 | let mut r = entry( |
| 608 | ("quality", i), | 616 | ("quality", i), |
| 609 | match quality { | 617 | match quality { |
| @@ -611,9 +619,10 @@ impl Player { | |||
| 611 | _ => "q", | 619 | _ => "q", |
| 612 | }, | 620 | }, |
| 613 | quality.label().into(), | 621 | quality.label().into(), |
| 614 | - match field { | 622 | + match (&exact_why, field) { |
| 615 | - Some(edit) => edit.detail().into(), | 623 | + (Some(why), _) => why.clone().into(), |
| 616 | - None => quality.detail(self.custom_mbps).into(), | 624 | + (None, Some(edit)) => edit.detail().into(), |
| 625 | + (None, None) => quality.detail(self.custom_mbps).into(), | ||
| 617 | }, | 626 | }, |
| 618 | self.quality == quality, | 627 | self.quality == quality, |
| 619 | true, | 628 | true, |
| @@ -622,7 +631,7 @@ impl Player { | |||
| 622 | move |this, _: &ClickEvent, _, cx| { | 631 | move |this, _: &ClickEvent, _, cx| { |
| 623 | match quality { | 632 | match quality { |
| 624 | Quality::Custom => this.edit_mbps(), | 633 | Quality::Custom => this.edit_mbps(), |
| 625 | - _ => this.quality = quality, | 634 | + _ => this.pick_quality(quality), |
| 626 | } | 635 | } |
| 627 | cx.notify(); | 636 | cx.notify(); |
| 628 | }, | 637 | }, |
crates/engine/src/export.rsmodified+61 -0
| @@ -373,6 +373,18 @@ pub struct ExportSettings { | |||
| 373 | /// export nobody has marked in or out on writes the same bytes it always | 373 | /// export nobody has marked in or out on writes the same bytes it always |
| 374 | /// did. Session state, like the mark itself: never saved to a `.edith`. | 374 | /// did. Session state, like the mark itself: never saved to a `.edith`. |
| 375 | pub range: Option<(u32, u32)>, | 375 | pub range: Option<(u32, u32)>, |
| 376 | + /// The Exact quality row: this file must be the source's own coded | ||
| 377 | + /// picture, copied wherever [`CopyPlan`] already says a copy is exactly | ||
| 378 | + /// what the timeline says. `bitrate` and `seat` mean nothing to a copied | ||
| 379 | + /// track, but a fallback re-encode (a cut off a sync point, a grade, a | ||
| 380 | + /// speed, a transform) still honours them, so a copy-minded caller sends | ||
| 381 | + /// `bitrate: None` beside this and gets the automatic figure rather than | ||
| 382 | + /// a preset's. | ||
| 383 | + /// | ||
| 384 | + /// [`exact_refusal`] is the gate a front-end asks before the button is | ||
| 385 | + /// pressed; [`run`] asks it again, which is what makes this a setting a | ||
| 386 | + /// worker can trust rather than one only the card checked. | ||
| 387 | + pub exact: bool, | ||
| 376 | } | 388 | } |
| 377 | 389 | ||
| 378 | /// The lowest H.264 level (Table A-1) whose frame size and macroblock rate | 390 | /// The lowest H.264 level (Table A-1) whose frame size and macroblock rate |
| @@ -1673,6 +1685,52 @@ struct CopyRegion { | |||
| 1673 | start: u32, | 1685 | start: u32, |
| 1674 | } | 1686 | } |
| 1675 | 1687 | ||
| 1688 | +/// Why [`ExportSettings::exact`] cannot be honoured for this project right | ||
| 1689 | +/// now, or `None` where [`CopyPlan`] already carries the whole file. A state | ||
| 1690 | +/// report, not an instruction: it says what the file *is* rather than what to | ||
| 1691 | +/// pick instead. | ||
| 1692 | +/// | ||
| 1693 | +/// Two shapes of reason, told apart because only one of them is permanent. | ||
| 1694 | +/// **The container cannot carry the source's own codec at all** -- Exact was | ||
| 1695 | +/// asked of an mp4, or of a Matroska file whose codec is not the source's own | ||
| 1696 | +/// -- which is [`CopyPlan`]'s own corner-cut (mp4 copies nothing yet) and | ||
| 1697 | +/// [`CopyPlan::of`]'s codec check, so it is checked here the same way rather | ||
| 1698 | +/// than duplicated with different words. **The edit is what stops it** -- a | ||
| 1699 | +/// cut off a sync point, a grade, a speed, a dissolve, a moved or scaled | ||
| 1700 | +/// clip -- which the same format would carry exactly if the edit let it, so | ||
| 1701 | +/// those six [`CopyPlan::of`] gates are named together rather than picked | ||
| 1702 | +/// apart into six different sentences. | ||
| 1703 | +pub fn exact_refusal(project: &Project, meta: &VideoMeta, settings: &ExportSettings) -> Option<String> { | ||
| 1704 | + if !settings.exact || CopyPlan::of(project, meta, settings).is_some() { | ||
| 1705 | + return None; | ||
| 1706 | + } | ||
| 1707 | + let codec = match settings.format { | ||
| 1708 | + Format::Hevc => Codec::Hevc, | ||
| 1709 | + Format::Av1 => Codec::Av1, | ||
| 1710 | + _ => { | ||
| 1711 | + return Some(format!( | ||
| 1712 | + "{} cannot carry a source's own coded picture byte for byte — pick an HEVC or AV1 Matroska to copy it exactly", | ||
| 1713 | + settings.format.name() | ||
| 1714 | + )); | ||
| 1715 | + } | ||
| 1716 | + }; | ||
| 1717 | + let carries = project.sources().iter().all(|source| { | ||
| 1718 | + crate::demux::is_matroska(&source.path) | ||
| 1719 | + && Demuxer::open(&source.path) | ||
| 1720 | + .ok() | ||
| 1721 | + .is_some_and(|(source_meta, _)| source_meta.codec == codec) | ||
| 1722 | + }); | ||
| 1723 | + Some(match carries { | ||
| 1724 | + false => format!( | ||
| 1725 | + "{} cannot carry the source's own codec byte for byte", | ||
| 1726 | + settings.format.name() | ||
| 1727 | + ), | ||
| 1728 | + true => "the edit does not let this file copy the source exactly — a cut off a sync \ | ||
| 1729 | + point, a grade, a speed or a transform forces a re-encode" | ||
| 1730 | + .to_string(), | ||
| 1731 | + }) | ||
| 1732 | +} | ||
| 1733 | + | ||
| 1676 | impl CopyPlan { | 1734 | impl CopyPlan { |
| 1677 | /// The plan for this timeline, or `None` where anything at all makes a copy | 1735 | /// The plan for this timeline, or `None` where anything at all makes a copy |
| 1678 | /// say something other than what the timeline says -- in which case the | 1736 | /// say something other than what the timeline says -- in which case the |
| @@ -2429,6 +2487,9 @@ fn run( | |||
| 2429 | if settings.intra_only && settings.format != Format::Mp4 { | 2487 | if settings.intra_only && settings.format != Format::Mp4 { |
| 2430 | return Err(format!("{} cannot be written intra-only", settings.format.name()).into()); | 2488 | return Err(format!("{} cannot be written intra-only", settings.format.name()).into()); |
| 2431 | } | 2489 | } |
| 2490 | + if let Some(why) = exact_refusal(project, meta, settings) { | ||
| 2491 | + return Err(why.into()); | ||
| 2492 | + } | ||
| 2432 | let sources = project.sources(); | 2493 | let sources = project.sources(); |
| 2433 | // The picture's decision first, before a sample of sound is touched: it is | 2494 | // The picture's decision first, before a sample of sound is touched: it is |
| 2434 | // the answer that decides what the whole export *is*, it costs one header | 2495 | // the answer that decides what the whole export *is*, it costs one header |
crates/engine/tests/video_copy.rsmodified+70 -0
| @@ -169,6 +169,76 @@ fn an_untouched_av1_timeline_leaves_as_its_source_packets() { | |||
| 169 | } | 169 | } |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | +/// The Exact quality row asked of a timeline nobody has touched: it must copy | ||
| 173 | +/// exactly as the plain [`Format::Hevc`] row above already does, since the | ||
| 174 | +/// only thing `exact` adds over an untouched timeline is the flag itself -- | ||
| 175 | +/// what it changes is the *fallback*, and there is none to reach here. | ||
| 176 | +#[test] | ||
| 177 | +fn exact_on_an_untouched_matroska_timeline_is_stream_identical() { | ||
| 178 | + let source = asset("test_hevc.mkv"); | ||
| 179 | + let session = PlaybackSession::open(&source).expect("open the fixture"); | ||
| 180 | + let out = Scratch::file("ve_copy_exact", "mkv"); | ||
| 181 | + let settings = ExportSettings { | ||
| 182 | + format: Format::Hevc, | ||
| 183 | + exact: true, | ||
| 184 | + ..Default::default() | ||
| 185 | + }; | ||
| 186 | + let handle = session.export_to_with(&out, &settings); | ||
| 187 | + let started = Instant::now(); | ||
| 188 | + while !handle.is_finished() { | ||
| 189 | + assert!( | ||
| 190 | + started.elapsed() < Duration::from_secs(600), | ||
| 191 | + "the export did not finish in 600 s" | ||
| 192 | + ); | ||
| 193 | + std::thread::sleep(Duration::from_millis(20)); | ||
| 194 | + } | ||
| 195 | + let line = handle.encoders().unwrap_or_default(); | ||
| 196 | + handle | ||
| 197 | + .result() | ||
| 198 | + .expect("an outcome") | ||
| 199 | + .unwrap_or_else(|e| panic!("export failed: {e}")); | ||
| 200 | + assert!(line.starts_with("copy · "), "exact did not copy: {line}"); | ||
| 201 | + let (before, after) = (blocks(&source), blocks(&out)); | ||
| 202 | + assert_eq!(before.len(), after.len(), "block count"); | ||
| 203 | + for (i, (a, b)) in before.iter().zip(&after).enumerate() { | ||
| 204 | + assert_eq!(a.bytes, b.bytes, "block {i} is not the source's bytes"); | ||
| 205 | + assert_eq!(a.key, b.key, "block {i} sync flag"); | ||
| 206 | + } | ||
| 207 | +} | ||
| 208 | + | ||
| 209 | +/// Exact asked of an mp4: [`CopyPlan`]'s own corner-cut is that mp4 copies | ||
| 210 | +/// nothing yet, so the container cannot carry the source's codec byte for | ||
| 211 | +/// byte -- a state report, named before a frame is touched, and not a silent | ||
| 212 | +/// re-encode wearing the Exact label. | ||
| 213 | +#[test] | ||
| 214 | +fn exact_refuses_a_container_that_cannot_carry_the_codec() { | ||
| 215 | + let source = asset("test_hevc.mkv"); | ||
| 216 | + let session = PlaybackSession::open(&source).expect("open the fixture"); | ||
| 217 | + let out = Scratch::file("ve_copy_exact_refused", "mp4"); | ||
| 218 | + let settings = ExportSettings { | ||
| 219 | + format: Format::Mp4, | ||
| 220 | + exact: true, | ||
| 221 | + ..Default::default() | ||
| 222 | + }; | ||
| 223 | + let handle = session.export_to_with(&out, &settings); | ||
| 224 | + let started = Instant::now(); | ||
| 225 | + while !handle.is_finished() { | ||
| 226 | + assert!( | ||
| 227 | + started.elapsed() < Duration::from_secs(600), | ||
| 228 | + "the export did not finish in 600 s" | ||
| 229 | + ); | ||
| 230 | + std::thread::sleep(Duration::from_millis(20)); | ||
| 231 | + } | ||
| 232 | + let err = handle | ||
| 233 | + .result() | ||
| 234 | + .expect("an outcome") | ||
| 235 | + .expect_err("an mp4 cannot honour exact"); | ||
| 236 | + assert!( | ||
| 237 | + err.to_string().contains("cannot carry"), | ||
| 238 | + "unexpected refusal: {err}" | ||
| 239 | + ); | ||
| 240 | +} | ||
| 241 | + | ||
| 172 | /// A cut placed on a sync point: the middle of the film is deleted and both | 242 | /// A cut placed on a sync point: the middle of the film is deleted and both |
| 173 | /// sides leave as copies. What is checked is the join -- the blocks either side | 243 | /// sides leave as copies. What is checked is the join -- the blocks either side |
| 174 | /// of it are the source's own, the timestamps rise a frame at a time across it | 244 | /// of it are the source's own, the timestamps rise a frame at a time across it |