1 // Copyright 2018 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #pragma once
6 
7 #include <inttypes.h>
8 
interpolate(uint32_t max,int32_t cur_frame,int32_t period)9 static inline uint32_t interpolate(uint32_t max, int32_t cur_frame, int32_t period) {
10     float fraction = ((float) (cur_frame % period)) / ((float) period - 1);
11     fraction = (cur_frame / period) % 2 ? 1.0f - fraction : fraction;
12     return (uint32_t) ((float) max * fraction);
13 }
14 
15