Settings is a centred modal
Browse files at this commit9085e57ce199be8f2c9edf0dabb285faa029fb97Parent: 3690c86- ui
- settings is a centred modal
- the budget goes below a megabit
8 changed files +140 -51
- DESIGN.md +4 -1
- crates/app/src/export_ui.rs +7 -5
- crates/app/src/player/export.rs +1 -1
- crates/app/src/tests/cards.rs +10 -7
- crates/app/src/tests/layout.rs +57 -0
- crates/app/src/tests/media.rs +4 -2
- crates/app/src/ui/settings_stance.rs +45 -31
- crates/engine/src/export.rs +12 -4
DESIGN.mdmodified+4 -1
| @@ -340,7 +340,10 @@ Before any new surface merges, it answers: | |||
| 340 | 4. **Scale:** define its degradation ladder step-by-width before merge. | 340 | 4. **Scale:** define its degradation ladder step-by-width before merge. |
| 341 | 5. **Achromatic check:** zero new hues in chrome; film inks only for identity; white only if it | 341 | 5. **Achromatic check:** zero new hues in chrome; film inks only for identity; white only if it |
| 342 | is literally the lamp. | 342 | is literally the lamp. |
| 343 | -6. **Occlusion check:** the picture stays visible; nothing floats over the screen. | 343 | +6. **Occlusion check:** the picture stays visible; nothing floats over the screen. Accepted |
| 344 | + exceptions are named where they live: the held-`?` cheat-sheet (amendment above), and the | ||
| 345 | + settings page, a centred modal since 2026-09-19 (user: the below-picture sheet covered the | ||
| 346 | + timeline) — it floats over the screen while open, and closes on a click away or `esc`. | ||
| 344 | 7. **States:** empty (safelight-composed, never bare), refusing (reason named), failing | 347 | 7. **States:** empty (safelight-composed, never bare), refusing (reason named), failing |
| 345 | (notice plate with remedy). | 348 | (notice plate with remedy). |
| 346 | 8. **Feel:** one ≤150ms motion spec from §10's vocabulary, or a stated reason for none. | 349 | 8. **Feel:** one ≤150ms motion spec from §10's vocabulary, or a stated reason for none. |
crates/app/src/export_ui.rsmodified+7 -5
| @@ -686,13 +686,15 @@ pub(crate) fn probe_settings(format: Format, audio_kbps: u32, seat: EncoderSeat) | |||
| 686 | 686 | ||
| 687 | /// The budget's bounds, the engine's own (`engine::export`'s `MIN_BITRATE` | 687 | /// The budget's bounds, the engine's own (`engine::export`'s `MIN_BITRATE` |
| 688 | /// and `MAX_EXPLICIT_BITRATE`): a number outside them would be written as a | 688 | /// and `MAX_EXPLICIT_BITRATE`): a number outside them would be written as a |
| 689 | -/// different one, so the lever and the field clamp to exactly these. | 689 | +/// different one, so the lever and the field clamp to exactly these. The floor |
| 690 | -pub(crate) const BPS_MIN: u64 = 1_000_000; | 690 | +/// is 100 kbps, not a megabit: a sub-Mbps delivery is an export too, and at a |
| 691 | +/// megabit this row could not say `0.6` at all. | ||
| 692 | +pub(crate) const BPS_MIN: u64 = 100_000; | ||
| 691 | pub(crate) const BPS_MAX: u64 = 50_000_000; | 693 | pub(crate) const BPS_MAX: u64 = 50_000_000; |
| 692 | 694 | ||
| 693 | -/// A wheel notch, and a notch with shift held: 0.1 and 1 Mbps. Fifty presses | 695 | +/// A wheel notch, and a notch with shift held: 0.1 and 1 Mbps. Five hundred |
| 694 | -/// is not a way across this range, and a tenth is the smallest step the row's | 696 | +/// tenths is not a way across this range, and a tenth is the smallest step |
| 695 | -/// own readout can show. | 697 | +/// the row's own readout can show. |
| 696 | pub(crate) const BPS_FINE: u64 = 100_000; | 698 | pub(crate) const BPS_FINE: u64 = 100_000; |
| 697 | pub(crate) const BPS_COARSE: u64 = 1_000_000; | 699 | pub(crate) const BPS_COARSE: u64 = 1_000_000; |
| 698 | 700 | ||
crates/app/src/player/export.rsmodified+1 -1
| @@ -536,7 +536,7 @@ impl Player { | |||
| 536 | if self.custom_bps > 0 { | 536 | if self.custom_bps > 0 { |
| 537 | return self.custom_bps; | 537 | return self.custom_bps; |
| 538 | } | 538 | } |
| 539 | - self.session.as_ref().map_or(BPS_MIN * 6, |s| { | 539 | + self.session.as_ref().map_or(6_000_000, |s| { |
| 540 | let (w, h) = s.resolution(); | 540 | let (w, h) = s.resolution(); |
| 541 | auto_bps(w, h, s.meta().frame_rate) | 541 | auto_bps(w, h, s.meta().frame_rate) |
| 542 | }) | 542 | }) |
crates/app/src/tests/cards.rsmodified+10 -7
| @@ -907,13 +907,13 @@ fn the_budget_is_the_one_number_the_engine_gets() { | |||
| 907 | } | 907 | } |
| 908 | // The lever's bounds are the engine's own (`MIN_BITRATE`, | 908 | // The lever's bounds are the engine's own (`MIN_BITRATE`, |
| 909 | // `MAX_EXPLICIT_BITRATE`), so no reachable number is silently rewritten. | 909 | // `MAX_EXPLICIT_BITRATE`), so no reachable number is silently rewritten. |
| 910 | - assert_eq!(BPS_MIN, 1_000_000); | 910 | + assert_eq!(BPS_MIN, 100_000); |
| 911 | assert_eq!(BPS_MAX, 50_000_000); | 911 | assert_eq!(BPS_MAX, 50_000_000); |
| 912 | // The default the lever opens on is the engine's automatic figure for | 912 | // The default the lever opens on is the engine's automatic figure for |
| 913 | // the picture that is open -- never the 0 Mbps the old `custom_mbps: 0` | 913 | // the picture that is open -- never the 0 Mbps the old `custom_mbps: 0` |
| 914 | // put on screen. | 914 | // put on screen. |
| 915 | assert_eq!(auto_bps(1920, 1080, 30.), 6_220_800); | 915 | assert_eq!(auto_bps(1920, 1080, 30.), 6_220_800); |
| 916 | - assert!(auto_bps(320, 240, 30.) >= BPS_MIN, "a tiny picture floors"); | 916 | + assert_eq!(auto_bps(160, 120, 15.), BPS_MIN, "a tiny picture floors"); |
| 917 | assert!(auto_bps(7680, 4320, 60.) <= 20_000_000, "and a huge one caps"); | 917 | assert!(auto_bps(7680, 4320, 60.) <= 20_000_000, "and a huge one caps"); |
| 918 | for bps in [auto_bps(1920, 1080, 30.), auto_bps(320, 240, 24.)] { | 918 | for bps in [auto_bps(1920, 1080, 30.), auto_bps(320, 240, 24.)] { |
| 919 | assert!((BPS_MIN..=BPS_MAX).contains(&bps)); | 919 | assert!((BPS_MIN..=BPS_MAX).contains(&bps)); |
| @@ -930,9 +930,11 @@ fn a_budget_is_said_four_ways_and_lands_inside_the_engines_range() { | |||
| 930 | assert_eq!(parse_budget("6.5", seconds, audio), Some(6_500_000)); | 930 | assert_eq!(parse_budget("6.5", seconds, audio), Some(6_500_000)); |
| 931 | assert_eq!(parse_budget("6.5 mbps", seconds, audio), Some(6_500_000)); | 931 | assert_eq!(parse_budget("6.5 mbps", seconds, audio), Some(6_500_000)); |
| 932 | assert_eq!(parse_budget("12M", seconds, audio), Some(12_000_000)); | 932 | assert_eq!(parse_budget("12M", seconds, audio), Some(12_000_000)); |
| 933 | - // 850 kbps is under the engine's floor, so it lands *on* the floor -- | 933 | + // A sub-Mbps ask is a rate this row can say: 850 kbps travels as itself. |
| 934 | - // clamped, and shown clamped in the same keystroke. | 934 | + assert_eq!(parse_budget("850k", seconds, audio), Some(850_000)); |
| 935 | - assert_eq!(parse_budget("850k", seconds, audio), Some(BPS_MIN)); | 935 | + // Under the engine's floor it lands *on* the floor -- clamped, and shown |
| 936 | + // clamped in the same keystroke. | ||
| 937 | + assert_eq!(parse_budget("50k", seconds, audio), Some(BPS_MIN)); | ||
| 936 | assert_eq!(parse_budget("2500k", seconds, audio), Some(2_500_000)); | 938 | assert_eq!(parse_budget("2500k", seconds, audio), Some(2_500_000)); |
| 937 | // `G` is a target file size: 1.2 GB over a minute is 160 Mbit/s of file, | 939 | // `G` is a target file size: 1.2 GB over a minute is 160 Mbit/s of file, |
| 938 | // less the sound -- past the ceiling, so the ceiling is what is written. | 940 | // less the sound -- past the ceiling, so the ceiling is what is written. |
| @@ -964,8 +966,9 @@ fn the_budget_lever_steps_by_a_tenth_and_a_whole_megabit() { | |||
| 964 | assert_eq!(BPS_COARSE, 1_000_000); | 966 | assert_eq!(BPS_COARSE, 1_000_000); |
| 965 | assert_eq!(rate_label(6_000_000 + BPS_FINE), "6.1"); | 967 | assert_eq!(rate_label(6_000_000 + BPS_FINE), "6.1"); |
| 966 | assert_eq!(rate_label(6_000_000 + BPS_COARSE), "7.0"); | 968 | assert_eq!(rate_label(6_000_000 + BPS_COARSE), "7.0"); |
| 967 | - // Fifty notches of the coarse step crosses the whole range, which is | 969 | + // Forty-nine coarse notches carry the range with change left in the |
| 968 | - // what a wheel is for; the fine one would take five hundred. | 970 | + // fiftieth, which is what a wheel is for; the fine step would take five |
| 971 | + // hundred. | ||
| 969 | assert_eq!((BPS_MAX - BPS_MIN) / BPS_COARSE, 49); | 972 | assert_eq!((BPS_MAX - BPS_MIN) / BPS_COARSE, 49); |
| 970 | // The step arithmetic itself, as `Player::nudge_budget` does it: a | 973 | // The step arithmetic itself, as `Player::nudge_budget` does it: a |
| 971 | // saturating walk that stops at both ends rather than wrapping. | 974 | // saturating walk that stops at both ends rather than wrapping. |
crates/app/src/tests/layout.rsmodified+57 -0
| @@ -4093,6 +4093,63 @@ fn the_settings_sections_are_tabs_that_carry_their_own_explanation() { | |||
| 4093 | } | 4093 | } |
| 4094 | } | 4094 | } |
| 4095 | 4095 | ||
| 4096 | +/// The page's own geometry, after the user retired the below-picture sheet | ||
| 4097 | +/// (2026-09-19: "this settings section should be a modal instead of covering | ||
| 4098 | +/// the timeline"). The page is a centred modal now -- a centred scrim and a | ||
| 4099 | +/// plate of one tabbed column's own measure, never `w_full()`, which put a | ||
| 4100 | +/// `justify_between` row's value a window away from its label, and never the | ||
| 4101 | +/// [`crate::ui::stance::below_picture_floor`] anchor that laid the sheet over | ||
| 4102 | +/// the bench at the window's full width. The height is a viewport cap with | ||
| 4103 | +/// headroom, the rows scroll under the strip when a short window cannot hold | ||
| 4104 | +/// them, and the modal keeps the two things its callers read: the | ||
| 4105 | +/// `settings-card` id and the press-away exit (`this.close_card()`, the same | ||
| 4106 | +/// one every other card's scrim leads with). A source scan, like every other | ||
| 4107 | +/// guard on this page -- this binary renders no window of its own. | ||
| 4108 | +#[test] | ||
| 4109 | +fn the_settings_page_is_a_centred_modal_with_one_column_of_measure() { | ||
| 4110 | + let source = src_text("ui/settings_stance.rs"); | ||
| 4111 | + let start = source | ||
| 4112 | + .find("pub(crate) fn render(") | ||
| 4113 | + .expect("the page's render fn"); | ||
| 4114 | + let body = &source[start..]; | ||
| 4115 | + let end = body.find("\n}\n").map_or(body.len(), |at| at + 2); | ||
| 4116 | + let body = &body[..end]; | ||
| 4117 | + | ||
| 4118 | + // Centred on both axes, and the below-picture sheet gone with the rest | ||
| 4119 | + // of it: no floor arithmetic, no bottom-edge alignment, no full-width | ||
| 4120 | + // plate. | ||
| 4121 | + for needle in [".justify_center()", ".items_center()"] { | ||
| 4122 | + assert!(body.contains(needle), "the settings modal lost {needle}"); | ||
| 4123 | + } | ||
| 4124 | + for gone in ["below_picture_floor", "items_end()", "w_full()"] { | ||
| 4125 | + assert!( | ||
| 4126 | + !body.contains(gone), | ||
| 4127 | + "the settings page drew {gone} again -- that is the below-picture sheet, \ | ||
| 4128 | + not the centred modal the user asked for" | ||
| 4129 | + ); | ||
| 4130 | + } | ||
| 4131 | + // The plate: one column's own measure with its yield for a narrow centre | ||
| 4132 | + // column, a capped height, and the rows scrolled inside the cap. | ||
| 4133 | + for needle in [ | ||
| 4134 | + ".id(\"settings-card\")", | ||
| 4135 | + ".w(px(SETTINGS_W))", | ||
| 4136 | + ".max_w(relative(1.))", | ||
| 4137 | + ".max_h(px(max_h))", | ||
| 4138 | + "\"settings-rows\"", | ||
| 4139 | + "overflow_y_scroll()", | ||
| 4140 | + ] { | ||
| 4141 | + assert!( | ||
| 4142 | + body.contains(needle), | ||
| 4143 | + "the settings modal lost {needle} -- the plate is no longer one capped \ | ||
| 4144 | + column with its rows scrolling" | ||
| 4145 | + ); | ||
| 4146 | + } | ||
| 4147 | + assert!( | ||
| 4148 | + body.contains("this.close_card()"), | ||
| 4149 | + "the settings scrim swallows the press without closing the modal" | ||
| 4150 | + ); | ||
| 4151 | +} | ||
| 4152 | + | ||
| 4096 | /// The Picture row said every refused format's reason after its value | 4153 | /// The Picture row said every refused format's reason after its value |
| 4097 | /// (`H.264 no picture -- an mp4 would \u{b7} AV1 no picture -- ...`; the user | 4154 | /// (`H.264 no picture -- an mp4 would \u{b7} AV1 no picture -- ...`; the user |
| 4098 | /// called it "funny"). A row says its own pick: one value, and a refusal only | 4155 | /// called it "funny"). A row says its own pick: one value, and a refusal only |
crates/app/src/tests/media.rsmodified+4 -2
| @@ -796,10 +796,12 @@ fn the_budget_row_states_the_size_before_it_is_written() { | |||
| 796 | assert_eq!(size_label(999_999_999), "1000 MB"); | 796 | assert_eq!(size_label(999_999_999), "1000 MB"); |
| 797 | assert_eq!(size_label(1_000_000_000), "1.00 GB"); | 797 | assert_eq!(size_label(1_000_000_000), "1.00 GB"); |
| 798 | assert_eq!(size_label(1_240_000_000), "1.24 GB"); | 798 | assert_eq!(size_label(1_240_000_000), "1.24 GB"); |
| 799 | - // The lever's own readout, one decimal, in the unit it is moved in. | 799 | + // The lever's own readout, one decimal, in the unit it is moved in -- |
| 800 | + // including below a megabit, which is where the floor lives now. | ||
| 800 | assert_eq!(rate_label(6_000_000), "6.0"); | 801 | assert_eq!(rate_label(6_000_000), "6.0"); |
| 801 | assert_eq!(rate_label(6_500_000), "6.5"); | 802 | assert_eq!(rate_label(6_500_000), "6.5"); |
| 802 | - assert_eq!(rate_label(BPS_MIN), "1.0"); | 803 | + assert_eq!(rate_label(600_000), "0.6"); |
| 804 | + assert_eq!(rate_label(BPS_MIN), "0.1"); | ||
| 803 | // Row 3's range readout: the marked span where there is one, and a | 805 | // Row 3's range readout: the marked span where there is one, and a |
| 804 | // sound-only file names no film to take a range from. | 806 | // sound-only file names no film to take a range from. |
| 805 | assert_eq!(range_word(None, true), "whole film"); | 807 | assert_eq!(range_word(None, true), "whole film"); |
crates/app/src/ui/settings_stance.rsmodified+45 -31
| @@ -777,38 +777,51 @@ fn export_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElement | |||
| 777 | )) | 777 | )) |
| 778 | } | 778 | } |
| 779 | 779 | ||
| 780 | -/// The page itself: a plate in the room's own below-picture footprint, | 780 | +/// The centred modal's plate width: one tabbed column's own measure, wide |
| 781 | -/// closed by a click away or `esc` through [`Player::close_card`] like every | 781 | +/// enough for the longest row a section carries (the EXPORT range's marks |
| 782 | -/// other card here. | 782 | +/// line, its chords and all) beside its label -- and no wider. The sheet this |
| 783 | +/// replaces was `w_full()`, which read every row as a line stretched across | ||
| 784 | +/// the room with its value a window away from the label it belongs to. | ||
| 785 | +/// [`KEYS_W`]'s class, and a step past its number: these rows carry the same | ||
| 786 | +/// label-left/stroke-right anatomy with a value where that card has none. | ||
| 787 | +const SETTINGS_W: f32 = 480.; | ||
| 788 | + | ||
| 789 | +/// The breathing room the modal keeps against the window edge, and the | ||
| 790 | +/// margin the plate's height cap is measured less -- headroom that keeps a | ||
| 791 | +/// short window's plate off both edges rather than clipped against them. | ||
| 792 | +const SETTINGS_EDGE: f32 = 24.; | ||
| 793 | + | ||
| 794 | +/// The floor under that cap, so a very short window's plate still shows the | ||
| 795 | +/// strip and a row under it -- the rows scroll from there. | ||
| 796 | +const SETTINGS_MIN_H: f32 = 160.; | ||
| 797 | + | ||
| 798 | +/// The page itself: a centred modal card, closed by a click away or `esc` | ||
| 799 | +/// through [`Player::close_card`] like every other card here. | ||
| 783 | /// | 800 | /// |
| 784 | -/// It used to be a centred modal over a dimming scrim, which put the whole | 801 | +/// It held to [`crate::ui::stance::below_picture_floor`] from 2026-08-21 |
| 785 | -/// settings sheet -- and every picker opened off one of its rows -- straight | 802 | +/// until 2026-09-19: a centred sheet then drew the whole page -- and every |
| 786 | -/// over the picture: DESIGN §11 check 6's one hard occlusion rule, and half | 803 | +/// picker opened off one of its rows -- over the picture (DESIGN §11 check |
| 787 | -/// of the user's 2026-08-21 report about menus "not aligning with our | 804 | +/// 6's occlusion rule, half of the user's own report about menus "not |
| 788 | -/// design". Anchored to [`crate::ui::stance::below_picture_floor`] it sits | 805 | +/// aligning with our design"), so the page was anchored over the bench and |
| 789 | -/// over the bench and ledger exactly as the export plate and the menus | 806 | +/// ledger at the window's full width. The user 2026-09-19 retired that read |
| 790 | -/// already do, and the catcher behind it paints nothing rather than tinting | 807 | +/// -- "this settings section should be a modal instead of covering the |
| 791 | -/// the frame. | 808 | +/// timeline" -- so the plate is centred again, at one tabbed column's own |
| 809 | +/// measure: it floats over the room's middle, the timeline beneath is not | ||
| 810 | +/// laid under a full-width sheet, and a short window scrolls the rows under | ||
| 811 | +/// the strip rather than clipping them. The catcher still paints nothing | ||
| 812 | +/// rather than tinting the frame, the same rule the menus it opens follow. | ||
| 792 | pub(crate) fn render( | 813 | pub(crate) fn render( |
| 793 | player: &Player, | 814 | player: &Player, |
| 794 | window_size: Size<Pixels>, | 815 | window_size: Size<Pixels>, |
| 795 | cx: &mut Context<Player>, | 816 | cx: &mut Context<Player>, |
| 796 | ) -> impl IntoElement { | 817 | ) -> impl IntoElement { |
| 797 | - let floor = crate::ui::stance::below_picture_floor( | 818 | + // The plate's own cap, a [`SETTINGS_EDGE`] off each edge. |
| 798 | - f32::from(window_size.height), | 819 | + let max_h = (f32::from(window_size.height) - 2. * SETTINGS_EDGE).max(SETTINGS_MIN_H); |
| 799 | - player.split_px(Split::Bench, window_size), | ||
| 800 | - ); | ||
| 801 | - // Below the time band, not merely below the picture: the transport and | ||
| 802 | - // the Export chip live on that band and a sheet over them hides controls | ||
| 803 | - // the editor is still using. Bench + ledger is this page's footprint. | ||
| 804 | - let top = floor + crate::ui::stance::TIME_BAND_H; | ||
| 805 | - let room = f32::from(window_size.height) - top; | ||
| 806 | drag_scrim(cx) | 820 | drag_scrim(cx) |
| 807 | .flex() | 821 | .flex() |
| 808 | .justify_center() | 822 | .justify_center() |
| 809 | - .items_end() | 823 | + .items_center() |
| 810 | - .pt(px(top + 6.)) | 824 | + .p(px(SETTINGS_EDGE)) |
| 811 | - .pb(px(6.)) | ||
| 812 | .on_mouse_down( | 825 | .on_mouse_down( |
| 813 | MouseButton::Left, | 826 | MouseButton::Left, |
| 814 | cx.listener(|this, _: &MouseDownEvent, _, cx| { | 827 | cx.listener(|this, _: &MouseDownEvent, _, cx| { |
| @@ -820,14 +833,15 @@ pub(crate) fn render( | |||
| 820 | .child( | 833 | .child( |
| 821 | div() | 834 | div() |
| 822 | .id("settings-card") | 835 | .id("settings-card") |
| 823 | - // The whole footprint's width: at 720p a 420px single column | 836 | + // One tabbed column's own measure, never the window's: the |
| 824 | - // put Mix, the palette and the subtitle font below a fold with | 837 | + // sheet this replaces spent the full width on one section -- |
| 825 | - // no visible scrollbar -- settings an editor cannot see are | 838 | + // a folded list is now answered by the height cap and |
| 826 | - // settings only a chord reaches, which is the defect class | 839 | + // `settings-rows`' own scroll, not by the plate reaching for |
| 827 | - // this page exists to close. The strip spends the width on | 840 | + // the window's edges. `max_w` yields to a centre column |
| 828 | - // tabs, and one section shows flat beneath it. | 841 | + // narrower than the measure (the 640px floor's own case). |
| 829 | - .w_full() | 842 | + .w(px(SETTINGS_W)) |
| 830 | - .max_h(px((room - 12.).max(120.))) | 843 | + .max_w(relative(1.)) |
| 844 | + .max_h(px(max_h)) | ||
| 831 | .on_mouse_down(MouseButton::Left, swallow) | 845 | .on_mouse_down(MouseButton::Left, swallow) |
| 832 | .flex() | 846 | .flex() |
| 833 | .flex_col() | 847 | .flex_col() |
crates/engine/src/export.rsmodified+12 -4
| @@ -112,7 +112,12 @@ fn picture_progress(done: u32, total: u32) -> u32 { | |||
| 112 | /// D2 rate control: bits per pixel per second, then a sane range. 720p30 lands | 112 | /// D2 rate control: bits per pixel per second, then a sane range. 720p30 lands |
| 113 | /// at 2.76 Mbps, which S1 measured the software encoder hitting within 1%. | 113 | /// at 2.76 Mbps, which S1 measured the software encoder hitting within 1%. |
| 114 | const BITS_PER_PIXEL: f64 = 0.1; | 114 | const BITS_PER_PIXEL: f64 = 0.1; |
| 115 | -const MIN_BITRATE: u64 = 1_000_000; | 115 | +/// The floor under a rate somebody *asked* for, and under the derived one: 100 |
| 116 | +/// kbps, so a sub-Mbps budget -- a lo-fi delivery, a tiny picture, a | ||
| 117 | +/// phone-rate master -- is a rate this export is written at. A megabit was the | ||
| 118 | +/// old floor, and it silently rewrote every such ask. Nothing below this is | ||
| 119 | +/// worth a container: the sound's own row starts at 128 kbps. | ||
| 120 | +const MIN_BITRATE: u64 = 100_000; | ||
| 116 | const MAX_BITRATE: u64 = 20_000_000; | 121 | const MAX_BITRATE: u64 = 20_000_000; |
| 117 | 122 | ||
| 118 | /// The ceiling on a bitrate somebody *asked* for, which is a different question | 123 | /// The ceiling on a bitrate somebody *asked* for, which is a different question |
| @@ -679,8 +684,9 @@ fn faded(project: &Project) -> bool { | |||
| 679 | } | 684 | } |
| 680 | 685 | ||
| 681 | /// The bitrate an export codes at: the caller's number clamped into what an | 686 | /// The bitrate an export codes at: the caller's number clamped into what an |
| 682 | -/// asked-for rate may be ([`MAX_EXPLICIT_BITRATE`]), the derived one where there | 687 | +/// asked-for rate may be ([`MIN_BITRATE`]..[`MAX_EXPLICIT_BITRATE`]), the |
| 683 | -/// was none. Clamped rather than refused, for the reason [`Enc::open`] states. | 688 | +/// derived one where there was none. Clamped rather than refused, for the |
| 689 | +/// reason [`Enc::open`] states. | ||
| 684 | fn bitrate_of(meta: &VideoMeta, settings: &ExportSettings) -> u64 { | 690 | fn bitrate_of(meta: &VideoMeta, settings: &ExportSettings) -> u64 { |
| 685 | settings.bitrate.map_or_else( | 691 | settings.bitrate.map_or_else( |
| 686 | || bitrate_for(meta), | 692 | || bitrate_for(meta), |
| @@ -5370,7 +5376,8 @@ mod tests { | |||
| 5370 | }; | 5376 | }; |
| 5371 | // 1280 * 720 * 30 * 0.1 | 5377 | // 1280 * 720 * 30 * 0.1 |
| 5372 | assert_eq!(bitrate_for(&meta(1280, 720, 30.0)), 2_764_800); | 5378 | assert_eq!(bitrate_for(&meta(1280, 720, 30.0)), 2_764_800); |
| 5373 | - assert_eq!(bitrate_for(&meta(320, 240, 30.0)), MIN_BITRATE, "tiny"); | 5379 | + assert_eq!(bitrate_for(&meta(320, 240, 30.0)), 230_400, "tiny"); |
| 5380 | + assert_eq!(bitrate_for(&meta(160, 120, 15.0)), MIN_BITRATE, "tinier floors"); | ||
| 5374 | assert_eq!(bitrate_for(&meta(3840, 2160, 60.0)), MAX_BITRATE, "huge"); | 5381 | assert_eq!(bitrate_for(&meta(3840, 2160, 60.0)), MAX_BITRATE, "huge"); |
| 5375 | // A rate somebody typed goes through untouched to its own ceiling, which | 5382 | // A rate somebody typed goes through untouched to its own ceiling, which |
| 5376 | // is above where the derived one stops: the card offers 50 Mbps, and a | 5383 | // is above where the derived one stops: the card offers 50 Mbps, and a |
| @@ -5386,6 +5393,7 @@ mod tests { | |||
| 5386 | }; | 5393 | }; |
| 5387 | assert_eq!(asked(50_000_000), 50_000_000, "the card's ceiling travels"); | 5394 | assert_eq!(asked(50_000_000), 50_000_000, "the card's ceiling travels"); |
| 5388 | assert_eq!(asked(21_000_000), 21_000_000, "past the derived range"); | 5395 | assert_eq!(asked(21_000_000), 21_000_000, "past the derived range"); |
| 5396 | + assert_eq!(asked(600_000), 600_000, "a sub-Mbps ask travels"); | ||
| 5389 | assert_eq!(asked(999_000_000), MAX_EXPLICIT_BITRATE, "still bounded"); | 5397 | assert_eq!(asked(999_000_000), MAX_EXPLICIT_BITRATE, "still bounded"); |
| 5390 | assert_eq!(asked(1), MIN_BITRATE, "and floored"); | 5398 | assert_eq!(asked(1), MIN_BITRATE, "and floored"); |
| 5391 | } | 5399 | } |