@@ -222,7 +222,6 @@ pub enum Status {
222
222
IlocBadQuantity ,
223
223
IlocBadSize ,
224
224
IlocDuplicateItemId ,
225
- IlocMissing ,
226
225
IlocNotFound ,
227
226
IlocOffsetOverflow ,
228
227
ImageItemType ,
@@ -260,6 +259,7 @@ pub enum Status {
260
259
NoImage ,
261
260
PitmBadQuantity ,
262
261
PitmMissing ,
262
+ PitmNotFound ,
263
263
PixiBadChannelCount ,
264
264
PixiMissing ,
265
265
PsshSizeOverflow ,
@@ -597,9 +597,6 @@ impl From<Status> for &str {
597
597
Status :: IlocDuplicateItemId => {
598
598
"duplicate item_ID in iloc"
599
599
}
600
- Status :: IlocMissing => {
601
- "iloc missing"
602
- }
603
600
Status :: IlocNotFound => {
604
601
"ItemLocationBox (iloc) contains an extent not present in any mdat or idat box"
605
602
}
@@ -732,6 +729,9 @@ impl From<Status> for &str {
732
729
"Missing required PrimaryItemBox (pitm), required \
733
730
per HEIF (ISO/IEC 23008-12:2017) § 10.2.1"
734
731
}
732
+ Status :: PitmNotFound => {
733
+ "PrimaryItemBox (pitm) referenced an item ID that was not present"
734
+ }
735
735
Status :: PixiBadChannelCount => {
736
736
"invalid num_channels"
737
737
}
@@ -2708,6 +2708,12 @@ pub fn read_avif<T: Read>(f: &mut T, strictness: ParseStrictness) -> Result<Avif
2708
2708
assert ! ( item. is_some( ) ) ;
2709
2709
}
2710
2710
2711
+ if ( primary_item_id. is_some ( ) && primary_item. is_none ( ) )
2712
+ || ( alpha_item_id. is_some ( ) && alpha_item. is_none ( ) )
2713
+ {
2714
+ fail_with_status_if ( strictness == ParseStrictness :: Strict , Status :: PitmNotFound ) ?;
2715
+ }
2716
+
2711
2717
assert ! ( primary_item. is_none( ) || primary_item_id. is_some( ) ) ;
2712
2718
assert ! ( alpha_item. is_none( ) || alpha_item_id. is_some( ) ) ;
2713
2719
@@ -2918,7 +2924,7 @@ fn read_avif_meta<T: Read + Offset>(
2918
2924
item_references : item_references. unwrap_or_default ( ) ,
2919
2925
primary_item_id,
2920
2926
item_infos : item_infos. unwrap_or_default ( ) ,
2921
- iloc_items : iloc_items. ok_or_else ( || Error :: from ( Status :: IlocMissing ) ) ? ,
2927
+ iloc_items : iloc_items. unwrap_or_default ( ) ,
2922
2928
item_data_box,
2923
2929
} )
2924
2930
}
0 commit comments