Repository navigation
Description
Unit
libobs/graphics/image-file.c.h, all of it, into rust/obs-graphics. About 400 lines. Unit 6 of #1846. It loads an image file for a texture (gs_image_file_ex_*): animated GIFs through the vendored libnsgif, everything else through gs_create_texture_file_data3 (graphics-ffmpeg), and steps GIF animation by elapsed time.
gs_image_file_ex_initgs_image_file_ex_freegs_image_file_ex_init_texturegs_image_file_ex_tickgs_image_file_ex_update_texture
Phase and position
Phase 6 (#444), next to texture-render (#1860). The file is its own include in the libobs.media unity group, so the whole file can leave the production build by moving to the ported graphics group. No open port touches it.
Dependencies and existing tests
struct gs_image_file_ex in the public graphics/image-file.h is ABI: the Rust shim uses a #[repr(C)] mirror and layout tests check it against the C. struct gs_image_file_internal is private to the file; the Rust side keeps its own private block, allocated with bzalloc so bnum_allocs counts the same.
What stays C and is called through extern declarations: libnsgif (nsgif_*, vendored), gs_create_texture_file_data3 (graphics-ffmpeg), gs_texture_create, gs_texture_destroy, gs_texture_set_image (graphics.c). The inline helpers it uses (gs_premultiply_xyza_loop, gs_premultiply_xyza_srgb_loop, gs_get_format_bpp) are ported with it. Cargo tests link libnsgif and a recording stand-in for the gs_* calls from the oracle crate, as #1861 did.
No test covers the file today beyond test_image_size_precheck (needs a display). The characterization needs no GPU: GIF and PNG fixtures, the same hand-built graphics_t with a fake device as test_texture_render, and it runs against the C build, the C reference and hybrid libobs.
Plan
One PR, as #1846 asks:
- Characterization:
test/cmocka/test_image_file.cwith small GIF/PNG fixtures: cx/cy/format/loaded/is_animated_gif, missing files, oversized GIF, single-frame GIF falling back to FFmpeg, alpha modes, tick timing across frames and loop counts, texture create/update/destroy calls,bnum_allocs. - RED: Tier 1 in the existing
obs-tests-graphicsbinary against atodo!()safe core. - GREEN: safe core for the timing math, decode range, premultiply;
#[no_mangle]shim for the five exports.image-file.c.hmoves tolibobs.ported-graphics+.h.c; Windows exports inrust-exports.d/obs-graphics-image_file.txt. No public header or exported symbol change. - Tier 3: the original built as
oracle_gs_image_file_ex_*; proptest over tick sequences comparing every public field, the frame bytes passed to the device and the call log; layout tests; one mutation check. - rust/README.md row and
port_comparisonbench.
Tier 4 does not apply.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Oct 23, 2026
Claiming: #1907 (unit 6 of #1846).
First PR today.
obs-graphics: Zero the image like the C memset, take libobs exports b…
obs-graphics: Keep image-file free of the Rust heap and panics
test: Characterize gs_image_file_ex before its port
obs-graphics: Port the image-file cases against stubs
obs-graphics: Port graphics/image-file.c.h
obs-graphics: Compare image-file with the original C
obs-graphics: Document the image-file port and bench it against C
obs-graphics: Zero the image like the C memset, take libobs exports b…
obs-graphics: Keep image-file free of the Rust heap and panics
obs-graphics: Port graphics/image-file.c.h (obs-rust#1911)