]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/qcelpdata.h
mpeg12dec: avoid signed overflow in bitrate calculation
[ffmpeg] / libavcodec / qcelpdata.h
index 11eb1d100b0b93458bb511da21e5e9709d4e8aff..319833e9045e76ff3daba87fd49a7378b910e03a 100644 (file)
@@ -2,20 +2,20 @@
  * QCELP decoder
  * Copyright (c) 2007 Reynaldo H. Verdejo Pinochet
  *
- * This file is part of FFmpeg.
+ * This file is part of Libav.
  *
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #define AVCODEC_QCELPDATA_H
 
 /**
- * @file qcelpdata.h
+ * @file
  * Data tables for the QCELP decoder
  * @author Reynaldo H. Verdejo Pinochet
- * @remark FFmpeg merging spearheaded by Kenan Gillet
+ * @remark Libav merging spearheaded by Kenan Gillet
+ * @remark Development mentored by Benjamin Larson
  */
 
 #include <stddef.h>
 /**
  * QCELP unpacked data frame
  */
-typedef struct {
-/// @defgroup qcelp_codebook_parameters QCELP excitation codebook parameters
+typedef struct QCELPFrame {
+/// @name QCELP excitation codebook parameters
 /// @{
-    uint8_t cbsign[16]; ///!< sign of the codebook gain for each codebook subframe
-    uint8_t cbgain[16]; ///!< unsigned codebook gain for each codebook subframe
-    uint8_t cindex[16]; ///!< codebook index for each codebook subframe
+    uint8_t cbsign[16]; ///< sign of the codebook gain for each codebook subframe
+    uint8_t cbgain[16]; ///< unsigned codebook gain for each codebook subframe
+    uint8_t cindex[16]; ///< codebook index for each codebook subframe
 /// @}
 
-/// @defgroup qcelp_pitch_parameters QCELP pitch prediction parameters
+/// @name QCELP pitch prediction parameters
 /// @{
-    uint8_t plag[4];    ///!< pitch lag for each pitch subframe
-    uint8_t pfrac[4];   ///!< fractional pitch lag for each pitch subframe
-    uint8_t pgain[4];   ///!< pitch gain for each pitch subframe
+    uint8_t plag[4];    ///< pitch lag for each pitch subframe
+    uint8_t pfrac[4];   ///< fractional pitch lag for each pitch subframe
+    uint8_t pgain[4];   ///< pitch gain for each pitch subframe
 /// @}
 
     /**
@@ -72,10 +73,10 @@ typedef struct {
  */
 static const float qcelp_hammsinc_table[4] = { -0.006822,  0.041249, -0.143459,  0.588863};
 
-typedef struct {
-    uint8_t index;  /*!< index into the QCELPContext structure */
-    uint8_t bitpos; /*!< position of the lowest bit in the value's byte */
-    uint8_t bitlen; /*!< number of bits to read */
+typedef struct QCELPBitmap {
+    uint8_t index;  /**< index into the QCELPContext structure */
+    uint8_t bitpos; /**< position of the lowest bit in the value's byte */
+    uint8_t bitlen; /**< number of bits to read */
 } QCELPBitmap;
 
 #define QCELP_OF(variable, bit, len) {offsetof(QCELPFrame, variable), bit, len}
@@ -265,7 +266,7 @@ static const QCELPBitmap qcelp_rate_octave_bitmap[] = {
  * the QCELPContext
  */
 static const QCELPBitmap * const qcelp_unpacking_bitmaps_per_rate[5] = {
-    NULL,                     ///!< for SILENCE rate
+    NULL,                     ///< for SILENCE rate
     qcelp_rate_octave_bitmap,
     qcelp_rate_quarter_bitmap,
     qcelp_rate_half_bitmap,
@@ -273,7 +274,7 @@ static const QCELPBitmap * const qcelp_unpacking_bitmaps_per_rate[5] = {
 };
 
 static const uint16_t qcelp_unpacking_bitmaps_lengths[5] = {
-    0, ///!< for SILENCE rate
+    0, ///< for SILENCE rate
     FF_ARRAY_ELEMS(qcelp_rate_octave_bitmap),
     FF_ARRAY_ELEMS(qcelp_rate_quarter_bitmap),
     FF_ARRAY_ELEMS(qcelp_rate_half_bitmap),
@@ -423,16 +424,6 @@ static const qcelp_vector * const qcelp_lspvq[5] = {
  */
 #define QCELP_SCALE 8192.
 
-/**
- * the upper boundary of the clipping, depends on QCELP_SCALE
- */
-#define QCELP_CLIP_UPPER_BOUND (8191.75/8192.)
-
-/**
- * the lower boundary of the clipping, depends on QCELP_SCALE
- */
-#define QCELP_CLIP_LOWER_BOUND -1.
-
 /**
  * table for computing Ga (decoded linear codebook gain magnitude)
  *
@@ -549,4 +540,13 @@ static const double qcelp_rnd_fir_coefs[11] = {
  */
 #define QCELP_LSP_OCTAVE_PREDICTOR 29.0/32
 
+/**
+ * initial coefficient to perform bandwidth expansion on LPC
+ *
+ * @note: 0.9883 looks like an approximation of 253/256.
+ *
+ * TIA/EIA/IS-733 2.4.3.3.6 6
+ */
+#define QCELP_BANDWIDTH_EXPANSION_COEFF 0.9883
+
 #endif /* AVCODEC_QCELPDATA_H */