kwave  18.07.70
OpusCommon.cpp
Go to the documentation of this file.
1 /*************************************************************************
2  OpusCommon.cpp - common functions for Opus Codec
3  -------------------
4  begin : Tue Jan 08 2013
5  copyright : (C) 2013 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "config.h"
19 
20 #include <KLocalizedString>
21 
22 #include "OpusCommon.h"
23 
24 //***************************************************************************
31 {
32  if (rate < 8000)
33  return 8000;
34  else if (rate <= 12000)
35  return 12000;
36  else if (rate <= 16000)
37  return 16000;
38  else if (rate <= 24000)
39  return 24000;
40  else
41  return 48000;
42 }
43 
44 //***************************************************************************
45 QString Kwave::opus_error(int err)
46 {
47  QString msg;
48 
49  switch (err)
50  {
51  case OPUS_OK:
52  msg = QString();
53  break;
54  case OPUS_BAD_ARG:
55  msg = i18n("One or more invalid/out of range arguments.");
56  break;
57  case OPUS_BUFFER_TOO_SMALL:
58  msg = i18n("The mode struct passed is invalid.");
59  break;
60  case OPUS_INTERNAL_ERROR:
61  msg = i18n("An internal error was detected.");
62  break;
63  case OPUS_INVALID_PACKET:
64  msg = i18n("The compressed data passed is corrupted.");
65  break;
66  case OPUS_UNIMPLEMENTED:
67  msg = i18n("Invalid/unsupported request number.");
68  break;
69  case OPUS_INVALID_STATE:
70  msg = i18n("A decoder structure is invalid or already freed.");
71  break;
72  case OPUS_ALLOC_FAIL:
73  msg = i18n("Out of memory");
74  break;
75  default:
76  msg = i18n("Decoder error: %1",
77  QString::fromLocal8Bit(opus_strerror(err)));
78  break;
79  }
80  return msg;
81 }
82 
83 //***************************************************************************
84 //***************************************************************************
int opus_next_sample_rate(int rate)
Definition: OpusCommon.cpp:30
QString opus_error(int err)
Definition: OpusCommon.cpp:45