2 Copyright (C) 2006 Jesse Chappell <jesse@essej.net> (AC3Jack)
3 Copyright (C) 2012 Grame
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __JackAC3Encoder__
22 #define __JackAC3Encoder__
24 #include <aften/aften.h>
25 #include <aften/aften-types.h>
27 #include "ringbuffer.h"
30 #define MAX_AC3_CHANNELS 6
32 #define SPDIF_HEADER_SIZE 8
33 #define SPDIF_FRAME_SIZE 6144
35 #define SAMPLE_MAX_16BIT 32768.0f
36 #define SAMPLE_MAX_24BIT 8388608.0f
41 struct JackAC3EncoderParams
44 unsigned int channels
;
47 unsigned int sample_rate
;
56 AftenContext fAftenContext
;
57 jack_ringbuffer_t
* fRingBuffer
;
60 unsigned char* fAC3Buffer
;
61 unsigned char* fZeroBuffer
;
65 jack_nframes_t fFramePos
;
66 jack_nframes_t fSampleRate
;
67 jack_nframes_t fByteRate
;
69 void FillSpdifHeader(unsigned char* buf
, int outsize
);
70 int Output2Driver(float** outputs
, jack_nframes_t nframes
);
72 void sample_move_dS_s16(jack_default_audio_sample_t
* dst
, char *src
, jack_nframes_t nsamples
, unsigned long src_skip
);
73 void sample_move_dS_s16_24ph(jack_default_audio_sample_t
* dst
, char *src
, jack_nframes_t nsamples
, unsigned long src_skip
);
78 JackAC3Encoder(const JackAC3EncoderParams
& params
) {}
79 virtual ~JackAC3Encoder() {}
81 bool Init(jack_nframes_t sample_rate
) {return false;}
83 void Process(float** inputs
, float** outputs
, int nframes
) {}
84 void GetChannelName(const char* name
, const char* alias
, char* portname
, int channel
) {}
86 JackAC3Encoder(const JackAC3EncoderParams
& params
);
87 virtual ~JackAC3Encoder();
89 bool Init(jack_nframes_t sample_rate
);
91 void Process(float** inputs
, float** outputs
, int nframes
);
92 void GetChannelName(const char* name
, const char* alias
, char* portname
, int channel
);
96 typedef JackAC3Encoder
* JackAC3EncoderPtr
;