kwave  18.07.70
Kwave::StandardBitrates Class Reference

#include <StandardBitrates.h>

Inheritance diagram for Kwave::StandardBitrates:
Inheritance graph
Collaboration diagram for Kwave::StandardBitrates:
Collaboration graph

Public Member Functions

 StandardBitrates ()
 
virtual ~StandardBitrates ()
 
virtual int nearest (int rate) const
 

Static Public Member Functions

static const StandardBitratesinstance ()
 

Detailed Description

Definition at line 28 of file StandardBitrates.h.

Constructor & Destructor Documentation

◆ StandardBitrates()

Kwave::StandardBitrates::StandardBitrates ( )

Constructor

Definition at line 26 of file StandardBitrates.cpp.

27  :QList<int>()
28 {
29  // use well-known bitrates from MP3
30  append( 8000);
31  append( 16000);
32  append( 24000);
33  append( 32000);
34  append( 40000);
35  append( 56000);
36  append( 64000);
37  append( 80000);
38  append( 96000);
39  append(112000);
40  append(128000);
41  append(144000);
42  append(160000);
43  append(176000);
44  append(192000);
45  append(224000);
46  append(256000);
47  append(288000);
48  append(320000);
49  append(352000);
50  append(384000);
51  append(416000);
52  append(448000);
53 }

◆ ~StandardBitrates()

Kwave::StandardBitrates::~StandardBitrates ( )
virtual

Destructor

Definition at line 56 of file StandardBitrates.cpp.

57 {
58 }

Member Function Documentation

◆ instance()

const Kwave::StandardBitrates & Kwave::StandardBitrates::instance ( )
static

returns a const reference to the list of bitrates

Definition at line 61 of file StandardBitrates.cpp.

References g_bitrates.

Referenced by Kwave::VorbisDecoder::close(), and Kwave::CompressionWidget::CompressionWidget().

62 {
63  return g_bitrates;
64 }
static Kwave::StandardBitrates g_bitrates
Here is the caller graph for this function:

◆ nearest()

int Kwave::StandardBitrates::nearest ( int  rate) const
virtual

Returns the standard bitrate that is nearest to the given one

Parameters
rategiven rate in [bits/second]
Returns
nearest bitrate in [bits/second]

Definition at line 67 of file StandardBitrates.cpp.

Referenced by Kwave::VorbisDecoder::close().

68 {
69  int best = rate;
70  int min_delta = INT_MAX;
71 
72  foreach (int value, *this) {
73  int delta = (value > rate) ? (value-rate) : (rate-value);
74  if (!delta) return rate; // complete match, easy case
75 
76  if (delta < min_delta) {
77  // found a better alternative
78  min_delta = delta;
79  best = value;
80  }
81  }
82 
83  return best;
84 }
Here is the caller graph for this function:

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