]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/cutils.c
Motion Pixels MVI Demuxer.
[ffmpeg] / libavformat / cutils.c
index eeeef51464afbbe74e8f168b25400fc93d40111a..42ef5996d996e57b59e147c3e0cc2b3d676d1e79 100644 (file)
  */
 #include "avformat.h"
 
-#if !defined(CONFIG_NOCUTILS)
-/**
- * Return TRUE if val is a prefix of str. If it returns TRUE, ptr is
- * set to the next character in 'str' after the prefix.
- *
- * @param str input string
- * @param pfx prefix to test
- * @param ptr updated after the prefix in str in there is a match
- * @return TRUE if there is a match
- */
-int strstart(const char *str, const char *pfx, const char **ptr)
-{
-    while (*pfx && *pfx++ == *str++);
-    if (!*pfx && ptr)
-        *ptr = str;
-    return !*pfx;
-}
-
-/**
- * Return TRUE if val is a prefix of str (case independent). If it
- * returns TRUE, ptr is set to the next character in 'str' after the
- * prefix.
- *
- * @param str input string
- * @param pfx prefix to test
- * @param ptr updated after the prefix in str in there is a match
- * @return TRUE if there is a match */
-int stristart(const char *str, const char *pfx, const char **ptr)
-{
-    while (*pfx && toupper((unsigned)*pfx++) == toupper((unsigned)*str++));
-    if (!*pfx && ptr)
-        *ptr = str;
-    return !*pfx;
-}
-
-/**
- * Copy the string str to buf. If str length is bigger than buf_size -
- * 1 then it is clamped to buf_size - 1.
- * NOTE: this function does what strncpy should have done to be
- * useful. NEVER use strncpy.
- *
- * @param buf destination buffer
- * @param buf_size size of destination buffer
- * @param str source string
- */
-void pstrcpy(char *buf, int buf_size, const char *str)
-{
-    if (buf_size <= 0)
-        return;
-
-    while (buf_size-- > 1 && *str)
-        *buf++ = *str++;
-    *buf = 0;
-}
-
-/* strcat and truncate. */
-char *pstrcat(char *buf, int buf_size, const char *s)
-{
-    int len = strlen(buf);
-    if (len < buf_size)
-        pstrcpy(buf + len, buf_size - len, s);
-    return buf;
-}
-
-#endif
-
 /* add one element to a dynamic array */
-void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem)
+void ff_dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem)
 {
     int nb, nb_alloc;
     unsigned long *tab;
@@ -128,7 +62,7 @@ time_t mktimegm(struct tm *tm)
 #define ISLEAP(y) (((y) % 4 == 0) && (((y) % 100) != 0 || ((y) % 400) == 0))
 #define LEAPS_COUNT(y) ((y)/4 - (y)/100 + (y)/400)
 
-/* this is our own gmtime_r. it differs from its POSIX counterpart in a
+/* This is our own gmtime_r. It differs from its POSIX counterpart in a
    couple of places, though. */
 struct tm *brktimegm(time_t secs, struct tm *tm)
 {
@@ -143,11 +77,12 @@ struct tm *brktimegm(time_t secs, struct tm *tm)
 
     /* oh well, may be someone some day will invent a formula for this stuff */
     y = 1970; /* start "guessing" */
-    while (days >= (ISLEAP(y)?366:365)) {
+    while (days > 365) {
         ny = (y + days/366);
         days -= (ny - y) * 365 + LEAPS_COUNT(ny - 1) - LEAPS_COUNT(y - 1);
         y = ny;
     }
+    if (days==365 && !ISLEAP(y)) { days=0; y++; }
     md[1] = ISLEAP(y)?29:28;
     for (m=0; days >= md[m]; m++)
          days -= md[m];