From bb0e90b4f73cf42e5dbda52b1ae3dc4ffd995b9c Mon Sep 17 00:00:00 2001 From: arpi Date: Thu, 24 Jul 2003 22:12:59 +0000 Subject: layer-1 support git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10469 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mp3lib/layer1.c | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mp3lib/sr1.c | 10 ++-- 2 files changed, 162 insertions(+), 5 deletions(-) create mode 100644 mp3lib/layer1.c (limited to 'mp3lib') diff --git a/mp3lib/layer1.c b/mp3lib/layer1.c new file mode 100644 index 0000000000..4af0933823 --- /dev/null +++ b/mp3lib/layer1.c @@ -0,0 +1,157 @@ +/* + * Mpeg Layer-1 audio decoder + * -------------------------- + * copyright (c) 1995 by Michael Hipp, All rights reserved. See also 'README' + * near unoptimzed ... + * + * may have a few bugs after last optimization ... + * + */ + +//#include "mpg123.h" + +static void I_step_one(unsigned int balloc[], unsigned int scale_index[2][SBLIMIT],struct frame *fr) +{ + unsigned int *ba=balloc; + unsigned int *sca = (unsigned int *) scale_index; + + if(fr->stereo) { + int i; + int jsbound = fr->jsbound; + for (i=0;istereo) { + int jsbound = fr->jsbound; + register real *f0 = fraction[0]; + register real *f1 = fraction[1]; + ba = balloc; + for (sample=smpb,i=0;idown_sample_sblimit;i<32;i++) + fraction[0][i] = fraction[1][i] = 0.0; + } + else { + register real *f0 = fraction[0]; + ba = balloc; + for (sample=smpb,i=0;idown_sample_sblimit;i<32;i++) + fraction[0][i] = 0.0; + } +} + +static int do_layer1(struct frame *fr,int single) +{ + int clip=0; + int i,stereo = fr->stereo; + unsigned int balloc[2*SBLIMIT]; + unsigned int scale_index[2][SBLIMIT]; + real fraction[2][SBLIMIT]; +// int single = fr->single; + +// printf("do_layer1(0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X )\n", +// wordpointer[0],wordpointer[1],wordpointer[2],wordpointer[3],wordpointer[4],wordpointer[5],wordpointer[6],wordpointer[7]); + + fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? + (fr->mode_ext<<2)+4 : 32; + + if(stereo == 1 || single == 3) + single = 0; + + I_step_one(balloc,scale_index,fr); + + for (i=0;i= 0) + { + clip += (fr->synth_mono)( (real *) fraction[single],pcm_sample,&pcm_point); + } + else { + int p1 = pcm_point; + clip += (fr->synth)( (real *) fraction[0],0,pcm_sample,&p1); + clip += (fr->synth)( (real *) fraction[1],1,pcm_sample,&pcm_point); + } + + } + + return clip; +} + + diff --git a/mp3lib/sr1.c b/mp3lib/sr1.c index cdd07bcdd0..760b95ce68 100644 --- a/mp3lib/sr1.c +++ b/mp3lib/sr1.c @@ -271,8 +271,9 @@ switch(fr->lay){ MP3_samplerate=freqs[fr->sampling_frequency]; fr->framesize = (long) MP3_bitrate * 12000; fr->framesize /= MP3_samplerate; - MP3_framesize = fr->framesize; - fr->framesize = ((fr->framesize+fr->padding)<<2)-4; + MP3_framesize = ((fr->framesize+fr->padding)<<2); + fr->framesize = MP3_framesize-4; + printf("framesize=%d\n",fr->framesize); break; default: MP3_framesize=fr->framesize=0; @@ -375,6 +376,7 @@ int _has_mmx = 0; // used by layer2.c, layer3.c to pre-scale coeffs #include "layer2.c" #include "layer3.c" +#include "layer1.c" /******************************************************************************/ /* PUBLIC FUNCTIONS */ @@ -516,9 +518,7 @@ int MP3_DecodeFrame(unsigned char *hova,short single){ switch(fr.lay){ case 2: do_layer2(&fr,single);break; case 3: do_layer3(&fr,single);break; - case 1: - printf("mp3lib: layer-1 audio not yet supported!\n"); - return 4608; + case 1: do_layer1(&fr,single);break; default: return 0; // unsupported } -- cgit v1.2.3