1 /*
2 * copyright (c) 2001 Fabrice Bellard
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #ifndef AVCODEC_H
22 #define AVCODEC_H
23
24 /* Just a heavily bastardized version of the original file from
25 * ffmpeg, just enough to get resample2.c to compile without
26 * modification -- Lennart */
27
28 #if defined(HAVE_CONFIG_H)
29 #include <config.h>
30 #endif
31
32 #include <sys/types.h>
33 #include <stdint.h>
34 #include <math.h>
35 #include <string.h>
36 #include <stdlib.h>
37 #include <assert.h>
38 #include <errno.h>
39
40 typedef void *AVClass;
41
42 #define av_mallocz(l) calloc(1, (l))
43 #define av_malloc(l) malloc(l)
44 #define av_realloc(p,l) realloc((p),(l))
45 #define av_free(p) free(p)
46
47 #ifdef _MSC_VER
48 #define CHROMAPRINT_C_INLINE __inline
49 #else
50 #define CHROMAPRINT_C_INLINE inline
51 #endif
52
av_freep(void * k)53 static CHROMAPRINT_C_INLINE void av_freep(void *k) {
54 void **p = (void **)k;
55
56 if (p) {
57 free(*p);
58 *p = NULL;
59 }
60 }
61
av_clip(int a,int amin,int amax)62 static CHROMAPRINT_C_INLINE int av_clip(int a, int amin, int amax)
63 {
64 if (a < amin) return amin;
65 else if (a > amax) return amax;
66 else return a;
67 }
68
69 #define av_log(a,b,c)
70
71 #define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
72 #define FFSIGN(a) ((a) > 0 ? 1 : -1)
73
74 #define FFMAX(a,b) ((a) > (b) ? (a) : (b))
75 #define FFMIN(a,b) ((a) > (b) ? (b) : (a))
76
77 struct AVResampleContext;
78 struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
79 int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
80 void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
81 void av_resample_close(struct AVResampleContext *c);
82 void av_build_filter(int16_t *filter, double factor, int tap_count, int phase_count, int scale, int type);
83
84 /* error handling */
85 #if EDOM > 0
86 #define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions.
87 #define AVUNERROR(e) (-(e)) ///< Returns a POSIX error code from a library function error return value.
88 #else
89 /* Some platforms have E* and errno already negated. */
90 #define AVERROR(e) (e)
91 #define AVUNERROR(e) (e)
92 #endif
93
94 /*
95 * crude lrintf for non-C99 systems.
96 */
97 #ifndef HAVE_LRINTF
98 #define lrintf(x) ((long int)floor(x + 0.5))
99 #endif
100
101 #endif /* AVCODEC_H */
102