MythTV  master
freesurround.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2007 Christian Kothe, Mark Spieth
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18 
19 #ifndef FREESURROUND_H
20 #define FREESURROUND_H
21 
22 #include <cstdint>
23 
24 using uint = unsigned int;
25 
26 static constexpr uint16_t SURROUND_BUFSIZE { 8192 };
27 
29 {
30 public:
31  enum SurroundMode : std::uint8_t
32  {
37  };
38 public:
39  FreeSurround(uint srate, bool moviemode, SurroundMode mode);
40  ~FreeSurround();
41 
42  // put frames in buffer, returns number of frames used
43  uint putFrames(void* buffer, uint numFrames, uint numChannels);
44  // get a number of frames
45  uint receiveFrames(void *buffer, uint maxFrames);
46  // flush unprocessed samples
47  void flush();
48  uint numUnprocessedFrames() const;
49  uint numFrames() const;
50 
51  long long getLatency();
52  uint frameLatency() const;
53 
54  static uint framesPerBlock();
55 
56 protected:
57  void process_block();
58  void open();
59  void close();
60  void SetParams();
61 
62 private:
63 
64  // the changeable parameters
66  int32_t center_width { 100 }; // presence of the center channel
67  int32_t dimension { 0 }; // dimension
68  float coeff_a { 0.8165 }; // surround mixing coefficients
69  float coeff_b { 0.5774 }; // surround mixing coefficients
70  int32_t phasemode { 0 }; // phase shifting mode
71  int32_t steering { 1 }; // steering mode (0=simple, 1=linear)
72  int32_t front_sep { 100 }; // front stereo separation
73  int32_t rear_sep { 100 }; // rear stereo separation
74  } m_params;
75 
76  // additional settings
78 
79  // info about the current setup
80  struct buffers *m_bufs {nullptr}; // our buffers
81  class fsurround_decoder *m_decoder {nullptr}; // the surround decoder
82  int m_inCount {0}; // amount in lt,rt
83  int m_outCount {0}; // amount in output bufs
84  bool m_processed {true}; // whether processing is enabled for latency calc
85  int m_processedSize {0}; // amount processed
86  SurroundMode m_surroundMode {SurroundModePassive}; // 1 of 3 surround modes supported
87  int m_latencyFrames {0}; // number of frames of incurred latency
88  int m_channels {0};
89 };
90 
91 #endif
FreeSurround::fsurround_params::coeff_a
float coeff_a
Definition: freesurround.h:68
FreeSurround::fsurround_params::dimension
int32_t dimension
Definition: freesurround.h:67
FreeSurround::SurroundModeActiveSimple
@ SurroundModeActiveSimple
Definition: freesurround.h:34
FreeSurround::SetParams
void SetParams()
Definition: freesurround.cpp:119
FreeSurround::fsurround_params::steering
int32_t steering
Definition: freesurround.h:71
FreeSurround::m_decoder
class fsurround_decoder * m_decoder
Definition: freesurround.h:81
FreeSurround::getLatency
long long getLatency()
Definition: freesurround.cpp:402
FreeSurround::fsurround_params::phasemode
int32_t phasemode
Definition: freesurround.h:70
FreeSurround::close
void close()
Definition: freesurround.cpp:433
FreeSurround::numFrames
uint numFrames() const
Definition: freesurround.cpp:444
FreeSurround::open
void open()
Definition: freesurround.cpp:420
FreeSurround
Definition: freesurround.h:28
SURROUND_BUFSIZE
static constexpr uint16_t SURROUND_BUFSIZE
Definition: freesurround.h:26
FreeSurround::fsurround_params
Definition: freesurround.h:65
FreeSurround::fsurround_params::front_sep
int32_t front_sep
Definition: freesurround.h:72
FreeSurround::putFrames
uint putFrames(void *buffer, uint numFrames, uint numChannels)
Definition: freesurround.cpp:139
FreeSurround::numUnprocessedFrames
uint numUnprocessedFrames() const
Definition: freesurround.cpp:439
FreeSurround::m_surroundMode
SurroundMode m_surroundMode
Definition: freesurround.h:86
FreeSurround::process_block
void process_block()
Definition: freesurround.cpp:387
FreeSurround::fsurround_params::rear_sep
int32_t rear_sep
Definition: freesurround.h:73
FreeSurround::fsurround_params::center_width
int32_t center_width
Definition: freesurround.h:66
FreeSurround::framesPerBlock
static uint framesPerBlock()
Definition: freesurround.cpp:456
FreeSurround::frameLatency
uint frameLatency() const
Definition: freesurround.cpp:449
FreeSurround::m_outCount
int m_outCount
Definition: freesurround.h:83
FreeSurround::flush
void flush()
Definition: freesurround.cpp:412
FreeSurround::m_processed
bool m_processed
Definition: freesurround.h:84
FreeSurround::m_channels
int m_channels
Definition: freesurround.h:88
fsurround_decoder
Definition: freesurround_decoder.h:23
FreeSurround::SurroundMode
SurroundMode
Definition: freesurround.h:31
buffers
Definition: freesurround.cpp:49
FreeSurround::SurroundModePassive
@ SurroundModePassive
Definition: freesurround.h:33
FreeSurround::SurroundModePassiveHall
@ SurroundModePassiveHall
Definition: freesurround.h:36
FreeSurround::fsurround_params::coeff_b
float coeff_b
Definition: freesurround.h:69
FreeSurround::SurroundModeActiveLinear
@ SurroundModeActiveLinear
Definition: freesurround.h:35
FreeSurround::m_srate
uint m_srate
Definition: freesurround.h:77
FreeSurround::m_inCount
int m_inCount
Definition: freesurround.h:82
FreeSurround::m_processedSize
int m_processedSize
Definition: freesurround.h:85
FreeSurround::FreeSurround
FreeSurround(uint srate, bool moviemode, SurroundMode mode)
Definition: freesurround.cpp:74
uint16_t
unsigned short uint16_t
Definition: iso6937tables.h:3
FreeSurround::m_bufs
struct buffers * m_bufs
Definition: freesurround.h:80
FreeSurround::m_latencyFrames
int m_latencyFrames
Definition: freesurround.h:87
FreeSurround::receiveFrames
uint receiveFrames(void *buffer, uint maxFrames)
Definition: freesurround.cpp:306
uint
unsigned int uint
Definition: freesurround.h:24
FreeSurround::~FreeSurround
~FreeSurround()
Definition: freesurround.cpp:130
FreeSurround::m_params
struct FreeSurround::fsurround_params m_params