kwave  18.07.70
Kwave::Compression Class Reference

#include <Compression.h>

Collaboration diagram for Kwave::Compression:
Collaboration graph

Classes

class  Info
 

Public Types

enum  Type {
  INVALID = -1, NONE = 0, G722 = 501, G711_ULAW = 502,
  G711_ALAW = 503, APPLE_ACE2 = 504, APPLE_ACE8 = 505, APPLE_MAC3 = 506,
  APPLE_MAC6 = 507, G726 = 517, G728 = 518, DVI_AUDIO = 519,
  GSM = 520, FS1016 = 521, DV = 522, MS_ADPCM = 523,
  FLAC = 530, ALAC = 540, MPEG_LAYER_I = 600, MPEG_LAYER_II,
  MPEG_LAYER_III, OGG_VORBIS, OGG_OPUS
}
 

Public Member Functions

 Compression ()
 
 Compression (const Type value)
 
 Compression (const Kwave::Compression &other)
 
virtual ~Compression ()
 
void assign (Type t)
 
QString name () const
 
QString preferredMimeType () const
 
QList< Kwave::SampleFormatsampleFormats () const
 
bool hasABR () const
 
bool hasVBR () const
 
int toInt () const
 

Static Public Member Functions

static Kwave::Compression::Type fromInt (int i)
 
static int toAudiofile (Kwave::Compression::Type compression)
 
static Kwave::Compression::Type fromAudiofile (int af_compression)
 

Static Private Member Functions

static void fillMap ()
 

Private Attributes

Type m_type
 

Static Private Attributes

static QMap< int, Kwave::Compression::Infom_map
 

Detailed Description

Definition at line 34 of file Compression.h.

Member Enumeration Documentation

◆ Type

supported compression types

Note
for compatibility with older settings these values are the same as defined in audiofile.h.
Enumerator
INVALID 
NONE 
G722 
G711_ULAW 
G711_ALAW 
APPLE_ACE2 
APPLE_ACE8 
APPLE_MAC3 
APPLE_MAC6 
G726 
G728 
DVI_AUDIO 
GSM 
FS1016 
DV 
MS_ADPCM 
FLAC 
ALAC 
MPEG_LAYER_I 
MPEG_LAYER_II 
MPEG_LAYER_III 
OGG_VORBIS 
OGG_OPUS 

Definition at line 43 of file Compression.h.

43  {
44  INVALID = -1,
45  NONE = 0,
46  G722 = 501,
47  G711_ULAW = 502,
48  G711_ALAW = 503,
49  APPLE_ACE2 = 504,
50  APPLE_ACE8 = 505,
51  APPLE_MAC3 = 506,
52  APPLE_MAC6 = 507,
53  G726 = 517,
54  G728 = 518,
55  DVI_AUDIO = 519,
56  GSM = 520,
57  FS1016 = 521,
58  DV = 522,
59  MS_ADPCM = 523,
60  FLAC = 530,
61  ALAC = 540,
62  MPEG_LAYER_I = 600,
65  OGG_VORBIS,
66  OGG_OPUS
67  } Type;

Constructor & Destructor Documentation

◆ Compression() [1/3]

Kwave::Compression::Compression ( )

default constructor

Definition at line 31 of file Compression.cpp.

References fillMap().

Here is the call graph for this function:

◆ Compression() [2/3]

Kwave::Compression::Compression ( const Type  value)
explicit

Constructor, from enum

Parameters
valuethe enum of an already known compression type

Definition at line 38 of file Compression.cpp.

References fillMap().

39  :m_type(value)
40 {
41  fillMap();
42 }
static void fillMap()
Definition: Compression.cpp:86
Here is the call graph for this function:

◆ Compression() [3/3]

Kwave::Compression::Compression ( const Kwave::Compression other)
explicit

Copy constructor

Parameters
otheranother compression to copy from

◆ ~Compression()

virtual Kwave::Compression::~Compression ( )
inlinevirtual

destructor

