Go to the documentation of this file.
32 #define SBG_SCALE (1 << 16)
33 #define DAY (24 * 60 * 60)
34 #define DAY_TS ((int64_t)DAY * AV_TIME_BASE)
159 int *
size,
int *max_size)
163 if (*
size == *max_size) {
164 int m =
FFMAX(32,
FFMIN(*max_size, INT_MAX / 2) * 2);
173 memset(
ret, 0, elsize);
180 const char *cur =
str;
185 if (*cur < '0' || *cur >
'9')
188 if (
end == cur || *
end !=
':' ||
end[1] <
'0' ||
end[1] >
'9')
191 minutes = strtol(cur, &
end, 10);
206 return c ==
' ' ||
c ==
'\t' ||
c ==
'\r';
212 if (m < INT_MIN || m >= INT_MAX) {
284 if (
s == p->
end || *
s ==
'\n')
298 while (c < p->
end && ((*
c >=
'a' && *
c <=
'z') || (*
c >=
'A' && *
c <=
'Z')
299 || (*
c >=
'0' && *
c <=
'9') || *
c ==
'_' || *
c ==
'-'))
315 #define FORWARD_ERROR(c) \
319 return errcode ? errcode : AVERROR_INVALIDDATA; \
325 "immediate sequences not yet implemented");
332 "preprogrammed sequences not yet implemented");
340 "option '%c' requires an argument", o);
357 for (; ostr.
s < ostr.
e; ostr.
s++) {
375 if (oarg.
e != tptr) {
377 "syntax error for option -F");
385 if (oarg.
e != oarg.
s +
r) {
387 "syntax error for option -L");
394 if (oarg.
e != oarg.
s +
r) {
396 "syntax error for option -T");
405 memcpy(tptr, oarg.
s, oarg.
e - oarg.
s);
406 tptr[oarg.
e - oarg.
s] = 0;
413 if (oarg.
e != tptr) {
415 "syntax error for option -q");
420 "speed factor other than 1 not supported");
426 r = strtol(oarg.
s, &tptr, 10);
427 if (oarg.
e != tptr) {
429 "syntax error for option -r");
434 "invalid sample rate");
441 "unknown option: '%c'", *ostr.
s);
462 int64_t
abs = 0, rel = 0, dt;
535 "relative time without previous absolute time");
570 "waveform definitions not yet implemented");
619 double carrierf, beatf;
620 int carrier, beat, vol;
685 double carrierf, beatf;
686 int carrier, beat, vol;
757 char *cursor_save = p->
cursor;
765 if (
name.e -
name.s == 6 && !memcmp(
name.s,
"wave", 4) &&
766 name.s[4] >=
'0' &&
name.s[4] <=
'9' &&
767 name.s[5] >=
'0' &&
name.s[5] <=
'9') {
768 int wavenum = (
name.s[4] -
'0') * 10 + (
name.s[5] -
'0');
798 .end =
script + script_len,
805 .sample_rate = 44100,
812 while (
sp.cursor <
sp.end) {
819 while (
sp.cursor <
sp.end) {
834 snprintf(
sp.err_msg,
sizeof(
sp.err_msg),
"syntax error");
835 if (
log && *
sp.err_msg) {
836 const char *
ctx =
sp.cursor;
839 int lctx = ectx -
ctx;
840 const char *quote =
"\"";
841 if (lctx > 0 &&
ctx[lctx - 1] ==
'\r')
844 ctx =
"the end of line";
849 sp.line_no,
sp.err_msg, quote, lctx,
ctx, quote);
857 int size = 0, bufsize = 0,
r;
860 if (bufsize -
size < 1024) {
861 bufsize =
FFMIN(
FFMAX(2 * bufsize, 8192), max_size);
862 if (bufsize -
size < 2) {
890 int64_t now, cur_ts,
delta = 0;
892 for (
i = 0;
i <
s->nb_tseq;
i++)
893 nb_rel +=
s->tseq[
i].ts.type ==
'N';
894 if (nb_rel ==
s->nb_tseq) {
899 "Start time ignored in a purely relative script.\n");
901 s->opt_start_at_first) {
904 s->start_ts =
s->tseq[0].ts.t;
909 struct tm *tm, tmpbuf;
912 "Scripts with mixed absolute and relative timestamps can give "
913 "unexpected results (pause, seeking, time zone change).\n");
917 now = tm ? tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec :
920 (
int)(now / 3600), (
int)(now / 60) % 60, (
int)now % 60);
922 for (
i = 0;
i <
s->nb_tseq;
i++) {
923 if (
s->tseq[
i].ts.type ==
'N') {
924 s->tseq[
i].ts.t += now;
925 s->tseq[
i].ts.type =
'T';
930 s->start_ts = (
s->opt_start_at_first &&
s->tseq) ?
s->tseq[0].ts.t : now;
931 s->end_ts =
s->opt_duration ?
s->start_ts +
s->opt_duration :
934 for (
i = 0;
i <
s->nb_tseq;
i++) {
935 if (
s->tseq[
i].ts.t +
delta < cur_ts)
937 cur_ts =
s->tseq[
i].ts.t +=
delta;
955 for (
i = 0;
i <
s->nb_def;
i++) {
960 if (
i >=
s->nb_def) {
966 if (def->
type ==
'B') {
975 &
s->nb_events, nb_ev_max);
989 int i,
r, nb_events_max = 0;
992 for (
i = 0;
i <
s->nb_tseq;
i++) {
1001 if (
s->opt_end_at_last)
1002 s->end_ts =
s->events[
s->nb_events - 1].ts;
1036 i->phi =
ref >= 0 ?
ref | 0x80000000 : 0;
1055 int64_t dt =
s->sample_rate / 20, ts3 =
ts1, ts4;
1059 ts3,
f,
a, ts4,
f, cpoints[
i][1]);
1070 int64_t
ts1, int64_t
ts2,
1077 if (
ts2 <=
ts1 || (
s1->vol == 0 &&
s2->vol == 0))
1083 if (
s1->beat == 0 &&
s2->beat == 0) {
1089 s2->ref.l =
s2->ref.r =
r;
1092 ts1,
s1->carrier +
s1->beat / 2,
s1->vol,
1093 ts2,
s2->carrier +
s2->beat / 2,
s2->vol);
1098 ts1,
s1->carrier -
s1->beat / 2,
s1->vol,
1099 ts2,
s2->carrier -
s2->beat / 2,
s2->vol);
1107 if (transition == 2) {
1116 "using pink noise instead.\n");
1130 ts1, 0,
s1->vol -
s1->vol / 4,
1131 ts2, 0,
s2->vol -
s2->vol / 4);
1134 s2->ref.l =
s2->ref.r =
r;
1141 "Type %d is not implemented\n",
s1->type);
1183 int64_t tsmid = (ts1 >> 1) + (ts2 >> 1) + (ts1 & ts2 & 1);
1197 for (
i = 0;
i < nb_elements;
i++) {
1221 ts1, ts2, &s1mod, &s2mod, 3);
1224 s2->ref = s2mod.
ref;
1232 ts1, tsmid, &s1mod, &smid, 1);
1239 tsmid, ts2, &smid, &s2mod, 2);
1242 s2->ref = s2mod.
ref;
1265 int64_t trans_time =
s->opt_fade_time / 2;
1273 period =
s->events[
s->nb_events - 1].ts -
s->events[0].ts;
1278 for (
i = 0;
i <
s->nb_events;
i++) {
1279 ev1 = &
s->events[
i];
1280 ev2 = &
s->events[(
i + 1) %
s->nb_events];
1283 : ev2->
ts + (ev1 < ev2 ? 0 :
period);
1285 for (
i = 0;
i <
s->nb_events;
i++) {
1286 ev1 = &
s->events[
i];
1287 ev2 = &
s->events[(
i + 1) %
s->nb_events];
1296 ev0 =
s->events[
s->nb_events - 1];
1302 for (
i = -1;
i <
s->nb_events;
i++) {
1303 ev1 =
i < 0 ? &ev0 : &
s->events[
i];
1310 for (
i = 0;
i <
s->nb_synth;
i++)
1311 s->synth[
i].ref.l =
s->synth[
i].ref.r = -1;
1312 for (
i = -1;
i <
s->nb_events;
i++) {
1313 ev1 =
i < 0 ? &ev0 : &
s->events[
i];
1314 ev2 = &
s->events[(
i + 1) %
s->nb_events];
1330 int i, edata_size = 4,
ret;
1343 #define ADD_EDATA32(v) do { AV_WL32(edata, (v)); edata += 4; } while(0)
1344 #define ADD_EDATA64(v) do { AV_WL64(edata, (v)); edata += 8; } while(0)
1365 if (edata != par->
extradata + edata_size)
1405 "-m is ignored and mix channels will be silent.\n");
1460 packet->
dts = packet->
pts = ts;
1464 return packet->
size;
1468 int64_t min_ts, int64_t ts, int64_t max_ts,
int flags)
1470 if (
flags || stream_index > 0)
1472 if (stream_index < 0)
1479 int64_t ts,
int flags)
1491 {
"max_file_size",
"", offsetof(
struct sbg_demuxer, max_file_size),
1513 .extensions =
"sbg",
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it be(in the first position) for now. Options ------- Then comes the options array. This is what will define the user accessible options. For example
enum ws_interval_type type
#define AV_LOG_WARNING
Something somehow does not look correct.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
static int parse_synth_channel(struct sbg_parser *p)
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
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
static int scale_double(void *log, double d, double m, int *r)
enum AVMediaType codec_type
General type of the encoded data.
static int str_to_time(const char *str, int64_t *rtime)
This struct describes the properties of an encoded stream.
double strtod(const char *, char **)
#define AVERROR_EOF
End of file.
#define MKTAG(a, b, c, d)
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
static int lex_char(struct sbg_parser *p, char c)
static int parse_synth_channel_pink(struct sbg_parser *p, struct sbg_script_synth *synth)
static av_cold int end(AVCodecContext *avctx)
struct sbg_script_tseq * block_tseq
AVStream ** streams
A list of all streams in the file.
struct sbg_timestamp current_time
static int lex_time(struct sbg_parser *p, int64_t *rt)
static int sbg_read_seek2(AVFormatContext *avf, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int buf_size
Size of buf except extra allocated bytes.
struct ws_interval * inter
static int is_space(char c)
static int sbg_read_packet(AVFormatContext *avf, AVPacket *packet)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
int64_t duration
Decoding: duration of the stream, in stream time base.
@ AV_CODEC_ID_FFWAVESYNTH
#define AV_CH_LAYOUT_STEREO
struct sbg_script_synth * synth
static int lex_space(struct sbg_parser *p)
static int add_interval(struct ws_intervals *inter, enum ws_interval_type type, uint32_t channels, int ref, int64_t ts1, int32_t f1, int32_t a1, int64_t ts2, int32_t f2, int32_t a2)
static int read_whole_file(AVIOContext *io, int max_size, char **rbuf)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int generate_plateau(void *log, struct sbg_script *s, struct ws_intervals *inter, struct sbg_script_event *ev1)
int frame_size
Audio only.
static int expand_tseq(void *log, struct sbg_script *s, int *nb_ev_max, int64_t t0, struct sbg_script_tseq *tseq)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
static int parse_wave_def(struct sbg_parser *p, int wavenum)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
static int lex_name(struct sbg_parser *p, struct sbg_string *rs)
static int parse_optarg(struct sbg_parser *p, char o, struct sbg_string *r)
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static const AVOption sbg_options[]
static int lex_fixed(struct sbg_parser *p, const char *t, int l)
struct sbg_script_tseq * tseq
static int sbg_read_seek(AVFormatContext *avf, int stream_index, int64_t ts, int flags)
#define av_realloc_f(p, o, n)
static int parse_synth_channel_sine(struct sbg_parser *p, struct sbg_script_synth *synth)
static int parse_synth_channel_spin(struct sbg_parser *p, struct sbg_script_synth *synth)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
static int generate_intervals(void *log, struct sbg_script *s, int sample_rate, struct ws_intervals *inter)
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally hours
Describe the class of an AVClass context structure.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
struct sbg_script_definition * def
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are in without period
const char * av_default_item_name(void *ptr)
Return the context name.
AVIOContext * pb
I/O context.
static int lex_wsword(struct sbg_parser *p, struct sbg_string *rs)
This structure contains the data a format has to probe a file.
struct sbg_script_synth::@278 ref
static int parse_script(void *log, char *script, int script_len, struct sbg_script *rscript)
static const AVClass sbg_demuxer_class
struct sbg_script_event * events
AVInputFormat ff_sbg_demuxer
static int parse_fade(struct sbg_parser *p, struct sbg_fade *fr)
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 sample_rate
Audio only.
static int parse_named_def(struct sbg_parser *p)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int parse_synth_channel_bell(struct sbg_parser *p, struct sbg_script_synth *synth)
int probe_packets
Number of packets to buffer for codec probing.
static int add_bell(struct ws_intervals *inter, struct sbg_script *s, int64_t ts1, int64_t ts2, int32_t f, int32_t a)
#define AV_NOPTS_VALUE
Undefined timestamp value.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
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
static int parse_time_sequence(struct sbg_parser *p, int inblock)
#define AV_LOG_INFO
Standard information.
static av_cold int sbg_read_header(AVFormatContext *avf)
static int parse_block_def(struct sbg_parser *p, struct sbg_script_definition *def)
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_TIME_BASE
Internal time base represented as integer.
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
static int parse_options(struct sbg_parser *p)
static int parse_volume(struct sbg_parser *p, int *vol)
static void fade(uint8_t *dst, ptrdiff_t dst_linesize, const uint8_t *src, ptrdiff_t src_linesize, int width, int height, int alpha, int beta)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static void expand_timestamps(void *log, struct sbg_script *s)
static int parse_immediate(struct sbg_parser *p)
static int array[MAX_W *MAX_W]
static int parse_timestamp(struct sbg_parser *p, struct sbg_timestamp *rts, int64_t *rrel)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static int parse_synth_def(struct sbg_parser *p, struct sbg_script_definition *def)
#define FF_ARRAY_ELEMS(a)
static av_cold int sbg_read_probe(const AVProbeData *p)
static int generate_transition(void *log, struct sbg_script *s, struct ws_intervals *inter, struct sbg_script_event *ev1, struct sbg_script_event *ev2)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int ref[MAX_W *MAX_W]
uint8_t opt_start_at_first
static void free_script(struct sbg_script *s)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
static void * alloc_array_elem(void **array, size_t elsize, int *size, int *max_size)
This structure stores compressed data.
uint64_t channel_layout
Audio only.
#define flags(name, subs,...)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
static int parse_preprogrammed(struct sbg_parser *p)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
static int encode_intervals(struct sbg_script *s, AVCodecParameters *par, struct ws_intervals *inter)
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell script
void * priv_data
Format private data.
static int lex_line_end(struct sbg_parser *p)
static int lex_double(struct sbg_parser *p, double *r)
static int parse_synth_channel_mix(struct sbg_parser *p, struct sbg_script_synth *synth)
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
static int expand_script(void *log, struct sbg_script *s)
static int generate_interval(void *log, struct sbg_script *s, struct ws_intervals *inter, int64_t ts1, int64_t ts2, struct sbg_script_synth *s1, struct sbg_script_synth *s2, int transition)