~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to ffmpeg/libavformat/cutils.c

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2008-02-25 15:47:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080225154712-qvr11ekcea4c9ry8
Tags: 1.1.6-0.1ubuntu1
* Merge from debian-multimedia (LP: #120003), Ubuntu Changes:
 - For ffmpeg-related build-deps, remove cvs from package names.
 - Standards-Version 3.7.3
 - Maintainer Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Various simple utilities for ffmpeg system
3
3
 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4
4
 *
5
 
 * This library is free software; you can redistribute it and/or
 
5
 * This file is part of FFmpeg.
 
6
 *
 
7
 * FFmpeg is free software; you can redistribute it and/or
6
8
 * modify it under the terms of the GNU Lesser General Public
7
9
 * License as published by the Free Software Foundation; either
8
 
 * version 2 of the License, or (at your option) any later version.
 
10
 * version 2.1 of the License, or (at your option) any later version.
9
11
 *
10
 
 * This library is distributed in the hope that it will be useful,
 
12
 * FFmpeg is distributed in the hope that it will be useful,
11
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
15
 * Lesser General Public License for more details.
14
16
 *
15
17
 * You should have received a copy of the GNU Lesser General Public
16
 
 * License along with this library; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 * License along with FFmpeg; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
20
 */
19
21
#include "avformat.h"
20
22
 
59
61
    p = str;
60
62
    q = val;
61
63
    while (*q != '\0') {
62
 
        if (toupper(*(const unsigned char *)p) != toupper(*(const unsigned char *)q))
 
64
        if (toupper(*(const unsigned char *)p) != toupper(*(const unsigned char *)q))
63
65
            return 0;
64
66
        p++;
65
67
        q++;
74
76
 * 1 then it is clamped to buf_size - 1.
75
77
 * NOTE: this function does what strncpy should have done to be
76
78
 * useful. NEVER use strncpy.
77
 
 * 
 
79
 *
78
80
 * @param buf destination buffer
79
81
 * @param buf_size size of destination buffer
80
82
 * @param str source string
101
103
{
102
104
    int len;
103
105
    len = strlen(buf);
104
 
    if (len < buf_size) 
 
106
    if (len < buf_size)
105
107
        pstrcpy(buf + len, buf_size - len, s);
106
108
    return buf;
107
109
}
139
141
        y--;
140
142
    }
141
143
 
142
 
    t = 86400 * 
 
144
    t = 86400 *
143
145
        (d + (153 * m - 457) / 5 + 365 * y + y / 4 - y / 100 + y / 400 - 719469);
144
146
 
145
147
    t += 3600 * tm->tm_hour + 60 * tm->tm_min + tm->tm_sec;
147
149
    return t;
148
150
}
149
151
 
 
152
#define ISLEAP(y) (((y) % 4 == 0) && (((y) % 100) != 0 || ((y) % 400) == 0))
 
153
#define LEAPS_COUNT(y) ((y)/4 - (y)/100 + (y)/400)
 
154
 
 
155
/* this is our own gmtime_r. it differs from its POSIX counterpart in a
 
156
   couple of places, though. */
 
157
struct tm *brktimegm(time_t secs, struct tm *tm)
 
158
{
 
159
    int days, y, ny, m;
 
160
    int md[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
 
161
 
 
162
    days = secs / 86400;
 
163
    secs %= 86400;
 
164
    tm->tm_hour = secs / 3600;
 
165
    tm->tm_min = (secs % 3600) / 60;
 
166
    tm->tm_sec =  secs % 60;
 
167
 
 
168
    /* oh well, may be someone some day will invent a formula for this stuff */
 
169
    y = 1970; /* start "guessing" */
 
170
    while (days >= (ISLEAP(y)?366:365)) {
 
171
        ny = (y + days/366);
 
172
        days -= (ny - y) * 365 + LEAPS_COUNT(ny - 1) - LEAPS_COUNT(y - 1);
 
173
        y = ny;
 
174
    }
 
175
    md[1] = ISLEAP(y)?29:28;
 
176
    for (m=0; days >= md[m]; m++)
 
177
         days -= md[m];
 
178
 
 
179
    tm->tm_year = y;  /* unlike gmtime_r we store complete year here */
 
180
    tm->tm_mon = m+1; /* unlike gmtime_r tm_mon is from 1 to 12 */
 
181
    tm->tm_mday = days+1;
 
182
 
 
183
    return tm;
 
184
}
 
185
 
150
186
/* get a positive number between n_min and n_max, for a maximum length
151
187
   of len_max. Return -1 if error. */
152
188
static int date_get_num(const char **pp,
174
210
}
175
211
 
176
212
/* small strptime for ffmpeg */
177
 
const char *small_strptime(const char *p, const char *fmt, 
 
213
const char *small_strptime(const char *p, const char *fmt,
178
214
                           struct tm *dt)
179
215
{
180
216
    int c, val;