Definition at line 87 of file Compression.h.

87 {}

Member Function Documentation

◆ assign()

void Kwave::Compression::assign ( Type  t)
inline

assignment operator from sample_format_t

Definition at line 90 of file Compression.h.

References name.

90 { m_type = t; }

◆ fillMap()

void Kwave::Compression::fillMap ( )
staticprivate

fills the map with known compression types (if empty)

Definition at line 86 of file Compression.cpp.

References _, APPLE_ACE2, APPLE_ACE8, APPLE_MAC3, APPLE_MAC6, Kwave::SampleFormat::Double, DV, DVI_AUDIO, FLAC, Kwave::SampleFormat::Float, FS1016, G711_ALAW, G711_ULAW, G722, G726, GSM, m_map, MPEG_LAYER_I, MPEG_LAYER_II, MPEG_LAYER_III, MS_ADPCM, NONE, OGG_OPUS, OGG_VORBIS, Kwave::SampleFormat::Signed, and Kwave::SampleFormat::Unsigned.

Referenced by Compression(), fromAudiofile(), fromInt(), and toAudiofile().

87 {
88  if (!m_map.isEmpty()) return; // bail out if already filled
89 
90  QList<Kwave::SampleFormat> sfmt_none;
91 
92  QList<Kwave::SampleFormat> sfmt_int;
95 
96  QList<Kwave::SampleFormat> sfmt_all;
97  sfmt_all += sfmt_int;
100 
101  /* no compression */
102 
104  _(I18N_NOOP("No Compression")),
105  QString(),
106  sfmt_all, false, false));
107 
108  /* types supported by OSS+ALSA record plugin and WAV codec */
109 
111  _(I18N_NOOP("CCITT G.711 u-law")),
112  QString(),
113  sfmt_int, false, false));
115  _(I18N_NOOP("CCITT G.711 A-law")),
116  QString(),
117  sfmt_int, false, false));
119  _(I18N_NOOP("MS ADPCM")),
120  QString(),
121  sfmt_int, false, false));
123  _(I18N_NOOP("GSM")),
124  QString(),
125  sfmt_int, false, false));
126 
127  /* compression types from libaudiofile (for display only, not supported) */
129  _(I18N_NOOP("G722")),
130  QString(),
131  sfmt_none, true, false));
133  _(I18N_NOOP("Apple ACE2")),
134  QString(),
135  sfmt_none, true, false));
137  _(I18N_NOOP("Apple ACE8")),
138  QString(),
139  sfmt_none, true, false));
141  _(I18N_NOOP("Apple MAC3")),
142  QString(),
143  sfmt_none, true, false));
145  _(I18N_NOOP("Apple MAC6")),
146  QString(),
147  sfmt_none, true, false));
149  _(I18N_NOOP("G726")),
150  QString(),
151  sfmt_none, true, false));
153  _(I18N_NOOP("DVI Audio / IMA")),
154  QString(),
155  sfmt_none, true, false));
157  _(I18N_NOOP("FS1016")),
158  QString(),
159  sfmt_none, true, false));
161  _(I18N_NOOP("DV")),
162  QString(),
163  sfmt_none, true, false));
164 
165  /* MPEG layer I/II/III */
166 #ifdef HAVE_MP3
168  _(I18N_NOOP("MPEG Layer I")),
169  _("audio/x-mp3"),
170  sfmt_none, true, false));
172  _(I18N_NOOP("MPEG Layer II")),
173  _("audio/x-mp3"),
174  sfmt_none, true, false));
176  _(I18N_NOOP("MPEG Layer III")),
177  _("audio/x-mp3"),
178  sfmt_none, true, false));
179 #endif /* HAVE_MP3 */
180 
181  /* FLAC */
182 #ifdef HAVE_FLAC
184  _(I18N_NOOP("FLAC")),
185  _("audio/x-flac"),
186  sfmt_none, false, false));
187 #endif /* HAVE_FLAC */
188 
189  /* Ogg Vorbis */
190 #ifdef HAVE_OGG_VORBIS
192  _(I18N_NOOP("Ogg Vorbis")),
193  _("audio/ogg"),
194  sfmt_none, true, true));
195 #endif /* HAVE_OGG_VORBIS */
196 
197  /* Ogg Opus */
198 #ifdef HAVE_OGG_OPUS
200  _(I18N_NOOP("Ogg Opus")),
201  _("audio/opus"),
202  sfmt_none, true, false));
203 #endif /* HAVE_OGG_OPUS */
204 
205 }
static QMap< int, Kwave::Compression::Info > m_map
Definition: Compression.h:196
#define _(m)
Definition: memcpy.c:66
Here is the caller graph for this function:

