summaryrefslogtreecommitdiffstats
path: root/package/twolame/0001-Fix-static-linking-with-libmagic.patch
blob: 094d7e997e2757de36c2dd3ff2aaee894f33cce7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
From 484275de103b2214cb8ff3868a2562e2c61ce0e1 Mon Sep 17 00:00:00 2001
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Date: Thu, 8 Nov 2018 20:57:08 +0100
Subject: [PATCH] Fix static linking with libmagic

libmagic (from file package) already provides the buffer_init function
so to avoid a build failure for applications wanting to statically link
with twolame and libmagic (for example sox), rename buffer_init into
bitbuffer_init (also rename buffer_deinit into bitbuffer_deinit and
buffer_sstell into bitbuffer_sstell for consistency)

Fixes:
 - http://autobuild.buildroot.org/results/b3fc62e7f372fe595966e84091c11ccdb4cfa77c

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
[Upstream status: https://github.com/njh/twolame/pull/81]
---
 libtwolame/bitbuffer.c |  4 ++--
 libtwolame/bitbuffer.h |  6 +++---
 libtwolame/energy.c    |  2 +-
 libtwolame/twolame.c   | 32 ++++++++++++++++----------------
 4 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/libtwolame/bitbuffer.c b/libtwolame/bitbuffer.c
index 38a632b..5b2fc4b 100644
--- a/libtwolame/bitbuffer.c
+++ b/libtwolame/bitbuffer.c
@@ -33,7 +33,7 @@
 
 
 /*create bit buffer*/
-bit_stream *buffer_init(unsigned char *buffer, int buffer_size)
+bit_stream *bitbuffer_init(unsigned char *buffer, int buffer_size)
 {
     bit_stream *bs = (bit_stream *) TWOLAME_MALLOC(sizeof(bit_stream));
 
@@ -49,7 +49,7 @@ bit_stream *buffer_init(unsigned char *buffer, int buffer_size)
 }
 
 /* Dellocate bit buffer */
-void buffer_deinit(bit_stream ** bs)
+void bitbuffer_deinit(bit_stream ** bs)
 {
 
     if (bs == NULL || *bs == NULL)
diff --git a/libtwolame/bitbuffer.h b/libtwolame/bitbuffer.h
index 0201347..f377c8f 100644
--- a/libtwolame/bitbuffer.h
+++ b/libtwolame/bitbuffer.h
@@ -39,11 +39,11 @@ typedef struct bit_stream_struc {
 } bit_stream;
 
 
-bit_stream *buffer_init(unsigned char *buffer, int buffer_size);
-void buffer_deinit(bit_stream ** bs);
+bit_stream *bitbuffer_init(unsigned char *buffer, int buffer_size);
+void bitbuffer_deinit(bit_stream ** bs);
 
 /*return the current bit stream length (in bits)*/
-#define buffer_sstell(bs) (bs->totbit)
+#define bitbuffer_sstell(bs) (bs->totbit)
 
 #endif
 
diff --git a/libtwolame/energy.c b/libtwolame/energy.c
index 219bd2c..312d8ae 100644
--- a/libtwolame/energy.c
+++ b/libtwolame/energy.c
@@ -73,7 +73,7 @@ void do_energy_levels(twolame_options * glopts, bit_stream * bs)
     unsigned char rhibyte, rlobyte, lhibyte, llobyte;
 
     // Get the position (in butes) of the end of the mpeg audio frame
-    int frameEnd = buffer_sstell(bs) / 8;
+    int frameEnd = bitbuffer_sstell(bs) / 8;
 
 
     // find the maximum in the left and right channels
diff --git a/libtwolame/twolame.c b/libtwolame/twolame.c
index fa4bcc0..d3b8450 100644
--- a/libtwolame/twolame.c
+++ b/libtwolame/twolame.c
@@ -442,7 +442,7 @@ static int encode_frame(twolame_options * glopts, bit_stream * bs)
     glopts->num_crc_bits = 0;
 
     // Store the number of bits initially in the bit buffer
-    initial_bits = buffer_sstell(bs);
+    initial_bits = bitbuffer_sstell(bs);
 
     adb = available_bits(glopts);
 
@@ -580,7 +580,7 @@ static int encode_frame(twolame_options * glopts, bit_stream * bs)
 
 
     // Calulate the number of bits in this frame
-    frameBits = buffer_sstell(bs) - initial_bits;
+    frameBits = bitbuffer_sstell(bs) - initial_bits;
     if (frameBits % 8) {        /* a program failure */
         fprintf(stderr, "Sent %ld bits = %ld slots plus %ld\n", frameBits, frameBits / 8,
                 frameBits % 8);
@@ -630,7 +630,7 @@ int twolame_encode_buffer(twolame_options * glopts,
 
     // now would be a great time to validate the size of the buffer.
     // samples/1152 * sizeof(frame) < mp2buffer_size 
-    mybs = buffer_init(mp2buffer, mp2buffer_size);
+    mybs = bitbuffer_init(mp2buffer, mp2buffer_size);
 
 
     // Use up all the samples in in_buffer
@@ -658,7 +658,7 @@ int twolame_encode_buffer(twolame_options * glopts,
         if (glopts->samples_in_buffer >= TWOLAME_SAMPLES_PER_FRAME) {
             int bytes = encode_frame(glopts, mybs);
             if (bytes <= 0) {
-                buffer_deinit(&mybs);
+                bitbuffer_deinit(&mybs);
                 return bytes;
             }
             mp2_size += bytes;
@@ -667,7 +667,7 @@ int twolame_encode_buffer(twolame_options * glopts,
     }
 
     // free up the bit stream buffer structure
-    buffer_deinit(&mybs);
+    bitbuffer_deinit(&mybs);
 
     return (mp2_size);
 }
@@ -687,7 +687,7 @@ int twolame_encode_buffer_interleaved(twolame_options * glopts,
 
     // now would be a great time to validate the size of the buffer.
     // samples/1152 * sizeof(frame) < mp2buffer_size 
-    mybs = buffer_init(mp2buffer, mp2buffer_size);
+    mybs = bitbuffer_init(mp2buffer, mp2buffer_size);
 
     // Use up all the samples in in_buffer
     while (num_samples) {
@@ -714,7 +714,7 @@ int twolame_encode_buffer_interleaved(twolame_options * glopts,
         if (glopts->samples_in_buffer >= TWOLAME_SAMPLES_PER_FRAME) {
             int bytes = encode_frame(glopts, mybs);
             if (bytes <= 0) {
-                buffer_deinit(&mybs);
+                bitbuffer_deinit(&mybs);
                 return bytes;
             }
             mp2_size += bytes;
@@ -723,7 +723,7 @@ int twolame_encode_buffer_interleaved(twolame_options * glopts,
     }
 
     // free up the bit stream buffer structure
-    buffer_deinit(&mybs);
+    bitbuffer_deinit(&mybs);
 
 
     return (mp2_size);
@@ -771,7 +771,7 @@ int twolame_encode_buffer_float32(twolame_options * glopts,
 
     // now would be a great time to validate the size of the buffer.
     // samples/1152 * sizeof(frame) < mp2buffer_size 
-    mybs = buffer_init(mp2buffer, mp2buffer_size);
+    mybs = bitbuffer_init(mp2buffer, mp2buffer_size);
 
 
     // Use up all the samples in in_buffer
@@ -800,7 +800,7 @@ int twolame_encode_buffer_float32(twolame_options * glopts,
         if (glopts->samples_in_buffer >= TWOLAME_SAMPLES_PER_FRAME) {
             int bytes = encode_frame(glopts, mybs);
             if (bytes <= 0) {
-                buffer_deinit(&mybs);
+                bitbuffer_deinit(&mybs);
                 return bytes;
             }
             mp2_size += bytes;
@@ -809,7 +809,7 @@ int twolame_encode_buffer_float32(twolame_options * glopts,
     }
 
     // free up the bit stream buffer structure
-    buffer_deinit(&mybs);
+    bitbuffer_deinit(&mybs);
 
     return (mp2_size);
 }
@@ -829,7 +829,7 @@ int twolame_encode_buffer_float32_interleaved(twolame_options * glopts,
 
     // now would be a great time to validate the size of the buffer.
     // samples/1152 * sizeof(frame) < mp2buffer_size 
-    mybs = buffer_init(mp2buffer, mp2buffer_size);
+    mybs = bitbuffer_init(mp2buffer, mp2buffer_size);
 
     // Use up all the samples in in_buffer
     while (num_samples) {
@@ -857,7 +857,7 @@ int twolame_encode_buffer_float32_interleaved(twolame_options * glopts,
         if (glopts->samples_in_buffer >= TWOLAME_SAMPLES_PER_FRAME) {
             int bytes = encode_frame(glopts, mybs);
             if (bytes <= 0) {
-                buffer_deinit(&mybs);
+                bitbuffer_deinit(&mybs);
                 return bytes;
             }
             mp2_size += bytes;
@@ -866,7 +866,7 @@ int twolame_encode_buffer_float32_interleaved(twolame_options * glopts,
     }
 
     // free up the bit stream buffer structure
-    buffer_deinit(&mybs);
+    bitbuffer_deinit(&mybs);
 
 
     return (mp2_size);
@@ -885,7 +885,7 @@ int twolame_encode_flush(twolame_options * glopts, unsigned char *mp2buffer, int
         return 0;
     }
     // Create bit stream structure
-    mybs = buffer_init(mp2buffer, mp2buffer_size);
+    mybs = bitbuffer_init(mp2buffer, mp2buffer_size);
 
     // Pad out the PCM buffers with 0 and encode the frame
     for (i = glopts->samples_in_buffer; i < TWOLAME_SAMPLES_PER_FRAME; i++) {
@@ -897,7 +897,7 @@ int twolame_encode_flush(twolame_options * glopts, unsigned char *mp2buffer, int
     glopts->samples_in_buffer = 0;
 
     // free up the bit stream buffer structure
-    buffer_deinit(&mybs);
+    bitbuffer_deinit(&mybs);
 
     return mp2_size;
 }
-- 
2.17.1

OpenPOWER on IntegriCloud