summaryrefslogtreecommitdiffstats
path: root/mpeglib/lib/splay/synthesis.h
blob: 801d658e9a864312d17ad4f4f9b63c1d0ab461c3 (plain)
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
/*
  header for synthesis
  Copyright (C) 2001  Martin Vogt

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU Library General Public License as published by
  the Free Software Foundation.

  For more information look at the file COPYRIGHT in this package

 */



#ifndef __SYNTHESIS_H
#define __SYNTHESIS_H

#include "common.h"
#include "dct.h"

#define CALCBUFFERSIZE     512
// AIX seems to have FRAMESIZE defined
#undef FRAMESIZE

#define FRAMESIZE         (2*2*2*32*18)


class Synthesis {

  //
  // Subbandsynthesis two calcbuffers for every channel, and two channels.
  // calcbufferL[0]=calcbuffer[0]
  // calcbufferL[1]=calcbuffer[1]
  // calcbufferR[0]=calcbuffer[2]
  // calcbufferR[1]=calcbuffer[3]
  ATTR_ALIGN(64) REAL calcbuffer[2][2][CALCBUFFERSIZE];
  ATTR_ALIGN(64) int  currentcalcbuffer,calcbufferoffset;
  static ATTR_ALIGN(64) const REAL filter[512];
  ATTR_ALIGN(64) REAL out[FRAMESIZE];
  int outpos;

 public:
  Synthesis();
  ~Synthesis();
  
  // mpeg1,2
  void doSynth(int lDownSample,int lOutputStereo,
	       REAL *fractionL,REAL *fractionR);

  void doMP3Synth(int lDownSample,int lOutputStereo,
		  REAL in[2][SSLIMIT][SBLIMIT]);

  // put mpeg to raw
  inline void putraw(REAL val) {
    out[outpos++]=val;
  }

  inline REAL* getOutputData() { return out; }
  inline void clearrawdata() { outpos=0; }
  inline int getLen() { return outpos; }
  

 private:
  void synth_Down(int lOutputStereo,REAL *fractionL,REAL *fractionR);
  void synth_Std(int lOutputStereo,REAL *fractionL,REAL *fractionR);
  
  void synthMP3_Down(int lOutputStereo,REAL hout [2][SSLIMIT][SBLIMIT]);
  void synthMP3_Std(int lOutputStereo,REAL hout [2][SSLIMIT][SBLIMIT]);

  inline void nextOffset() {
    calcbufferoffset++;
    calcbufferoffset&=0xf;
    /*
    if (calcbufferoffset<15) {
      calcbufferoffset++;
    } else {
      calcbufferoffset=0;
    }
    */
    currentcalcbuffer^=1;
  }

  
  void computebuffer_Std(REAL *fraction,REAL buffer[2][CALCBUFFERSIZE]);
  void generate_Std(void);
  void generatesingle_Std(void);
  
  void computebuffer_Down(REAL *fraction,REAL buffer[2][CALCBUFFERSIZE]);
  void generate_Down(void);
  void generatesingle_Down(void);
  

};

#endif