@@ -853,13 +853,18 @@ func decodeBox(ctx *decodeContext, d *decode.D, typ string) {
853
853
}
854
854
})
855
855
case "ctts" :
856
- d .FieldU8 ("version" )
856
+ version := d .FieldU8 ("version" )
857
857
d .FieldU24 ("flags" )
858
858
entryCount := d .FieldU32 ("entry_count" )
859
859
var i uint64
860
860
d .FieldStructArrayLoop ("entries" , "entry" , func () bool { return i < entryCount }, func (d * decode.D ) {
861
861
d .FieldS32 ("sample_count" )
862
- d .FieldS32 ("sample_offset" )
862
+ switch version {
863
+ case 0 :
864
+ d .FieldU32 ("sample_offset" )
865
+ case 1 :
866
+ d .FieldS32 ("sample_offset" )
867
+ }
863
868
i ++
864
869
})
865
870
// TODO: refactor: merge with stco?
@@ -1006,7 +1011,7 @@ func decodeBox(ctx *decodeContext, d *decode.D, typ string) {
1006
1011
m = t .moof
1007
1012
}
1008
1013
1009
- d .FieldU8 ("version" )
1014
+ version := d .FieldU8 ("version" )
1010
1015
sampleCompositionTimeOffsetsPresent := false
1011
1016
sampleFlagsPresent := false
1012
1017
sampleSizePresent := false
@@ -1054,7 +1059,11 @@ func decodeBox(ctx *decodeContext, d *decode.D, typ string) {
1054
1059
d .FieldStruct ("sample_flags" , decodeSampleFlags )
1055
1060
}
1056
1061
if sampleCompositionTimeOffsetsPresent {
1057
- d .FieldU32 ("sample_composition_time_offset" )
1062
+ if version == 0 {
1063
+ d .FieldU32 ("sample_composition_time_offset" )
1064
+ } else {
1065
+ d .FieldS32 ("sample_composition_time_offset" )
1066
+ }
1058
1067
}
1059
1068
})
1060
1069
@@ -1166,27 +1175,54 @@ func decodeBox(ctx *decodeContext, d *decode.D, typ string) {
1166
1175
}
1167
1176
})
1168
1177
case "infe" :
1169
- d .FieldU8 ("version" )
1178
+ version := d .FieldU8 ("version" )
1170
1179
d .FieldU24 ("flags" )
1171
- d .FieldU16 ("id" )
1172
- d .FieldU16 ("protection_index" )
1173
- d .FieldUTF8Null ("item_name" )
1174
- // TODO: really optional? seems so
1175
- if d .NotEnd () {
1180
+ if version == 0 || version == 1 {
1181
+ d .FieldU16 ("item_id" )
1182
+ d .FieldU16 ("item_protection_index" )
1183
+ d .FieldUTF8Null ("item_name" )
1176
1184
d .FieldUTF8Null ("content_type" )
1185
+ if ! d .End () {
1186
+ d .FieldUTF8Null ("content_encoding" )
1187
+ }
1177
1188
}
1178
- if d .NotEnd () {
1179
- d .FieldUTF8Null ("content_encoding" )
1189
+ if version == 1 {
1190
+ if ! d .End () {
1191
+ d .FieldU32 ("extension_type" )
1192
+ }
1193
+ if ! d .End () {
1194
+ d .FieldU32 ("extension_type_extra" )
1195
+ }
1196
+ }
1197
+ if version >= 2 {
1198
+ switch version {
1199
+ case 2 :
1200
+ d .FieldU16 ("item_id" )
1201
+ case 3 :
1202
+ d .FieldU32 ("item_id" )
1203
+ }
1204
+ d .FieldU16 ("item_protection_index" )
1205
+ itemType := d .FieldUTF8 ("item_type" , 4 )
1206
+ d .FieldUTF8Null ("item_name" )
1207
+ switch itemType {
1208
+ case "mime" :
1209
+ d .FieldUTF8Null ("content_type" )
1210
+ if ! d .End () {
1211
+ d .FieldUTF8Null ("content_encoding" )
1212
+ }
1213
+ case "uri " :
1214
+ d .FieldUTF8Null ("item_uri_type" )
1215
+ }
1180
1216
}
1181
1217
case "iinf" :
1182
1218
version := d .FieldU8 ("version" )
1183
1219
d .FieldU24 ("flags" )
1184
1220
if version == 0 {
1185
- _ = d .FieldU16 ("entry_count" )
1186
- decodeBoxes (ctx , d )
1221
+ d .FieldU16 ("entry_count" )
1187
1222
} else {
1188
- d .FieldRawLen ( "data" , d . BitsLeft () )
1223
+ d .FieldU32 ( "entry_count" )
1189
1224
}
1225
+ decodeBoxes (ctx , d )
1190
1226
case "iprp" :
1191
1227
decodeBoxes (ctx , d )
1192
1228
case "ipco" :
@@ -1609,7 +1645,7 @@ func decodeBox(ctx *decodeContext, d *decode.D, typ string) {
1609
1645
case "pitm" :
1610
1646
version := d .FieldU8 ("version" )
1611
1647
d .FieldU24 ("flags" )
1612
- if version < 1 {
1648
+ if version == 0 {
1613
1649
d .FieldU16 ("item_id" )
1614
1650
} else {
1615
1651
d .FieldU32 ("item_id" )
0 commit comments