◆ fromAudiofile()

Kwave::Compression::Type Kwave::Compression::fromAudiofile ( int  af_compression)
static

conversion from a numeric value from libaudiofile

Definition at line 279 of file Compression.cpp.

References ALAC, APPLE_ACE2, APPLE_ACE8, APPLE_MAC3, APPLE_MAC6, DV, DVI_AUDIO, fillMap(), FLAC, FS1016, G711_ALAW, G711_ULAW, G722, G726, G728, GSM, MS_ADPCM, and NONE.

Referenced by Kwave::audiofileCompressionTypes(), Kwave::AudiofileDecoder::open(), and Kwave::WavDecoder::open().

280 {
281  Kwave::Compression::Type compression_type;
282 
283  fillMap();
284  switch (af_compression)
285  {
286  case AF_COMPRESSION_NONE :
287  compression_type = Kwave::Compression::NONE;
288  break;
289  case AF_COMPRESSION_G722:
290  compression_type = Kwave::Compression::G722;
291  break;
292  case AF_COMPRESSION_G711_ULAW:
293  compression_type = Kwave::Compression::G711_ULAW;
294  break;
295  case AF_COMPRESSION_G711_ALAW:
296  compression_type = Kwave::Compression::G711_ALAW;
297  break;
298  case AF_COMPRESSION_APPLE_ACE2:
299  compression_type = Kwave::Compression::APPLE_ACE2;
300  break;
301  case AF_COMPRESSION_APPLE_ACE8:
302  compression_type = Kwave::Compression::APPLE_ACE8;
303  break;
304  case AF_COMPRESSION_APPLE_MAC3:
305  compression_type = Kwave::Compression::APPLE_MAC3;
306  break;
307  case AF_COMPRESSION_APPLE_MAC6:
308  compression_type = Kwave::Compression::APPLE_MAC6;
309  break;
310  case AF_COMPRESSION_G726:
311  compression_type = Kwave::Compression::G726;
312  break;
313  case AF_COMPRESSION_G728:
314  compression_type = Kwave::Compression::G728;
315  break;
316  case AF_COMPRESSION_DVI_AUDIO:
317  compression_type = Kwave::Compression::DVI_AUDIO;
318  break;
319  case AF_COMPRESSION_GSM:
320  compression_type = Kwave::Compression::GSM;
321  break;
322  case AF_COMPRESSION_FS1016:
323  compression_type = Kwave::Compression::FS1016;
324  break;
325  case AF_COMPRESSION_DV:
326  compression_type = Kwave::Compression::DV;
327  break;
328  case AF_COMPRESSION_MS_ADPCM:
329  compression_type = Kwave::Compression::MS_ADPCM;
330  break;
331 #ifdef HAVE_AF_COMPRESSION_FLAC
332  case AF_COMPRESSION_FLAC:
333  compression_type = Kwave::Compression::FLAC;
334  break;
335 #endif /* HAVE_AF_COMPRESSION_FLAC */
336 #ifdef HAVE_AF_COMPRESSION_ALAC
337  case AF_COMPRESSION_ALAC:
338  compression_type = Kwave::Compression::ALAC;
339  break;
340 #endif /* HAVE_AF_COMPRESSION_ALAC */
341  default:
342  compression_type = Kwave::Compression::NONE;
343  break;
344  }
345 
346  return compression_type;
347 }
static void fillMap()
Definition: Compression.cpp:86
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fromInt()

