]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/cutils.c
The AAC demuxer now depends on id3v1.o.
[ffmpeg] / libavformat / cutils.c
index dfc6f9c85ea9189ece43aff2879749862f38baca..4967d5b90c211a23823a66e7f4d087a2666964a9 100644 (file)
 #include "avformat.h"
 
 /* add one element to a dynamic array */
-void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem)
+void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem)
 {
     int nb, nb_alloc;
-    unsigned long *tab;
+    intptr_t *tab;
 
     nb = *nb_ptr;
     tab = *tab_ptr;
@@ -33,7 +33,7 @@ void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem)
             nb_alloc = 1;
         else
             nb_alloc = nb * 2;
-        tab = av_realloc(tab, nb_alloc * sizeof(unsigned long));
+        tab = av_realloc(tab, nb_alloc * sizeof(intptr_t));
         *tab_ptr = tab;
     }
     tab[nb++] = elem;
@@ -62,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)
 {
@@ -77,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];