/*1* Copyright (c) 2004 Michael Niedermayer <[email protected]>2*3* This file is part of FFmpeg.4*5* FFmpeg is free software; you can redistribute it and/or6* modify it under the terms of the GNU Lesser General Public7* License as published by the Free Software Foundation; either8* version 2.1 of the License, or (at your option) any later version.9*10* FFmpeg is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13* Lesser General Public License for more details.14*15* You should have received a copy of the GNU Lesser General Public16* License along with FFmpeg; if not, write to the Free Software17* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18*/1920#ifndef AVRESAMPLE_RESAMPLE_H21#define AVRESAMPLE_RESAMPLE_H2223#include "avresample.h"24#include "internal.h"25#include "audio_data.h"2627struct ResampleContext {28AVAudioResampleContext *avr;29AudioData *buffer;30uint8_t *filter_bank;31int filter_length;32int ideal_dst_incr;33int dst_incr;34unsigned int index;35int frac;36int src_incr;37int compensation_distance;38int phase_shift;39int phase_mask;40int linear;41enum AVResampleFilterType filter_type;42int kaiser_beta;43void (*set_filter)(void *filter, double *tab, int phase, int tap_count);44void (*resample_one)(struct ResampleContext *c, void *dst0,45int dst_index, const void *src0,46unsigned int index, int frac);47void (*resample_nearest)(void *dst0, int dst_index,48const void *src0, unsigned int index);49int padding_size;50int initial_padding_filled;51int initial_padding_samples;52int final_padding_filled;53int final_padding_samples;54};5556/**57* Allocate and initialize a ResampleContext.58*59* The parameters in the AVAudioResampleContext are used to initialize the60* ResampleContext.61*62* @param avr AVAudioResampleContext63* @return newly-allocated ResampleContext64*/65ResampleContext *ff_audio_resample_init(AVAudioResampleContext *avr);6667/**68* Free a ResampleContext.69*70* @param c ResampleContext71*/72void ff_audio_resample_free(ResampleContext **c);7374/**75* Resample audio data.76*77* Changes the sample rate.78*79* @par80* All samples in the source data may not be consumed depending on the81* resampling parameters and the size of the output buffer. The unconsumed82* samples are automatically added to the start of the source in the next call.83* If the destination data can be reallocated, that may be done in this function84* in order to fit all available output. If it cannot be reallocated, fewer85* input samples will be consumed in order to have the output fit in the86* destination data buffers.87*88* @param c ResampleContext89* @param dst destination audio data90* @param src source audio data91* @return 0 on success, negative AVERROR code on failure92*/93int ff_audio_resample(ResampleContext *c, AudioData *dst, AudioData *src);9495#endif /* AVRESAMPLE_RESAMPLE_H */969798