added Jamfiles to include mpglib
clean up of mpglib removed global variable from mpglib, should be thread save now moved global initialization code in it's own function git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5431 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f3f8a29195
commit
90ca169469
11
src/add-ons/media/plugins/mp3_decoder/Jamfile
Normal file
11
src/add-ons/media/plugins/mp3_decoder/Jamfile
Normal file
@ -0,0 +1,11 @@
|
||||
SubDir OBOS_TOP src add-ons media plugins mp3_decoder ;
|
||||
|
||||
UsePrivateHeaders media ;
|
||||
|
||||
Addon mp3_decoder : media plugins :
|
||||
mp3DecoderPlugin.cpp
|
||||
;
|
||||
|
||||
LinkSharedOSLibs mp3_decoder : be libmedia.so ;
|
||||
|
||||
SubInclude OBOS_TOP src add-ons media plugins mp3_decoder mpglib ;
|
@ -2,3 +2,7 @@
|
||||
- VBR fix
|
||||
- Layer2 and Layer1 added
|
||||
|
||||
21/Nov/2003: (by Marcus Overhagen)
|
||||
- modified for usage with OpenBeOS
|
||||
- removed global variable struct mpstr *gmp
|
||||
- moved initialization into separate function
|
||||
|
12
src/add-ons/media/plugins/mp3_decoder/mpglib/Jamfile
Normal file
12
src/add-ons/media/plugins/mp3_decoder/mpglib/Jamfile
Normal file
@ -0,0 +1,12 @@
|
||||
SubDir OBOS_TOP src add-ons media plugins mp3_decoder mpglib ;
|
||||
|
||||
StaticLibrary mpglib :
|
||||
common.c
|
||||
dct64_i386.c
|
||||
decode_i386.c
|
||||
interface.c
|
||||
layer1.c
|
||||
layer2.c
|
||||
layer3.c
|
||||
tabinit.c
|
||||
;
|
@ -17,22 +17,20 @@
|
||||
#include "mpg123.h"
|
||||
#include "mpglib.h"
|
||||
|
||||
extern struct mpstr *gmp;
|
||||
|
||||
/* old WRITE_SAMPLE */
|
||||
#define WRITE_SAMPLE(samples,sum,clip) \
|
||||
if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \
|
||||
else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
|
||||
else { *(samples) = sum; }
|
||||
|
||||
int synth_1to1_mono(real *bandPtr,unsigned char *samples,int *pnt)
|
||||
int synth_1to1_mono(struct mpstr *mp, real *bandPtr,unsigned char *samples,int *pnt)
|
||||
{
|
||||
short samples_tmp[64];
|
||||
short *tmp1 = samples_tmp;
|
||||
int i,ret;
|
||||
int pnt1 = 0;
|
||||
|
||||
ret = synth_1to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
|
||||
ret = synth_1to1(mp, bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
|
||||
samples += *pnt;
|
||||
|
||||
for(i=0;i<32;i++) {
|
||||
@ -46,7 +44,7 @@ int synth_1to1_mono(real *bandPtr,unsigned char *samples,int *pnt)
|
||||
}
|
||||
|
||||
|
||||
int synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
|
||||
int synth_1to1(struct mpstr *mp, real *bandPtr,int channel,unsigned char *out,int *pnt)
|
||||
{
|
||||
static const int step = 2;
|
||||
int bo;
|
||||
@ -56,16 +54,16 @@ int synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
|
||||
int clip = 0;
|
||||
int bo1;
|
||||
|
||||
bo = gmp->synth_bo;
|
||||
bo = mp->synth_bo;
|
||||
|
||||
if(!channel) {
|
||||
bo--;
|
||||
bo &= 0xf;
|
||||
buf = gmp->synth_buffs[0];
|
||||
buf = mp->synth_buffs[0];
|
||||
}
|
||||
else {
|
||||
samples++;
|
||||
buf = gmp->synth_buffs[1];
|
||||
buf = mp->synth_buffs[1];
|
||||
}
|
||||
|
||||
if(bo & 0x1) {
|
||||
@ -79,7 +77,7 @@ int synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
|
||||
dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
|
||||
}
|
||||
|
||||
gmp->synth_bo = bo;
|
||||
mp->synth_bo = bo;
|
||||
|
||||
{
|
||||
register int j;
|
||||
|
@ -1,18 +1,18 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mpg123.h"
|
||||
#include "mpglib.h"
|
||||
|
||||
/* Global mp .. it's a hack */
|
||||
struct mpstr *gmp;
|
||||
|
||||
|
||||
BOOL InitMP3(struct mpstr *mp)
|
||||
void InitMpgLib(void)
|
||||
{
|
||||
static int init = 0;
|
||||
make_decode_tables(32767);
|
||||
init_layer2();
|
||||
init_layer3(SBLIMIT);
|
||||
}
|
||||
|
||||
void InitMP3(struct mpstr *mp)
|
||||
{
|
||||
memset(mp,0,sizeof(struct mpstr));
|
||||
|
||||
mp->framesize = 0;
|
||||
@ -22,15 +22,6 @@ BOOL InitMP3(struct mpstr *mp)
|
||||
mp->fr.single = -1;
|
||||
mp->bsnum = 0;
|
||||
mp->synth_bo = 1;
|
||||
|
||||
if(!init) {
|
||||
init = 1;
|
||||
make_decode_tables(32767);
|
||||
init_layer2();
|
||||
init_layer3(SBLIMIT);
|
||||
}
|
||||
|
||||
return !0;
|
||||
}
|
||||
|
||||
void ExitMP3(struct mpstr *mp)
|
||||
@ -139,8 +130,6 @@ int decodeMP3(struct mpstr *mp,char *in,int isize,char *out,
|
||||
{
|
||||
int len;
|
||||
|
||||
gmp = mp;
|
||||
|
||||
if(osize < 4608) {
|
||||
fprintf(stderr,"To less out space\n");
|
||||
return MP3_ERR;
|
||||
@ -193,13 +182,13 @@ int decodeMP3(struct mpstr *mp,char *in,int isize,char *out,
|
||||
getbits(16);
|
||||
switch(mp->fr.lay) {
|
||||
case 1:
|
||||
do_layer1(&mp->fr,(unsigned char *) out,done);
|
||||
do_layer1(mp, &mp->fr,(unsigned char *) out,done);
|
||||
break;
|
||||
case 2:
|
||||
do_layer2(&mp->fr,(unsigned char *) out,done);
|
||||
do_layer2(mp, &mp->fr,(unsigned char *) out,done);
|
||||
break;
|
||||
case 3:
|
||||
do_layer3(&mp->fr,(unsigned char *) out,done);
|
||||
do_layer3(mp, &mp->fr,(unsigned char *) out,done);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -209,21 +198,17 @@ int decodeMP3(struct mpstr *mp,char *in,int isize,char *out,
|
||||
return MP3_OK;
|
||||
}
|
||||
|
||||
int set_pointer(long backstep)
|
||||
int set_pointer(struct mpstr *mp, long backstep)
|
||||
{
|
||||
unsigned char *bsbufold;
|
||||
if(gmp->fsizeold < 0 && backstep > 0) {
|
||||
if(mp->fsizeold < 0 && backstep > 0) {
|
||||
fprintf(stderr,"Can't step back %ld!\n",backstep);
|
||||
return MP3_ERR;
|
||||
}
|
||||
bsbufold = gmp->bsspace[gmp->bsnum] + 512;
|
||||
bsbufold = mp->bsspace[mp->bsnum] + 512;
|
||||
wordpointer -= backstep;
|
||||
if (backstep)
|
||||
memcpy(wordpointer,bsbufold+gmp->fsizeold-backstep,backstep);
|
||||
memcpy(wordpointer,bsbufold+mp->fsizeold-backstep,backstep);
|
||||
bitindex = 0;
|
||||
return MP3_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -10,6 +10,10 @@
|
||||
|
||||
#include "mpg123.h"
|
||||
|
||||
void I_step_one(unsigned int balloc[], unsigned int scale_index[2][SBLIMIT],struct frame *fr);
|
||||
void I_step_two(real fraction[2][SBLIMIT],unsigned int balloc[2*SBLIMIT],
|
||||
unsigned int scale_index[2][SBLIMIT],struct frame *fr);
|
||||
|
||||
void I_step_one(unsigned int balloc[], unsigned int scale_index[2][SBLIMIT],struct frame *fr)
|
||||
{
|
||||
unsigned int *ba=balloc;
|
||||
@ -111,7 +115,7 @@ void I_step_two(real fraction[2][SBLIMIT],unsigned int balloc[2*SBLIMIT],
|
||||
}
|
||||
}
|
||||
|
||||
int do_layer1(struct frame *fr,unsigned char *pcm_sample,int *pcm_point)
|
||||
int do_layer1(struct mpstr *mp, struct frame *fr,unsigned char *pcm_sample,int *pcm_point)
|
||||
{
|
||||
int clip=0;
|
||||
int i,stereo = fr->stereo;
|
||||
@ -132,12 +136,12 @@ int do_layer1(struct frame *fr,unsigned char *pcm_sample,int *pcm_point)
|
||||
I_step_two(fraction,balloc,scale_index,fr);
|
||||
|
||||
if(single >= 0) {
|
||||
clip += synth_1to1_mono( (real*)fraction[single],pcm_sample,pcm_point);
|
||||
clip += synth_1to1_mono(mp, (real*)fraction[single],pcm_sample,pcm_point);
|
||||
}
|
||||
else {
|
||||
int p1 = *pcm_point;
|
||||
clip += synth_1to1( (real*)fraction[0],0,pcm_sample,&p1);
|
||||
clip += synth_1to1( (real*)fraction[1],1,pcm_sample,pcm_point);
|
||||
clip += synth_1to1(mp, (real*)fraction[0],0,pcm_sample,&p1);
|
||||
clip += synth_1to1(mp, (real*)fraction[1],1,pcm_sample,pcm_point);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,9 @@ static int grp_9tab[1024 * 3] = { 0, }; /* used: 729 */
|
||||
|
||||
real muls[27][64]; /* also used by layer 1 */
|
||||
|
||||
void II_step_one(unsigned int *bit_alloc,int *scale,struct frame *fr);
|
||||
void II_step_two(unsigned int *bit_alloc,real fraction[2][4][SBLIMIT],int *scale,struct frame *fr,int x1);
|
||||
|
||||
void init_layer2(void)
|
||||
{
|
||||
static double mulmul[27] = {
|
||||
@ -247,7 +250,7 @@ static void II_select_table(struct frame *fr)
|
||||
fr->II_sblimit = sblim;
|
||||
}
|
||||
|
||||
int do_layer2(struct frame *fr,unsigned char *pcm_sample,int *pcm_point)
|
||||
int do_layer2(struct mpstr *mp, struct frame *fr,unsigned char *pcm_sample,int *pcm_point)
|
||||
{
|
||||
int clip=0;
|
||||
int i,j;
|
||||
@ -271,12 +274,12 @@ int do_layer2(struct frame *fr,unsigned char *pcm_sample,int *pcm_point)
|
||||
II_step_two(bit_alloc,fraction,scale,fr,i>>2);
|
||||
for (j=0;j<3;j++) {
|
||||
if(single >= 0) {
|
||||
clip += synth_1to1_mono(fraction[0][j],pcm_sample,pcm_point);
|
||||
clip += synth_1to1_mono(mp, fraction[0][j],pcm_sample,pcm_point);
|
||||
}
|
||||
else {
|
||||
int p1 = *pcm_point;
|
||||
clip += synth_1to1(fraction[0][j],0,pcm_sample,&p1);
|
||||
clip += synth_1to1(fraction[1][j],1,pcm_sample,pcm_point);
|
||||
clip += synth_1to1(mp, fraction[0][j],0,pcm_sample,&p1);
|
||||
clip += synth_1to1(mp, fraction[1][j],1,pcm_sample,pcm_point);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,8 +10,6 @@
|
||||
#include "mpglib.h"
|
||||
#include "huffman.h"
|
||||
|
||||
extern struct mpstr *gmp;
|
||||
|
||||
#define MPEG1
|
||||
|
||||
|
||||
@ -1812,12 +1810,12 @@ static void dct12(real *in,real *rawout1,real *rawout2,register real *wi,registe
|
||||
/*
|
||||
* III_hybrid
|
||||
*/
|
||||
static void III_hybrid(real fsIn[SBLIMIT][SSLIMIT],real tsOut[SSLIMIT][SBLIMIT],
|
||||
static void III_hybrid(struct mpstr *mp, real fsIn[SBLIMIT][SSLIMIT],real tsOut[SSLIMIT][SBLIMIT],
|
||||
int ch,struct gr_info_s *gr_info)
|
||||
{
|
||||
real *tspnt = (real *) tsOut;
|
||||
real (*block)[2][SBLIMIT*SSLIMIT] = gmp->hybrid_block;
|
||||
int *blc = gmp->hybrid_blc;
|
||||
real (*block)[2][SBLIMIT*SSLIMIT] = mp->hybrid_block;
|
||||
int *blc = mp->hybrid_blc;
|
||||
real *rawout1,*rawout2;
|
||||
int bt;
|
||||
int sb = 0;
|
||||
@ -1840,13 +1838,13 @@ static void III_hybrid(real fsIn[SBLIMIT][SSLIMIT],real tsOut[SSLIMIT][SBLIMIT],
|
||||
|
||||
bt = gr_info->block_type;
|
||||
if(bt == 2) {
|
||||
for (; sb<gr_info->maxb; sb+=2,tspnt+=2,rawout1+=36,rawout2+=36) {
|
||||
for (; sb<(int)gr_info->maxb; sb+=2,tspnt+=2,rawout1+=36,rawout2+=36) {
|
||||
dct12(fsIn[sb],rawout1,rawout2,win[2],tspnt);
|
||||
dct12(fsIn[sb+1],rawout1+18,rawout2+18,win1[2],tspnt+1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (; sb<gr_info->maxb; sb+=2,tspnt+=2,rawout1+=36,rawout2+=36) {
|
||||
for (; sb<(int)gr_info->maxb; sb+=2,tspnt+=2,rawout1+=36,rawout2+=36) {
|
||||
dct36(fsIn[sb],rawout1,rawout2,win[bt],tspnt);
|
||||
dct36(fsIn[sb+1],rawout1+18,rawout2+18,win1[bt],tspnt+1);
|
||||
}
|
||||
@ -1864,7 +1862,7 @@ static void III_hybrid(real fsIn[SBLIMIT][SSLIMIT],real tsOut[SSLIMIT][SBLIMIT],
|
||||
/*
|
||||
* main layer3 handler
|
||||
*/
|
||||
int do_layer3(struct frame *fr,unsigned char *pcm_sample,int *pcm_point)
|
||||
int do_layer3(struct mpstr *mp, struct frame *fr,unsigned char *pcm_sample,int *pcm_point)
|
||||
{
|
||||
int gr, ch, ss,clip=0;
|
||||
int scalefacs[2][39]; /* max 39 for short[13][3] mode, mixed: 38, long: 22 */
|
||||
@ -1906,7 +1904,7 @@ int do_layer3(struct frame *fr,unsigned char *pcm_sample,int *pcm_point)
|
||||
#endif
|
||||
}
|
||||
|
||||
if(set_pointer(sideinfo.main_data_begin) == MP3_ERR)
|
||||
if(set_pointer(mp, sideinfo.main_data_begin) == MP3_ERR)
|
||||
return -1;
|
||||
|
||||
for (gr=0;gr<granules;gr++)
|
||||
@ -1971,7 +1969,7 @@ int do_layer3(struct frame *fr,unsigned char *pcm_sample,int *pcm_point)
|
||||
{
|
||||
register int i;
|
||||
register real *in0 = (real *) hybridIn[0],*in1 = (real *) hybridIn[1];
|
||||
for(i=0;i<SSLIMIT*gr_info->maxb;i++,in0++)
|
||||
for(i=0;i<(int)(SSLIMIT*gr_info->maxb);i++,in0++)
|
||||
*in0 = (*in0 + *in1++); /* *0.5 done by pow-scale */
|
||||
}
|
||||
break;
|
||||
@ -1979,7 +1977,7 @@ int do_layer3(struct frame *fr,unsigned char *pcm_sample,int *pcm_point)
|
||||
{
|
||||
register int i;
|
||||
register real *in0 = (real *) hybridIn[0],*in1 = (real *) hybridIn[1];
|
||||
for(i=0;i<SSLIMIT*gr_info->maxb;i++)
|
||||
for(i=0;i<(int)(SSLIMIT*gr_info->maxb);i++)
|
||||
*in0++ = *in1++;
|
||||
}
|
||||
break;
|
||||
@ -1989,17 +1987,17 @@ int do_layer3(struct frame *fr,unsigned char *pcm_sample,int *pcm_point)
|
||||
for(ch=0;ch<stereo1;ch++) {
|
||||
struct gr_info_s *gr_info = &(sideinfo.ch[ch].gr[gr]);
|
||||
III_antialias(hybridIn[ch],gr_info);
|
||||
III_hybrid(hybridIn[ch], hybridOut[ch], ch,gr_info);
|
||||
III_hybrid(mp, hybridIn[ch], hybridOut[ch], ch,gr_info);
|
||||
}
|
||||
|
||||
for(ss=0;ss<SSLIMIT;ss++) {
|
||||
if(single >= 0) {
|
||||
clip += synth_1to1_mono(hybridOut[0][ss],pcm_sample,pcm_point);
|
||||
clip += synth_1to1_mono(mp, hybridOut[0][ss],pcm_sample,pcm_point);
|
||||
}
|
||||
else {
|
||||
int p1 = *pcm_point;
|
||||
clip += synth_1to1(hybridOut[0][ss],0,pcm_sample,&p1);
|
||||
clip += synth_1to1(hybridOut[1][ss],1,pcm_sample,pcm_point);
|
||||
clip += synth_1to1(mp, hybridOut[0][ss],0,pcm_sample,&p1);
|
||||
clip += synth_1to1(mp, hybridOut[1][ss],1,pcm_sample,pcm_point);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +1,9 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <sys/signal.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# undef WIN32
|
||||
# define WIN32
|
||||
|
||||
# define M_PI 3.14159265358979323846
|
||||
# define M_SQRT2 1.41421356237309504880
|
||||
# define REAL_IS_FLOAT
|
||||
# define NEW_DCT9
|
||||
|
||||
# define random rand
|
||||
# define srandom srand
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef REAL_IS_FLOAT
|
||||
# define real float
|
||||
#elif defined(REAL_IS_LONG_DOUBLE)
|
||||
@ -40,13 +21,6 @@
|
||||
/* AUDIOBUFSIZE = n*64 with n=1,2,3 ... */
|
||||
#define AUDIOBUFSIZE 16384
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#define SBLIMIT 32
|
||||
#define SSLIMIT 18
|
||||
|
||||
@ -64,6 +38,8 @@
|
||||
/* Pre Shift fo 16 to 8 bit converter table */
|
||||
#define AUSHIFT (3)
|
||||
|
||||
struct mpstr;
|
||||
|
||||
struct frame {
|
||||
int stereo;
|
||||
int jsbound;
|
||||
@ -99,15 +75,15 @@ struct parameter {
|
||||
extern unsigned int get1bit(void);
|
||||
extern unsigned int getbits(int);
|
||||
extern unsigned int getbits_fast(int);
|
||||
extern int set_pointer(long);
|
||||
extern int set_pointer(struct mpstr *mp, long backstep);
|
||||
|
||||
extern unsigned char *wordpointer;
|
||||
extern int bitindex;
|
||||
|
||||
extern void make_decode_tables(long scaleval);
|
||||
extern int do_layer3(struct frame *fr,unsigned char *,int *);
|
||||
extern int do_layer2(struct frame *fr,unsigned char *,int *);
|
||||
extern int do_layer1(struct frame *fr,unsigned char *,int *);
|
||||
extern int do_layer3(struct mpstr *mp, struct frame *fr,unsigned char *,int *);
|
||||
extern int do_layer2(struct mpstr *mp, struct frame *fr,unsigned char *,int *);
|
||||
extern int do_layer1(struct mpstr *mp, struct frame *fr,unsigned char *,int *);
|
||||
extern int decode_header(struct frame *fr,unsigned long newhead);
|
||||
|
||||
|
||||
@ -142,9 +118,9 @@ struct III_sideinfo
|
||||
} ch[2];
|
||||
};
|
||||
|
||||
extern int synth_1to1 (real *,int,unsigned char *,int *);
|
||||
extern int synth_1to1 (struct mpstr *mp, real *,int,unsigned char *,int *);
|
||||
extern int synth_1to1_8bit (real *,int,unsigned char *,int *);
|
||||
extern int synth_1to1_mono (real *,unsigned char *,int *);
|
||||
extern int synth_1to1_mono (struct mpstr *mp, real *,unsigned char *,int *);
|
||||
extern int synth_1to1_mono2stereo (real *,unsigned char *,int *);
|
||||
extern int synth_1to1_8bit_mono (real *,unsigned char *,int *);
|
||||
extern int synth_1to1_8bit_mono2stereo (real *,unsigned char *,int *);
|
||||
@ -189,5 +165,3 @@ extern real decwin[512+32];
|
||||
extern real *pnts[5];
|
||||
|
||||
extern struct parameter param;
|
||||
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
#ifndef _MPGLIB_H
|
||||
#define _MPGLIB_H
|
||||
|
||||
struct buf {
|
||||
unsigned char *pnt;
|
||||
@ -29,20 +31,16 @@ struct mpstr {
|
||||
int synth_bo;
|
||||
};
|
||||
|
||||
#ifndef BOOL
|
||||
#define BOOL int
|
||||
#endif
|
||||
|
||||
#define MP3_ERR -1
|
||||
#define MP3_OK 0
|
||||
#define MP3_NEED_MORE 1
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
BOOL InitMP3(struct mpstr *mp);
|
||||
|
||||
void InitMpgLib(void);
|
||||
void InitMP3(struct mpstr *mp);
|
||||
int decodeMP3(struct mpstr *mp,char *inmemory,int inmemsize,
|
||||
char *outmemory,int outmemsize,int *done);
|
||||
void ExitMP3(struct mpstr *mp);
|
||||
@ -51,4 +49,4 @@ void ExitMP3(struct mpstr *mp);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user