33 int av_strstart(
const char *str,
const char *pfx,
const char **ptr)
35 while (*pfx && *pfx == *str) {
44 int av_stristart(
const char *str,
const char *pfx,
const char **ptr)
58 return (
char*)(intptr_t)s1;
62 return (
char*)(intptr_t)s1;
68 char *
av_strnstr(
const char *haystack,
const char *needle,
size_t hay_length)
70 size_t needle_len = strlen(needle);
72 return (
char*)haystack;
73 while (hay_length >= needle_len) {
75 if (!memcmp(haystack, needle, needle_len))
76 return (
char*)haystack;
85 while (++len < size && *src)
89 return len + strlen(src) - 1;
94 size_t len = strlen(dst);
96 return len + strlen(src);
97 return len +
av_strlcpy(dst + len, src, size - len);
102 int len = strlen(dst);
106 len +=
vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl);
146 #define WHITESPACES " \n\t"
152 const char *p = *
buf;
157 while (*p && !strspn(p, term)) {
159 if (c ==
'\\' && *p) {
162 }
else if (c ==
'\'') {
163 while (*p && *p !=
'\'')
187 if (!s && !(s = *saveptr))
191 s += strspn(s, delim);
201 s += strcspn(s, delim);
218 }
while (c1 && c1 == c2);
224 const char *
end = a +
n;
229 }
while (a < end && c1 && c1 == c2);
235 char *p = strrchr(path,
'/');
238 char *q = strrchr(path,
'\\');
239 char *d = strchr(path,
':');
252 char *p = strrchr(path,
'/');
255 char *q = strrchr(path,
'\\');
256 char *d = strchr(path,
':');
290 return c >=
'0' && c <=
'9';
295 return c > 32 && c < 127;
300 return c ==
' ' || c ==
'\f' || c ==
'\n' || c ==
'\r' || c ==
'\t' ||
307 return av_isdigit(c) || (c >=
'a' && c <=
'f');
315 static const char *
const strings[] = {
331 "'foo : ' :blahblah",
337 " foo bar : blahblah",
339 "'foo : \\ \\ ' : blahblah",
340 "'\\fo\\o:': blahblah",
341 "\\'fo\\o\\:': foo ' :blahblah"
344 printf(
"Testing av_get_token()\n");
346 const char *p = strings[i];
350 printf(
" -> |%s|", q);
351 printf(
" + |%s|\n", p);
int av_isxdigit(int c)
Locale-independent conversion of ASCII isxdigit.
int av_escape(char **dst, const char *src, const char *special_chars, enum AVEscapeMode mode, int flags)
Escape string in src, and put the escaped string in an allocated string in *dst, which must be freed ...
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.
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...
const char * av_dirname(char *path)
Thread safe dirname.
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
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_stristart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str independent of case.
static av_cold int end(AVCodecContext *avctx)
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(). ...
char * av_stristr(const char *haystack, const char *needle)
Locate the first case-independent occurrence in the string haystack of the string needle...
#define AV_BPRINT_SIZE_UNLIMITED
Convenience macros for special values for av_bprint_init() size_max parameter.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
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.
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Init a print buffer.
#define FF_ARRAY_ELEMS(a)
Buffer to print data progressively.
static int av_bprint_is_complete(AVBPrint *buf)
Test if the print buffer is complete (not truncated).
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
size_t char * av_asprintf(const char *fmt,...) av_printf_format(1
Print arguments following specified format into a large enough auto allocated buffer.
memory handling functions
const char * av_basename(const char *path)
Thread safe basename.
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...
size_t char char * av_d2str(double d)
Convert a number to a av_malloced string.
static int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
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.
void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars, enum AVEscapeMode mode, int flags)
Escape the content in src and append it to dstbuf.
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok()...
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){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));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=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);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);ff_audio_convert_init_arm(ac);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 main(int argc, char **argv)
common internal and external API header
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...) av_printf_format(3
Append output to a string, according to a format.