2011-09-19 06:13:30 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2011 Michael Niedermayer (michaelni@gmx.at)
|
|
|
|
*
|
|
|
|
* This file is part of libswresample
|
|
|
|
*
|
|
|
|
* libswresample 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.
|
|
|
|
*
|
|
|
|
* libswresample 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 libswresample; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SWR_INTERNAL_H
|
|
|
|
#define SWR_INTERNAL_H
|
|
|
|
|
|
|
|
#include "swresample.h"
|
|
|
|
|
|
|
|
typedef struct AudioData{
|
|
|
|
uint8_t *ch[SWR_CH_MAX];
|
|
|
|
uint8_t *data;
|
|
|
|
int ch_count;
|
|
|
|
int bps;
|
|
|
|
int count;
|
|
|
|
int planar;
|
|
|
|
} AudioData;
|
|
|
|
|
|
|
|
typedef struct SwrContext { //FIXME find unused fields
|
2011-10-21 00:33:04 +02:00
|
|
|
const AVClass *av_class;
|
2011-09-19 06:13:30 +02:00
|
|
|
int log_level_offset;
|
|
|
|
void *log_ctx;
|
|
|
|
enum AVSampleFormat in_sample_fmt;
|
|
|
|
enum AVSampleFormat int_sample_fmt; ///<AV_SAMPLE_FMT_FLT OR AV_SAMPLE_FMT_S16
|
|
|
|
enum AVSampleFormat out_sample_fmt;
|
|
|
|
int64_t in_ch_layout;
|
|
|
|
int64_t out_ch_layout;
|
|
|
|
int in_sample_rate;
|
|
|
|
int out_sample_rate;
|
|
|
|
int flags;
|
2011-10-26 00:44:35 +02:00
|
|
|
float slev, clev, rematrix_volume;
|
2011-11-04 18:54:01 +01:00
|
|
|
const int *channel_map; ///< channel index (or -1 if muted channel) map
|
|
|
|
int used_ch_count; ///< number of used channels (mapped channel count if channel_map, otherwise in.ch_count)
|
2011-09-19 06:13:30 +02:00
|
|
|
|
|
|
|
//below are private
|
|
|
|
int int_bps;
|
|
|
|
int resample_first;
|
|
|
|
int rematrix; ///< flag to indicate if rematrixing is used
|
|
|
|
|
|
|
|
AudioData in, postin, midbuf, preout, out, in_buffer;
|
|
|
|
int in_buffer_index;
|
|
|
|
int in_buffer_count;
|
|
|
|
int resample_in_constraint;
|
|
|
|
|
2011-11-16 08:00:31 +01:00
|
|
|
struct AudioConvert *in_convert;
|
|
|
|
struct AudioConvert *out_convert;
|
|
|
|
struct AudioConvert *full_convert;
|
2011-11-16 08:06:42 +01:00
|
|
|
struct ResampleContext *resample;
|
2011-09-19 06:13:30 +02:00
|
|
|
|
|
|
|
float matrix[SWR_CH_MAX][SWR_CH_MAX];
|
2011-10-26 00:41:26 +02:00
|
|
|
int32_t matrix32[SWR_CH_MAX][SWR_CH_MAX];
|
2011-09-19 06:13:30 +02:00
|
|
|
uint8_t matrix_ch[SWR_CH_MAX][SWR_CH_MAX+1];
|
|
|
|
|
|
|
|
//TODO callbacks for asm optims
|
|
|
|
}SwrContext;
|
|
|
|
|
2011-11-16 08:12:48 +01:00
|
|
|
struct ResampleContext *swri_resample_init(struct ResampleContext *, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff);
|
|
|
|
void swri_resample_free(struct ResampleContext **c);
|
|
|
|
int swri_multiple_resample(struct ResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed);
|
|
|
|
void swri_resample_compensate(struct ResampleContext *c, int sample_delta, int compensation_distance);
|
|
|
|
int swri_resample(struct ResampleContext *c, short *dst, const short *src, int *consumed, int src_size, int dst_size, int update_ctx);
|
2011-09-19 06:13:30 +02:00
|
|
|
|
2011-11-16 08:12:48 +01:00
|
|
|
int swri_rematrix_init(SwrContext *s);
|
|
|
|
int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mustcopy);
|
2011-09-19 06:13:30 +02:00
|
|
|
#endif
|