1cabdff1aSopenharmony_ci/*
2cabdff1aSopenharmony_ci * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
3cabdff1aSopenharmony_ci *
4cabdff1aSopenharmony_ci * This file is part of FFmpeg.
5cabdff1aSopenharmony_ci *
6cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or
7cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public
8cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either
9cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version.
10cabdff1aSopenharmony_ci *
11cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful,
12cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
13cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14cabdff1aSopenharmony_ci * Lesser General Public License for more details.
15cabdff1aSopenharmony_ci *
16cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public
17cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software
18cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19cabdff1aSopenharmony_ci */
20cabdff1aSopenharmony_ci
21cabdff1aSopenharmony_ci#ifndef AVRESAMPLE_INTERNAL_H
22cabdff1aSopenharmony_ci#define AVRESAMPLE_INTERNAL_H
23cabdff1aSopenharmony_ci
24cabdff1aSopenharmony_ci#include "libavutil/audio_fifo.h"
25cabdff1aSopenharmony_ci#include "libavutil/log.h"
26cabdff1aSopenharmony_ci#include "libavutil/opt.h"
27cabdff1aSopenharmony_ci#include "libavutil/samplefmt.h"
28cabdff1aSopenharmony_ci#include "avresample.h"
29cabdff1aSopenharmony_ci
30cabdff1aSopenharmony_citypedef struct AudioData AudioData;
31cabdff1aSopenharmony_citypedef struct AudioConvert AudioConvert;
32cabdff1aSopenharmony_citypedef struct AudioMix AudioMix;
33cabdff1aSopenharmony_citypedef struct ResampleContext ResampleContext;
34cabdff1aSopenharmony_ci
35cabdff1aSopenharmony_cienum RemapPoint {
36cabdff1aSopenharmony_ci    REMAP_NONE,
37cabdff1aSopenharmony_ci    REMAP_IN_COPY,
38cabdff1aSopenharmony_ci    REMAP_IN_CONVERT,
39cabdff1aSopenharmony_ci    REMAP_OUT_COPY,
40cabdff1aSopenharmony_ci    REMAP_OUT_CONVERT,
41cabdff1aSopenharmony_ci};
42cabdff1aSopenharmony_ci
43cabdff1aSopenharmony_citypedef struct ChannelMapInfo {
44cabdff1aSopenharmony_ci    int channel_map[AVRESAMPLE_MAX_CHANNELS];   /**< source index of each output channel, -1 if not remapped */
45cabdff1aSopenharmony_ci    int do_remap;                               /**< remap needed */
46cabdff1aSopenharmony_ci    int channel_copy[AVRESAMPLE_MAX_CHANNELS];  /**< dest index to copy from */
47cabdff1aSopenharmony_ci    int do_copy;                                /**< copy needed */
48cabdff1aSopenharmony_ci    int channel_zero[AVRESAMPLE_MAX_CHANNELS];  /**< dest index to zero */
49cabdff1aSopenharmony_ci    int do_zero;                                /**< zeroing needed */
50cabdff1aSopenharmony_ci    int input_map[AVRESAMPLE_MAX_CHANNELS];     /**< dest index of each input channel */
51cabdff1aSopenharmony_ci} ChannelMapInfo;
52cabdff1aSopenharmony_ci
53cabdff1aSopenharmony_cistruct AVAudioResampleContext {
54cabdff1aSopenharmony_ci    const AVClass *av_class;        /**< AVClass for logging and AVOptions  */
55cabdff1aSopenharmony_ci
56cabdff1aSopenharmony_ci    uint64_t in_channel_layout;                 /**< input channel layout   */
57cabdff1aSopenharmony_ci    enum AVSampleFormat in_sample_fmt;          /**< input sample format    */
58cabdff1aSopenharmony_ci    int in_sample_rate;                         /**< input sample rate      */
59cabdff1aSopenharmony_ci    uint64_t out_channel_layout;                /**< output channel layout  */
60cabdff1aSopenharmony_ci    enum AVSampleFormat out_sample_fmt;         /**< output sample format   */
61cabdff1aSopenharmony_ci    int out_sample_rate;                        /**< output sample rate     */
62cabdff1aSopenharmony_ci    enum AVSampleFormat internal_sample_fmt;    /**< internal sample format */
63cabdff1aSopenharmony_ci    enum AVMixCoeffType mix_coeff_type;         /**< mixing coefficient type */
64cabdff1aSopenharmony_ci    double center_mix_level;                    /**< center mix level       */
65cabdff1aSopenharmony_ci    double surround_mix_level;                  /**< surround mix level     */
66cabdff1aSopenharmony_ci    double lfe_mix_level;                       /**< lfe mix level          */
67cabdff1aSopenharmony_ci    int normalize_mix_level;                    /**< enable mix level normalization */
68cabdff1aSopenharmony_ci    int force_resampling;                       /**< force resampling       */
69cabdff1aSopenharmony_ci    int filter_size;                            /**< length of each FIR filter in the resampling filterbank relative to the cutoff frequency */
70cabdff1aSopenharmony_ci    int phase_shift;                            /**< log2 of the number of entries in the resampling polyphase filterbank */
71cabdff1aSopenharmony_ci    int linear_interp;                          /**< if 1 then the resampling FIR filter will be linearly interpolated */
72cabdff1aSopenharmony_ci    double cutoff;                              /**< resampling cutoff frequency. 1.0 corresponds to half the output sample rate */
73cabdff1aSopenharmony_ci    enum AVResampleFilterType filter_type;      /**< resampling filter type */
74cabdff1aSopenharmony_ci    int kaiser_beta;                            /**< beta value for Kaiser window (only applicable if filter_type == AV_FILTER_TYPE_KAISER) */
75cabdff1aSopenharmony_ci    enum AVResampleDitherMethod dither_method;  /**< dither method          */
76cabdff1aSopenharmony_ci
77cabdff1aSopenharmony_ci    int in_channels;        /**< number of input channels                   */
78cabdff1aSopenharmony_ci    int out_channels;       /**< number of output channels                  */
79cabdff1aSopenharmony_ci    int resample_channels;  /**< number of channels used for resampling     */
80cabdff1aSopenharmony_ci    int downmix_needed;     /**< downmixing is needed                       */
81cabdff1aSopenharmony_ci    int upmix_needed;       /**< upmixing is needed                         */
82cabdff1aSopenharmony_ci    int mixing_needed;      /**< either upmixing or downmixing is needed    */
83cabdff1aSopenharmony_ci    int resample_needed;    /**< resampling is needed                       */
84cabdff1aSopenharmony_ci    int in_convert_needed;  /**< input sample format conversion is needed   */
85cabdff1aSopenharmony_ci    int out_convert_needed; /**< output sample format conversion is needed  */
86cabdff1aSopenharmony_ci    int in_copy_needed;     /**< input data copy is needed                  */
87cabdff1aSopenharmony_ci
88cabdff1aSopenharmony_ci    AudioData *in_buffer;           /**< buffer for converted input         */
89cabdff1aSopenharmony_ci    AudioData *resample_out_buffer; /**< buffer for output from resampler   */
90cabdff1aSopenharmony_ci    AudioData *out_buffer;          /**< buffer for converted output        */
91cabdff1aSopenharmony_ci    AVAudioFifo *out_fifo;          /**< FIFO for output samples            */
92cabdff1aSopenharmony_ci
93cabdff1aSopenharmony_ci    AudioConvert *ac_in;        /**< input sample format conversion context  */
94cabdff1aSopenharmony_ci    AudioConvert *ac_out;       /**< output sample format conversion context */
95cabdff1aSopenharmony_ci    ResampleContext *resample;  /**< resampling context                      */
96cabdff1aSopenharmony_ci    AudioMix *am;               /**< channel mixing context                  */
97cabdff1aSopenharmony_ci    enum AVMatrixEncoding matrix_encoding;      /**< matrixed stereo encoding */
98cabdff1aSopenharmony_ci
99cabdff1aSopenharmony_ci    /**
100cabdff1aSopenharmony_ci     * mix matrix
101cabdff1aSopenharmony_ci     * only used if avresample_set_matrix() is called before avresample_open()
102cabdff1aSopenharmony_ci     */
103cabdff1aSopenharmony_ci    double *mix_matrix;
104cabdff1aSopenharmony_ci
105cabdff1aSopenharmony_ci    int use_channel_map;
106cabdff1aSopenharmony_ci    enum RemapPoint remap_point;
107cabdff1aSopenharmony_ci    ChannelMapInfo ch_map_info;
108cabdff1aSopenharmony_ci};
109cabdff1aSopenharmony_ci
110cabdff1aSopenharmony_ci
111cabdff1aSopenharmony_civoid ff_audio_resample_init_aarch64(ResampleContext *c,
112cabdff1aSopenharmony_ci                                    enum AVSampleFormat sample_fmt);
113cabdff1aSopenharmony_civoid ff_audio_resample_init_arm(ResampleContext *c,
114cabdff1aSopenharmony_ci                                enum AVSampleFormat sample_fmt);
115cabdff1aSopenharmony_ci
116cabdff1aSopenharmony_ci#endif /* AVRESAMPLE_INTERNAL_H */
117