@@ -1297,6 +1297,7 @@ pub unsafe extern "C" fn mp4parse_avif_get_indice_table(
1297
1297
parser : * mut Mp4parseAvifParser ,
1298
1298
track_id : u32 ,
1299
1299
indices : * mut Mp4parseByteData ,
1300
+ timescale : * mut u64 ,
1300
1301
) -> Mp4parseStatus {
1301
1302
if parser. is_null ( ) {
1302
1303
return Mp4parseStatus :: BadArg ;
@@ -1306,10 +1307,35 @@ pub unsafe extern "C" fn mp4parse_avif_get_indice_table(
1306
1307
return Mp4parseStatus :: BadArg ;
1307
1308
}
1308
1309
1310
+ if timescale. is_null ( ) {
1311
+ return Mp4parseStatus :: BadArg ;
1312
+ }
1313
+
1309
1314
// Initialize fields to default values to ensure all fields are always valid.
1310
1315
* indices = Default :: default ( ) ;
1311
1316
1312
1317
if let Some ( sequence) = & ( * parser) . context . sequence {
1318
+ // Use the top level timescale, and the track timescale if present.
1319
+ let mut found_timescale = false ;
1320
+ if let Some ( context_timescale) = sequence. timescale {
1321
+ * timescale = context_timescale. 0 ;
1322
+ found_timescale = true ;
1323
+ }
1324
+ let maybe_track_timescale = match sequence
1325
+ . tracks
1326
+ . iter ( )
1327
+ . find ( |track| track. track_id == Some ( track_id) )
1328
+ {
1329
+ Some ( track) => track. timescale ,
1330
+ _ => None ,
1331
+ } ;
1332
+ if let Some ( track_timescale) = maybe_track_timescale {
1333
+ found_timescale = true ;
1334
+ * timescale = track_timescale. 0 ;
1335
+ }
1336
+ if !found_timescale {
1337
+ return Mp4parseStatus :: Invalid ;
1338
+ }
1313
1339
return get_indice_table (
1314
1340
sequence,
1315
1341
& mut ( * parser) . sample_table ,
0 commit comments