forge
Explore
Log in

Don't you dare go Hollow

apply(decode): stretch the anamorphic picture once, at the single post-decode step

Browse files at this commit

b3a5acb21e15906718a0375ad1112a58ec70b1beAhmet Kaan GümüşParent: 66a1c40
ffmpeg applies the sample aspect exactly once, at the conversion to the
square-pixel raster; so does this engine now. Render::frame takes the
file's pixel_aspect beside its rotation and, only where the samples are
not square, resamples the coded picture to the displayed width with the
existing scale_i420 -- the same bilinear the canvas places through. A
square-pixel file takes the branch by a bool and not one byte is
touched: the passthrough fast path, the tonemap FNV constants and the
graded path are all exactly what they were (matrix_render and
tonemap_render green unchanged).

The export takes the same two facts through place_picture -- stretch
after turn, the order ffmpeg composes -- and an anamorphic span is
barred from the DMA fast path, whose whole premise is that no seat
touches a sample before the encoder. Dissolve's B half carries its own
file's aspect beside its own rotation.

VhMeta grows the coded pair and the aspect ratio, so the plugin ABI
answers both questions a display size may now raise: what to draw and
what the samples are stored at.
crates/engine-hw/src/lib.rsmodified+12 -0
@@ -403,6 +403,10 @@ impl Session {
403403 height: meta.height,
404404 frame_rate: meta.frame_rate,
405405 frame_count: meta.frame_count,
406+ coded_width: meta.coded_width,
407+ coded_height: meta.coded_height,
408+ pixel_aspect_h: meta.pixel_aspect.h,
409+ pixel_aspect_v: meta.pixel_aspect.v,
406410 },
407411 ready: VecDeque::new(),
408412 pending: Vec::new(),
@@ -935,6 +939,10 @@ impl VpxSession {
935939 height: meta.height,
936940 frame_rate: meta.frame_rate,
937941 frame_count: meta.frame_count,
942+ coded_width: meta.coded_width,
943+ coded_height: meta.coded_height,
944+ pixel_aspect_h: meta.pixel_aspect.h,
945+ pixel_aspect_v: meta.pixel_aspect.v,
938946 },
939947 flushed: false,
940948 skip: 0,
@@ -1110,6 +1118,10 @@ pub unsafe extern "C" fn vh_meta(session: *mut c_void, out: *mut VhMeta) -> i32
11101118 (*out).height = meta.height;
11111119 (*out).frame_rate = meta.frame_rate;
11121120 (*out).frame_count = meta.frame_count;
1121+ (*out).coded_width = meta.coded_width;
1122+ (*out).coded_height = meta.coded_height;
1123+ (*out).pixel_aspect_h = meta.pixel_aspect_h;
1124+ (*out).pixel_aspect_v = meta.pixel_aspect_v;
11131125 }
11141126 0
11151127 }))
crates/engine/src/decode.rsmodified+54 -1
@@ -18,7 +18,7 @@ use ec_h264::H264Decoder;
1818 use crate::color::ColorParams;
1919 use crate::colorspace::{ColorDescription, Matrix, Transfer};
2020 use crate::convert::{i420_to_bgra, i420_to_bgra_with};
21-use crate::demux::{Codec, Demuxer, Rotation, VideoMeta};
21+use crate::demux::{Codec, Demuxer, PixelAspect, Rotation, VideoMeta};
2222 use crate::hw::HwSession;
2323 use crate::project::Speed;
2424 use crate::scale::Composer;
@@ -562,6 +562,8 @@ impl DecodeSession {
562562 transform,
563563 // A still has no display matrix: what the file holds is what it is.
564564 Rotation::None,
565+ // ...and no sample aspect either: a still is authored square.
566+ PixelAspect::SQUARE,
565567 ColorDescription::default(),
566568 canvas,
567569 tonemap::Preset::default(),
@@ -691,6 +693,9 @@ impl DecodeSession {
691693 transform,
692694 // Painted here, at the canvas's own size: nothing turned it.
693695 Rotation::None,
696+ // ...and nothing drew it anamorphic: it is square by
697+ // construction.
698+ PixelAspect::SQUARE,
694699 ColorDescription::default(),
695700 canvas,
696701 tonemap::Preset::default(),
@@ -1108,6 +1113,7 @@ fn run_span(
11081113 color,
11091114 transform,
11101115 opened.meta.rotation,
1116+ opened.meta.pixel_aspect,
11111117 opened.meta.color,
11121118 canvas,
11131119 tone,
@@ -1197,6 +1203,12 @@ struct Render {
11971203 /// every file that states no turn, which is the whole of an ordinary
11981204 /// library.
11991205 rotation: Rotation,
1206+ /// The ratio one coded pixel is drawn at ([`crate::demux::PixelAspect`]):
1207+ /// the file's sample aspect ratio, applied exactly once, at this one
1208+ /// conversion to the square-pixel raster -- the same place ffmpeg's swscale
1209+ /// applies it, and nowhere else. Square for every file that states no
1210+ /// aspect, which takes the branch by a bool and touches no byte.
1211+ pixel_aspect: PixelAspect,
12001212 /// What the source's samples mean -- the stream's own matrix and range,
12011213 /// which is what the conversion below is done in rather than the BT.601 it
12021214 /// used to assume of every file.
@@ -1215,6 +1227,10 @@ struct Render {
12151227 /// asks for none, and resized once for one that does -- a steady-state
12161228 /// buffer rather than three plane allocations per decoded frame.
12171229 turned: (Vec<u8>, Vec<u8>, Vec<u8>),
1230+ /// The same, for the pixel-aspect stretch: the coded picture widened to
1231+ /// the displayed width, empty for every square-pixel file and sized once
1232+ /// for one that is not.
1233+ stretched: (Vec<u8>, Vec<u8>, Vec<u8>),
12181234 /// Where [`Composer::place_transformed`]'s owned picture lands, so a
12191235 /// transformed frame's planes live as long as `self` -- matching what
12201236 /// [`Composer::place`] already hands back by borrowing `self.canvas`.
@@ -1238,6 +1254,7 @@ impl Render {
12381254 color: ColorParams,
12391255 transform: TransformParams,
12401256 rotation: Rotation,
1257+ pixel_aspect: PixelAspect,
12411258 desc: ColorDescription,
12421259 canvas: Composer,
12431260 preset: tonemap::Preset,
@@ -1247,6 +1264,7 @@ impl Render {
12471264 color,
12481265 transform,
12491266 rotation,
1267+ pixel_aspect,
12501268 desc,
12511269 canvas,
12521270 // corner-cut: the ceiling is that the map reads limited-range codes
@@ -1261,6 +1279,7 @@ impl Render {
12611279 },
12621280 graded: (Vec::new(), Vec::new(), Vec::new()),
12631281 turned: (Vec::new(), Vec::new(), Vec::new()),
1282+ stretched: (Vec::new(), Vec::new(), Vec::new()),
12641283 placed: (Vec::new(), Vec::new(), Vec::new()),
12651284 }
12661285 }
@@ -1302,6 +1321,40 @@ impl Render {
13021321 )
13031322 }
13041323 };
1324+ // The pixel aspect, applied exactly once -- the single conversion to
1325+ // the square-pixel raster this engine makes, where ffmpeg's swscale
1326+ // makes its own. Only a file whose samples are not square reaches the
1327+ // resample: a square one takes the branch by a bool and not one byte
1328+ // is touched, which is what keeps every existing picture identical to
1329+ // the day before anamorphic sources existed.
1330+ let (y, u, v, width, height) = if self.pixel_aspect.is_square() {
1331+ (y, u, v, width, height)
1332+ } else {
1333+ // The aspect widens the *width*, always: 4:3 SAR over 1440x1080
1334+ // shows 1920x1080. `width_factor` lands on the even grid 4:2:0
1335+ // composes on, and a height is never touched by it.
1336+ let display_width = self.pixel_aspect.width_factor(width);
1337+ let (sy, su, sv) = &mut self.stretched;
1338+ crate::scale::scale_i420(
1339+ y,
1340+ u,
1341+ v,
1342+ width as usize,
1343+ height as usize,
1344+ sy,
1345+ su,
1346+ sv,
1347+ display_width as usize,
1348+ height as usize,
1349+ );
1350+ (
1351+ &sy[..display_width as usize * height as usize],
1352+ &su[..display_width.div_ceil(2) as usize * height.div_ceil(2) as usize],
1353+ &sv[..display_width.div_ceil(2) as usize * height.div_ceil(2) as usize],
1354+ display_width,
1355+ height,
1356+ )
1357+ };
13051358 let passthrough = self.canvas.is_passthrough(width, height);
13061359 // A transform still has a picture to place even where the canvas
13071360 // itself would hand this size back untouched -- moving, scaling,
crates/engine/src/export.rsmodified+102 -16
@@ -1229,10 +1229,16 @@ struct Dissolve<'a> {
12291229 /// B's own file's display-matrix turn, [`place_picture`]'s first stage;
12301230 /// B is a different file and may be turned differently from A.
12311231 rotation: Rotation,
1232+ /// B's own file's sample aspect, [`place_picture`]'s second stage, for
1233+ /// the same reason the turn is per file.
1234+ pixel_aspect: crate::demux::PixelAspect,
12321235 canvas: Composer,
12331236 /// The turn's, the grade's and the transform's scratch, exactly as A's
12341237 /// span keeps them: refilled per picture, allocated once.
12351238 rotated: (Vec<u8>, Vec<u8>, Vec<u8>),
1239+ /// The stretch's own scratch, [`place_picture`]'s second stage -- the
1240+ /// pixel aspect's, beside the turn's.
1241+ stretched: (Vec<u8>, Vec<u8>, Vec<u8>),
12361242 graded: (Vec<u8>, Vec<u8>, Vec<u8>),
12371243 transformed: (Vec<u8>, Vec<u8>, Vec<u8>),
12381244 }
@@ -2721,7 +2727,13 @@ fn run(
27212727 // samples *mean* ([`ColorDescription`]), which is what decides whether they
27222728 // are remapped on the way in. Real time for a still, a song and a
27232729 // single-rate project, where every conversion below is the identity.
2724- let rates: Vec<(Rate, ColorDescription, Option<f32>, Rotation)> = sources
2730+ let rates: Vec<(
2731+ Rate,
2732+ ColorDescription,
2733+ Option<f32>,
2734+ Rotation,
2735+ crate::demux::PixelAspect,
2736+ )> = sources
27252737 .iter()
27262738 .map(|source| source_rate(&source.path, meta.frame_rate))
27272739 .collect();
@@ -2740,7 +2752,7 @@ fn run(
27402752 let preset = project.tone();
27412753 let tone: Vec<Option<ToneMapper>> = rates
27422754 .iter()
2743- .map(|(_, color, peak, _)| match color.transfer {
2755+ .map(|(_, color, peak, _, _)| match color.transfer {
27442756 // A preview file keeps the film's own curve and is tone-mapped when
27452757 // it is *shown* ([`ExportSettings::keep_source_colour`]), which is
27462758 // both cheaper and the only way the preset can still be changed
@@ -2806,12 +2818,14 @@ fn run(
28062818 // A's pixels on the CPU, so a dissolving span never asks for a GPU
28072819 // buffer, not even outside its own window.
28082820 let dissolve = dissolve_window(project, &span);
2809- let (mut pictures, rate, in_frame, color, mapper, rotation) = match span.from {
2821+ let (mut pictures, rate, in_frame, color, mapper, rotation, pixel_aspect) =
2822+ match span.from
2823+ {
28102824 Some((source, in_frame)) => {
28112825 let entry = sources
28122826 .get(source)
28132827 .ok_or_else(|| format!("clip names source {source} of {}", sources.len()))?;
2814- let (rate, color, _peak, rotation) = rates[source];
2828+ let (rate, color, _peak, rotation, pixel_aspect) = rates[source];
28152829 let mapper = tone[source].as_ref();
28162830 // Nothing on the way from this span's decoder to the encoder
28172831 // touches a sample: no tone map, no matrix remap, no grade --
@@ -2831,8 +2845,12 @@ fn run(
28312845 // A file whose display matrix asks for a turn is *not*
28322846 // untouched, whatever else the timeline says: its pictures
28332847 // have to be turned, which is a read-back no GPU buffer
2834- // survives.
2848+ // survives. The sample aspect is the same refusal one
2849+ // stage later: its pictures have to be stretched to the
2850+ // square-pixel raster before an encoder sees them, which
2851+ // is the same kind of touch.
28352852 && rotation.is_none()
2853+ && pixel_aspect.is_square()
28362854 && dissolve.is_none();
28372855 let want = untouched.then(|| encoder.dma_want(meta)).flatten();
28382856 // Opened at the file's own frame, which is the only place the
@@ -2852,13 +2870,21 @@ fn run(
28522870 } else {
28532871 ClipDecoder::open(&entry.path, rate.source_at(in_frame), want)?
28542872 };
2855- (Some(pictures), rate, in_frame, Some(color), mapper, rotation)
2873+ (Some(pictures), rate, in_frame, Some(color), mapper, rotation, pixel_aspect)
28562874 }
28572875 // A gap's black is 16/128/128, which is black in every matrix here
28582876 // and on every curve: nothing to remap and nothing to tone-map,
28592877 // which is what `None` says. A gap is no file either, so nothing
28602878 // turns it.
2861- None => (None, Rate::REAL_TIME, 0, None, None, Rotation::None),
2879+ None => (
2880+ None,
2881+ Rate::REAL_TIME,
2882+ 0,
2883+ None,
2884+ None,
2885+ Rotation::None,
2886+ crate::demux::PixelAspect::SQUARE,
2887+ ),
28622888 };
28632889 // Mixed spaces on one timeline: a clip coded against another matrix than
28642890 // the one this file declares is rewritten into it, *after* the grade --
@@ -2885,8 +2911,10 @@ fn run(
28852911 let mut transformed = (Vec::new(), Vec::new(), Vec::new());
28862912 // ...and one more for the file's own display-matrix turn, which happens
28872913 // before all of those (see [`place_picture`]): empty for every source
2888- // that states no turn.
2914+ // that states no turn. `stretched` is its twin for the pixel aspect,
2915+ // which happens right after it.
28892916 let mut rotated = (Vec::new(), Vec::new(), Vec::new());
2917+ let mut stretched = (Vec::new(), Vec::new(), Vec::new());
28902918 // ...and the canvas it is placed on, which is where a source of another
28912919 // resolution becomes a picture at the project's. The same `Composer`
28922920 // playback composes with, given the same policy, so an export is what
@@ -2905,7 +2933,7 @@ fn run(
29052933 let entry = sources.get(b_source).ok_or_else(|| {
29062934 format!("clip names source {b_source} of {}", sources.len())
29072935 })?;
2908- let (b_rate, b_color, _peak, b_rotation) = rates[b_source];
2936+ let (b_rate, b_color, _peak, b_rotation, b_pixel_aspect) = rates[b_source];
29092937 let b_mapper = tone[b_source].as_ref();
29102938 let b_remap = remap_into(Some(b_color), b_mapper.is_some(), out_color.matrix);
29112939 Ok(Dissolve {
@@ -2935,12 +2963,14 @@ fn run(
29352963 .copied()
29362964 .unwrap_or_default(),
29372965 rotation: b_rotation,
2966+ pixel_aspect: b_pixel_aspect,
29382967 canvas: Composer::new(
29392968 meta.width,
29402969 meta.height,
29412970 project.composite_fit_at(b_start),
29422971 ),
29432972 rotated: (Vec::new(), Vec::new(), Vec::new()),
2973+ stretched: (Vec::new(), Vec::new(), Vec::new()),
29442974 graded: (Vec::new(), Vec::new(), Vec::new()),
29452975 transformed: (Vec::new(), Vec::new(), Vec::new()),
29462976 })
@@ -3045,11 +3075,13 @@ fn run(
30453075 width,
30463076 height,
30473077 rotation,
3078+ pixel_aspect,
30483079 grade,
30493080 transform,
30503081 remap,
30513082 mapper,
30523083 &mut rotated,
3084+ &mut stretched,
30533085 &mut graded,
30543086 &mut transformed,
30553087 &mut canvas,
@@ -3079,9 +3111,10 @@ fn run(
30793111 }
30803112 Some(Frame::Pixels(by, bu, bv, bw, bh)) => {
30813113 let (by, bu, bv, _, _) = place_picture(
3082- by, bu, bv, bw, bh, d.rotation, d.grade, d.transform,
3083- d.remap, d.mapper, &mut d.rotated, &mut d.graded,
3084- &mut d.transformed, &mut d.canvas,
3114+ by, bu, bv, bw, bh, d.rotation, d.pixel_aspect, d.grade,
3115+ d.transform, d.remap, d.mapper, &mut d.rotated,
3116+ &mut d.stretched, &mut d.graded, &mut d.transformed,
3117+ &mut d.canvas,
30853118 );
30863119 let idx_in_window = done_here + r - d.tail_start;
30873120 let t = dissolve_weight(idx_in_window, d.window);
@@ -3236,11 +3269,13 @@ fn place_picture<'a>(
32363269 width: u32,
32373270 height: u32,
32383271 rotation: Rotation,
3272+ pixel_aspect: crate::demux::PixelAspect,
32393273 grade: Option<crate::color::ColorParams>,
32403274 transform: TransformParams,
32413275 remap: Option<(Matrix, Matrix)>,
32423276 mapper: Option<&ToneMapper>,
32433277 turned: &'a mut (Vec<u8>, Vec<u8>, Vec<u8>),
3278+ stretched: &'a mut (Vec<u8>, Vec<u8>, Vec<u8>),
32443279 graded: &'a mut (Vec<u8>, Vec<u8>, Vec<u8>),
32453280 transformed: &'a mut (Vec<u8>, Vec<u8>, Vec<u8>),
32463281 canvas: &'a mut Composer,
@@ -3264,6 +3299,35 @@ fn place_picture<'a>(
32643299 (&turned.0[..], &turned.1[..], &turned.2[..], w, h)
32653300 }
32663301 };
3302+ // The pixel aspect, applied exactly once -- the same single conversion to
3303+ // the square-pixel raster the decode funnel makes, in the same order
3304+ // (stretch after turn), so the encoder is fed the pixels the preview
3305+ // showed to the byte. A square-pixel file -- every file whose samples are
3306+ // one to one -- borrows the planes through.
3307+ let (y, u, v, width, height) = if pixel_aspect.is_square() {
3308+ (y, u, v, width, height)
3309+ } else {
3310+ let display_width = pixel_aspect.width_factor(width);
3311+ crate::scale::scale_i420(
3312+ y,
3313+ u,
3314+ v,
3315+ width as usize,
3316+ height as usize,
3317+ &mut stretched.0,
3318+ &mut stretched.1,
3319+ &mut stretched.2,
3320+ display_width as usize,
3321+ height as usize,
3322+ );
3323+ (
3324+ &stretched.0[..],
3325+ &stretched.1[..],
3326+ &stretched.2[..],
3327+ display_width,
3328+ height,
3329+ )
3330+ };
32673331 // The planes are borrowed from the decoder (and `Black::picture` hands the
32683332 // same slice as both u and v), so a grade cannot be applied in place: it
32693333 // goes onto a copy, which the encoder then reads instead.
@@ -3334,13 +3398,26 @@ fn remap_into(
33343398 fn source_rate(
33353399 path: &Path,
33363400 timeline_fps: f64,
3337-) -> (Rate, ColorDescription, Option<f32>, Rotation) {
3401+) -> (
3402+ Rate,
3403+ ColorDescription,
3404+ Option<f32>,
3405+ Rotation,
3406+ crate::demux::PixelAspect,
3407+) {
33383408 if crate::is_image(path) || crate::is_audio(path) {
33393409 // A still is BT.601 by construction whatever it was authored as:
33403410 // `decode::rgb_to_i420` is the one matrix that turns its pixels into
33413411 // planes. A song has no picture and the answer is never read. Neither
3342- // has a display matrix to be turned by.
3343- return (Rate::REAL_TIME, ColorDescription::default(), None, Rotation::None);
3412+ // has a display matrix to be turned by, nor an aspect to be widened
3413+ // by: both are authored square.
3414+ return (
3415+ Rate::REAL_TIME,
3416+ ColorDescription::default(),
3417+ None,
3418+ Rotation::None,
3419+ crate::demux::PixelAspect::SQUARE,
3420+ );
33443421 }
33453422 match Demuxer::open(path) {
33463423 // ...and one whose rate cannot be named against the timeline's, which
@@ -3357,10 +3434,19 @@ fn source_rate(
33573434 // The file's own turn, so the encoder is fed the picture the
33583435 // preview shows: the same header read, one more answer.
33593436 meta.rotation,
3437+ // ...and its own sample aspect, for the same reason on the same
3438+ // read: the encoder is fed the shape the preview showed.
3439+ meta.pixel_aspect,
33603440 ),
33613441 // Unreadable here means unreadable below too, where the span dies with a
33623442 // real message; the file's own space is the least of that.
3363- Err(_) => (Rate::REAL_TIME, ColorDescription::default(), None, Rotation::None),
3443+ Err(_) => (
3444+ Rate::REAL_TIME,
3445+ ColorDescription::default(),
3446+ None,
3447+ Rotation::None,
3448+ crate::demux::PixelAspect::SQUARE,
3449+ ),
33643450 }
33653451 }
33663452
crates/engine/src/hw.rsmodified+26 -5
@@ -15,7 +15,7 @@
1515 //! path -- the same "no" it gives for an unsupported profile, and the caller's
1616 //! honest [`crate::demux::Codec::needs_plugin`] refusal covers both.
1717
18-use std::ffi::{CString, c_char, c_void};
18+use std::ffi::{c_char, c_void, CString};
1919 use std::os::fd::FromRawFd;
2020 use std::path::{Path, PathBuf};
2121 use std::sync::OnceLock;
@@ -26,7 +26,18 @@ use crate::colorspace::ColorDescription;
2626
2727 const LIB_NAME: &str = "libengine_hw.so";
2828
29-/// Stream metadata, C layout. Mirrors [`crate::VideoMeta`].
29+/// Stream metadata, C layout. Mirrors [`crate::VideoMeta`]'s picture half --
30+/// the four fields a session was opened with, plus the coded pair and the
31+/// sample aspect a display size can now differ from the coded one by.
32+///
33+/// `width`/`height` are the *displayed* shape, exactly as [`crate::VideoMeta`]
34+/// promises: a plugin opened on a rotated file has always been handed a
35+/// swapped pair here, and the pictures it hands back are sized by its own
36+/// decoder's output, which is the coded pair. `coded_width`/`coded_height`
37+/// name that pair explicitly, and `pixel_aspect_h`/`_v` carry the ratio one
38+/// coded pixel is drawn at, so a caller that needs the stored shape (a copy
39+/// declaring a track, an encoder agreeing on a surface) asks the coded one and
40+/// a caller that draws asks the display one -- both answered, neither derived.
3041 #[repr(C)]
3142 #[derive(Default)]
3243 pub struct VhMeta {
@@ -34,6 +45,13 @@ pub struct VhMeta {
3445 pub height: u32,
3546 pub frame_rate: f64,
3647 pub frame_count: u32,
48+ /// What the samples are stored at, before any turn or stretch.
49+ pub coded_width: u32,
50+ pub coded_height: u32,
51+ /// The sample aspect ratio, h over v, square as 1 and 1 -- or 0 and 0,
52+ /// which is `Default` and reads square ([`crate::demux::PixelAspect`]).
53+ pub pixel_aspect_h: u32,
54+ pub pixel_aspect_v: u32,
3755 }
3856
3957 /// One decoded picture as planar I420. Pointers belong to the plugin and stay
@@ -371,7 +389,9 @@ impl HwSession {
371389 /// for a few pictures only: encode it before asking this for a few more.
372390 pub fn next_frame_dma(&mut self, want: DmaWant) -> crate::Result<Option<HwPicture<'_>>> {
373391 let Some(next_dma) = self.plugin.next_frame_dma else {
374- return Ok(self.next_frame()?.map(|(y, u, v, w, h)| HwPicture::Pixels(y, u, v, w, h)));
392+ return Ok(self
393+ .next_frame()?
394+ .map(|(y, u, v, w, h)| HwPicture::Pixels(y, u, v, w, h)));
375395 };
376396 let mut frame = VhFrame::default();
377397 let mut dma = VhDma::default();
@@ -482,8 +502,9 @@ struct EncPlugin {
482502 /// neither and every picture reaches it as bytes, which is what it always
483503 /// did.
484504 dma_geometry: Option<unsafe extern "C" fn(*mut c_void, *mut u32, *mut u32) -> i32>,
485- frame_dma:
486- Option<unsafe extern "C" fn(*mut c_void, *const VhDma, i32, *mut *const u8, *mut usize) -> i32>,
505+ frame_dma: Option<
506+ unsafe extern "C" fn(*mut c_void, *const VhDma, i32, *mut *const u8, *mut usize) -> i32,
507+ >,
487508 drain: unsafe extern "C" fn(*mut c_void, *mut *const u8, *mut usize) -> i32,
488509 close: unsafe extern "C" fn(*mut c_void),
489510 // Never dropped (lives in a static), so the fn pointers above stay valid.