23
45
#include <dmalloc.h>
27
int InitMP3( PMPSTR mp)
29
memset(mp,0,sizeof(MPSTR));
40
mp->old_free_format=0;
45
mp->head = mp->tail = NULL;
48
mp->wordpointer = mp->bsspace[mp->bsnum] + 512;
51
mp->sync_bitstream = 1;
53
make_decode_tables(32767);
62
void ExitMP3( PMPSTR mp)
75
static struct buf *addbuf( PMPSTR mp, unsigned char *buf,int size)
79
nbuf = (struct buf*) malloc( sizeof(struct buf) );
81
fprintf(stderr,"Out of memory!\n");
84
nbuf->pnt = (unsigned char*) malloc((size_t)size);
90
memcpy(nbuf->pnt,buf,(size_t)size);
92
nbuf->prev = mp->head;
99
mp->head->next = nbuf;
108
void remove_buf(PMPSTR mp)
110
struct buf *buf = mp->tail;
112
mp->tail = buf->next;
114
mp->tail->prev = NULL;
116
mp->tail = mp->head = NULL;
124
static int read_buf_byte(PMPSTR mp)
48
/* #define HIP_DEBUG */
53
memset(mp, 0, sizeof(MPSTR));
60
mp->header_parsed = 0;
64
mp->old_free_format = 0;
69
mp->head = mp->tail = NULL;
72
mp->wordpointer = mp->bsspace[mp->bsnum] + 512;
75
mp->sync_bitstream = 1;
77
make_decode_tables(32767);
101
addbuf(PMPSTR mp, unsigned char *buf, int size)
105
nbuf = (struct buf *) malloc(sizeof(struct buf));
107
fprintf(stderr, "hip: addbuf() Out of memory!\n");
110
nbuf->pnt = (unsigned char *) malloc((size_t) size);
116
memcpy(nbuf->pnt, buf, (size_t) size);
118
nbuf->prev = mp->head;
125
mp->head->next = nbuf;
135
remove_buf(PMPSTR mp)
137
struct buf *buf = mp->tail;
139
mp->tail = buf->next;
141
mp->tail->prev = NULL;
143
mp->tail = mp->head = NULL;
152
read_buf_byte(PMPSTR mp)
160
while (pos >= mp->tail->size) {
163
fprintf(stderr, "hip: Fatal error! tried to read past mp buffer\n");
131
166
pos = mp->tail->pos;
132
while(pos >= mp->tail->size) {
135
fprintf(stderr,"Fatal error! tried to read past mp buffer\n");
141
b = mp->tail->pnt[pos];
151
static void read_head(PMPSTR mp)
155
head = read_buf_byte(mp);
157
head |= read_buf_byte(mp);
159
head |= read_buf_byte(mp);
161
head |= read_buf_byte(mp);
172
copy_mp(PMPSTR mp,int size,unsigned char *ptr)
176
while(len < size && mp->tail) {
178
int blen = mp->tail->size - mp->tail->pos;
179
if( (size - len) <= blen) {
185
memcpy(ptr+len,mp->tail->pnt+mp->tail->pos,(size_t)nlen);
187
mp->tail->pos += nlen;
189
if(mp->tail->pos == mp->tail->size) {
169
b = mp->tail->pnt[pos];
184
head = read_buf_byte(mp);
186
head |= read_buf_byte(mp);
188
head |= read_buf_byte(mp);
190
head |= read_buf_byte(mp);
199
copy_mp(PMPSTR mp, int size, unsigned char *ptr)
203
while (len < size && mp->tail) {
205
int blen = mp->tail->size - mp->tail->pos;
206
if ((size - len) <= blen) {
212
memcpy(ptr + len, mp->tail->pnt + mp->tail->pos, (size_t) nlen);
214
mp->tail->pos += nlen;
216
if (mp->tail->pos == mp->tail->size) {
195
222
/* number of bytes needed by GetVbrTag to parse header */
196
223
#define XING_HEADER_SIZE 194
198
/* traverse mp data structure without changing it */
199
/* (just like sync_buffer) */
200
/* pull out Xing bytes */
201
/* call vbr header check code from LAME */
202
/* if we find a header, parse it and also compute the VBR header size */
203
/* if no header, do nothing. */
205
/* bytes = number of bytes before MPEG header. skip this many bytes */
206
/* before starting to read */
207
/* return value: number of bytes in VBR header, including syncword */
226
traverse mp data structure without changing it
227
(just like sync_buffer)
229
call vbr header check code from LAME
230
if we find a header, parse it and also compute the VBR header size
231
if no header, do nothing.
233
bytes = number of bytes before MPEG header. skip this many bytes
234
before starting to read
235
return value: number of bytes in VBR header, including syncword
209
check_vbr_header(PMPSTR mp,int bytes)
238
check_vbr_header(PMPSTR mp, int bytes)
212
struct buf *buf=mp->tail;
213
unsigned char xing[XING_HEADER_SIZE];
217
/* skip to valid header */
218
for (i=0; i<bytes; ++i) {
219
while(pos >= buf->size) {
222
if(!buf) return -1; /* fatal error */
226
/* now read header */
227
for (i=0; i<XING_HEADER_SIZE; ++i) {
228
while(pos >= buf->size) {
230
if(!buf) return -1; /* fatal error */
233
xing[i] = buf->pnt[pos];
237
/* check first bytes for Xing header */
238
mp->vbr_header = GetVbrTag(&pTagData,xing);
239
if (mp->vbr_header) {
240
mp->num_frames=pTagData.frames;
241
mp->enc_delay=pTagData.enc_delay;
242
mp->enc_padding=pTagData.enc_padding;
244
/*fprintf(stderr,"\rmpglib: delays: %i %i \n",mp->enc_delay,mp->enc_padding); */
245
/* fprintf(stderr,"\rmpglib: Xing VBR header dectected. MP3 file has %i frames\n", pTagData.frames); */
246
if ( pTagData.headersize < 1 ) return 1;
247
return pTagData.headersize;
241
struct buf *buf = mp->tail;
242
unsigned char xing[XING_HEADER_SIZE];
246
/* skip to valid header */
247
for (i = 0; i < bytes; ++i) {
248
while (pos >= buf->size) {
251
return -1; /* fatal error */
256
/* now read header */
257
for (i = 0; i < XING_HEADER_SIZE; ++i) {
258
while (pos >= buf->size) {
261
return -1; /* fatal error */
264
xing[i] = buf->pnt[pos];
268
/* check first bytes for Xing header */
269
mp->vbr_header = GetVbrTag(&pTagData, xing);
270
if (mp->vbr_header) {
271
mp->num_frames = pTagData.frames;
272
mp->enc_delay = pTagData.enc_delay;
273
mp->enc_padding = pTagData.enc_padding;
275
/* fprintf(stderr,"hip: delays: %i %i \n",mp->enc_delay,mp->enc_padding); */
276
/* fprintf(stderr,"hip: Xing VBR header dectected. MP3 file has %i frames\n", pTagData.frames); */
277
if (pTagData.headersize < 1)
279
return pTagData.headersize;
259
sync_buffer(PMPSTR mp,int free_match)
289
sync_buffer(PMPSTR mp, int free_match)
261
/* traverse mp structure without modifing pointers, looking
262
* for a frame valid header.
263
* if free_format, valid header must also have the same
265
* return number of bytes in mp, before the header
266
* return -1 if header is not found
268
unsigned int b[4]={0,0,0,0};
270
struct buf *buf=mp->tail;
274
for (i=0; i<mp->bsize; i++) {
277
b[0]=b[1]; b[1]=b[2]; b[2]=b[3];
278
while(pos >= buf->size) {
291
/* traverse mp structure without modifying pointers, looking
292
* for a frame valid header.
293
* if free_format, valid header must also have the same
295
* return number of bytes in mp, before the header
296
* return -1 if header is not found
298
unsigned int b[4] = { 0, 0, 0, 0 };
300
struct buf *buf = mp->tail;
283
/* not enough data to read 4 bytes */
286
b[3] = buf->pnt[pos];
290
struct frame *fr = &mp->fr;
300
h = head_check(head,fr->lay);
302
if (h && free_match) {
303
/* just to be even more thorough, match the sample rate */
304
int mode,stereo,sampling_frequency,mpeg25,lsf;
306
if( head & (1<<20) ) {
307
lsf = (head & (1<<19)) ? 0x0 : 0x1;
315
mode = ((head>>6)&0x3);
316
stereo = (mode == MPG_MD_MONO) ? 1 : 2;
319
sampling_frequency = 6 + ((head>>10)&0x3);
321
sampling_frequency = ((head>>10)&0x3) + (lsf*3);
322
h = ((stereo==fr->stereo) && (lsf==fr->lsf) && (mpeg25==fr->mpeg25) &&
323
(sampling_frequency == fr->sampling_frequency));
305
for (i = 0; i < mp->bsize; i++) {
311
while (pos >= buf->size) {
316
/* not enough data to read 4 bytes */
319
b[3] = buf->pnt[pos];
323
struct frame *fr = &mp->fr;
333
h = head_check(head, fr->lay);
335
if (h && free_match) {
336
/* just to be even more thorough, match the sample rate */
337
int mode, stereo, sampling_frequency, mpeg25, lsf;
339
if (head & (1 << 20)) {
340
lsf = (head & (1 << 19)) ? 0x0 : 0x1;
348
mode = ((head >> 6) & 0x3);
349
stereo = (mode == MPG_MD_MONO) ? 1 : 2;
352
sampling_frequency = 6 + ((head >> 10) & 0x3);
354
sampling_frequency = ((head >> 10) & 0x3) + (lsf * 3);
355
h = ((stereo == fr->stereo) && (lsf == fr->lsf) && (mpeg25 == fr->mpeg25) &&
356
(sampling_frequency == fr->sampling_frequency));
369
decode_reset(PMPSTR mp)
373
/* start looking for next frame */
374
/* mp->fsizeold = mp->framesize; */
376
mp->old_free_format = mp->free_format;
378
mp->header_parsed = 0;
381
mp->sync_bitstream = 1; /* TODO check if this is right */
383
InitMP3(mp); /* Less error prone to just to reinitialise. */
388
audiodata_precedesframes(PMPSTR mp)
391
return layer3_audiodata_precedesframes(mp);
393
return 0; /* For Layer 1 & 2 the audio data starts at the frame that describes it, so no audio data precedes. */
338
decodeMP3_clipchoice( PMPSTR mp,unsigned char *in,int isize,char *out,int *done,
339
int (*synth_1to1_mono_ptr)(PMPSTR,real *,unsigned char *,int *),
340
int (*synth_1to1_ptr)(PMPSTR,real *,int,unsigned char *, int *) )
397
decodeMP3_clipchoice(PMPSTR mp, unsigned char *in, int isize, char *out, int *done,
398
int (*synth_1to1_mono_ptr) (PMPSTR, real *, unsigned char *, int *),
399
int (*synth_1to1_ptr) (PMPSTR, real *, int, unsigned char *, int *))
342
int i,iret,bits,bytes;
344
if (in && isize && addbuf(mp,in,isize) == NULL)
347
/* First decode header */
348
if(!mp->header_parsed) {
350
if (mp->fsizeold==-1 || mp->sync_bitstream) {
352
mp->sync_bitstream=0;
354
/* This is the very first call. sync with anything */
355
/* bytes= number of bytes before header */
356
bytes=sync_buffer(mp,0);
358
/* now look for Xing VBR header */
359
if (mp->bsize >= bytes+XING_HEADER_SIZE ) {
360
/* vbrbytes = number of bytes in entire vbr header */
361
vbrbytes=check_vbr_header(mp,bytes);
363
/* not enough data to look for Xing header */
364
return MP3_NEED_MORE;
367
if (mp->vbr_header) {
368
/* do we have enough data to parse entire Xing header? */
369
if (bytes+vbrbytes > mp->bsize) return MP3_NEED_MORE;
371
/* read in Xing header. Buffer data in case it
372
* is used by a non zero main_data_begin for the next
373
* frame, but otherwise dont decode Xing header */
374
/*fprintf(stderr,"found xing header, skipping %i bytes\n",vbrbytes+bytes);*/
375
for (i=0; i<vbrbytes+bytes; ++i) read_buf_byte(mp);
376
/* now we need to find another syncword */
377
/* just return and make user send in more data */
378
return MP3_NEED_MORE;
381
/* match channels, samplerate, etc, when syncing */
382
bytes=sync_buffer(mp,1);
385
if (bytes<0) return MP3_NEED_MORE;
387
/* there were some extra bytes in front of header.
388
* bitstream problem, but we are now resynced
389
* should try to buffer previous data in case new
390
* frame has nonzero main_data_begin, but we need
391
* to make sure we do not overflow buffer
394
fprintf(stderr,"bitstream problem: resyncing...\n");
395
mp->old_free_format=0;
396
mp->sync_bitstream=1;
398
/* skip some bytes, buffer the rest */
399
size = (int) (mp->wordpointer - (mp->bsspace[mp->bsnum]+512));
401
if (size > MAXFRAMESIZE) {
402
/* wordpointer buffer is trashed. probably cant recover, but try anyway */
403
fprintf(stderr,"mpglib: wordpointer trashed. size=%i (%i) bytes=%i \n",
404
size,MAXFRAMESIZE,bytes);
406
mp->wordpointer = mp->bsspace[mp->bsnum]+512;
409
/* buffer contains 'size' data right now
410
we want to add 'bytes' worth of data, but do not
411
exceed MAXFRAMESIZE, so we through away 'i' bytes */
412
i = (size+bytes)-MAXFRAMESIZE;
401
int i, iret, bits, bytes;
403
if (in && isize && addbuf(mp, in, isize) == NULL)
406
/* First decode header */
407
if (!mp->header_parsed) {
409
if (mp->fsizeold == -1 || mp->sync_bitstream) {
411
mp->sync_bitstream = 0;
413
/* This is the very first call. sync with anything */
414
/* bytes= number of bytes before header */
415
bytes = sync_buffer(mp, 0);
417
/* now look for Xing VBR header */
418
if (mp->bsize >= bytes + XING_HEADER_SIZE) {
419
/* vbrbytes = number of bytes in entire vbr header */
420
vbrbytes = check_vbr_header(mp, bytes);
423
/* not enough data to look for Xing header */
425
fprintf(stderr, "hip: not enough data to look for Xing header\n");
427
return MP3_NEED_MORE;
430
if (mp->vbr_header) {
431
/* do we have enough data to parse entire Xing header? */
432
if (bytes + vbrbytes > mp->bsize) {
433
/* fprintf(stderr,"hip: not enough data to parse entire Xing header\n"); */
434
return MP3_NEED_MORE;
437
/* read in Xing header. Buffer data in case it
438
* is used by a non zero main_data_begin for the next
439
* frame, but otherwise dont decode Xing header */
441
fprintf(stderr, "hip: found xing header, skipping %i bytes\n", vbrbytes + bytes);
443
for (i = 0; i < vbrbytes + bytes; ++i)
415
444
read_buf_byte(mp);
418
copy_mp(mp,bytes,mp->wordpointer);
419
mp->fsizeold += bytes;
423
decode_header(&mp->fr,mp->header);
425
mp->framesize = mp->fr.framesize;
426
mp->free_format = (mp->framesize==0);
429
mp->ssize = (mp->fr.stereo == 1) ? 9 : 17;
431
mp->ssize = (mp->fr.stereo == 1) ? 17 : 32;
432
if (mp->fr.error_protection)
435
mp->bsnum = 1-mp->bsnum; /* toggle buffer */
436
mp->wordpointer = mp->bsspace[mp->bsnum] + 512;
439
/* for very first header, never parse rest of data */
440
if (mp->fsizeold==-1)
441
return MP3_NEED_MORE;
444
/* now decode side information */
445
if (!mp->side_parsed) {
450
if (mp->bsize < mp->ssize)
451
return MP3_NEED_MORE;
453
copy_mp(mp,mp->ssize,mp->wordpointer);
455
if(mp->fr.error_protection)
457
bits=do_layer3_sideinfo(mp);
458
/* bits = actual number of bits needed to parse this frame */
459
/* can be negative, if all bits needed are in the reservoir */
462
/* read just as many bytes as necessary before decoding */
463
mp->dsize = (bits+7)/8;
465
/* this will force mpglib to read entire frame before decoding */
466
/* mp->dsize= mp->framesize - mp->ssize;*/
474
/* check if there is enough input data */
475
if(mp->fr.framesize > mp->bsize)
476
return MP3_NEED_MORE;
478
/* takes care that the right amount of data is copied into wordpointer */
479
mp->dsize=mp->fr.framesize;
486
/* now decode main data */
488
if (!mp->data_parsed ) {
489
if(mp->dsize > mp->bsize) {
490
return MP3_NEED_MORE;
493
copy_mp(mp,mp->dsize,mp->wordpointer);
497
/*do_layer3(&mp->fr,(unsigned char *) out,done); */
501
if(mp->fr.error_protection)
504
do_layer1(mp,(unsigned char *) out,done);
508
if(mp->fr.error_protection)
511
do_layer2(mp,(unsigned char *) out,done);
515
do_layer3(mp,(unsigned char *) out,done, synth_1to1_mono_ptr, synth_1to1_ptr);
518
fprintf(stderr,"invalid layer %d\n",mp->fr.lay);
521
mp->wordpointer = mp->bsspace[mp->bsnum] + 512 + mp->ssize + mp->dsize;
528
/* remaining bits are ancillary data, or reservoir for next frame
529
* If free format, scan stream looking for next frame to determine
531
if (mp->free_format) {
532
if (mp->old_free_format) {
445
/* now we need to find another syncword */
446
/* just return and make user send in more data */
448
return MP3_NEED_MORE;
452
/* match channels, samplerate, etc, when syncing */
453
bytes = sync_buffer(mp, 1);
456
/* buffer now synchronized */
458
/* fprintf(stderr,"hip: need more bytes %d\n", bytes); */
459
return MP3_NEED_MORE;
462
/* there were some extra bytes in front of header.
463
* bitstream problem, but we are now resynced
464
* should try to buffer previous data in case new
465
* frame has nonzero main_data_begin, but we need
466
* to make sure we do not overflow buffer
469
fprintf(stderr, "hip: bitstream problem, resyncing skipping %d bytes...\n", bytes);
470
mp->old_free_format = 0;
472
/* FIXME: correct ??? */
473
mp->sync_bitstream = 1;
475
/* skip some bytes, buffer the rest */
476
size = (int) (mp->wordpointer - (mp->bsspace[mp->bsnum] + 512));
478
if (size > MAXFRAMESIZE) {
479
/* wordpointer buffer is trashed. probably cant recover, but try anyway */
480
fprintf(stderr, "hip: wordpointer trashed. size=%i (%i) bytes=%i \n",
481
size, MAXFRAMESIZE, bytes);
483
mp->wordpointer = mp->bsspace[mp->bsnum] + 512;
486
/* buffer contains 'size' data right now
487
we want to add 'bytes' worth of data, but do not
488
exceed MAXFRAMESIZE, so we through away 'i' bytes */
489
i = (size + bytes) - MAXFRAMESIZE;
495
copy_mp(mp, bytes, mp->wordpointer);
496
mp->fsizeold += bytes;
500
decode_header(&mp->fr, mp->header);
501
mp->header_parsed = 1;
502
mp->framesize = mp->fr.framesize;
503
mp->free_format = (mp->framesize == 0);
506
mp->ssize = (mp->fr.stereo == 1) ? 9 : 17;
508
mp->ssize = (mp->fr.stereo == 1) ? 17 : 32;
509
if (mp->fr.error_protection)
512
mp->bsnum = 1 - mp->bsnum; /* toggle buffer */
513
mp->wordpointer = mp->bsspace[mp->bsnum] + 512;
516
/* for very first header, never parse rest of data */
517
if (mp->fsizeold == -1) {
519
fprintf(stderr, "hip: not parsing the rest of the data of the first header\n");
521
return MP3_NEED_MORE;
523
} /* end of header parsing block */
525
/* now decode side information */
526
if (!mp->side_parsed) {
529
if (mp->fr.lay == 3) {
530
if (mp->bsize < mp->ssize)
531
return MP3_NEED_MORE;
533
copy_mp(mp, mp->ssize, mp->wordpointer);
535
if (mp->fr.error_protection)
537
bits = do_layer3_sideinfo(mp);
538
/* bits = actual number of bits needed to parse this frame */
539
/* can be negative, if all bits needed are in the reservoir */
543
/* read just as many bytes as necessary before decoding */
544
mp->dsize = (bits + 7) / 8;
548
"hip: %d bits needed to parse layer III frame, number of bytes to read before decoding dsize = %d\n",
552
/* this will force mpglib to read entire frame before decoding */
553
/* mp->dsize= mp->framesize - mp->ssize; */
559
/* check if there is enough input data */
560
if (mp->fr.framesize > mp->bsize)
561
return MP3_NEED_MORE;
563
/* takes care that the right amount of data is copied into wordpointer */
564
mp->dsize = mp->fr.framesize;
571
/* now decode main data */
572
iret = MP3_NEED_MORE;
573
if (!mp->data_parsed) {
574
if (mp->dsize > mp->bsize) {
575
return MP3_NEED_MORE;
578
copy_mp(mp, mp->dsize, mp->wordpointer);
582
/*do_layer3(&mp->fr,(unsigned char *) out,done); */
583
switch (mp->fr.lay) {
585
if (mp->fr.error_protection)
588
do_layer1(mp, (unsigned char *) out, done);
592
if (mp->fr.error_protection)
595
do_layer2(mp, (unsigned char *) out, done);
599
do_layer3(mp, (unsigned char *) out, done, synth_1to1_mono_ptr, synth_1to1_ptr);
602
fprintf(stderr, "hip: invalid layer %d\n", mp->fr.lay);
605
mp->wordpointer = mp->bsspace[mp->bsnum] + 512 + mp->ssize + mp->dsize;
612
/* remaining bits are ancillary data, or reservoir for next frame
613
* If free format, scan stream looking for next frame to determine
615
if (mp->free_format) {
616
if (mp->old_free_format) {
533
617
/* free format. bitrate must not vary */
534
mp->framesize=mp->fsizeold_nopadding + (mp->fr.padding);
536
bytes=sync_buffer(mp,1);
537
if (bytes<0) return iret;
538
mp->framesize = bytes + mp->ssize+mp->dsize;
539
mp->fsizeold_nopadding= mp->framesize - mp->fr.padding;
618
mp->framesize = mp->fsizeold_nopadding + (mp->fr.padding);
621
bytes = sync_buffer(mp, 1);
624
mp->framesize = bytes + mp->ssize + mp->dsize;
625
mp->fsizeold_nopadding = mp->framesize - mp->fr.padding;
541
fprintf(stderr,"freeformat bitstream: estimated bitrate=%ikbs \n",
542
8*(4+mp->framesize)*freqs[mp->fr.sampling_frequency]/
543
(1000*576*(2-mp->fr.lsf)));
548
/* buffer the ancillary data and reservoir for next frame */
549
bytes = mp->framesize-(mp->ssize+mp->dsize);
550
if (bytes > mp->bsize) {
556
copy_mp(mp,bytes,mp->wordpointer);
557
mp->wordpointer += bytes;
559
size = (int) (mp->wordpointer - (mp->bsspace[mp->bsnum]+512));
560
if (size > MAXFRAMESIZE) {
561
fprintf(stderr,"fatal error. MAXFRAMESIZE not large enough.\n");
566
/* the above frame is completey parsed. start looking for next frame */
567
mp->fsizeold = mp->framesize;
568
mp->old_free_format = mp->free_format;
627
fprintf(stderr,"hip: freeformat bitstream: estimated bitrate=%ikbs \n",
628
8*(4+mp->framesize)*freqs[mp->fr.sampling_frequency]/
629
(1000*576*(2-mp->fr.lsf)));
634
/* buffer the ancillary data and reservoir for next frame */
635
bytes = mp->framesize - (mp->ssize + mp->dsize);
636
if (bytes > mp->bsize) {
577
int decodeMP3( PMPSTR mp,unsigned char *in,int isize,char *out,
581
fprintf(stderr,"To less out space\n");
585
/* passing pointers to the functions which clip the samples */
586
return decodeMP3_clipchoice(mp, in, isize, out, done, synth_1to1_mono, synth_1to1);
589
int decodeMP3_unclipped( PMPSTR mp,unsigned char *in,int isize,char *out,
592
/* we forbid input with more than 1152 samples per channel for output in unclipped mode */
593
if(osize < (int)(1152 * 2 * sizeof(real)) ) {
594
fprintf(stderr,"To less out space\n");
598
/* passing pointers to the functions which don't clip the samples */
599
return decodeMP3_clipchoice(mp, in, isize, out, done, synth_1to1_mono_unclipped, synth_1to1_unclipped);
643
/* FIXME: while loop OK ??? */
644
while (bytes > 512) {
650
copy_mp(mp, bytes, mp->wordpointer);
651
mp->wordpointer += bytes;
653
size = (int) (mp->wordpointer - (mp->bsspace[mp->bsnum] + 512));
654
if (size > MAXFRAMESIZE) {
655
fprintf(stderr, "hip: fatal error. MAXFRAMESIZE not large enough.\n");
660
/* the above frame is completely parsed. start looking for next frame */
661
mp->fsizeold = mp->framesize;
662
mp->old_free_format = mp->free_format;
664
mp->header_parsed = 0;
672
decodeMP3(PMPSTR mp, unsigned char *in, int isize, char *out, int osize, int *done)
675
fprintf(stderr, "hip: Insufficient memory for decoding buffer %d\n", osize);
679
/* passing pointers to the functions which clip the samples */
680
return decodeMP3_clipchoice(mp, in, isize, out, done, synth_1to1_mono, synth_1to1);
684
decodeMP3_unclipped(PMPSTR mp, unsigned char *in, int isize, char *out, int osize, int *done)
686
/* we forbid input with more than 1152 samples per channel for output in unclipped mode */
687
if (osize < (int) (1152 * 2 * sizeof(real))) {
688
fprintf(stderr, "hip: out space too small for unclipped mode\n");
692
/* passing pointers to the functions which don't clip the samples */
693
return decodeMP3_clipchoice(mp, in, isize, out, done, synth_1to1_mono_unclipped,
694
synth_1to1_unclipped);