2024-04-11 06:54:40 +00:00
|
|
|
/* Copyright (c) 2013-2024 Jeffrey Pfau
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef M_INTERPOLATOR_H
|
|
|
|
#define M_INTERPOLATOR_H
|
|
|
|
|
|
|
|
#include <mgba-util/common.h>
|
|
|
|
|
2024-04-16 08:21:29 +00:00
|
|
|
CXX_GUARD_START
|
|
|
|
|
2024-04-21 23:32:45 +00:00
|
|
|
enum mInterpolatorType {
|
|
|
|
mINTERPOLATOR_SINC,
|
|
|
|
mINTERPOLATOR_COSINE,
|
|
|
|
};
|
|
|
|
|
2024-04-16 08:21:29 +00:00
|
|
|
struct mInterpolationData {
|
|
|
|
int16_t (*at)(int index, const void* context);
|
|
|
|
void* context;
|
2024-04-11 06:54:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mInterpolator {
|
2024-04-16 08:21:29 +00:00
|
|
|
int16_t (*interpolate)(const struct mInterpolator* interp, const struct mInterpolationData* data, double time, double sampleStep);
|
2024-04-11 06:54:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mInterpolatorSinc {
|
|
|
|
struct mInterpolator d;
|
|
|
|
|
|
|
|
unsigned resolution;
|
|
|
|
unsigned width;
|
|
|
|
double* sincLut;
|
|
|
|
double* windowLut;
|
|
|
|
};
|
|
|
|
|
2024-04-21 23:26:20 +00:00
|
|
|
struct mInterpolatorCosine {
|
|
|
|
struct mInterpolator d;
|
|
|
|
|
|
|
|
unsigned resolution;
|
|
|
|
double* lut;
|
|
|
|
};
|
|
|
|
|
2024-04-11 06:54:40 +00:00
|
|
|
void mInterpolatorSincInit(struct mInterpolatorSinc* interp, unsigned resolution, unsigned width);
|
|
|
|
void mInterpolatorSincDeinit(struct mInterpolatorSinc* interp);
|
|
|
|
|
2024-04-21 23:26:20 +00:00
|
|
|
void mInterpolatorCosineInit(struct mInterpolatorCosine* interp, unsigned resolution);
|
|
|
|
void mInterpolatorCosineDeinit(struct mInterpolatorCosine* interp);
|
|
|
|
|
2024-04-16 08:21:29 +00:00
|
|
|
CXX_GUARD_END
|
|
|
|
|
2024-04-11 06:54:40 +00:00
|
|
|
#endif
|