@@ -1354,8 +1354,8 @@ fn read_avif_meta<T: Read + Offset>(src: &mut BMFFBox<T>) -> Result<AvifMeta> {
1354
1354
let mut primary_item_id = None ;
1355
1355
let mut item_infos = None ;
1356
1356
let mut iloc_items = None ;
1357
- let mut item_references = TryVec :: new ( ) ;
1358
- let mut properties = TryVec :: new ( ) ;
1357
+ let mut item_references = None ;
1358
+ let mut properties = None ;
1359
1359
1360
1360
let mut iter = src. box_iter ( ) ;
1361
1361
while let Some ( mut b) = iter. next_box ( ) ? {
@@ -1379,16 +1379,22 @@ fn read_avif_meta<T: Read + Offset>(src: &mut BMFFBox<T>) -> Result<AvifMeta> {
1379
1379
BoxType :: PrimaryItemBox => {
1380
1380
if primary_item_id. is_some ( ) {
1381
1381
return Err ( Error :: InvalidData (
1382
- "There should be zero or one iloc boxes per ISO 14496-12:2015 § 8.11.4.1" ,
1382
+ "There should be zero or one pitm boxes per ISO 14496-12:2015 § 8.11.4.1" ,
1383
1383
) ) ;
1384
1384
}
1385
1385
primary_item_id = Some ( read_pitm ( & mut b) ?) ;
1386
1386
}
1387
1387
BoxType :: ImageReferenceBox => {
1388
- item_references = read_iref ( & mut b) ?;
1388
+ if item_references. is_some ( ) {
1389
+ return Err ( Error :: InvalidData ( "There should be zero or one iref boxes" ) ) ;
1390
+ }
1391
+ item_references = Some ( read_iref ( & mut b) ?) ;
1389
1392
}
1390
1393
BoxType :: ImagePropertiesBox => {
1391
- properties = read_iprp ( & mut b) ?;
1394
+ if properties. is_some ( ) {
1395
+ return Err ( Error :: InvalidData ( "There should be zero or one iprp boxes" ) ) ;
1396
+ }
1397
+ properties = Some ( read_iprp ( & mut b) ?) ;
1392
1398
}
1393
1399
_ => skip_box_content ( & mut b) ?,
1394
1400
}
@@ -1414,8 +1420,8 @@ fn read_avif_meta<T: Read + Offset>(src: &mut BMFFBox<T>) -> Result<AvifMeta> {
1414
1420
}
1415
1421
1416
1422
Ok ( AvifMeta {
1417
- properties,
1418
- item_references,
1423
+ properties : properties . unwrap_or_else ( TryVec :: new ) ,
1424
+ item_references : item_references . unwrap_or_else ( TryVec :: new ) ,
1419
1425
primary_item_id,
1420
1426
iloc_items : iloc_items. ok_or ( Error :: InvalidData ( "iloc missing" ) ) ?,
1421
1427
} )
0 commit comments