@@ -462,7 +462,8 @@ pub struct DataFormatDescriptor<'data> {
462
462
pub data : & ' data [ u8 ] ,
463
463
}
464
464
465
- pub struct BasicDataFormatDescriptor < ' data > {
465
+ #[ derive( Debug , Copy , Clone ) ]
466
+ pub struct BasicDataFormatDescriptorHeader {
466
467
/// None means Unspecified
467
468
pub color_model : Option < ColorModel > , //: 8;
468
469
/// None means Unspecified
@@ -472,11 +473,12 @@ pub struct BasicDataFormatDescriptor<'data> {
472
473
pub flags : DataFormatFlags , //: 8;
473
474
pub texel_block_dimensions : [ u32 ; 4 ] , //: 8 x 4;
474
475
pub bytes_planes : [ u32 ; 8 ] , //: 8 x 8;
475
- sample_data : & ' data [ u8 ] ,
476
476
}
477
477
478
- impl < ' data > BasicDataFormatDescriptor < ' data > {
479
- pub fn parse ( bytes : & ' data [ u8 ] ) -> Result < Self , ParseError > {
478
+ impl BasicDataFormatDescriptorHeader {
479
+ pub const LENGTH : usize = 16 ;
480
+
481
+ pub fn parse ( bytes : & [ u8 ] ) -> Result < Self , ParseError > {
480
482
let mut offset = 0 ;
481
483
482
484
let v = bytes_to_u32 ( bytes, & mut offset) ?;
@@ -513,12 +515,29 @@ impl<'data> BasicDataFormatDescriptor<'data> {
513
515
flags : DataFormatFlags :: from_bits_truncate ( flags) ,
514
516
texel_block_dimensions,
515
517
bytes_planes,
516
- sample_data : & bytes[ offset..] ,
518
+ } )
519
+ }
520
+ }
521
+
522
+ pub struct BasicDataFormatDescriptor < ' data > {
523
+ pub header : BasicDataFormatDescriptorHeader ,
524
+ sample_information : & ' data [ u8 ] ,
525
+ }
526
+
527
+ impl < ' data > BasicDataFormatDescriptor < ' data > {
528
+ pub fn parse ( bytes : & ' data [ u8 ] ) -> Result < Self , ParseError > {
529
+ let header = BasicDataFormatDescriptorHeader :: parse ( bytes) ?;
530
+
531
+ Ok ( Self {
532
+ header,
533
+ sample_information : & bytes[ BasicDataFormatDescriptorHeader :: LENGTH ..] ,
517
534
} )
518
535
}
519
536
520
537
pub fn sample_information ( & self ) -> impl Iterator < Item = SampleInformation > + ' data {
521
- SampleInformationIterator { data : self . sample_data }
538
+ SampleInformationIterator {
539
+ data : self . sample_information ,
540
+ }
522
541
}
523
542
}
524
543
0 commit comments