Skip to content

Commit 90ca3df

Browse files
committed
Add an API exposing alpha_item and premultiplied_alpha
1 parent 1220fd4 commit 90ca3df

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

mp4parse_capi/fuzz/fuzz_targets/avif.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ fuzz_target!(|data: &[u8]| {
3232
let mut primary_item = Default::default();
3333
mp4parse_avif_get_primary_item(context, &mut primary_item);
3434

35+
let mut alpha_item = Default::default();
36+
let mut premultiplied_alpha = Default::default();
37+
mp4parse_avif_get_alpha_item(context, &mut alpha_item, &mut premultiplied_alpha);
38+
3539
mp4parse_avif_free(context);
3640
}
3741
});

mp4parse_capi/src/lib.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,28 @@ pub unsafe extern "C" fn mp4parse_avif_get_primary_item(
12011201
Mp4parseStatus::Ok
12021202
}
12031203

1204+
#[no_mangle]
1205+
pub unsafe extern "C" fn mp4parse_avif_get_alpha_item(
1206+
parser: *mut Mp4parseAvifParser,
1207+
alpha_item: *mut Mp4parseByteData,
1208+
premultiplied_alpha: *mut bool,
1209+
) -> Mp4parseStatus {
1210+
if parser.is_null() {
1211+
return Mp4parseStatus::BadArg;
1212+
}
1213+
1214+
*alpha_item = Default::default();
1215+
1216+
let context = (*parser).context();
1217+
if let Some(context_alpha_item) = context.alpha_item() {
1218+
(*alpha_item).set_data(context_alpha_item);
1219+
*premultiplied_alpha = context.premultiplied_alpha;
1220+
Mp4parseStatus::Ok
1221+
} else {
1222+
Mp4parseStatus::Invalid
1223+
}
1224+
}
1225+
12041226
/// Fill the supplied `Mp4parseByteData` with index information from `track`.
12051227
///
12061228
/// # Safety

0 commit comments

Comments
 (0)