-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmp3tocsv.c
696 lines (636 loc) · 22.4 KB
/
mp3tocsv.c
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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
/* HTAB = 4 */
/****************************************************************************
* mp3tocsv.c -- A simple program decoding an MPEG audio stream to 16-bit *
* PCM from stdin to stdout. This program is just a simple sample *
* demonstrating how the low-level libmad API can be used. *
*--------------------------------------------------------------------------*
* (c) 2001--2004 Bertrand Petit *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above *
* copyright notice, this list of conditions and the following *
* disclaimer in the documentation and/or other materials provided *
* with the distribution. *
* *
* 3. Neither the name of the author nor the names of its contributors *
* may be used to endorse or promote products derived from this *
* software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' *
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR *
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF *
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, *
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT *
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF *
* SUCH DAMAGE. *
* *
****************************************************************************/
/*
* $Name: v1_1p1 $
* $Date: 2004/03/19 07:13:13 $
* $Revision: 1.20 $
*/
/****************************************************************************
* Includes *
****************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include <math.h> /* for pow() and log10() */
#include <mad.h>
#include <unistd.h>
#include "bstdfile.h"
/****************************************************************************
* Global variables. *
****************************************************************************/
/* Keeps a pointer to the program invocation name for the error
* messages.
*/
const char *ProgName;
int DoWrite = 0, DoRead = 0;
FILE *CSVFp = NULL;
/****************************************************************************
* Converts a sample from libmad's fixed point number format to a signed *
* short (16 bits). *
****************************************************************************/
static signed short MadFixedToSshort(mad_fixed_t Fixed)
{
/* A fixed point number is formed of the following bit pattern:
*
* SWWWFFFFFFFFFFFFFFFFFFFFFFFFFFFF
* MSB LSB
* S ==> Sign (0 is positive, 1 is negative)
* W ==> Whole part bits
* F ==> Fractional part bits
*
* This pattern contains MAD_F_FRACBITS fractional bits, one
* should alway use this macro when working on the bits of a fixed
* point number. It is not guaranteed to be constant over the
* different platforms supported by libmad.
*
* The signed short value is formed, after clipping, by the least
* significant whole part bit, followed by the 15 most significant
* fractional part bits. Warning: this is a quick and dirty way to
* compute the 16-bit number, madplay includes much better
* algorithms.
*/
/* Clipping */
if(Fixed>=MAD_F_ONE)
return(SHRT_MAX);
if(Fixed<=-MAD_F_ONE)
return(-SHRT_MAX);
/* Conversion. */
Fixed=Fixed>>(MAD_F_FRACBITS-15);
return((signed short)Fixed);
}
/****************************************************************************
* Print human readable informations about an audio MPEG frame. *
****************************************************************************/
static int PrintFrameInfo(FILE *fp, struct mad_header *Header)
{
const char *Layer,
*Mode,
*Emphasis;
/* Convert the layer number to it's printed representation. */
switch(Header->layer)
{
case MAD_LAYER_I:
Layer="I";
break;
case MAD_LAYER_II:
Layer="II";
break;
case MAD_LAYER_III:
Layer="III";
break;
default:
Layer="(unexpected layer value)";
break;
}
/* Convert the audio mode to it's printed representation. */
switch(Header->mode)
{
case MAD_MODE_SINGLE_CHANNEL:
Mode="single channel";
break;
case MAD_MODE_DUAL_CHANNEL:
Mode="dual channel";
break;
case MAD_MODE_JOINT_STEREO:
Mode="joint (MS/intensity) stereo";
break;
case MAD_MODE_STEREO:
Mode="normal LR stereo";
break;
default:
Mode="(unexpected mode value)";
break;
}
/* Convert the emphasis to it's printed representation. Note that
* the MAD_EMPHASIS_RESERVED enumeration value appeared in libmad
* version 0.15.0b.
*/
switch(Header->emphasis)
{
case MAD_EMPHASIS_NONE:
Emphasis="no";
break;
case MAD_EMPHASIS_50_15_US:
Emphasis="50/15 us";
break;
case MAD_EMPHASIS_CCITT_J_17:
Emphasis="CCITT J.17";
break;
case MAD_EMPHASIS_RESERVED:
Emphasis="reserved(!)";
break;
default:
Emphasis="(unexpected emphasis value)";
break;
}
fprintf(fp,"%s: %lu kb/s audio MPEG layer %s stream %s CRC, "
"%s with %s emphasis at %d Hz sample rate\n",
ProgName,Header->bitrate,Layer,
Header->flags&MAD_FLAG_PROTECTION?"with":"without",
Mode,Emphasis,Header->samplerate);
return(ferror(fp));
}
/****************************************************************************
* Process a frequency-domain filter to audio data in the subband-domain. *
****************************************************************************/
static int ProcessFrame(struct mad_frame *Frame)
{
static int Counter;
int Channel, Sample, Samples, SubBand, result;
int scnCounter, scnChannel, scnSample;
Samples=MAD_NSBSAMPLES(&Frame->header);
if(Frame->header.mode!=MAD_MODE_SINGLE_CHANNEL)
for(Channel=0;Channel<2;Channel++)
for(Sample=0;Sample<Samples;Sample++)
{
if(DoWrite)
{
fprintf(CSVFp, "%d,%d,%d", Counter, Channel, Sample);
for(SubBand=0;SubBand<32;SubBand++)
fprintf(CSVFp, ",%f", mad_f_todouble(Frame->sbsample[Channel][Sample][SubBand]));
fprintf(CSVFp, "\n");
}
if(DoRead)
{
result = fscanf(CSVFp, "%d,%d,%d", &scnCounter, &scnChannel, &scnSample);
if(result == 0 || result == EOF)
{
fprintf(stderr,"%s expected counter value can not be found. result = %d, counters = %d,%d,%d\n",
ProgName, result, Counter, Channel, Sample);
return result;
}
if(scnChannel != Channel || scnSample != Sample)
{
fprintf(stderr,"%s invalid counters: %d,%d,%d %d,%d,%d\n",ProgName,
Counter, Channel, Sample, scnCounter, scnChannel, scnSample);
return -1;
}
for(SubBand=0;SubBand<32;SubBand++)
{
double sample = 0.0;
result = fscanf(CSVFp, ",%lf", &sample);
Frame->sbsample[Channel][Sample][SubBand] = mad_f_tofixed(sample);
if(result == 0 || result == EOF)
{
fprintf(stderr,"%s invalid sample value. result = %d, counters = %d,%d,%d\n",
ProgName, result, Counter, Channel, Sample);
return result;
}
}
result = fscanf(CSVFp, "\n");
if(result == EOF)
{
fprintf(stderr,"%s expected LNF is not found. result = %d, counters = %d,%d,%d\n",
ProgName, result, Counter, Channel, Sample);
return result;
}
}
}
Counter++;
return 1;
}
/****************************************************************************
* Main decoding loop. This is where mad is used. *
****************************************************************************/
#define INPUT_BUFFER_SIZE (5*8192)
#define OUTPUT_BUFFER_SIZE 8192 /* Must be an integer multiple of 4. */
static int MpegAudioDecoder(FILE *InputFp, FILE *OutputFp)
{
struct mad_stream Stream;
struct mad_frame Frame;
struct mad_synth Synth;
mad_timer_t Timer;
unsigned char InputBuffer[INPUT_BUFFER_SIZE+MAD_BUFFER_GUARD],
OutputBuffer[OUTPUT_BUFFER_SIZE],
*OutputPtr=OutputBuffer,
*GuardPtr=NULL;
const unsigned char *OutputBufferEnd=OutputBuffer+OUTPUT_BUFFER_SIZE;
int Status=0,
i;
unsigned long FrameCount=0;
bstdfile_t *BstdFile;
/* First the structures used by libmad must be initialized. */
mad_stream_init(&Stream);
mad_frame_init(&Frame);
mad_synth_init(&Synth);
mad_timer_reset(&Timer);
/* Decoding options can here be set in the options field of the
* Stream structure.
*/
/* {1} When decoding from a file we need to know when the end of
* the file is reached at the same time as the last bytes are read
* (see also the comment marked {3} bellow). Neither the standard
* C fread() function nor the POSIX read() system call provides
* this feature. We thus need to perform our reads through an
* interface having this feature, this is implemented here by the
* bstdfile.c module.
*/
BstdFile=NewBstdFile(InputFp);
if(BstdFile==NULL)
{
fprintf(stderr,"%s: can't create a new bstdfile_t (%s).\n",
ProgName,strerror(errno));
return(1);
}
/* This is the decoding loop. */
do
{
if(CSVFp)
{
if(feof(CSVFp))
{
fprintf(stderr,"%s: end of CSV file.\n",ProgName);
break;
}
}
/* The input bucket must be filled if it becomes empty or if
* it's the first execution of the loop.
*/
if(Stream.buffer==NULL || Stream.error==MAD_ERROR_BUFLEN)
{
size_t ReadSize,
Remaining;
unsigned char *ReadStart;
/* {2} libmad may not consume all bytes of the input
* buffer. If the last frame in the buffer is not wholly
* contained by it, then that frame's start is pointed by
* the next_frame member of the Stream structure. This
* common situation occurs when mad_frame_decode() fails,
* sets the stream error code to MAD_ERROR_BUFLEN, and
* sets the next_frame pointer to a non NULL value. (See
* also the comment marked {4} bellow.)
*
* When this occurs, the remaining unused bytes must be
* put back at the beginning of the buffer and taken in
* account before refilling the buffer. This means that
* the input buffer must be large enough to hold a whole
* frame at the highest observable bit-rate (currently 448
* kb/s). XXX=XXX Is 2016 bytes the size of the largest
* frame? (448000*(1152/32000))/8
*/
if(Stream.next_frame!=NULL)
{
Remaining=Stream.bufend-Stream.next_frame;
memmove(InputBuffer,Stream.next_frame,Remaining);
ReadStart=InputBuffer+Remaining;
ReadSize=INPUT_BUFFER_SIZE-Remaining;
}
else
ReadSize=INPUT_BUFFER_SIZE,
ReadStart=InputBuffer,
Remaining=0;
/* Fill-in the buffer. If an error occurs print a message
* and leave the decoding loop. If the end of stream is
* reached we also leave the loop but the return status is
* left untouched.
*/
ReadSize=BstdRead(ReadStart,1,ReadSize,BstdFile);
if(ReadSize<=0)
{
if(ferror(InputFp))
{
fprintf(stderr,"%s: read error on bit-stream (%s)\n",
ProgName,strerror(errno));
Status=1;
}
if(feof(InputFp))
fprintf(stderr,"%s: end of input stream\n",ProgName);
break;
}
/* {3} When decoding the last frame of a file, it must be
* followed by MAD_BUFFER_GUARD zero bytes if one wants to
* decode that last frame. When the end of file is
* detected we append that quantity of bytes at the end of
* the available data. Note that the buffer can't overflow
* as the guard size was allocated but not used the the
* buffer management code. (See also the comment marked
* {1}.)
*
* In a message to the mad-dev mailing list on May 29th,
* 2001, Rob Leslie explains the guard zone as follows:
*
* "The reason for MAD_BUFFER_GUARD has to do with the
* way decoding is performed. In Layer III, Huffman
* decoding may inadvertently read a few bytes beyond
* the end of the buffer in the case of certain invalid
* input. This is not detected until after the fact. To
* prevent this from causing problems, and also to
* ensure the next frame's main_data_begin pointer is
* always accessible, MAD requires MAD_BUFFER_GUARD
* (currently 8) bytes to be present in the buffer past
* the end of the current frame in order to decode the
* frame."
*/
if(BstdFileEofP(BstdFile))
{
GuardPtr=ReadStart+ReadSize;
memset(GuardPtr,0,MAD_BUFFER_GUARD);
ReadSize+=MAD_BUFFER_GUARD;
}
/* Pipe the new buffer content to libmad's stream decoder
* facility.
*/
mad_stream_buffer(&Stream,InputBuffer,ReadSize+Remaining);
Stream.error=0;
}
/* Decode the next MPEG frame. The streams is read from the
* buffer, its constituents are break down and stored the the
* Frame structure, ready for examination/alteration or PCM
* synthesis. Decoding options are carried in the Frame
* structure from the Stream structure.
*
* Error handling: mad_frame_decode() returns a non zero value
* when an error occurs. The error condition can be checked in
* the error member of the Stream structure. A mad error is
* recoverable or fatal, the error status is checked with the
* MAD_RECOVERABLE macro.
*
* {4} When a fatal error is encountered all decoding
* activities shall be stopped, except when a MAD_ERROR_BUFLEN
* is signaled. This condition means that the
* mad_frame_decode() function needs more input to complete
* its work. One shall refill the buffer and repeat the
* mad_frame_decode() call. Some bytes may be left unused at
* the end of the buffer if those bytes forms an incomplete
* frame. Before refilling, the remaining bytes must be moved
* to the beginning of the buffer and used for input for the
* next mad_frame_decode() invocation. (See the comments
* marked {2} earlier for more details.)
*
* Recoverable errors are caused by malformed bit-streams, in
* this case one can call again mad_frame_decode() in order to
* skip the faulty part and re-sync to the next frame.
*/
if(mad_frame_decode(&Frame,&Stream))
{
if(MAD_RECOVERABLE(Stream.error))
{
/* Do not print a message if the error is a loss of
* synchronization and this loss is due to the end of
* stream guard bytes. (See the comments marked {3}
* supra for more informations about guard bytes.)
*/
if(Stream.error!=MAD_ERROR_LOSTSYNC ||
Stream.this_frame!=GuardPtr)
{
fprintf(stderr,"%s: recoverable frame level error (%s)\n",
ProgName,mad_stream_errorstr(&Stream));
fflush(stderr);
}
continue;
}
else
if(Stream.error==MAD_ERROR_BUFLEN)
continue;
else
{
fprintf(stderr,"%s: unrecoverable frame level error (%s).\n",
ProgName,mad_stream_errorstr(&Stream));
Status=1;
break;
}
}
/* The characteristics of the stream's first frame is printed
* on stderr. The first frame is representative of the entire
* stream.
*/
if(FrameCount==0)
if(PrintFrameInfo(stderr,&Frame.header))
{
Status=1;
break;
}
/* Accounting. The computed frame duration is in the frame
* header structure. It is expressed as a fixed point number
* whole data type is mad_timer_t. It is different from the
* samples fixed point format and unlike it, it can't directly
* be added or subtracted. The timer module provides several
* functions to operate on such numbers. Be careful there, as
* some functions of libmad's timer module receive some of
* their mad_timer_t arguments by value!
*/
FrameCount++;
mad_timer_add(&Timer,Frame.header.duration);
/* Between the frame decoding and samples synthesis we can
* perform some operations on the audio data. We do this only
* if some processing was required. Detailed explanations are
* given in the ProcessFrame() function.
*/
if(CSVFp)
{
int result = ProcessFrame(&Frame);
if(result != 1)
{
fprintf(stderr,"%s: read error on CSV-stream.\n", ProgName);
Status=1;
break;
}
}
/* Once decoded the frame is synthesized to PCM samples. No errors
* are reported by mad_synth_frame();
*/
mad_synth_frame(&Synth,&Frame);
/* Synthesized samples must be converted from libmad's fixed
* point number to the consumer format. Here we use unsigned
* 16 bit big endian integers on two channels. Integer samples
* are temporarily stored in a buffer that is flushed when
* full.
*/
for(i=0;i<Synth.pcm.length;i++)
{
signed short Sample;
/* Left channel */
Sample=MadFixedToSshort(Synth.pcm.samples[0][i]);
*(OutputPtr++)=Sample>>8;
*(OutputPtr++)=Sample&0xff;
/* Right channel. If the decoded stream is monophonic then
* the right output channel is the same as the left one.
*/
if(MAD_NCHANNELS(&Frame.header)==2)
Sample=MadFixedToSshort(Synth.pcm.samples[1][i]);
*(OutputPtr++)=Sample>>8;
*(OutputPtr++)=Sample&0xff;
/* Flush the output buffer if it is full. */
if(OutputPtr==OutputBufferEnd)
{
if(fwrite(OutputBuffer,1,OUTPUT_BUFFER_SIZE,OutputFp)!=OUTPUT_BUFFER_SIZE)
{
fprintf(stderr,"%s: PCM write error (%s).\n",
ProgName,strerror(errno));
Status=2;
break;
}
OutputPtr=OutputBuffer;
}
}
}while(1);
/* The input file was completely read; the memory allocated by our
* reading module must be reclaimed.
*/
BstdFileDestroy(BstdFile);
/* Mad is no longer used, the structures that were initialized must
* now be cleared.
*/
mad_synth_finish(&Synth);
mad_frame_finish(&Frame);
mad_stream_finish(&Stream);
/* If the output buffer is not empty and no error occurred during
* the last write, then flush it.
*/
if(OutputPtr!=OutputBuffer && Status!=2)
{
size_t BufferSize=OutputPtr-OutputBuffer;
if(fwrite(OutputBuffer,1,BufferSize,OutputFp)!=BufferSize)
{
fprintf(stderr,"%s: PCM write error (%s).\n",
ProgName,strerror(errno));
Status=2;
}
}
/* Accounting report if no error occurred. */
if(!Status)
{
char Buffer[80];
/* The duration timer is converted to a human readable string
* with the versatile, but still constrained mad_timer_string()
* function, in a fashion not unlike strftime(). The main
* difference is that the timer is broken into several
* values according some of it's arguments. The units and
* fracunits arguments specify the intended conversion to be
* executed.
*
* The conversion unit (MAD_UNIT_MINUTES in our example) also
* specify the order and kind of conversion specifications
* that can be used in the format string.
*
* It is best to examine libmad's timer.c source-code for details
* of the available units, fraction of units, their meanings,
* the format arguments, etc.
*/
mad_timer_string(Timer,Buffer,"%lu:%02lu.%03u",
MAD_UNITS_MINUTES,MAD_UNITS_MILLISECONDS,0);
fprintf(stderr,"%s: %lu frames decoded (%s).\n",
ProgName,FrameCount,Buffer);
}
/* That's the end of the world (in the H. G. Wells way). */
return(Status);
}
/****************************************************************************
* Prints a message on stderr explaining the usage of the program. Two *
* versions of this function are provided, depending on the system type. *
****************************************************************************/
static void PrintUsage(void)
{
fprintf(stderr,"usage: %s [-r|-w] [filename] < file.mp3 | play -t cdr -\n"
"\t-w\tWrite SubBand values to filename;\n"
"\t-r\tRead SubBand values from filename;\n.",
ProgName);
}
/****************************************************************************
* Command-line arguments parsing. We use two methods and two command-line *
* formats depending on the system type. On unix system we apply the good *
* old getopt() method, other system are offered a really primitive options *
* interface. *
****************************************************************************/
static int ParseArgs(int argc, char * const argv[])
{
/* Parse the command line. */
if(argc > 1)
{
char Option = argv[1][0] == '-' ? argv[1][1] : '?';
char *filename = argc > 2 ? argv[2] : NULL;
switch(Option)
{
case 'r':
case 'w':
DoWrite = (Option == 'w');
DoRead = (Option == 'r');
if(filename == NULL || !strlen(filename))
{
fprintf(stderr,"Warning: Output/Input file path was not set!\n");
DoWrite = DoRead = 0;
}
CSVFp = fopen (filename, &argv[1][1]);
if(!CSVFp)
{
fprintf(stderr,"Warning: Can't open output file!\n");
DoWrite = DoRead = 0;
return(1);
}
break;
/* Print usage guide for invalid options. */
case '?':
default:
PrintUsage();
return(1);
}
}
/* Command-line arguments are okay. */
return(0);
}
/****************************************************************************
* Program entry point. *
****************************************************************************/
int main(int argc, char *argv[])
{
char *cptr;
int Status;
/* Keep this for error messages. */
cptr=strrchr(argv[0],'/');
if(cptr==NULL)
ProgName=argv[0];
else
ProgName=cptr+1;
/* The command-line arguments are analyzed. */
if(ParseArgs(argc,argv))
return(1);
/* Decode stdin to stdout. */
Status=MpegAudioDecoder(stdin,stdout);
if(Status)
fprintf(stderr,"%s: an error occurred during decoding.\n",ProgName);
if(CSVFp != NULL)
fclose(CSVFp);
/* All done. */
return(Status);
}
/****************************************************************************
* End of file mp3tocsv.c *
****************************************************************************/