aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/lowpass.h
blob: 6a779077463fa2b4703e139710946c82d677c5a0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * Lowpass IIR filter
 * Copyright (c) 2008 Konstantin Shishkov
 *
 * 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
 */

/**
 * @file lowpass.h
 * lowpass filter interface
 */

#ifndef FFMPEG_LOWPASS_H
#define FFMPEG_LOWPASS_H

#include "avcodec.h"

struct FFLPFilterCoeffs;
struct FFLPFilterState;

/**
 * Initialize filter coefficients.
 *
 * @param order        filter order
 * @param cutoff_ratio cutoff to input frequency ratio
 *
 * @return pointer to filter coefficients structure or NULL if filter cannot be created
 */
const struct FFLPFilterCoeffs* ff_lowpass_filter_init_coeffs(int order, float cutoff_ratio);

/**
 * Create new filter state.
 *
 * @param order filter order
 *
 * @return pointer to new filter state or NULL if state creation fails
 */
struct FFLPFilterState* ff_lowpass_filter_init_state(int order);

#if 0 //enable with arbitrary order filter implementation, use av_free() for filter state only for now
/**
 * Free filter coefficients.
 *
 * @param coeffs pointer allocated with ff_lowpass_filter_init_coeffs()
 */
void ff_lowpass_filter_free_coeffs(struct FFLPFilterCoeffs *coeffs);

/**
 * Free filter state.
 *
 * @param state pointer allocated with ff_lowpass_filter_init_state()
 */
void ff_lowpass_filter_free_state(struct FFLPFilterState *state);
#endif

/**
 * Perform lowpass filtering on input samples.
 *
 * @param coeffs pointer to filter coefficients
 * @param state  pointer to filter state
 * @param size   input length
 * @param src    source samples
 * @param sstep  source stride
 * @param dst    filtered samples (destination may be the same as input)
 * @param dstep  destination stride
 */
void ff_lowpass_filter(const struct FFLPFilterCoeffs *coeffs, struct FFLPFilterState *state, int size, int16_t *src, int sstep, int16_t *dst, int dstep);

#endif /* FFMPEG_LOWPASS_H */