1178825Sdfr// Copyright 2018 The Fuchsia Authors. All rights reserved.
2178825Sdfr// Use of this source code is governed by a BSD-style license that can be
3178825Sdfr// found in the LICENSE file.
4178825Sdfr
5178825Sdfr#pragma once
6178825Sdfr
7178825Sdfr#include <inttypes.h>
8178825Sdfr
9178825Sdfrstatic inline uint32_t interpolate(uint32_t max, int32_t cur_frame, int32_t period) {
10178825Sdfr    float fraction = ((float) (cur_frame % period)) / ((float) period - 1);
11178825Sdfr    fraction = (cur_frame / period) % 2 ? 1.0f - fraction : fraction;
12178825Sdfr    return (uint32_t) ((float) max * fraction);
13178825Sdfr}
14178825Sdfr
15178825Sdfr