32 int av_strstart(
const char *str,
const char *pfx,
const char **ptr)
34 while (*pfx && *pfx == *str) {
43 int av_stristart(
const char *str,
const char *pfx,
const char **ptr)
67 char *
av_strnstr(
const char *haystack,
const char *needle,
size_t hay_length)
69 size_t needle_len = strlen(needle);
72 while (hay_length >= needle_len) {
74 if (!memcmp(haystack, needle, needle_len))
84 while (++len < size && *src)
88 return len + strlen(src) - 1;
93 size_t len = strlen(dst);
95 return len + strlen(src);
96 return len +
av_strlcpy(dst + len, src, size - len);
101 int len = strlen(dst);
105 len += vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl);
115 snprintf(str, 16,
"%f", d);
119 #define WHITESPACES " \n\t"
124 char *ret =
out, *end =
out;
125 const char *p = *
buf;
130 while (*p && !strspn(p, term)) {
132 if (c ==
'\\' && *p) {
135 }
else if (c ==
'\'') {
136 while (*p && *p !=
'\'')
162 }
while (c1 && c1 == c2);
168 const char *end = a + n;
173 }
while (a < end && c1 && c1 == c2);
179 char *p = strrchr(path,
'/');
182 char *q = strrchr(path,
'\\');
183 char *d = strchr(path,
':');
196 char *p = strrchr(path,
'/');
199 char *q = strrchr(path,
'\\');
200 char *d = strchr(path,
':');
217 return c >=
'0' && c <=
'9';
222 return c > 32 && c < 127;
227 return c ==
' ' || c ==
'\f' || c ==
'\n' || c ==
'\r' || c ==
'\t' ||
234 return av_isdigit(c) || (c >=
'a' && c <=
'f');
245 namelen = strlen(name);
246 while ((p = strchr(names,
','))) {
247 len =
FFMAX(p - names, namelen);
262 const char *strings[] = {
278 "'foo : ' :blahblah",
284 " foo bar : blahblah",
286 "'foo : \\ \\ ' : blahblah",
287 "'\\fo\\o:': blahblah",
288 "\\'fo\\o\\:': foo ' :blahblah"
291 printf(
"Testing av_get_token()\n");
293 const char *p = strings[i];
297 printf(
" -> |%s|", q);
298 printf(
" + |%s|\n", p);
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int av_isxdigit(int c)
Locale-independent conversion of ASCII isxdigit.
memory handling functions
char * av_stristr(const char *s1, const char *s2)
Locate the first case-independent occurrence in the string haystack of the string needle...
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
#define FF_ARRAY_ELEMS(a)
int av_stristart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str independent of case.
const char * av_basename(const char *path)
Thread safe basename.
static int av_tolower(int c)
Locale-independent conversion of ASCII characters to lowercase.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int main(int argc, char **argv)
int av_match_name(const char *name, const char *names)
Match instances of a name in a comma-separated list of names.
int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
int av_strcasecmp(const char *a, const char *b)
AVFifoBuffer ** buf
single buffer for interleaved, per-channel buffers for planar
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
char * av_d2str(double d)
Convert a number to a av_malloced string.
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
static int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
int av_isgraph(int c)
Locale-independent conversion of ASCII isgraph.
char * av_strnstr(const char *haystack, const char *needle, size_t hay_length)
Locate the first occurrence of the string needle in the string haystack where not more than hay_lengt...
common internal and external API header
const char * av_dirname(char *path)
Thread safe dirname.