-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcodec.diff
437 lines (375 loc) · 14.5 KB
/
codec.diff
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
Includes of the patches from osmocom-tetra, and also patches to log to stderr,
enables compiler optimizations and allows building in a 64-bit gcc.
--sq5bpf
--Antonio Eugenio Burriel <[email protected]>
diff -ur orig/amr-code/channel.h new/amr-code/channel.h
--- orig/amr-code/channel.h 2003-01-09 13:33:48.000000000 +0100
+++ new/amr-code/channel.h 2015-02-28 23:09:40.431796317 +0100
@@ -139,7 +139,7 @@
Word16 negate(Word16 var1); /* Short negate, 1 */
Word16 norm_l(Word32 L_var1); /* Long norm, 30 */
Word16 norm_s(Word16 var1); /* Short norm, 15 */
-Word16 round(Word32 L_var1); /* Round, 1 */
+Word16 etsi_round(Word32 L_var1); /* Round, 1 */
Word16 shl(Word16 var1, Word16 var2); /* Short shift left, 1 */
Word16 shr(Word16 var1, Word16 var2); /* Short shift right, 1 */
Word16 sub(Word16 var1, Word16 var2); /* Short sub, 1 */
diff -ur orig/amr-code/init_params.c new/amr-code/init_params.c
--- orig/amr-code/init_params.c 2003-01-09 13:30:52.000000000 +0100
+++ new/amr-code/init_params.c 2015-02-28 23:09:40.435796388 +0100
@@ -26,11 +26,11 @@
#include "const.tab" /* contains constants for channel coding/decoding */
#include "arrays.h" /* contains constants for channel coding/decoding */
-#include "const_TETRA.tab" /* contains constants for channel coding/decoding */
-#include "arrays_TETRA.tab" /* contains arrays for channel coding/decoding */
+#include "const_tetra.tab" /* contains constants for channel coding/decoding */
+#include "arrays_tetra.tab" /* contains arrays for channel coding/decoding */
-#include "const_AMR475.tab" /* contains constants for channel coding/decoding */
-#include "arrays_AMR475.tab" /* contains arrays for channel coding/decoding */
+#include "const_amr475.tab" /* contains constants for channel coding/decoding */
+#include "arrays_amr475.tab" /* contains arrays for channel coding/decoding */
#define ALLOW_NEG(x) (((x) < 0) ? (((-x)%2 == 1) ? (-x)/2 - N1_2 + 1 : (x)/2 + 1) : (x))
diff -ur orig/amr-code/makefile new/amr-code/makefile
--- orig/amr-code/makefile 2003-01-09 13:29:36.000000000 +0100
+++ new/amr-code/makefile 2015-02-28 23:16:31.371084599 +0100
@@ -21,7 +21,7 @@
CC=gcc
-CFLAGS = -g -I.
+CFLAGS = -g -I. -Wall -O3
SRCS1 = ccoder.c ccod_tet.c init_params.c sub_cc.c \
tetra_op.c
@@ -33,10 +33,10 @@
all: ccoder cdecoder
-ccoder:
+ccoder: $(SRCS1)
$(CC) $(SRCS1) $(CFLAGS) -o ccoder
-cdecoder:
+cdecoder: $(SRCS2)
$(CC) $(SRCS2) $(CFLAGS) -o cdecoder
clean:
diff -ur orig/amr-code/source.h new/amr-code/source.h
--- orig/amr-code/source.h 2002-11-18 15:54:26.000000000 +0100
+++ new/amr-code/source.h 2015-02-28 23:27:09.550436888 +0100
@@ -19,11 +19,11 @@
#ifndef TYPEDEF_H
#define TYPEDEF_H
+#include <stdint.h>
-
-typedef short Word16;
-typedef long Word32;
-typedef int Flag;
+typedef int16_t Word16;
+typedef int32_t Word32;
+typedef int Flag;
#endif
@@ -164,7 +164,7 @@
Word16 negate(Word16 var1); /* Short negate, 1 */
Word16 norm_l(Word32 L_var1); /* Long norm, 30 */
Word16 norm_s(Word16 var1); /* Short norm, 15 */
-Word16 round(Word32 L_var1); /* Round, 1 */
+Word16 etsi_round(Word32 L_var1); /* Round, 1 */
Word16 shl(Word16 var1, Word16 var2); /* Short shift left, 1 */
Word16 shr(Word16 var1, Word16 var2); /* Short shift right, 1 */
Word16 sub(Word16 var1, Word16 var2); /* Short sub, 1 */
diff -ur orig/amr-code/tetra_op.c new/amr-code/tetra_op.c
--- orig/amr-code/tetra_op.c 2003-01-09 13:36:22.000000000 +0100
+++ new/amr-code/tetra_op.c 2015-02-28 23:09:40.435796388 +0100
@@ -31,7 +31,7 @@
* - negate()
* - norm_l()
* - norm_s()
-* - round()
+* - etsi_round()
* - sature()
* - shl()
* - shr()
@@ -1336,14 +1336,14 @@
/************************************************************************
*
-* Function Name : round
+* Function Name : etsi_round
*
* Purpose :
*
* Round the lower 16 bits of the 32 bit input number into its MS 16 bits
* with saturation. Shift the resulting bits right by 16 and return the 16
* bit number:
-* round(L_var1) = extract_h(L_add(L_var1,32768))
+* etsi_round(L_var1) = extract_h(L_add(L_var1,32768))
*
* Complexity Weight : 1
*
@@ -1365,7 +1365,7 @@
*
************************************************************************/
-Word16 round(Word32 L_var1)
+Word16 etsi_round(Word32 L_var1)
{
Word16 var_out;
Word32 L_arrondi;
diff -ur orig/c-code/cdecoder.c new/c-code/cdecoder.c
--- orig/c-code/cdecoder.c 1995-06-06 11:32:14.000000000 +0200
+++ new/c-code/cdecoder.c 2015-02-28 23:09:40.435796388 +0100
@@ -67,23 +67,23 @@
/* Parse arguments */
if ( argc != 3 )
{
- puts( "usage : cdecoder input_file output_file" );
- puts( "format for input_file : $6B21...114 bits");
- puts( " ...$6B22...114..." );
- puts( " ...$6B26...114...$6B21");
- puts( "format for output_file : two 138 (BFI + 137) bit frames");
+ fputs("usage : cdecoder input_file output_file",stderr );
+ fputs("format for input_file : $6B21...114 bits",stderr);
+ fputs(" ...$6B22...114...",stderr );
+ fputs(" ...$6B26...114...$6B21",stderr);
+ fputs("format for output_file : two 138 (BFI + 137) bit frames",stderr);
exit( 1 );
}
if ( (fin = fopen( argv[1], "rb" )) == NULL )
{
- puts("cdecoder: can't open input_file" );
+ fputs("cdecoder: can't open input_file" ,stderr);
exit( 1 );
}
if ( (fout = fopen( argv[2], "wb" )) == NULL )
{
- puts("cdecoder: can't open output_file" );
+ fputs("cdecoder: can't open output_file",stderr );
exit( 1 );
}
@@ -93,7 +93,7 @@
/* read Input_array (1 TETRA frame = 2 speech frames) from input file */
if (Read_Tetra_File (fin, Interleaved_coded_array) == -1)
{
- puts ("cdecoder: reached end of input_file");
+ fputs ("cdecoder: reached end of input_file",stderr);
break;
}
@@ -116,7 +116,7 @@
in "Coded_array" */
/* Message in case the Frame was stolen */
- if (bfi1) printf("Frame Nb %ld was stolen\n",Loop_counter+1);
+ if (bfi1) fprintf(stderr,"Frame Nb %ld was stolen\n",Loop_counter+1);
/* Channel Decoding */
bfi2 = Channel_Decoding(first_pass,Frame_stealing,
@@ -126,35 +126,35 @@
/* Increment Loop counter */
Loop_counter++;
/* Message in case the Bad Frame Indicator was set */
- if (bfi2) printf("Frame Nb %ld Bfi active\n\n",Loop_counter);
+ if (bfi2) fprintf(stderr,"Frame Nb %ld Bfi active\n\n",Loop_counter);
/* writing Reordered_array to output file */
/* bfi bit */
if( fwrite( &bfi1, sizeof(short), 1, fout ) != 1 ) {
- puts( "cdecoder: can't write to output_file" );
+ fputs( "cdecoder: can't write to output_file",stderr );
break;
}
/* 1st speech frame */
if( fwrite( Reordered_array, sizeof(short), 137, fout ) != 137 )
{
- puts( "cdecoder: can't write to output_file" );
+ fputs("cdecoder: can't write to output_file",stderr );
break;
}
/* bfi bit */
if( fwrite( &bfi2, sizeof(short), 1, fout ) != 1 ) {
- puts( "cdecoder: can't write to output_file" );
+ fputs("cdecoder: can't write to output_file",stderr );
break;
}
/* 2nd speech frame */
if( fwrite( Reordered_array+137, sizeof(short), 137, fout )
!= 137 ) {
- puts( "cdecoder: can't write to output_file" );
+ fputs("cdecoder: can't write to output_file",stderr );
break;
}
}
- printf("%ld Channel Frames processed\n",Loop_counter);
- printf("ie %ld Speech Frames\n",2*Loop_counter);
+ fprintf(stderr,"%ld Channel Frames processed\n",Loop_counter);
+ fprintf(stderr,"ie %ld Speech Frames\n",2*Loop_counter);
/* closing files */
fclose( fin );
diff -ur orig/c-code/channel.h new/c-code/channel.h
--- orig/c-code/channel.h 1995-06-09 16:14:42.000000000 +0200
+++ new/c-code/channel.h 2015-02-28 23:09:40.435796388 +0100
@@ -130,7 +130,7 @@
Word16 negate(Word16 var1); /* Short negate, 1 */
Word16 norm_l(Word32 L_var1); /* Long norm, 30 */
Word16 norm_s(Word16 var1); /* Short norm, 15 */
-Word16 round(Word32 L_var1); /* Round, 1 */
+Word16 etsi_round(Word32 L_var1); /* Round, 1 */
Word16 shl(Word16 var1, Word16 var2); /* Short shift left, 1 */
Word16 shr(Word16 var1, Word16 var2); /* Short shift right, 1 */
Word16 sub(Word16 var1, Word16 var2); /* Short sub, 1 */
diff -ur orig/c-code/makefile new/c-code/makefile
--- orig/c-code/makefile 1995-06-06 11:35:40.000000000 +0200
+++ new/c-code/makefile 2015-02-28 23:12:08.158414239 +0100
@@ -21,9 +21,9 @@
# macro definitions
-CC=acc
+CC=gcc
-CFLAGS = -I.
+CFLAGS = -I. -Wall -g -O3
SRCS1 = scoder.c scod_tet.c sub_sc_d.c \
sub_dsp.c fbas_tet.c fexp_tet.c \
@@ -43,18 +43,18 @@
all: scoder ccoder sdecoder cdecoder
-scoder:
+scoder: $(SRCS1)
$(CC) $(SRCS1) $(CFLAGS) -o scoder
-ccoder:
+ccoder: $(SRCS2)
$(CC) $(SRCS2) $(CFLAGS) -o ccoder
-sdecoder:
+sdecoder: $(SRCS3)
$(CC) $(SRCS3) $(CFLAGS) -o sdecoder
-cdecoder:
+cdecoder: $(SRCS4)
$(CC) $(SRCS4) $(CFLAGS) -o cdecoder
clean:
- rm -f core *.o
+ rm -f core *.o cdecoder sdecoder ccoder scoder
Sólo en new/c-code: makefile.orig
diff -ur orig/c-code/sdecoder.c new/c-code/sdecoder.c
--- orig/c-code/sdecoder.c 1995-06-06 10:55:28.000000000 +0200
+++ new/c-code/sdecoder.c 2015-02-28 23:09:40.435796388 +0100
@@ -58,15 +58,15 @@
if ( argc != 3 )
{
- printf("Usage : sdecoder serial_file synth_file\n");
- printf("\n");
- printf("Format for serial_file:\n");
- printf(" Serial stream input is read from a binary file\n");
- printf(" where each 16-bit word represents 1 encoded bit.\n");
- printf(" BFI + 137 bits by frame\n");
- printf("\n");
- printf("Format for synth_file:\n");
- printf(" Synthesis is written to a binary file of 16 bits data.\n");
+ fprintf(stderr,"Usage : sdecoder serial_file synth_file\n");
+ fprintf(stderr,"\n");
+ fprintf(stderr,"Format for serial_file:\n");
+ fprintf(stderr," Serial stream input is read from a binary file\n");
+ fprintf(stderr," where each 16-bit word represents 1 encoded bit.\n");
+ fprintf(stderr," BFI + 137 bits by frame\n");
+ fprintf(stderr,"\n");
+ fprintf(stderr,"Format for synth_file:\n");
+ fprintf(stderr," Synthesis is written to a binary file of 16 bits data.\n");
exit( 1 );
}
@@ -74,13 +74,13 @@
if( (f_serial = fopen(argv[1],"rb") ) == NULL )
{
- printf("Input file '%s' does not exist !!\n",argv[1]);
+ fprintf(stderr,"Input file '%s' does not exist !!\n",argv[1]);
exit(0);
}
if( (f_syn = fopen(argv[2], "wb") ) == NULL )
{
- printf("Cannot open file '%s' !!\n", argv[2]);
+ fprintf(stderr,"Cannot open file '%s' !!\n", argv[2]);
exit(0);
}
@@ -95,7 +95,7 @@
while( fread(serial, sizeof(Word16), serial_size, f_serial) == serial_size)
{
- printf("frame=%d\n", ++frame);
+ fprintf(stderr,"frame=%d\n", ++frame);
Bits2prm_Tetra(serial, parm); /* serial to parameters */
diff -ur orig/c-code/source.h new/c-code/source.h
--- orig/c-code/source.h 1995-06-06 11:10:52.000000000 +0200
+++ new/c-code/source.h 2015-02-28 23:27:09.550436888 +0100
@@ -19,11 +19,11 @@
#ifndef TYPEDEF_H
#define TYPEDEF_H
+#include <stdint.h>
-
-typedef short Word16;
-typedef long Word32;
-typedef int Flag;
+typedef int16_t Word16;
+typedef int32_t Word32;
+typedef int Flag;
#endif
@@ -164,7 +164,7 @@
Word16 negate(Word16 var1); /* Short negate, 1 */
Word16 norm_l(Word32 L_var1); /* Long norm, 30 */
Word16 norm_s(Word16 var1); /* Short norm, 15 */
-Word16 round(Word32 L_var1); /* Round, 1 */
+Word16 etsi_round(Word32 L_var1); /* Round, 1 */
Word16 shl(Word16 var1, Word16 var2); /* Short shift left, 1 */
Word16 shr(Word16 var1, Word16 var2); /* Short shift right, 1 */
Word16 sub(Word16 var1, Word16 var2); /* Short sub, 1 */
diff -ur orig/c-code/sub_dsp.c new/c-code/sub_dsp.c
--- orig/c-code/sub_dsp.c 1996-03-19 11:25:12.000000000 +0100
+++ new/c-code/sub_dsp.c 2015-02-28 23:09:40.439796459 +0100
@@ -554,7 +554,7 @@
fac[0] = gamma;
for(i=1; i<pp; i++)
- fac[i] = round( L_mult(fac[i-1], gamma) );
+ fac[i] = etsi_round( L_mult(fac[i-1], gamma) );
return;
}
@@ -1088,7 +1088,7 @@
a_exp[0] = a[0];
for(i=1; i<=pp; i++)
- a_exp[i] = round( L_mult(a[i], fac[i-1]) );
+ a_exp[i] = etsi_round( L_mult(a[i], fac[i-1]) );
return;
}
diff -ur orig/c-code/sub_sc_d.c new/c-code/sub_sc_d.c
--- orig/c-code/sub_sc_d.c 1996-04-25 08:46:54.000000000 +0200
+++ new/c-code/sub_sc_d.c 2015-02-28 23:09:40.439796459 +0100
@@ -1829,7 +1829,7 @@
s = L_mac0(s, x[i-15], coef[i]);
s = L_add(s, s);
- i = round(s);
+ i = etsi_round(s);
return(i);
}
@@ -1877,7 +1877,7 @@
s = L_mac0(s, x[i-16], coef[i]);
s = L_add(s, s);
- i = round(s);
+ i = etsi_round(s);
return(i);
}
diff -ur orig/c-code/tetra_op.c new/c-code/tetra_op.c
--- orig/c-code/tetra_op.c 1995-06-06 11:22:52.000000000 +0200
+++ new/c-code/tetra_op.c 2015-02-28 23:09:40.439796459 +0100
@@ -31,7 +31,7 @@
* - negate()
* - norm_l()
* - norm_s()
-* - round()
+* - etsi_round()
* - sature()
* - shl()
* - shr()
@@ -1335,14 +1335,14 @@
/************************************************************************
*
-* Function Name : round
+* Function Name : etsi_round
*
* Purpose :
*
* Round the lower 16 bits of the 32 bit input number into its MS 16 bits
* with saturation. Shift the resulting bits right by 16 and return the 16
* bit number:
-* round(L_var1) = extract_h(L_add(L_var1,32768))
+* etsi_round(L_var1) = extract_h(L_add(L_var1,32768))
*
* Complexity Weight : 1
*
@@ -1364,7 +1364,7 @@
*
************************************************************************/
-Word16 round(Word32 L_var1)
+Word16 etsi_round(Word32 L_var1)
{
Word16 var_out;
Word32 L_arrondi;