media: use the shared GIF text control fix (#4040)

* media: use the shared GIF text control fix

* chore: repin craft-gif to storytold/craft-libs main (ba25ccd2)

---------

Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com>
This commit is contained in:
Terra854andDylan M. Taylor authored and GitHub committed 2026-11-21 13:33:27 -05:00
1 parent f70208cef3
commit 563fea6582
3 files changed
+28 -2

No files matched your search

Generated
+1 -1
View File
@@ -1352,7 +1352,7 @@ dependencies = [
[[package]]
name = "craft-gif"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87#5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87"
source = "git+https://github.com/storytold/craft-libs?rev=ba25ccd233934d1b2f74e3c0f235168bf5f13ef3#ba25ccd233934d1b2f74e3c0f235168bf5f13ef3"
dependencies = [
"gif",
"image",
+1 -1
View File
@@ -21,7 +21,7 @@ craft-ecproj-format = { version = "0.1.0", git = "https://github.com/storytold/c
craft-dpx = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-ps = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "808730f49b9637b7909fe2ae56f9d63fdb100cae", default-features = false, features = ["read"] }
craft-exr = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "3b8e426a260695af840a2cd79a064d40778f939e" }
craft-gif = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-gif = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "ba25ccd233934d1b2f74e3c0f235168bf5f13ef3" }
craft-psd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "08da5e1486ee640de1d2cccd8fe8dd32b1d3b62c" }
craft-codepage = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-svg = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "3dff4793f1a5bd1f99a4fe3280d48f515158dff3" }
+26
View File
@@ -223,6 +223,32 @@ mod tests {
assert!(e.to_lowercase().contains("memory"), "{e}");
}
#[test]
fn gif_probe_and_playback_respect_text_control_scope() {
let mut bytes = Vec::new();
{
let mut encoder = gif::Encoder::new(&mut bytes, 2, 2, &[255, 0, 0, 0, 0, 255]).unwrap();
for (index, delay, transparent) in [(0, 23, Some(0)), (1, 7, None)] {
let frame = gif::Frame { width: 2, height: 2, delay, transparent, buffer: vec![index; 4].into(), ..gif::Frame::default() };
encoder.write_frame(&frame).unwrap();
}
}
let offset = craft_gif::scan(&bytes, 1).unwrap().frames[0].offset;
// A text grid consumes the first Graphic Control Extension. The first
// image then uses the app's default display delay of 100 ms.
let text = [0x21, 0x01, 12, 0, 0, 0, 0, 2, 0, 2, 0, 1, 1, 1, 0, 1, b'X', 0];
bytes.splice(offset..offset, text);
let bytes: std::sync::Arc<[u8]> = bytes.into();
let footage = probe_bytes("text-control.gif", bytes.clone()).unwrap();
let pool = MediaPool::new();
pool.add_bytes("text-control.gif", bytes);
assert_eq!(
(footage.duration, colour_at(&pool, &footage, 0.09), colour_at(&pool, &footage, 0.11)),
(Tick::from_units(17, 100), [1.0, 0.0, 0.0], [0.0, 0.0, 1.0])
);
}
#[test]
fn a_zero_delay_is_ten_hundredths_like_in_browsers() {
let f = probe_bytes("a.gif", gif(&[(RED, 0), (GREEN, 1)]).into()).unwrap();