Dana 11. 8. 2015. 03:51 osoba "Ganesh Ajjanagadde" <gajjanaga...@gmail.com> napisala je: > > Moves structure definitions and related macros to g729dec.h > Also exports format in priv_data > > Signed-off-by: Ganesh Ajjanagadde <gajjanaga...@gmail.com> > --- > libavcodec/g729dec.c | 111 ++--------------------------------------- > libavcodec/g729dec.h | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 141 insertions(+), 108 deletions(-) > create mode 100644 libavcodec/g729dec.h > > diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c > index 99053ad..e5b2de0 100644 > --- a/libavcodec/g729dec.c > +++ b/libavcodec/g729dec.c > @@ -30,6 +30,7 @@ > > > #include "g729.h" > +#include "g729dec.h" > #include "lsp.h" > #include "celp_math.h" > #include "celp_filters.h" > @@ -39,57 +40,6 @@ > #include "g729data.h" > #include "g729postfilter.h" > > -/** > - * minimum quantized LSF value (3.2.4) > - * 0.005 in Q13 > - */ > -#define LSFQ_MIN 40 > - > -/** > - * maximum quantized LSF value (3.2.4) > - * 3.135 in Q13 > - */ > -#define LSFQ_MAX 25681 > - > -/** > - * minimum LSF distance (3.2.4) > - * 0.0391 in Q13 > - */ > -#define LSFQ_DIFF_MIN 321 > - > -/// interpolation filter length > -#define INTERPOL_LEN 11 > - > -/** > - * minimum gain pitch value (3.8, Equation 47) > - * 0.2 in (1.14) > - */ > -#define SHARP_MIN 3277 > - > -/** > - * maximum gain pitch value (3.8, Equation 47) > - * (EE) This does not comply with the specification. > - * Specification says about 0.8, which should be > - * 13107 in (1.14), but reference C code uses > - * 13017 (equals to 0.7945) instead of it. > - */ > -#define SHARP_MAX 13017 > - > -/** > - * MR_ENERGY (mean removed energy) = mean_energy + 10 * log10(2^26 * subframe_size) in (7.13) > - */ > -#define MR_ENERGY 1018156 > - > -#define DECISION_NOISE 0 > -#define DECISION_INTERMEDIATE 1 > -#define DECISION_VOICE 2 > - > -typedef enum { > - FORMAT_G729_8K = 0, > - FORMAT_G729D_6K4, > - FORMAT_COUNT, > -} G729Formats; > - > typedef struct { > uint8_t ac_index_bits[2]; ///< adaptive codebook index for second subframe (size in bits) > uint8_t parity_bit; ///< parity bit for pitch delay > @@ -99,61 +49,6 @@ typedef struct { > uint8_t fc_indexes_bits; ///< size (in bits) of fixed-codebook index entry > } G729FormatDescription; > > -typedef struct { > - AudioDSPContext adsp; > - > - /// past excitation signal buffer > - int16_t exc_base[2*SUBFRAME_SIZE+PITCH_DELAY_MAX+INTERPOL_LEN]; > - > - int16_t* exc; ///< start of past excitation data in buffer > - int pitch_delay_int_prev; ///< integer part of previous subframe's pitch delay (4.1.3) > - > - /// (2.13) LSP quantizer outputs > - int16_t past_quantizer_output_buf[MA_NP + 1][10]; > - int16_t* past_quantizer_outputs[MA_NP + 1]; > - > - int16_t lsfq[10]; ///< (2.13) quantized LSF coefficients from previous frame > - int16_t lsp_buf[2][10]; ///< (0.15) LSP coefficients (previous and current frames) (3.2.5) > - int16_t *lsp[2]; ///< pointers to lsp_buf > - > - int16_t quant_energy[4]; ///< (5.10) past quantized energy > - > - /// previous speech data for LP synthesis filter > - int16_t syn_filter_data[10]; > - > - > - /// residual signal buffer (used in long-term postfilter) > - int16_t residual[SUBFRAME_SIZE + RES_PREV_DATA_SIZE]; > - > - /// previous speech data for residual calculation filter > - int16_t res_filter_data[SUBFRAME_SIZE+10]; > - > - /// previous speech data for short-term postfilter > - int16_t pos_filter_data[SUBFRAME_SIZE+10]; > - > - /// (1.14) pitch gain of current and five previous subframes > - int16_t past_gain_pitch[6]; > - > - /// (14.1) gain code from current and previous subframe > - int16_t past_gain_code[2]; > - > - /// voice decision on previous subframe (0-noise, 1-intermediate, 2-voice), G.729D > - int16_t voice_decision; > - > - int16_t onset; ///< detected onset level (0-2) > - int16_t was_periodic; ///< whether previous frame was declared as periodic or not (4.4) > - int16_t ht_prev_data; ///< previous data for 4.2.3, equation 86 > - int gain_coeff; ///< (1.14) gain coefficient (4.2.4) > - uint16_t rand_value; ///< random number generator value (4.4.4) > - int ma_predictor_prev; ///< switched MA predictor of LSP quantizer from last good frame > - > - /// (14.14) high-pass filter data (past input) > - int hpf_f[2]; > - > - /// high-pass filter data (past output) > - int16_t hpf_z[2]; > -} G729Context; > - > static const G729FormatDescription format_g729_8k = { > .ac_index_bits = {8,5}, > .parity_bit = 1, > @@ -422,14 +317,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, > out_frame = (int16_t*) frame->data[0]; > > if (buf_size % 10 == 0) { > - packet_type = FORMAT_G729_8K; > + ctx->format = packet_type = FORMAT_G729_8K; > format = &format_g729_8k; > //Reset voice decision > ctx->onset = 0; > ctx->voice_decision = DECISION_VOICE; > av_log(avctx, AV_LOG_DEBUG, "Packet type: %s\n", "G.729 @ 8kbit/s"); > } else if (buf_size == 8) { > - packet_type = FORMAT_G729D_6K4; > + ctx->format = packet_type = FORMAT_G729D_6K4; > format = &format_g729d_6k4; > av_log(avctx, AV_LOG_DEBUG, "Packet type: %s\n", "G.729D @ 6.4kbit/s"); > } else { > diff --git a/libavcodec/g729dec.h b/libavcodec/g729dec.h > new file mode 100644 > index 0000000..06cbebf > --- /dev/null > +++ b/libavcodec/g729dec.h > @@ -0,0 +1,138 @@ > +/* > + * G.729 decoder > + * Copyright (C) 2015 Ganesh Ajjanagadde
Unacceptable, moving things around can not give you right to do this. > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg 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, > + * 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 > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +#ifndef AVCODEC_G729DEC_H > +#define AVCODEC_G729DEC_H > + > +#include "acelp_pitch_delay.h" > +#include "g729data.h" > +#include "g729postfilter.h" > + > +typedef enum { > + FORMAT_G729_8K = 0, > + FORMAT_G729D_6K4, > + FORMAT_COUNT, > +} G729Formats; > + > +/** > + * minimum quantized LSF value (3.2.4) > + * 0.005 in Q13 > + */ > +#define LSFQ_MIN 40 > + > +/** > + * maximum quantized LSF value (3.2.4) > + * 3.135 in Q13 > + */ > +#define LSFQ_MAX 25681 > + > +/** > + * minimum LSF distance (3.2.4) > + * 0.0391 in Q13 > + */ > +#define LSFQ_DIFF_MIN 321 > + > +/// interpolation filter length > +#define INTERPOL_LEN 11 > + > +/** > + * minimum gain pitch value (3.8, Equation 47) > + * 0.2 in (1.14) > + */ > +#define SHARP_MIN 3277 > + > +/** > + * maximum gain pitch value (3.8, Equation 47) > + * (EE) This does not comply with the specification. > + * Specification says about 0.8, which should be > + * 13107 in (1.14), but reference C code uses > + * 13017 (equals to 0.7945) instead of it. > + */ > +#define SHARP_MAX 13017 > + > +/** > + * MR_ENERGY (mean removed energy) = mean_energy + 10 * log10(2^26 * subframe_size) in (7.13) > + */ > +#define MR_ENERGY 1018156 > + > +#define DECISION_NOISE 0 > +#define DECISION_INTERMEDIATE 1 > +#define DECISION_VOICE 2 > + > +typedef struct { > + AudioDSPContext adsp; > + > + /// past excitation signal buffer > + int16_t exc_base[2*SUBFRAME_SIZE+PITCH_DELAY_MAX+INTERPOL_LEN]; > + > + int16_t* exc; ///< start of past excitation data in buffer > + int pitch_delay_int_prev; ///< integer part of previous subframe's pitch delay (4.1.3) > + > + /// (2.13) LSP quantizer outputs > + int16_t past_quantizer_output_buf[MA_NP + 1][10]; > + int16_t* past_quantizer_outputs[MA_NP + 1]; > + > + int16_t lsfq[10]; ///< (2.13) quantized LSF coefficients from previous frame > + int16_t lsp_buf[2][10]; ///< (0.15) LSP coefficients (previous and current frames) (3.2.5) > + int16_t *lsp[2]; ///< pointers to lsp_buf > + > + int16_t quant_energy[4]; ///< (5.10) past quantized energy > + > + /// previous speech data for LP synthesis filter > + int16_t syn_filter_data[10]; > + > + > + /// residual signal buffer (used in long-term postfilter) > + int16_t residual[SUBFRAME_SIZE + RES_PREV_DATA_SIZE]; > + > + /// previous speech data for residual calculation filter > + int16_t res_filter_data[SUBFRAME_SIZE+10]; > + > + /// previous speech data for short-term postfilter > + int16_t pos_filter_data[SUBFRAME_SIZE+10]; > + > + /// (1.14) pitch gain of current and five previous subframes > + int16_t past_gain_pitch[6]; > + > + /// (14.1) gain code from current and previous subframe > + int16_t past_gain_code[2]; > + > + /// voice decision on previous subframe (0-noise, 1-intermediate, 2-voice), G.729D > + int16_t voice_decision; > + > + int16_t onset; ///< detected onset level (0-2) > + int16_t was_periodic; ///< whether previous frame was declared as periodic or not (4.4) > + int16_t ht_prev_data; ///< previous data for 4.2.3, equation 86 > + int gain_coeff; ///< (1.14) gain coefficient (4.2.4) > + uint16_t rand_value; ///< random number generator value (4.4.4) > + int ma_predictor_prev; ///< switched MA predictor of LSP quantizer from last good frame > + > + /// (14.14) high-pass filter data (past input) > + int hpf_f[2]; > + > + /// high-pass filter data (past output) > + int16_t hpf_z[2]; > + > + /// format type > + G729Formats format; > +} G729Context; > + > +#endif /* AVCODEC_G729DEC_H */ > -- > 2.5.0 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel