Go to the documentation of this file.
30 #define WS_MAX_CHANNELS 32
31 #define INF_TS 0x7FFFFFFFFFFFFFFF
107 #define LCG_A 1284865837
108 #define LCG_C 4150755663
109 #define LCG_AI 849225893
119 uint32_t
a,
c, t = *
s;
147 for (j = 0; j < 7; j++) {
167 if (
b < (uint64_t)1 << 32) {
169 return ((
a /
b) << 32) | ((
a %
b) << 32) /
b;
171 if (
b < (uint64_t)1 << 48) {
172 for (
i = 0;
i < 4;
i++) {
174 r = (
r << 16) | (
a /
b);
179 for (
i = 63;
i >= 0;
i--) {
180 if (
a >= (uint64_t)1 << 63 || a << 1 >=
b) {
181 r |= (uint64_t)1 <<
i;
192 uint64_t dt = ts - (uint64_t)in->
ts_start;
193 uint64_t dt2 = dt & 1 ?
194 dt * ((dt - 1) >> 1) : (dt >> 1) * (dt - 1);
222 uint64_t pink_ts_next = ts & ~(
PINK_UNIT - 1);
239 uint8_t *edata, *edata_end;
242 int64_t dphi1, dphi2, dt, cur_ts = -0x8000000000000000;
258 if (edata_end - edata < 24)
274 if (edata_end - edata < 20 || avc->
sample_rate <= 0)
286 if (
phi & 0x80000000) {
292 in->
phi0 = (uint64_t)
phi << 33;
296 if (edata_end - edata < 8)
305 in->
amp0 = (uint64_t)
a1 << 32;
306 in->
damp = (
int64_t)(((uint64_t)
a2 << 32) - ((uint64_t)
a1 << 32)) / dt;
308 if (edata != edata_end)
320 "This implementation is limited to %d channels.\n",
351 uint32_t
c, all_ch = 0;
375 val =
amp * (unsigned)pink;
383 *cv += (unsigned)
val;
463 .
p.
name =
"wavesynth",
const FFCodec ff_ffwavesynth_decoder
enum ws_interval_type type
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
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
int sample_rate
samples per second
This structure describes decoded (raw) audio or video data.
struct ws_interval * inter
int nb_channels
Number of channels in this layout.
static void wavesynth_synth_sample(struct wavesynth_context *ws, int64_t ts, int32_t *channels)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVCodec p
The public AVCodec.
AVChannelLayout ch_layout
Audio channel layout.
static double val(void *priv, double ch)
@ AV_CODEC_ID_FFWAVESYNTH
static uint64_t phi_at(struct ws_interval *in, int64_t ts)
static int wavesynth_parse_extradata(AVCodecContext *avc)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_CODEC_DECODE_CB(func)
static int wavesynth_decode(AVCodecContext *avc, AVFrame *frame, int *rgot_frame, AVPacket *packet)
static __device__ float floor(float a)
static uint64_t frac64(uint64_t a, uint64_t b)
static void wavesynth_enter_intervals(struct wavesynth_context *ws, int64_t ts)
#define CODEC_LONG_NAME(str)
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
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
enum AVSampleFormat sample_fmt
audio sample format
static void wavesynth_seek(struct wavesynth_context *ws, int64_t ts)
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
int nb_samples
number of audio samples (per channel) described by this frame
#define i(width, name, range_min, range_max)
static av_cold int wavesynth_init(AVCodecContext *avc)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
enum AVPacketSideDataType packet
int32_t pink_pool[PINK_UNIT]
@ AV_SAMPLE_FMT_S16
signed 16 bits
const char * name
Name of the codec implementation.
void * av_calloc(size_t nmemb, size_t size)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
main external API structure.
static av_cold int wavesynth_close(AVCodecContext *avc)
static uint32_t lcg_next(uint32_t *s)
static void lcg_seek(uint32_t *s, uint32_t dt)
static void pink_fill(struct wavesynth_context *ws)
This structure stores compressed data.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)