@@ -3082,7 +3082,26 @@ mp4lib.boxes.SubSampleInformationBox.prototype.constructor = mp4lib.boxes.SubSam
30823082
30833083mp4lib . boxes . SubSampleInformationBox . prototype . computeLength = function ( ) {
30843084 mp4lib . boxes . FullBox . prototype . computeLength . call ( this ) ;
3085- // To Define if needed
3085+
3086+ this . size += mp4lib . fields . FIELD_UINT32 . getLength ( ) ; //entry_count size
3087+ for ( i = 0 ; i < this . entry_count ; i ++ ) {
3088+ this . size += mp4lib . fields . FIELD_UINT32 . getLength ( ) ; //sample_delta size
3089+ this . size += mp4lib . fields . FIELD_UINT16 . getLength ( ) ; //subsample_count size
3090+
3091+ if ( this . entry [ i ] . subsample_count > 0 ) {
3092+ for ( j = 0 ; j < this . entry [ i ] . subsample_count ; j ++ ) {
3093+ if ( this . version === 1 ) {
3094+ this . size += mp4lib . fields . FIELD_UINT32 . getLength ( ) ; //subsample_size size
3095+ } else {
3096+ this . size += mp4lib . fields . FIELD_UINT16 . getLength ( ) ; //subsample_size size
3097+ }
3098+
3099+ this . size += mp4lib . fields . FIELD_UINT8 . getLength ( ) ; //subsample_priority size
3100+ this . size += mp4lib . fields . FIELD_UINT8 . getLength ( ) ; //discardable size
3101+ this . size += mp4lib . fields . FIELD_UINT32 . getLength ( ) ; //reserved size
3102+ }
3103+ }
3104+ }
30863105} ;
30873106
30883107mp4lib . boxes . SubSampleInformationBox . prototype . read = function ( data , pos , end ) {
@@ -3121,7 +3140,30 @@ mp4lib.boxes.SubSampleInformationBox.prototype.read = function(data, pos, end) {
31213140
31223141mp4lib . boxes . SubSampleInformationBox . prototype . write = function ( data , pos ) {
31233142 mp4lib . boxes . FullBox . prototype . write . call ( this , data , pos ) ;
3124- // To Define if needed
3143+ var i = 0 ,
3144+ j = 0 ;
3145+
3146+ this . _writeData ( data , mp4lib . fields . FIELD_UINT32 , this . entry_count ) ;
3147+
3148+ for ( i = 0 ; i < this . entry_count ; i ++ ) {
3149+ this . _writeData ( data , mp4lib . fields . FIELD_UINT32 , this . entry [ i ] . sample_delta ) ;
3150+ this . _writeData ( data , mp4lib . fields . FIELD_UINT16 , this . entry [ i ] . subsample_count ) ;
3151+ if ( this . entry [ i ] . subsample_count > 0 ) {
3152+
3153+ for ( j = 0 ; j < this . entry [ i ] . subsample_count ; j ++ ) {
3154+ if ( this . version === 1 ) {
3155+ this . _writeData ( data , mp4lib . fields . FIELD_UINT32 , this . entry [ i ] . subSampleEntries [ j ] . subsample_size ) ;
3156+ } else {
3157+ this . _writeData ( data , mp4lib . fields . FIELD_UINT16 , this . entry [ i ] . subSampleEntries [ j ] . subsample_size ) ;
3158+ }
3159+ this . _writeData ( data , mp4lib . fields . FIELD_UINT8 , this . entry [ i ] . subSampleEntries [ j ] . subsample_priority ) ;
3160+ this . _writeData ( data , mp4lib . fields . FIELD_UINT8 , this . entry [ i ] . subSampleEntries [ j ] . discardable ) ;
3161+ this . _writeData ( data , mp4lib . fields . FIELD_UINT32 , this . entry [ i ] . subSampleEntries [ j ] . reserved ) ;
3162+ }
3163+ }
3164+ }
3165+
3166+ return this . localPos ;
31253167} ;
31263168
31273169mp4lib . registerTypeBoxes ( ) ;
0 commit comments