2 * Copyright (C) 2011 Michael Niedermayer (michaelni@gmx.at)
4 * This file is part of libswresample
6 * libswresample is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * libswresample is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with libswresample; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef SWR_INTERNAL_H
22 #define SWR_INTERNAL_H
24 #include "swresample.h"
26 typedef struct AudioData{
27 uint8_t *ch[SWR_CH_MAX];
35 typedef struct SwrContext { //FIXME find unused fields
39 enum AVSampleFormat in_sample_fmt;
40 enum AVSampleFormat int_sample_fmt; ///<AV_SAMPLE_FMT_FLT OR AV_SAMPLE_FMT_S16
41 enum AVSampleFormat out_sample_fmt;
43 int64_t out_ch_layout;
52 int rematrix; ///< flag to indicate if rematrixing is used
54 AudioData in, postin, midbuf, preout, out, in_buffer;
57 int resample_in_constraint;
59 struct AVAudioConvert *in_convert;
60 struct AVAudioConvert *out_convert;
61 struct AVResampleContext *resample;
63 float matrix[SWR_CH_MAX][SWR_CH_MAX];
64 int16_t matrix16[SWR_CH_MAX][SWR_CH_MAX];
65 uint8_t matrix_ch[SWR_CH_MAX][SWR_CH_MAX+1];
67 //TODO callbacks for asm optims
70 struct AVResampleContext *swr_resample_init(struct AVResampleContext *, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff);
71 void swr_resample_free(struct AVResampleContext **c);
72 int swr_multiple_resample(struct AVResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed);
73 void swr_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
74 int swr_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
76 int swr_rematrix_init(SwrContext *s);
77 int swr_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mustcopy);