X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fqcelpdata.h;h=4c6cf15e3e07c90ff7c25f22cd8d24cda1f1f88b;hb=0b8b3387a977dcdb6fb9e53bcc9966d34b2e4cec;hp=6916b95a0e5b355e7013513b357618742fda0158;hpb=31fb59ec98838a15b45b50c6f8a16733be86e208;p=ffmpeg diff --git a/libavcodec/qcelpdata.h b/libavcodec/qcelpdata.h index 6916b95a0e5..4c6cf15e3e0 100644 --- a/libavcodec/qcelpdata.h +++ b/libavcodec/qcelpdata.h @@ -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 */ @@ -23,13 +23,47 @@ #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 #include +#include "libavutil/common.h" + +/** + * QCELP unpacked data frame + */ +typedef struct { +/// @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 +/// @} + +/// @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 +/// @} + + /** + * line spectral pair frequencies (LSP) for RATE_OCTAVE, + * line spectral pair frequencies grouped into five vectors + * of dimension two (LSPV) for other rates + */ + uint8_t lspv[10]; + + /** + * reserved bits only present in bitrate 1, 1/4 and 1/8 packets + */ + uint8_t reserved; +} QCELPFrame; /** * pre-calculated table for hammsinc function @@ -40,12 +74,12 @@ 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 */ + 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(QCELPContext, variable), bit, len} +#define QCELP_OF(variable, bit, len) {offsetof(QCELPFrame, variable), bit, len} /** * bitmap unpacking tables for RATE_FULL @@ -232,15 +266,15 @@ 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, qcelp_rate_full_bitmap, }; -static const uint16_t qcelp_bits_per_rate[5] = { - 0, ///!< for SILENCE rate +static const uint16_t qcelp_unpacking_bitmaps_lengths[5] = { + 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), @@ -470,7 +504,7 @@ static const int8_t qcelp_rate_half_codebook[128] = { /** * sqrt(1.887) is the maximum of the pseudorandom * white sequence used to generate the scaled codebook - * vector for framerate 1/4. + * vector for bitrate 1/4. * * TIA/EIA/IS-733 2.4.8.1.2 */ @@ -478,7 +512,7 @@ static const int8_t qcelp_rate_half_codebook[128] = { /** * table for impulse response of BPF used to filter - * the white excitation for framerate 1/4 synthesis + * the white excitation for bitrate 1/4 synthesis * * Only half the tables are needed because of symmetry. * @@ -490,4 +524,29 @@ static const double qcelp_rnd_fir_coefs[11] = { -9.918777e-2, 3.749518e-2, 8.985137e-1 }; +/** + * This spread factor is used, for bitrate 1/8 and I_F_Q, + * to force the LSP frequencies to be at least 80 Hz apart. + * + * TIA/EIA/IS-733 2.4.3.3.2 + */ +#define QCELP_LSP_SPREAD_FACTOR 0.02 + +/** + * predictor coefficient for the conversion of LSP codes + * to LSP frequencies for 1/8 and I_F_Q + * + * TIA/EIA/IS-733 2.4.3.2.7-2 + */ +#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 */