00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __JackAC3Encoder__
00022 #define __JackAC3Encoder__
00023
00024 #include <aften/aften.h>
00025 #include <aften/aften-types.h>
00026
00027 #include "ringbuffer.h"
00028 #include "types.h"
00029
00030 #define MAX_AC3_CHANNELS 6
00031
00032 #define SPDIF_HEADER_SIZE 8
00033 #define SPDIF_FRAME_SIZE 6144
00034
00035 #define SAMPLE_MAX_16BIT 32768.0f
00036 #define SAMPLE_MAX_24BIT 8388608.0f
00037
00038 namespace Jack
00039 {
00040
00041 struct JackAC3EncoderParams
00042 {
00043 int64_t duration;
00044 unsigned int channels;
00045 int bitdepth;
00046 int bitrate;
00047 unsigned int sample_rate;
00048 bool lfe;
00049 };
00050
00051 class JackAC3Encoder
00052 {
00053
00054 private:
00055
00056 AftenContext fAftenContext;
00057 jack_ringbuffer_t* fRingBuffer;
00058
00059 float* fSampleBuffer;
00060 unsigned char* fAC3Buffer;
00061 unsigned char* fZeroBuffer;
00062
00063 int fOutSizeByte;
00064
00065 jack_nframes_t fFramePos;
00066 jack_nframes_t fSampleRate;
00067 jack_nframes_t fByteRate;
00068
00069 void FillSpdifHeader(unsigned char* buf, int outsize);
00070 int Output2Driver(float** outputs, jack_nframes_t nframes);
00071
00072 void sample_move_dS_s16(jack_default_audio_sample_t* dst, char *src, jack_nframes_t nsamples, unsigned long src_skip);
00073 void sample_move_dS_s16_24ph(jack_default_audio_sample_t* dst, char *src, jack_nframes_t nsamples, unsigned long src_skip);
00074
00075 public:
00076
00077 #ifdef __ppc__
00078 JackAC3Encoder(const JackAC3EncoderParams& params) {}
00079 virtual ~JackAC3Encoder() {}
00080
00081 bool Init(jack_nframes_t sample_rate) {return false;}
00082
00083 void Process(float** inputs, float** outputs, int nframes) {}
00084 void GetChannelName(const char* name, const char* alias, char* portname, int channel) {}
00085 #else
00086 JackAC3Encoder(const JackAC3EncoderParams& params);
00087 virtual ~JackAC3Encoder();
00088
00089 bool Init(jack_nframes_t sample_rate);
00090
00091 void Process(float** inputs, float** outputs, int nframes);
00092 void GetChannelName(const char* name, const char* alias, char* portname, int channel);
00093 #endif
00094 };
00095
00096 typedef JackAC3Encoder * JackAC3EncoderPtr;
00097
00098 }
00099
00100 #endif