Kwave::Compression::Type Kwave::Compression::fromInt ( int  i)
static

conversion from int (e.g. for use in plugin parameters)

Definition at line 78 of file Compression.cpp.

References fillMap(), m_map, and NONE.

Referenced by Kwave::FileInfoDialog::accept(), Kwave::FileInfoDialog::compressionChanged(), Kwave::RecordDialog::compressionChanged(), Kwave::OggEncoder::encode(), Kwave::WavEncoder::encode(), Kwave::RecordParams::fromList(), Kwave::RecordDialog::setCompression(), and Kwave::FileInfoDialog::setupFileInfoTab().

79 {
80  fillMap();
81  return (m_map.contains(static_cast<Kwave::Compression::Type>(i))) ?
82  static_cast<Kwave::Compression::Type>(i) : Kwave::Compression::NONE;
83 }
static void fillMap()
Definition: Compression.cpp:86
static QMap< int, Kwave::Compression::Info > m_map
Definition: Compression.h:196
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasABR()

bool Kwave::Compression::hasABR ( ) const

Returns whether average bitrate mode is supported

Returns
true if supported, false if not

Definition at line 66 of file Compression.cpp.

References m_map, and m_type.

Referenced by Kwave::FileInfoDialog::accept().

67 {
68  return (m_map.contains(m_type)) ? m_map[m_type].m_has_abr : false;
69 }
static QMap< int, Kwave::Compression::Info > m_map
Definition: Compression.h:196
Here is the caller graph for this function:

◆ hasVBR()

bool Kwave::Compression::hasVBR ( ) const

Returns whether variable bitrate mode is supported

Returns
true if supported, false if not

Definition at line 72 of file Compression.cpp.

References m_map, and m_type.

Referenced by Kwave::FileInfoDialog::accept().

73 {
74  return (m_map.contains(m_type)) ? m_map[m_type].m_has_vbr : false;
75 }
static QMap< int, Kwave::Compression::Info > m_map
Definition: Compression.h:196
Here is the caller graph for this function:

◆ name()

QString Kwave::Compression::name ( ) const

Returns the descriptive name of the compression, already localized

Returns
localized name

Definition at line 45 of file Compression.cpp.

References m_map, m_type, and UTF8.

Referenced by Kwave::RecordPulseAudio::detectSupportedFormats(), Kwave::RecordDialog::setCompression(), Kwave::RecordDialog::setSupportedCompressions(), Kwave::FileInfoDialog::setupFileInfoTab(), and Kwave::FileInfoDialog::updateAvailableCompressions().

46 {
47  return (m_map.contains(m_type)) ?
48  i18n(UTF8(m_map[m_type].m_name)) : QString();
49 }
static QMap< int, Kwave::Compression::Info > m_map
Definition: Compression.h:196
#define UTF8(qs)
Definition: String.h:48
Here is the caller graph for this function:

◆ preferredMimeType()

QString Kwave::Compression::preferredMimeType ( ) const

Returns the preferred mime type or an empty string

Definition at line 52 of file Compression.cpp.

References m_map, m_type, and UTF8.

Referenced by Kwave::FileInfoDialog::setupFileInfoTab().

53 {
54  return (m_map.contains(m_type)) ?
55  i18n(UTF8(m_map[m_type].m_mime_type)) : QString();
56 }
static QMap< int, Kwave::Compression::Info > m_map
Definition: Compression.h:196
#define UTF8(qs)
Definition: String.h:48
Here is the caller graph for this function:

◆ sampleFormats()

QList< Kwave::SampleFormat > Kwave::Compression::sampleFormats ( ) const

Returns a list of supported sample formats

Returns
list of sample formats, or empty list if none supported

Definition at line 59 of file Compression.cpp.

References m_map, and m_type.

