diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2017-02-21 02:22:51 +0300 |
---|---|---|
committer | Rostislav Pehlivanov <atomnuker@gmail.com> | 2017-05-08 07:56:14 +0300 |
commit | b8c2b9c39279171f647d9c81f34ffa3d3ae93c47 (patch) | |
tree | fc50e13f8009274c05ab06eeeb80757b6dc10a94 /libavcodec/dcaadpcm.h | |
parent | 5f928c5201c077b9765610bc5304235c3f1d9bd6 (diff) |
avcodec/dcaenc: Initial implementation of ADPCM encoding for DCA encoder
Diffstat (limited to 'libavcodec/dcaadpcm.h')
-rw-r--r-- | libavcodec/dcaadpcm.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/libavcodec/dcaadpcm.h b/libavcodec/dcaadpcm.h new file mode 100644 index 0000000000..23bfa79636 --- /dev/null +++ b/libavcodec/dcaadpcm.h @@ -0,0 +1,54 @@ +/* + * DCA ADPCM engine + * Copyright (C) 2017 Daniil Cherednik + * + * 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_DCAADPCM_H +#define AVCODEC_DCAADPCM_H + +#include "dcamath.h" +#include "dcadata.h" +#include "dcaenc.h" + +typedef struct DCAADPCMEncContext { + void *private_data; +} DCAADPCMEncContext; + +static inline int64_t ff_dcaadpcm_predict(int pred_vq_index, const int32_t *input) +{ + int i; + const int16_t *coeff = ff_dca_adpcm_vb[pred_vq_index]; + int64_t pred = 0; + for (i = 0; i < DCA_ADPCM_COEFFS; i++) + pred += (int64_t)input[DCA_ADPCM_COEFFS - 1 - i] * coeff[i]; + + return clip23(norm13(pred)); +} + +int ff_dcaadpcm_subband_analysis(const DCAADPCMEncContext *s, const int32_t *input, int len, int *diff); + +int ff_dcaadpcm_do_real(int pred_vq_index, + softfloat quant, int32_t scale_factor, int32_t step_size, + const int32_t *prev_hist, const int32_t *in, int32_t *next_hist, int32_t *out, + int len, int32_t peak); + +av_cold int ff_dcaadpcm_init(DCAADPCMEncContext *s); +av_cold void ff_dcaadpcm_free(DCAADPCMEncContext *s); + +#endif /* AVCODEC_DCAADPCM_H */ |