Skip to content

Commit b1860f0

Browse files
kornelskibaumanj
andcommitted
Require only one alpha item
Co-authored-by: baumanj <[email protected]>
1 parent 6b42422 commit b1860f0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

mp4parse/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ pub fn read_avif<T: Read>(f: &mut T, context: &mut AvifContext) -> Result<()> {
12661266

12671267
let meta = meta.ok_or(Error::InvalidData("missing meta"))?;
12681268

1269-
let alpha_item_id = meta
1269+
let mut alpha_item_ids = meta
12701270
.item_references
12711271
.iter()
12721272
// Auxiliary image for the primary image
@@ -1288,8 +1288,11 @@ pub fn read_avif<T: Read>(f: &mut T, context: &mut AvifContext) -> Result<()> {
12881288
_ => false,
12891289
}
12901290
})
1291-
})
1292-
.next();
1291+
});
1292+
let alpha_item_id = alpha_item_ids.next();
1293+
if alpha_item_ids.next().is_some() {
1294+
return Err(Error::InvalidData("multiple alpha planes"));
1295+
}
12931296

12941297
context.premultiplied_alpha = alpha_item_id.map_or(false, |alpha_item_id| {
12951298
meta.item_references.iter().any(|iref| {

0 commit comments

Comments
 (0)