~ubuntu-branches/ubuntu/vivid/transcode/vivid

« back to all changes in this revision

Viewing changes to import/nuv/soxfuncs.c

  • Committer: Bazaar Package Importer
  • Author(s): Iain Lane
  • Date: 2009-01-08 22:33:52 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090108223352-xzwpx7r22tzm7grp
Tags: 2:1.0.7-0ubuntu1
* New upstream release. (LP: #311202)
* debian/watch: Update 
* debian/patches/01_configure.dpatch, 03_imagemagick.dpatch,
  05_filter.c.dpatch, 06_libavcodec.dpatch: Dropped, applied upstream 
* debian/control: libmagickwand-dev, build-depend on new Imagemagick dev
  package.
* debian/patches/01_configure_magickcore.dpatch, 98_autoreconf.dpatch:
  Link against -lMagickCore instead of -lMagick, upstream changed name.
* debian/control: Bump s-v to 3.8.0, add homepage field 
* debian/control: Recommend mawk to run provided scripts 
* debian/control: linux -> Linux spelling fix (Lintian) 
* debian/control, debian/rules: Strip rpath from
  /usr/lib/transcode/export_fame.so 
* debian/transcode-doc.doc-base, debian/copyright, debian/changelog: Fix
  encoding.
* debian/transcode-doc.doc-base: Use valid section.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * July 5, 1991
3
 
 * Copyright 1991 Lance Norskog And Sundry Contributors
4
 
 * This source code is freely redistributable and may be used for
5
 
 * any purpose.  This copyright notice must be maintained. 
6
 
 * Lance Norskog And Sundry Contributors are not responsible for 
7
 
 * the consequences of using this software.
8
 
 */
9
 
 
10
 
#include "st.h"
11
 
#include <string.h>
12
 
#include <ctype.h>
13
 
#include <signal.h>
14
 
 
15
 
#ifdef __STDC__
16
 
#include <stdarg.h>
17
 
#else
18
 
#include <varargs.h>
19
 
#endif
20
 
 
21
 
/*
22
 
 * util.c.
23
 
 * Incorporate Jimen Ching's fixes for real library operation: Aug 3, 1994.
24
 
 * Redo all work from scratch, unfortunately.
25
 
 * Separate out all common variables used by effects & handlers,
26
 
 * and utility routines for other main programs to use.
27
 
 */
28
 
 
29
 
/* export flags */
30
 
/* FIXME: To be moved inside of fileop structure per handler. */
31
 
int verbose = 0;        /* be noisy on stderr */
32
 
 
33
 
/* FIXME:  These functions are user level concepts.  Move them outside
34
 
 * the ST library. 
35
 
 */
36
 
char *myname = 0;
37
 
 
38
 
void
39
 
st_report(const char *fmt, ...) 
40
 
{
41
 
        va_list args;
42
 
 
43
 
        //      if (! verbose)
44
 
                return;
45
 
 
46
 
        fprintf(stderr, "%s: ", myname);
47
 
        va_start(args, fmt);
48
 
        vfprintf(stderr, fmt, args);
49
 
        va_end(args);
50
 
        fprintf(stderr, "\n");
51
 
}
52
 
 
53
 
 
54
 
void
55
 
st_warn(const char *fmt, ...) 
56
 
{
57
 
        va_list args;
58
 
 
59
 
        fprintf(stderr, "%s: ", myname);
60
 
        va_start(args, fmt);
61
 
 
62
 
        vfprintf(stderr, fmt, args);
63
 
        va_end(args);
64
 
        fprintf(stderr, "\n");
65
 
}
66
 
 
67
 
void
68
 
st_fail(const char *fmt, ...) 
69
 
{
70
 
        va_list args;
71
 
 
72
 
        fprintf(stderr, "%s: ", myname);
73
 
 
74
 
        va_start(args, fmt);
75
 
        vfprintf(stderr, fmt, args);
76
 
        va_end(args);
77
 
        fprintf(stderr, "\n");
78
 
        exit(2);
79
 
}
80
 
 
81
 
 
82
 
/* Warning: no error checking is done with errstr.  Be sure not to
83
 
 * go over the array limit ourself!
84
 
 */
85
 
void
86
 
st_fail_errno(ft_t ft, int st_errno, const char *fmt, ...)
87
 
{
88
 
        va_list args;
89
 
 
90
 
        ft->st_errno = st_errno;
91
 
 
92
 
        va_start(args, fmt);
93
 
        vsprintf(ft->st_errstr, fmt, args);
94
 
        va_end(args);
95
 
}
96
 
 
97
 
int st_is_bigendian(void)
98
 
{
99
 
    int b;
100
 
    char *p;
101
 
 
102
 
    b = 1;
103
 
    p = (char *) &b;
104
 
    if (!*p)
105
 
        return 1;
106
 
    else
107
 
        return 0;
108
 
}
109
 
 
110
 
int st_is_littleendian(void)
111
 
{
112
 
    int b;
113
 
    char *p;
114
 
 
115
 
    b = 1;
116
 
    p = (char *) &b;
117
 
    if (*p)
118
 
        return 1;
119
 
    else
120
 
        return 0;
121
 
}
122
 
 
123
 
int strcmpcase(s1, s2)
124
 
char *s1, *s2;
125
 
{
126
 
        while(*s1 && *s2 && (tolower(*s1) == tolower(*s2)))
127
 
                s1++, s2++;
128
 
        return *s1 - *s2;
129
 
}
130
 
 
131
 
/*
132
 
 * File format routines 
133
 
 */
134
 
 
135
 
void st_copyformat(ft, ft2)
136
 
ft_t ft, ft2;
137
 
{
138
 
        int noise = 0, i;
139
 
        double factor;
140
 
 
141
 
        if (ft2->info.rate == 0) {
142
 
                ft2->info.rate = ft->info.rate;
143
 
                noise = 1;
144
 
        }
145
 
        if (ft2->info.size == -1) {
146
 
                ft2->info.size = ft->info.size;
147
 
                noise = 1;
148
 
        }
149
 
        if (ft2->info.encoding == -1) {
150
 
                ft2->info.encoding = ft->info.encoding;
151
 
                noise = 1;
152
 
        }
153
 
        if (ft2->info.channels == -1) {
154
 
                ft2->info.channels = ft->info.channels;
155
 
                noise = 1;
156
 
        }
157
 
        if (ft2->comment == NULL) {
158
 
                ft2->comment = ft->comment;
159
 
                noise = 1;
160
 
        }
161
 
        /* 
162
 
         * copy loop info, resizing appropriately 
163
 
         * it's in samples, so # channels don't matter
164
 
         */
165
 
        factor = (double) ft2->info.rate / (double) ft->info.rate;
166
 
        for(i = 0; i < ST_MAX_NLOOPS; i++) {
167
 
                ft2->loops[i].start = ft->loops[i].start * factor;
168
 
                ft2->loops[i].length = ft->loops[i].length * factor;
169
 
                ft2->loops[i].count = ft->loops[i].count;
170
 
                ft2->loops[i].type = ft->loops[i].type;
171
 
        }
172
 
        /* leave SMPTE # alone since it's absolute */
173
 
        ft2->instr = ft->instr;
174
 
}
175
 
 
176
 
void st_cmpformats(ft, ft2)
177
 
ft_t ft, ft2;
178
 
{
179
 
}
180
 
 
181
 
/* check that all settings have been given */
182
 
void st_checkformat(ft) 
183
 
ft_t ft;
184
 
{
185
 
        if (ft->info.rate == 0)
186
 
                st_fail("Sampling rate for %s file was not given\n", ft->filename);
187
 
        if ((ft->info.rate < 100) || (ft->info.rate > 999999L))
188
 
                st_fail("Sampling rate %lu for %s file is bogus\n", 
189
 
                        ft->info.rate, ft->filename);
190
 
        if (ft->info.size == -1)
191
 
                st_fail("Data size was not given for %s file\nUse one of -b/-w/-l/-f/-d/-D", ft->filename);
192
 
        if (ft->info.encoding == -1 && ft->info.size != ST_SIZE_FLOAT)
193
 
                st_fail("Data encoding was not given for %s file\nUse one of -s/-u/-U/-A", ft->filename);
194
 
        /* it's so common, might as well default */
195
 
        if (ft->info.channels == -1)
196
 
                ft->info.channels = 1;
197
 
        /*      st_fail("Number of output channels was not given for %s file",
198
 
                        ft->filename); */
199
 
}
200
 
 
201
 
static ft_t ft_queue[2];
202
 
 
203
 
void
204
 
sigint(s)
205
 
int s;
206
 
{
207
 
    if (s == SIGINT) {
208
 
        if (ft_queue[0])
209
 
            ft_queue[0]->file.eof = 1;
210
 
        if (ft_queue[1])
211
 
            ft_queue[1]->file.eof = 1;
212
 
    }
213
 
}
214
 
 
215
 
void
216
 
sigintreg(ft)
217
 
ft_t ft;
218
 
{
219
 
    if (ft_queue[0] == 0)
220
 
        ft_queue[0] = ft;
221
 
    else
222
 
        ft_queue[1] = ft;
223
 
    signal(SIGINT, sigint);
224
 
}