31#define WS_MAX_CHANNELS 32
32#define INF_TS 0x7FFFFFFFFFFFFFFF
108#define LCG_A 1284865837
109#define LCG_C 4150755663
110#define LCG_AI 849225893
120 uint32_t
a,
c, t = *
s;
148 for (j = 0; j < 7; j++) {
168 if (
b < (uint64_t)1 << 32) {
170 return ((
a /
b) << 32) | ((
a %
b) << 32) /
b;
172 if (
b < (uint64_t)1 << 48) {
173 for (
i = 0;
i < 4;
i++) {
175 r = (
r << 16) | (
a /
b);
180 for (
i = 63;
i >= 0;
i--) {
181 if (
a >= (uint64_t)1 << 63 ||
a << 1 >=
b) {
182 r |= (uint64_t)1 <<
i;
193 uint64_t dt = ts - (uint64_t)in->
ts_start;
194 uint64_t dt2 = dt & 1 ?
195 dt * ((dt - 1) >> 1) : (dt >> 1) * (dt - 1);
223 uint64_t pink_ts_next = ts & ~(
PINK_UNIT - 1);
240 uint8_t *edata, *edata_end;
243 int64_t dphi1, dphi2, dt, cur_ts = -0x8000000000000000;
259 if (edata_end - edata < 24)
275 if (edata_end - edata < 20 || avc->sample_rate <= 0)
287 if (
phi & 0x80000000) {
293 in->
phi0 = (uint64_t)
phi << 33;
297 if (edata_end - edata < 8)
306 in->
amp0 = (uint64_t)
a1 << 32;
307 in->
damp = (
int64_t)(((uint64_t)
a2 << 32) - ((uint64_t)
a1 << 32)) / dt;
309 if (edata != edata_end)
321 "This implementation is limited to %d channels.\n",
352 uint32_t
c, all_ch = 0;
376 val =
amp * (unsigned)pink;
384 *cv += (unsigned)
val;
428 if (packet->
size != 12)
440 pcm = (int16_t *)
frame->data[0];
464 .p.name =
"wavesynth",
static double val(void *priv, double ch)
const FFCodec ff_ffwavesynth_decoder
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static __device__ float floor(float a)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
static void wavesynth_enter_intervals(struct wavesynth_context *ws, int64_t ts)
static int wavesynth_parse_extradata(AVCodecContext *avc)
static uint64_t phi_at(struct ws_interval *in, int64_t ts)
static av_cold int wavesynth_close(AVCodecContext *avc)
static av_cold int wavesynth_init(AVCodecContext *avc)
static int wavesynth_decode(AVCodecContext *avc, AVFrame *frame, int *rgot_frame, AVPacket *packet)
static uint64_t frac64(uint64_t a, uint64_t b)
static void lcg_seek(uint32_t *s, uint32_t dt)
static uint32_t lcg_next(uint32_t *s)
static void wavesynth_synth_sample(struct wavesynth_context *ws, int64_t ts, int32_t *channels)
static void wavesynth_seek(struct wavesynth_context *ws, int64_t ts)
static void pink_fill(struct wavesynth_context *ws)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
@ AV_CODEC_ID_FFWAVESYNTH
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_SAMPLE_FMT_S16
signed 16 bits
#define MKTAG(a, b, c, d)
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
int nb_channels
Number of channels in this layout.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
int sample_rate
samples per second
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
struct ws_interval * inter
int32_t pink_pool[PINK_UNIT]
enum ws_interval_type type
static double a2(void *priv, double x, double y)
static double a1(void *priv, double x, double y)