diff --git a/lib/libmisc/sync.c b/lib/libmisc/sync.c index 06c3cc7e..2a4ae770 100644 --- a/lib/libmisc/sync.c +++ b/lib/libmisc/sync.c @@ -28,6 +28,19 @@ void TrackInit(TrackT *track) { track->type = TRACK_LINEAR; track->pending = true; + { + short prevFrame = -1; + TrackKeyT *curr; + + for (curr = track->data; curr->frame != END_KEY; curr++) { + if (curr->frame < 0) + continue; + if (prevFrame >= 0) + curr->frame += prevFrame; + prevFrame = curr->frame; + } + } + TrackAdvance(track, track->data); } diff --git a/tools/sync2c/main.go b/tools/sync2c/main.go index acaf08ae..b59a4235 100644 --- a/tools/sync2c/main.go +++ b/tools/sync2c/main.go @@ -82,6 +82,18 @@ func parseFrame(token string) (frame int64, err error) { } } + if prevFrame >= 0 { + delta := frame - prevFrame + if delta < 0 { + return 0, &parseError{ + "frame numbers must be specified in ascending order"} + } + prevFrame = frame + frame = delta + } else { + prevFrame = frame + } + return frame, err } @@ -89,6 +101,8 @@ func parseValue(token string) (value int64, err error) { return strconv.ParseInt(token, 0, 16) } +var prevFrame int64 + func parseTrack(tokens []string, track *Track) (err error) { var frame, value int64 @@ -105,9 +119,6 @@ func parseTrack(tokens []string, track *Track) (err error) { if value, err = parseValue(tokens[1]); err != nil { return err } - if track.First != nil && track.First.Key > int(frame) { - return &parseError{"frame numbers must be specified in ascending order"} - } if len(tokens) == 3 && tokens[2][0] == '!' { typ := tokens[2][1:] @@ -167,6 +178,7 @@ func parseSyncFile(path string) []Track { // Create new track if tokens[0] == "@track" { + prevFrame = -1 track = &Track{RawName: tokens[1]} continue }