60 {
61  return (m_map.contains(m_type)) ?
62  m_map[m_type].m_sample_formats : QList<Kwave::SampleFormat>();
63 }
static QMap< int, Kwave::Compression::Info > m_map
Definition: Compression.h:196

◆ toAudiofile()

int Kwave::Compression::toAudiofile ( Kwave::Compression::Type  compression)
static

conversion to a numeric value from libaudiofile

Definition at line 208 of file Compression.cpp.

References ALAC, APPLE_ACE2, APPLE_ACE8, APPLE_MAC3, APPLE_MAC6, DV, DVI_AUDIO, fillMap(), FLAC, FS1016, G711_ALAW, G711_ULAW, G722, G726, G728, GSM, MS_ADPCM, and NONE.

Referenced by Kwave::WavEncoder::encode().

209 {
210  int af_compression = AF_COMPRESSION_UNKNOWN;
211 
212  fillMap();
213  switch (compression)
214  {
216  af_compression = AF_COMPRESSION_NONE;
217  break;
219  af_compression = AF_COMPRESSION_G722;
220  break;
222  af_compression = AF_COMPRESSION_G711_ULAW;
223  break;
225  af_compression = AF_COMPRESSION_G711_ALAW;
226  break;
228  af_compression = AF_COMPRESSION_APPLE_ACE2;
229  break;
231  af_compression = AF_COMPRESSION_APPLE_ACE8;
232  break;
234  af_compression = AF_COMPRESSION_APPLE_MAC3;
235  break;
237  af_compression = AF_COMPRESSION_APPLE_MAC6;
238  break;
240  af_compression = AF_COMPRESSION_G726;
241  break;
243  af_compression = AF_COMPRESSION_G728;
244  break;
246  af_compression = AF_COMPRESSION_DVI_AUDIO;
247  break;
249  af_compression = AF_COMPRESSION_GSM;
250  break;
252  af_compression = AF_COMPRESSION_FS1016;
253  break;
255  af_compression = AF_COMPRESSION_DV;
256  break;
258  af_compression = AF_COMPRESSION_MS_ADPCM;
259  break;
260 #ifdef HAVE_AF_COMPRESSION_FLAC
262  af_compression = AF_COMPRESSION_FLAC;
263  break;
264 #endif /* HAVE_AF_COMPRESSION_FLAC */
265 #ifdef HAVE_AF_COMPRESSION_ALAC
267  af_compression = AF_COMPRESSION_ALAC;
268  break;
269 #endif /* HAVE_AF_COMPRESSION_ALAC */
270  default:
271  af_compression = AF_COMPRESSION_UNKNOWN;
272  break;
273  }
274 
275  return af_compression;
276 }
static void fillMap()
Definition: Compression.cpp:86
Here is the call graph for this function:
Here is the caller graph for this function:

◆ toInt()

int Kwave::Compression::toInt ( ) const
inline

conversion to int (e.g. for use in plugin parameters)

Definition at line 122 of file Compression.h.

Referenced by Kwave::AudiofileDecoder::open(), Kwave::WavDecoder::open(), Kwave::RecordDialog::setSupportedCompressions(), Kwave::FileInfoDialog::setupFileInfoTab(), and Kwave::FileInfoDialog::updateAvailableCompressions().

122 { return static_cast<int>(m_type); }
Here is the caller graph for this function:

Member Data Documentation

◆ m_map

QMap< int, Kwave::Compression::Info > Kwave::Compression::m_map
staticprivate

map with all known compression types

Definition at line 196 of file Compression.h.

Referenced by fillMap(), fromInt(), hasABR(), hasVBR(), name(), preferredMimeType(), and sampleFormats().

◆ m_type

Type Kwave::Compression::m_type
private

internal storage of the compression type, see Type

Definition at line 141 of file Compression.h.

Referenced by hasABR(), hasVBR(), name(), preferredMimeType(), and sampleFormats().


The documentation for this class was generated from the following files: