summaryrefslogtreecommitdiff
path: root/audio/resampler.h
blob: 0bb471c7d9960a7e01ad6bb50d17b9311b8e4a9e (plain)
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
#ifndef AUDIO_RESAMPLER_H_
#define AUDIO_RESAMPLER_H_

#include <libavutil/channel_layout.h>
#include <libavutil/samplefmt.h>
#include <libswresample/swresample.h>
#include "decoder.h"
#include "encoder.h"

struct Resampler {
	SwrContext *swr;
	uint64_t stored;
	uint64_t needed;
	int      in_sample_rate;

	/* Passed by *_init, used by *_conf */
	const AVChannelLayout *out_chlayout;
	enum AVSampleFormat    out_sample_fmt;
	uint64_t               out_sample_rate;
	uint64_t               out_frame_size;
};

int  resampler_init_for_encoder (struct Resampler *resampler, const struct Encoder *encoder);
int  resampler_conf_for_decoder (struct Resampler *resampler, const struct Decoder *decoder);
int  resampler_send_frame       (struct Resampler *resampler, AVFrame *in);
int  resampler_send_empty       (struct Resampler *resampler, unsigned int microsecond);
int  resampler_convert          (struct Resampler *resmapler, AVFrame *out);
int  resampler_has_enough       (struct Resampler *resampler);
void resampler_free             (struct Resampler *resampler);

#endif // AUDIO_RESAMPLER_H_