@@ -762,7 +762,7 @@ impl AvifContext {
762
762
}
763
763
764
764
struct AvifMeta {
765
- item_references : TryVec < ItemReferenceEntry > ,
765
+ item_references : TryVec < SingleItemTypeReferenceBox > ,
766
766
properties : TryVec < AssociatedProperty > ,
767
767
primary_item_id : u32 ,
768
768
iloc_items : TryVec < ItemLocationBoxItem > ,
@@ -844,7 +844,7 @@ struct ItemInfoEntry {
844
844
845
845
/// See ISO 14496-12:2015 § 8.11.12
846
846
#[ derive( Debug ) ]
847
- struct ItemReferenceEntry {
847
+ struct SingleItemTypeReferenceBox {
848
848
item_type : FourCC ,
849
849
from_item_id : u32 ,
850
850
to_item_id : u32 ,
@@ -1508,8 +1508,8 @@ fn read_infe<T: Read>(src: &mut BMFFBox<T>) -> Result<ItemInfoEntry> {
1508
1508
Ok ( ItemInfoEntry { item_id, item_type } )
1509
1509
}
1510
1510
1511
- fn read_iref < T : Read > ( src : & mut BMFFBox < T > ) -> Result < TryVec < ItemReferenceEntry > > {
1512
- let mut entries = TryVec :: new ( ) ;
1511
+ fn read_iref < T : Read > ( src : & mut BMFFBox < T > ) -> Result < TryVec < SingleItemTypeReferenceBox > > {
1512
+ let mut item_references = TryVec :: new ( ) ;
1513
1513
let version = read_fullbox_version_no_flags ( src) ?;
1514
1514
if version > 1 {
1515
1515
return Err ( Error :: Unsupported ( "iref version" ) ) ;
@@ -1518,25 +1518,31 @@ fn read_iref<T: Read>(src: &mut BMFFBox<T>) -> Result<TryVec<ItemReferenceEntry>
1518
1518
let mut iter = src. box_iter ( ) ;
1519
1519
while let Some ( mut b) = iter. next_box ( ) ? {
1520
1520
let from_item_id = if version == 0 {
1521
- be_u16 ( & mut b) ? as u32
1521
+ be_u16 ( & mut b) ?. into ( )
1522
1522
} else {
1523
1523
be_u32 ( & mut b) ?
1524
1524
} ;
1525
- let item_count = be_u16 ( & mut b) ?;
1526
- for _ in 0 ..item_count {
1525
+ let reference_count = be_u16 ( & mut b) ?;
1526
+ for _ in 0 ..reference_count {
1527
1527
let to_item_id = if version == 0 {
1528
1528
be_u16 ( & mut b) ? as u32
1529
1529
} else {
1530
1530
be_u32 ( & mut b) ?
1531
1531
} ;
1532
- entries. push ( ItemReferenceEntry {
1532
+ if from_item_id == to_item_id {
1533
+ return Err ( Error :: InvalidData (
1534
+ "from_item_id and to_item_id must be different" ,
1535
+ ) ) ;
1536
+ }
1537
+ item_references. push ( SingleItemTypeReferenceBox {
1533
1538
item_type : b. head . name . into ( ) ,
1534
1539
from_item_id,
1535
1540
to_item_id,
1536
1541
} ) ?;
1537
1542
}
1543
+ check_parser_state ! ( b. content) ;
1538
1544
}
1539
- Ok ( entries )
1545
+ Ok ( item_references )
1540
1546
}
1541
1547
1542
1548
fn read_iprp < T : Read > ( src : & mut BMFFBox < T > ) -> Result < TryVec < AssociatedProperty > > {
0 commit comments