34 int av_strstart(
const char *str, 
const char *pfx, 
const char **ptr)
 
   36     while (*pfx && *pfx == *str) {
 
   45 int av_stristart(
const char *str, 
const char *pfx, 
const char **ptr)
 
   59         return (
char*)(intptr_t)s1;
 
   63             return (
char*)(intptr_t)s1;
 
   69 char *
av_strnstr(
const char *haystack, 
const char *needle, 
size_t hay_length)
 
   71     size_t needle_len = strlen(needle);
 
   73         return (
char*)haystack;
 
   74     while (hay_length >= needle_len) {
 
   76         if (!memcmp(haystack, needle, needle_len))
 
   77             return (
char*)haystack;
 
   86     while (++len < size && *src)
 
   90     return len + strlen(src) - 1;
 
   95     size_t len = strlen(dst);
 
   97         return len + strlen(src);
 
   98     return len + 
av_strlcpy(dst + len, src, size - len);
 
  103     size_t len = strlen(dst);
 
  107     len += 
vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl);
 
  147 #define WHITESPACES " \n\t" 
  153     const char *p = *
buf;
 
  158     while (*p && !strspn(p, term)) {
 
  160         if (c == 
'\\' && *p) {
 
  163         } 
else if (c == 
'\'') {
 
  164             while (*p && *p != 
'\'')
 
  188     if (!s && !(s = *saveptr))
 
  192     s += strspn(s, delim);
 
  202     s += strcspn(s, delim);
 
  219     } 
while (c1 && c1 == c2);
 
  225     const char *
end = a + 
n;
 
  230     } 
while (a < end && c1 && c1 == c2);
 
  236     char *p = strrchr(path, 
'/');
 
  239     char *q = strrchr(path, 
'\\');
 
  240     char *d = strchr(path, 
':');
 
  253     char *p = strrchr(path, 
'/');
 
  256     char *q = strrchr(path, 
'\\');
 
  257     char *d = strchr(path, 
':');
 
  282     p_len = strlen(path);
 
  283     c_len = strlen(component);
 
  284     if (p_len > SIZE_MAX - c_len || p_len + c_len > SIZE_MAX - 2)
 
  291                 if (fullpath[p_len - 1] != 
'/' && component[0] != 
'/')
 
  292                     fullpath[p_len++] = 
'/';
 
  293                 else if (fullpath[p_len - 1] == 
'/' && component[0] == 
'/')
 
  297         av_strlcpy(&fullpath[p_len], component, c_len + 1);
 
  298         fullpath[p_len + c_len] = 0;
 
  322     return c >= 
'0' && c <= 
'9';
 
  327     return c > 32 && c < 127;
 
  332     return c == 
' ' || c == 
'\f' || c == 
'\n' || c == 
'\r' || c == 
'\t' ||
 
  339     return av_isdigit(c) || (c >= 
'a' && c <= 
'f');
 
  350     namelen = strlen(name);
 
  351     while ((p = strchr(names, 
','))) {
 
  352         len = 
FFMAX(p - names, namelen);
 
  366     int ret = 0, tail_len;
 
  367     uint32_t overlong_encoding_mins[6] = {
 
  368         0x00000000, 0x00000080, 0x00000800, 0x00010000, 0x00200000, 0x04000000,
 
  378     if ((code & 0xc0) == 0x80 || code >= 0xFE) {
 
  382     top = (code & 128) >> 1;
 
  399         code = (code<<6) + tmp;
 
  402     code &= (top << 1) - 1;
 
  406     if (code < overlong_encoding_mins[tail_len]) {
 
  418     if (code > 0x10FFFF &&
 
  421     if (code < 0x20 && code != 0x9 && code != 0xA && code != 0xD &&
 
  424     if (code >= 0xD800 && code <= 0xDFFF &&
 
  427     if ((code == 0xFFFE || code == 0xFFFF) &&
 
  440     for (p = name; p && *p; ) {
 
  441         for (q = list; q && *q; ) {
 
  443             for (k = 0; p[k] == q[k] || (p[k]*q[k] == 0 && p[k]+q[k] == separator); k++)
 
  444                 if (k && (!p[k] || p[k] == separator))
 
  446             q = strchr(q, separator);
 
  449         p = strchr(p, separator);
 
  462     static const char * 
const strings[] = {
 
  478         "'foo :  '  :blahblah",
 
  484         " foo   bar    :   blahblah",
 
  486         "'foo : \\ \\  '   : blahblah",
 
  487         "'\\fo\\o:': blahblah",
 
  488         "\\'fo\\o\\:':  foo  '  :blahblah" 
  491     printf(
"Testing av_get_token()\n");
 
  493         const char *p = strings[i];
 
  497         printf(
" -> |%s|", q);
 
  498         printf(
" + |%s|\n", p);
 
  502     printf(
"Testing av_append_path_component()\n");
 
  503     #define TEST_APPEND_PATH_COMPONENT(path, component, expected) \ 
  504         fullpath = av_append_path_component((path), (component)); \ 
  505         printf("%s = %s\n", fullpath, expected); \ 
  507     TEST_APPEND_PATH_COMPONENT(
NULL, 
NULL, 
"(null)")
 
  508     TEST_APPEND_PATH_COMPONENT("path", 
NULL, "path");
 
  509     TEST_APPEND_PATH_COMPONENT(NULL, "
comp", "comp");
 
  510     TEST_APPEND_PATH_COMPONENT("path", "comp", "path/comp");
 
  511     TEST_APPEND_PATH_COMPONENT("path/", "comp", "path/comp");
 
  512     TEST_APPEND_PATH_COMPONENT("path", "/comp", "path/comp");
 
  513     TEST_APPEND_PATH_COMPONENT("path/", "/comp", "path/comp");
 
  514     TEST_APPEND_PATH_COMPONENT("path/path2/", "/comp/comp2", "path/path2/comp/comp2");
 
int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit. 
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 ...
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. 
#define FF_ARRAY_ELEMS(a)
int av_isgraph(int c)
Locale-independent conversion of ASCII isgraph. 
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer. 
#define av_assert0(cond)
assert() equivalent, that is always enabled. 
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. 
int av_isspace(int c)
Locale-independent conversion of ASCII isspace. 
static av_cold int end(AVCodecContext *avctx)
char * av_d2str(double d)
Convert a number to a av_malloced string. 
#define AV_UTF8_FLAG_ACCEPT_INVALID_BIG_CODES
accept codepoints over 0x10FFFF 
#define AV_UTF8_FLAG_ACCEPT_SURROGATES
accept UTF-16 surrogates codes 
static av_const int av_tolower(int c)
Locale-independent conversion of ASCII characters to lowercase. 
#define AV_BPRINT_SIZE_UNLIMITED
int av_utf8_decode(int32_t *codep, const uint8_t **bufp, const uint8_t *buf_end, unsigned int flags)
Read and decode a single UTF-8 code point (character) from the buffer in *buf, and update *buf to poi...
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
int av_match_list(const char *name, const char *list, char separator)
Check if a name is in a list. 
simple assert() macros that are a bit more flexible than ISO C assert(). 
int av_match_name(const char *name, const char *names)
Match instances of a name in a comma-separated list of names. 
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...
char * av_asprintf(const char *fmt,...)
#define AV_UTF8_FLAG_EXCLUDE_XML_INVALID_CONTROL_CODES
exclude control codes not accepted by XML 
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare. 
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated). 
char * av_strdup(const char *s)
Duplicate the string s. 
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase. 
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
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...
int av_isxdigit(int c)
Locale-independent conversion of ASCII isxdigit. 
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()...
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str. 
char * av_append_path_component(const char *path, const char *component)
Append path component to the existing path. 
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_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. 
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_log(ac->avr, AV_LOG_TRACE,"%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
#define AV_UTF8_FLAG_ACCEPT_NON_CHARACTERS
accept non-characters - 0xFFFE and 0xFFFF 
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
int main(int argc, char **argv)