fn new(track: &TrackBox, from: u32, to: u32) -> SampleDefaults {
        let tables = track.media().media_info().sample_table();

        // If the TimeToSample box has just one entry, it covers all
        // samples so that one entry is the default.
        let entries = &tables.time_to_sample().entries;
        let sample_duration = if entries.len() == 1 {
            Some(entries[0].delta)
        } else {
            None
        };

        // If 'size' in the SampleSize box > 0, then all entries
        // have the same size, so use that as the default.
        // samples so that one entry is the default.
        let size = tables.sample_size().size;
        let sample_size = if size > 0 { Some(size) } else { None };

        // We have a SyncSampleBox. Skip the first sample. Then if the rest is all
        // sync or all non-sync, use that as the default.
        let sample_flags;
        if let Some(sync_table) = tables.sync_samples() {
            let mut is_sync = 0_u32;
            if to >= 1 && to != u32::MAX {
                for entry in &sync_table.entries {
                    if *entry > from && *entry <= to {
                        is_sync += 1;
                    }
                    if *entry > to {
                        break;
                    }
                }
            }
            if is_sync == 0 || is_sync == to - from {
                sample_flags = Some(build_sample_flags(is_sync > 0));
            } else {
                sample_flags = None;
            }
        } else {
            // No SyncSampleBox means all samples are sync.
            sample_flags = Some(build_sample_flags(true));
        }

        // If there is no composition offset box, the default is 0.
        let sample_composition_time_offset = if tables.composition_time_to_sample().is_some() {
            None
        } else {
            Some(0)
        };

        SampleDefaults {
            sample_duration,
            sample_flags,
            sample_size,
            sample_composition_time_offset,
        }
    }
//
// Analyze the tables in the SampleTableBox and see if there are any
// defaults for the samples in this track.
//
Analyze the tables in the SampleTableBox and see if there are any
defaults for the samples in this track.
Analyze the tables in the SampleTableBox and see if there are any defaults for the samples in this track .
fn new(track: &TrackBox, from: u32, to: u32) -> SampleDefaults {
        let tables = track.media().media_info().sample_table();
        // If the TimeToSample box has just one entry, it covers all
        // samples so that one entry is the default.
        let entries = &tables.time_to_sample().entries;
        let sample_duration = if entries.len() == 1 {
            Some(entries[0].delta)
        } else {
            None
        };
        // If 'size' in the SampleSize box > 0, then all entries
        // have the same size, so use that as the default.
        // samples so that one entry is the default.
        let size = tables.sample_size().size;
        let sample_size = if size > 0 { Some(size) } else { None };
        // We have a SyncSampleBox. Skip the first sample. Then if the rest is all
        // sync or all non-sync, use that as the default.
        let sample_flags;
        if let Some(sync_table) = tables.sync_samples() {
            let mut is_sync = 0_u32;
            if to >= 1 && to != u32::MAX {
                for entry in &sync_table.entries {
                    if *entry > from && *entry <= to {
                        is_sync += 1;
                    }
                    if *entry > to {
                        break;
                    }
                }
            }
            if is_sync == 0 || is_sync == to - from {
                sample_flags = Some(build_sample_flags(is_sync > 0));
            } else {
                sample_flags = None;
            }
        } else {
            // No SyncSampleBox means all samples are sync.
            sample_flags = Some(build_sample_flags(true));
        }
        // If there is no composition offset box, the default is 0.
        let sample_composition_time_offset = if tables.composition_time_to_sample().is_some() {
            None
        } else {
            Some(0)
        };
        SampleDefaults {
            sample_duration,
            sample_flags,
            sample_size,
            sample_composition_time_offset,
        }
    }
fn new ( track : & TrackBox , from : u32 , to : u32 ) -> SampleDefaults { let tables = track . media ( ) . media_info ( ) . sample_table ( ) ; // If the TimeToSample box has just one entry, it covers all // samples so that one entry is the default. let entries = & tables . time_to_sample ( ) . entries ; let sample_duration = if entries . len ( ) == 1 { Some ( entries [ 0 ] . delta ) } else { None } ; // If 'size' in the SampleSize box > 0, then all entries // have the same size, so use that as the default. // samples so that one entry is the default. let size = tables . sample_size ( ) . size ; let sample_size = if size > 0 { Some ( size ) } else { None } ; // We have a SyncSampleBox. Skip the first sample. Then if the rest is all // sync or all non-sync, use that as the default. let sample_flags ; if let Some ( sync_table ) = tables . sync_samples ( ) { let mut is_sync = 0_u32 ; if to >= 1 && to != u32 :: MAX { for entry in & sync_table . entries { if * entry > from && * entry <= to { is_sync += 1 ; } if * entry > to { break ; } } } if is_sync == 0 || is_sync == to - from { sample_flags = Some ( build_sample_flags ( is_sync > 0 ) ) ; } else { sample_flags = None ; } } else { // No SyncSampleBox means all samples are sync. sample_flags = Some ( build_sample_flags ( true ) ) ; } // If there is no composition offset box, the default is 0. let sample_composition_time_offset = if tables . composition_time_to_sample ( ) . is_some ( ) { None } else { Some ( 0 ) } ; SampleDefaults { sample_duration , sample_flags , sample_size , sample_composition_time_offset , } }
Analyze the tables in the SampleTableBox and see if there are any
defaults for the samples in this track.
Analyze the tables in the SampleTableBox and see if there are any defaults for the samples in this track .
track
&TrackBox
from
u32
to
u32
track
&TrackBox
from
u32
to
u32