Пример #1
0
int attribute_align_arg mpg123_init(void)
{
	if((sizeof(short) != 2) || (sizeof(long) < 4)) return MPG123_BAD_TYPES;

	if(initialized) return MPG123_OK; /* no need to initialize twice */

#ifndef NO_LAYER12
	init_layer12(); /* inits also shared tables with layer1 */
#endif
#ifndef NO_LAYER3
	init_layer3();
#endif
	prepare_decode_tables();
	check_decoders();
	initialized = 1;
#if (defined REAL_IS_FLOAT) && (defined IEEE_FLOAT)
	/* This is rather pointless but it eases my mind to check that we did
	   not enable the special rounding on a VAX or something. */
	if(12346 != REAL_TO_SHORT_ACCURATE(12345.67f))
	{
		error("Bad IEEE 754 rounding. Re-build libmpg123 properly.");
		return MPG123_ERR;
	}
#endif
	return MPG123_OK;
}
Пример #2
0
void init_tables(mpadec_t mpadec, MYFLT scale, int32_t sblimit)
{
    register struct mpadec_t *mpa = (struct mpadec_t *)mpadec;

    if (mpa->state < MPADEC_STATE_START) {
      init_layer2(mpa);
      init_layer3(mpa);
    }
    init_limits(mpa, sblimit);
    make_synth_window(mpa, scale);
}
Пример #3
0
BOOL MPGLIB_Init(PMPSTR mp) 
{
    static int init = 0;

    MPGLIB_Reset(mp);

    if(!init) {
        make_decode_tables(32767);
        init_layer2();
        init_layer3(SBLIMIT);
        init = 1;
    }

    return !0;
}
Пример #4
0
int attribute_align_arg mpg123_init(void)
{
	if((sizeof(short) != 2) || (sizeof(long) < 4)) return MPG123_BAD_TYPES;

	if(initialized) return MPG123_OK; /* no need to initialize twice */

#ifndef NO_LAYER12
	init_layer12(); /* inits also shared tables with layer1 */
#endif
#ifndef NO_LAYER3
	init_layer3();
#endif
	prepare_decode_tables();
	check_decoders();
	initialized = 1;
	return MPG123_OK;
}
Пример #5
0
BOOL InitMP3(struct mpstr *mp) 
{
	memset(mp,0,sizeof(struct mpstr));

	mp->framesize = 0;
	mp->fsizeold = -1;
	mp->bsize = 0;
	mp->head = mp->tail = NULL;
	mp->fr.single = -1;
	mp->bsnum = 0;
	mp->synth_bo = 1;

	make_decode_tables(32767);
	init_layer3(SBLIMIT);

	return !0;
}
Пример #6
0
int InitMP3(struct mpstr *mp)
{
    memset(mp,0,sizeof(struct mpstr));

    initStaticData(&mp->psd);

    mp->framesize = 0;
    mp->fsizeold = -1;
    mp->bsize = 0;
    mp->head = mp->tail = NULL;
    mp->fr.single = -1;
    mp->bsnum = 0;
    mp->synth_bo = 1;

    make_decode_tables(&mp->psd, 32767);
    init_layer3(&mp->psd, SBLIMIT);

    mp->fr.II_sblimit=SBLIMIT;
    init_layer2(&mp->psd);

    return !0;
}
Пример #7
0
/*
 * The poll function. Checks if more data is needed, and decodes/plays if
 * needed.
 */
int _apeg_audio_poll(APEG_LAYER *layer)
{
#ifndef DISABLE_MPEG_AUDIO
	struct reader *rd = &(layer->audio.rd);
	struct frame *fr = &(layer->audio.fr);
	struct mpstr *mp = &(layer->audio.mp);
	int ret = APEG_OK;
#endif

	if(layer->multiple <= 0.0f)
		return APEG_OK;

	if(layer->stream.flags & APEG_VORBIS_AUDIO)
		return alvorbis_update(layer);

#ifdef DISABLE_MPEG_AUDIO
	return APEG_ERROR;
#else
	// Check if we actually need more data yet
	while(!rd->eof && layer->audio.pcm.point < layer->audio.bufsize)
	{
		// Make sure we're not still in the process of decoding the previous
		// frame
		if(mp->return_later)
		{
			decode_frame(layer, fr, mp);
			continue;
		}

		ret = read_frame(layer, fr);
		if(ret != ALMPA_OK)
		{
			// Stream ended, but check if there's still audio in the buffer
			if(!layer->audio.pcm.point)
				return ret;

			ret = APEG_OK;
			break;
		}

		/* TODO: for fast forwarding */
/*		if(stream->frame > layer->audio.frame)
		{
			if(fr->lay == 3)
				set_pointer(mp, fr->sideInfoSize, 512);
			goto do_again;
		}*/

		// Check for header change. This works, but it will introduce a jump
		// if the frequency/channel count changes.
		if(!layer->audio.inited)
		{
			int old_rate = layer->stream.audio.freq;
			int old_channels = layer->stream.audio.channels;

			int newrate = freqs[fr->sampling_frequency] >>
			              layer->stream.audio.down_sample;

			layer->stream.audio.channels = (layer->stream.audio.down_channel?1:
			                                fr->stereo);
			layer->stream.audio.freq = newrate;

			layer->stream.audio.layer = fr->lay;
			layer->stream.audio.kbps = tabsel_123[fr->lsf][fr->lay-1][fr->bitrate_index];
			fr->down_sample_sblimit = SBLIMIT>>layer->stream.audio.down_sample;

			if(layer->stream.audio.freq != old_rate ||
			   layer->stream.audio.channels != old_channels)
			{
				if(fr->lay == 3)
					init_layer3(layer->stream.audio.down_sample);

				if(_apeg_audio_reset_parameters(layer) != APEG_OK)
					return APEG_ERROR;
			}

			layer->audio.inited = TRUE;
		}

		++(layer->audio.frame);
		decode_frame(layer, fr, mp);
	}