FFmpeg
ffwavesynth.c
Go to the documentation of this file.
1 /*
2  * Wavesynth pseudo-codec
3  * Copyright (c) 2011 Nicolas George
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "libavutil/intreadwrite.h"
23 #include "libavutil/log.h"
24 #include "avcodec.h"
25 #include "codec_internal.h"
26 #include "decode.h"
27 
28 
29 #define SIN_BITS 14
30 #define WS_MAX_CHANNELS 32
31 #define INF_TS 0x7FFFFFFFFFFFFFFF
32 
33 #define PINK_UNIT 128
34 
35 /*
36  Format of the extradata and packets
37 
38  THIS INFORMATION IS NOT PART OF THE PUBLIC API OR ABI.
39  IT CAN CHANGE WITHOUT NOTIFICATION.
40 
41  All numbers are in little endian.
42 
43  The codec extradata define a set of intervals with uniform content.
44  Overlapping intervals are added together.
45 
46  extradata:
47  uint32 number of intervals
48  ... intervals
49 
50  interval:
51  int64 start timestamp; time_base must be 1/sample_rate;
52  start timestamps must be in ascending order
53  int64 end timestamp
54  uint32 type
55  uint32 channels mask
56  ... additional information, depends on type
57 
58  sine interval (type fourcc "SINE"):
59  int32 start frequency, in 1/(1<<16) Hz
60  int32 end frequency
61  int32 start amplitude, 1<<16 is the full amplitude
62  int32 end amplitude
63  uint32 start phase, 0 is sin(0), 0x20000000 is sin(pi/2), etc.;
64  n | (1<<31) means to match the phase of previous channel #n
65 
66  pink noise interval (type fourcc "NOIS"):
67  int32 start amplitude
68  int32 end amplitude
69 
70  The input packets encode the time and duration of the requested segment.
71 
72  packet:
73  int64 start timestamp
74  int32 duration
75 
76 */
77 
79  WS_SINE = MKTAG('S','I','N','E'),
80  WS_NOISE = MKTAG('N','O','I','S'),
81 };
82 
83 struct ws_interval {
84  int64_t ts_start, ts_end;
85  uint64_t phi0, dphi0, ddphi;
86  uint64_t amp0, damp;
87  uint64_t phi, dphi, amp;
88  uint32_t channels;
90  int next;
91 };
92 
94  int64_t cur_ts;
95  int64_t next_ts;
97  struct ws_interval *inter;
98  uint32_t dither_state;
99  uint32_t pink_state;
101  unsigned pink_need, pink_pos;
102  int nb_inter;
105 };
106 
107 #define LCG_A 1284865837
108 #define LCG_C 4150755663
109 #define LCG_AI 849225893 /* A*AI = 1 [mod 1<<32] */
110 
111 static uint32_t lcg_next(uint32_t *s)
112 {
113  *s = *s * LCG_A + LCG_C;
114  return *s;
115 }
116 
117 static void lcg_seek(uint32_t *s, uint32_t dt)
118 {
119  uint32_t a, c, t = *s;
120 
121  a = LCG_A;
122  c = LCG_C;
123  while (dt) {
124  if (dt & 1)
125  t = a * t + c;
126  c *= a + 1; /* coefficients for a double step */
127  a *= a;
128  dt >>= 1;
129  }
130  *s = t;
131 }
132 
133 /* Emulate pink noise by summing white noise at the sampling frequency,
134  * white noise at half the sampling frequency (each value taken twice),
135  * etc., with a total of 8 octaves.
136  * This is known as the Voss-McCartney algorithm. */
137 
138 static void pink_fill(struct wavesynth_context *ws)
139 {
140  int32_t vt[7] = { 0 }, v = 0;
141  int i, j;
142 
143  ws->pink_pos = 0;
144  if (!ws->pink_need)
145  return;
146  for (i = 0; i < PINK_UNIT; i++) {
147  for (j = 0; j < 7; j++) {
148  if ((i >> j) & 1)
149  break;
150  v -= vt[j];
151  vt[j] = (int32_t)lcg_next(&ws->pink_state) >> 3;
152  v += vt[j];
153  }
154  ws->pink_pool[i] = v + ((int32_t)lcg_next(&ws->pink_state) >> 3);
155  }
156  lcg_next(&ws->pink_state); /* so we use exactly 256 steps */
157 }
158 
159 /**
160  * @return (1<<64) * a / b, without overflow, if a < b
161  */
162 static uint64_t frac64(uint64_t a, uint64_t b)
163 {
164  uint64_t r = 0;
165  int i;
166 
167  if (b < (uint64_t)1 << 32) { /* b small, use two 32-bits steps */
168  a <<= 32;
169  return ((a / b) << 32) | ((a % b) << 32) / b;
170  }
171  if (b < (uint64_t)1 << 48) { /* b medium, use four 16-bits steps */
172  for (i = 0; i < 4; i++) {
173  a <<= 16;
174  r = (r << 16) | (a / b);
175  a %= b;
176  }
177  return r;
178  }
179  for (i = 63; i >= 0; i--) {
180  if (a >= (uint64_t)1 << 63 || a << 1 >= b) {
181  r |= (uint64_t)1 << i;
182  a = (a << 1) - b;
183  } else {
184  a <<= 1;
185  }
186  }
187  return r;
188 }
189 
190 static uint64_t phi_at(struct ws_interval *in, int64_t ts)
191 {
192  uint64_t dt = ts - (uint64_t)in->ts_start;
193  uint64_t dt2 = dt & 1 ? /* dt * (dt - 1) / 2 without overflow */
194  dt * ((dt - 1) >> 1) : (dt >> 1) * (dt - 1);
195  return in->phi0 + dt * in->dphi0 + dt2 * in->ddphi;
196 }
197 
198 static void wavesynth_seek(struct wavesynth_context *ws, int64_t ts)
199 {
200  int *last, i;
201  struct ws_interval *in;
202 
203  last = &ws->cur_inter;
204  for (i = 0; i < ws->nb_inter; i++) {
205  in = &ws->inter[i];
206  if (ts < in->ts_start)
207  break;
208  if (ts >= in->ts_end)
209  continue;
210  *last = i;
211  last = &in->next;
212  in->phi = phi_at(in, ts);
213  in->dphi = in->dphi0 + (ts - in->ts_start) * in->ddphi;
214  in->amp = in->amp0 + (ts - in->ts_start) * in->damp;
215  }
216  ws->next_inter = i;
217  ws->next_ts = i < ws->nb_inter ? ws->inter[i].ts_start : INF_TS;
218  *last = -1;
219  lcg_seek(&ws->dither_state, (uint32_t)ts - (uint32_t)ws->cur_ts);
220  if (ws->pink_need) {
221  uint64_t pink_ts_cur = (ws->cur_ts + (uint64_t)PINK_UNIT - 1) & ~(PINK_UNIT - 1);
222  uint64_t pink_ts_next = ts & ~(PINK_UNIT - 1);
223  int pos = ts & (PINK_UNIT - 1);
224  lcg_seek(&ws->pink_state, (uint32_t)(pink_ts_next - pink_ts_cur) * 2);
225  if (pos) {
226  pink_fill(ws);
227  ws->pink_pos = pos;
228  } else {
229  ws->pink_pos = PINK_UNIT;
230  }
231  }
232  ws->cur_ts = ts;
233 }
234 
236 {
237  struct wavesynth_context *ws = avc->priv_data;
238  struct ws_interval *in;
239  uint8_t *edata, *edata_end;
240  int32_t f1, f2, a1, a2;
241  uint32_t phi;
242  int64_t dphi1, dphi2, dt, cur_ts = -0x8000000000000000;
243  int i;
244 
245  if (avc->extradata_size < 4)
246  return AVERROR(EINVAL);
247  edata = avc->extradata;
248  edata_end = edata + avc->extradata_size;
249  ws->nb_inter = AV_RL32(edata);
250  edata += 4;
251  if (ws->nb_inter < 0 || (edata_end - edata) / 24 < ws->nb_inter)
252  return AVERROR(EINVAL);
253  ws->inter = av_calloc(ws->nb_inter, sizeof(*ws->inter));
254  if (!ws->inter)
255  return AVERROR(ENOMEM);
256  for (i = 0; i < ws->nb_inter; i++) {
257  in = &ws->inter[i];
258  if (edata_end - edata < 24)
259  return AVERROR(EINVAL);
260  in->ts_start = AV_RL64(edata + 0);
261  in->ts_end = AV_RL64(edata + 8);
262  in->type = AV_RL32(edata + 16);
263  in->channels = AV_RL32(edata + 20);
264  edata += 24;
265  if (in->ts_start < cur_ts ||
266  in->ts_end <= in->ts_start ||
267  (uint64_t)in->ts_end - in->ts_start > INT64_MAX
268  )
269  return AVERROR(EINVAL);
270  cur_ts = in->ts_start;
271  dt = in->ts_end - in->ts_start;
272  switch (in->type) {
273  case WS_SINE:
274  if (edata_end - edata < 20 || avc->sample_rate <= 0)
275  return AVERROR(EINVAL);
276  f1 = AV_RL32(edata + 0);
277  f2 = AV_RL32(edata + 4);
278  a1 = AV_RL32(edata + 8);
279  a2 = AV_RL32(edata + 12);
280  phi = AV_RL32(edata + 16);
281  edata += 20;
282  dphi1 = frac64(f1, (int64_t)avc->sample_rate << 16);
283  dphi2 = frac64(f2, (int64_t)avc->sample_rate << 16);
284  in->dphi0 = dphi1;
285  in->ddphi = (int64_t)(dphi2 - (uint64_t)dphi1) / dt;
286  if (phi & 0x80000000) {
287  phi &= ~0x80000000;
288  if (phi >= i)
289  return AVERROR(EINVAL);
290  in->phi0 = phi_at(&ws->inter[phi], in->ts_start);
291  } else {
292  in->phi0 = (uint64_t)phi << 33;
293  }
294  break;
295  case WS_NOISE:
296  if (edata_end - edata < 8)
297  return AVERROR(EINVAL);
298  a1 = AV_RL32(edata + 0);
299  a2 = AV_RL32(edata + 4);
300  edata += 8;
301  break;
302  default:
303  return AVERROR(EINVAL);
304  }
305  in->amp0 = (uint64_t)a1 << 32;
306  in->damp = (int64_t)(((uint64_t)a2 << 32) - ((uint64_t)a1 << 32)) / dt;
307  }
308  if (edata != edata_end)
309  return AVERROR(EINVAL);
310  return 0;
311 }
312 
314 {
315  struct wavesynth_context *ws = avc->priv_data;
316  int i, r;
317 
319  av_log(avc, AV_LOG_ERROR,
320  "This implementation is limited to %d channels.\n",
322  return AVERROR(EINVAL);
323  }
325  if (r < 0) {
326  av_log(avc, AV_LOG_ERROR, "Invalid intervals definitions.\n");
327  return r;
328  }
329  ws->sin = av_malloc(sizeof(*ws->sin) << SIN_BITS);
330  if (!ws->sin)
331  return AVERROR(ENOMEM);
332  for (i = 0; i < 1 << SIN_BITS; i++)
333  ws->sin[i] = floor(32767 * sin(2 * M_PI * i / (1 << SIN_BITS)));
334  ws->dither_state = MKTAG('D','I','T','H');
335  for (i = 0; i < ws->nb_inter; i++)
336  ws->pink_need += ws->inter[i].type == WS_NOISE;
337  ws->pink_state = MKTAG('P','I','N','K');
338  ws->pink_pos = PINK_UNIT;
339  wavesynth_seek(ws, 0);
341  return 0;
342 }
343 
344 static void wavesynth_synth_sample(struct wavesynth_context *ws, int64_t ts,
345  int32_t *channels)
346 {
347  int32_t amp, *cv;
348  unsigned val;
349  struct ws_interval *in;
350  int i, *last, pink;
351  uint32_t c, all_ch = 0;
352 
353  i = ws->cur_inter;
354  last = &ws->cur_inter;
355  if (ws->pink_pos == PINK_UNIT)
356  pink_fill(ws);
357  pink = ws->pink_pool[ws->pink_pos++] >> 16;
358  while (i >= 0) {
359  in = &ws->inter[i];
360  i = in->next;
361  if (ts >= in->ts_end) {
362  *last = i;
363  continue;
364  }
365  last = &in->next;
366  amp = in->amp >> 32;
367  in->amp += in->damp;
368  switch (in->type) {
369  case WS_SINE:
370  val = amp * (unsigned)ws->sin[in->phi >> (64 - SIN_BITS)];
371  in->phi += in->dphi;
372  in->dphi += in->ddphi;
373  break;
374  case WS_NOISE:
375  val = amp * (unsigned)pink;
376  break;
377  default:
378  val = 0;
379  }
380  all_ch |= in->channels;
381  for (c = in->channels, cv = channels; c; c >>= 1, cv++)
382  if (c & 1)
383  *cv += (unsigned)val;
384  }
385  val = (int32_t)lcg_next(&ws->dither_state) >> 16;
386  for (c = all_ch, cv = channels; c; c >>= 1, cv++)
387  if (c & 1)
388  *cv += val;
389 }
390 
391 static void wavesynth_enter_intervals(struct wavesynth_context *ws, int64_t ts)
392 {
393  int *last, i;
394  struct ws_interval *in;
395 
396  last = &ws->cur_inter;
397  for (i = ws->cur_inter; i >= 0; i = ws->inter[i].next)
398  last = &ws->inter[i].next;
399  for (i = ws->next_inter; i < ws->nb_inter; i++) {
400  in = &ws->inter[i];
401  if (ts < in->ts_start)
402  break;
403  if (ts >= in->ts_end)
404  continue;
405  *last = i;
406  last = &in->next;
407  in->phi = in->phi0;
408  in->dphi = in->dphi0;
409  in->amp = in->amp0;
410  }
411  ws->next_inter = i;
412  ws->next_ts = i < ws->nb_inter ? ws->inter[i].ts_start : INF_TS;
413  *last = -1;
414 }
415 
417  int *rgot_frame, AVPacket *packet)
418 {
419  struct wavesynth_context *ws = avc->priv_data;
420  int64_t ts;
421  int duration;
422  int s, c, r;
423  int16_t *pcm;
425 
426  *rgot_frame = 0;
427  if (packet->size != 12)
428  return AVERROR_INVALIDDATA;
429  ts = AV_RL64(packet->data);
430  if (ts != ws->cur_ts)
431  wavesynth_seek(ws, ts);
432  duration = AV_RL32(packet->data + 8);
433  if (duration <= 0)
434  return AVERROR(EINVAL);
436  r = ff_get_buffer(avc, frame, 0);
437  if (r < 0)
438  return r;
439  pcm = (int16_t *)frame->data[0];
440  for (s = 0; s < duration; s++, ts+=(uint64_t)1) {
441  memset(channels, 0, avc->ch_layout.nb_channels * sizeof(*channels));
442  if (ts >= ws->next_ts)
445  for (c = 0; c < avc->ch_layout.nb_channels; c++)
446  *(pcm++) = channels[c] >> 16;
447  }
448  ws->cur_ts += (uint64_t)duration;
449  *rgot_frame = 1;
450  return packet->size;
451 }
452 
454 {
455  struct wavesynth_context *ws = avc->priv_data;
456 
457  av_freep(&ws->sin);
458  av_freep(&ws->inter);
459  return 0;
460 }
461 
463  .p.name = "wavesynth",
464  CODEC_LONG_NAME("Wave synthesis pseudo-codec"),
465  .p.type = AVMEDIA_TYPE_AUDIO,
466  .p.id = AV_CODEC_ID_FFWAVESYNTH,
467  .priv_data_size = sizeof(struct wavesynth_context),
468  .init = wavesynth_init,
469  .close = wavesynth_close,
471  .p.capabilities = AV_CODEC_CAP_DR1,
472  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
473 };
ws_interval::phi
uint64_t phi
Definition: ffwavesynth.c:87
ff_ffwavesynth_decoder
const FFCodec ff_ffwavesynth_decoder
Definition: ffwavesynth.c:462
ws_interval::type
enum ws_interval_type type
Definition: ffwavesynth.c:89
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
r
const char * r
Definition: vf_curves.c:126
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
wavesynth_context::pink_state
uint32_t pink_state
Definition: ffwavesynth.c:99
AVCodecContext::sample_rate
int sample_rate
samples per second
Definition: avcodec.h:1050
wavesynth_context::next_inter
int next_inter
Definition: ffwavesynth.c:104
AV_RL64
uint64_t_TMPL AV_RL64
Definition: bytestream.h:91
ws_interval::amp0
uint64_t amp0
Definition: ffwavesynth.c:86
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
wavesynth_context::pink_need
unsigned pink_need
Definition: ffwavesynth.c:101
b
#define b
Definition: input.c:41
wavesynth_context::inter
struct ws_interval * inter
Definition: ffwavesynth.c:97
FFCodec
Definition: codec_internal.h:127
wavesynth_context::nb_inter
int nb_inter
Definition: ffwavesynth.c:102
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:313
wavesynth_synth_sample
static void wavesynth_synth_sample(struct wavesynth_context *ws, int64_t ts, int32_t *channels)
Definition: ffwavesynth.c:344
sample_rate
sample_rate
Definition: ffmpeg_filter.c:425
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:361
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
wavesynth_context::cur_ts
int64_t cur_ts
Definition: ffwavesynth.c:94
ws_interval::ts_start
int64_t ts_start
Definition: ffwavesynth.c:84
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
AVCodecContext::ch_layout
AVChannelLayout ch_layout
Audio channel layout.
Definition: avcodec.h:1065
ws_interval::dphi
uint64_t dphi
Definition: ffwavesynth.c:87
val
static double val(void *priv, double ch)
Definition: aeval.c:78
wavesynth_context::cur_inter
int cur_inter
Definition: ffwavesynth.c:103
AV_CODEC_ID_FFWAVESYNTH
@ AV_CODEC_ID_FFWAVESYNTH
Definition: codec_id.h:508
LCG_A
#define LCG_A
Definition: ffwavesynth.c:107
phi_at
static uint64_t phi_at(struct ws_interval *in, int64_t ts)
Definition: ffwavesynth.c:190
wavesynth_parse_extradata
static int wavesynth_parse_extradata(AVCodecContext *avc)
Definition: ffwavesynth.c:235
a1
#define a1
Definition: regdef.h:47
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
ws_interval::next
int next
Definition: ffwavesynth.c:90
av_cold
#define av_cold
Definition: attributes.h:90
ws_interval::ddphi
uint64_t ddphi
Definition: ffwavesynth.c:85
duration
int64_t duration
Definition: movenc.c:64
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:524
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:287
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
ws_interval::f2
int32_t f2
Definition: sbgdec.c:150
wavesynth_decode
static int wavesynth_decode(AVCodecContext *avc, AVFrame *frame, int *rgot_frame, AVPacket *packet)
Definition: ffwavesynth.c:416
floor
static __device__ float floor(float a)
Definition: cuda_runtime.h:173
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
frac64
static uint64_t frac64(uint64_t a, uint64_t b)
Definition: ffwavesynth.c:162
ws_interval::phi0
uint64_t phi0
Definition: ffwavesynth.c:85
WS_SINE
@ WS_SINE
Definition: ffwavesynth.c:79
wavesynth_context::sin
int32_t * sin
Definition: ffwavesynth.c:96
channels
channels
Definition: aptx.h:31
decode.h
wavesynth_context
Definition: ffwavesynth.c:93
wavesynth_enter_intervals
static void wavesynth_enter_intervals(struct wavesynth_context *ws, int64_t ts)
Definition: ffwavesynth.c:391
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
frame
static AVFrame * frame
Definition: demux_decode.c:54
SIN_BITS
#define SIN_BITS
Definition: ffwavesynth.c:29
LCG_C
#define LCG_C
Definition: ffwavesynth.c:108
ws_interval::dphi0
uint64_t dphi0
Definition: ffwavesynth.c:85
ws_interval::amp
uint64_t amp
Definition: ffwavesynth.c:87
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
PINK_UNIT
#define PINK_UNIT
Definition: ffwavesynth.c:33
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1568
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:365
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
codec_internal.h
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AVCodecContext::sample_fmt
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:1057
ws_interval::channels
uint32_t channels
Definition: ffwavesynth.c:88
INF_TS
#define INF_TS
Definition: ffwavesynth.c:31
wavesynth_seek
static void wavesynth_seek(struct wavesynth_context *ws, int64_t ts)
Definition: ffwavesynth.c:198
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
M_PI
#define M_PI
Definition: mathematics.h:67
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:420
log.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
wavesynth_init
static av_cold int wavesynth_init(AVCodecContext *avc)
Definition: ffwavesynth.c:313
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:523
WS_MAX_CHANNELS
#define WS_MAX_CHANNELS
Definition: ffwavesynth.c:30
wavesynth_context::next_ts
int64_t next_ts
Definition: ffwavesynth.c:95
a2
#define a2
Definition: regdef.h:48
packet
enum AVPacketSideDataType packet
Definition: decode.c:1380
wavesynth_context::pink_pool
int32_t pink_pool[PINK_UNIT]
Definition: ffwavesynth.c:100
AV_SAMPLE_FMT_S16
@ AV_SAMPLE_FMT_S16
signed 16 bits
Definition: samplefmt.h:58
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
wavesynth_context::dither_state
uint32_t dither_state
Definition: ffwavesynth.c:98
ws_interval
Definition: ffwavesynth.c:83
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
ws_interval::ts_end
int64_t ts_end
Definition: ffwavesynth.c:84
ws_interval::f1
int32_t f1
Definition: sbgdec.c:150
avcodec.h
pos
unsigned int pos
Definition: spdifenc.c:413
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
AVCodecContext
main external API structure.
Definition: avcodec.h:445
wavesynth_close
static av_cold int wavesynth_close(AVCodecContext *avc)
Definition: ffwavesynth.c:453
lcg_next
static uint32_t lcg_next(uint32_t *s)
Definition: ffwavesynth.c:111
lcg_seek
static void lcg_seek(uint32_t *s, uint32_t dt)
Definition: ffwavesynth.c:117
WS_NOISE
@ WS_NOISE
Definition: ffwavesynth.c:80
pink_fill
static void pink_fill(struct wavesynth_context *ws)
Definition: ffwavesynth.c:138
AVPacket
This structure stores compressed data.
Definition: packet.h:499
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:472
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
int32_t
int32_t
Definition: audioconvert.c:56
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
wavesynth_context::pink_pos
unsigned pink_pos
Definition: ffwavesynth.c:101
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
ws_interval::damp
uint64_t damp
Definition: ffwavesynth.c:86
ws_interval_type
ws_interval_type
Definition: ffwavesynth.c:78