mirror of
https://github.com/mpv-player/mpv
synced 2024-11-18 21:16:10 +01:00
7019e0dcfe
Similar to the previous commit, and for the same reasons. Unlike with af_scaletempo, resampling does not have a natural frame size, so we set an arbitrary size limit on output frames. We add a new option to control this size, although I'm not sure whether anyone will use it, so mark it for testing only. Note that we go through some effort to avoid buffering data in libswresample itself. One reason is that we might have to reinitialize the resampler completely when changing speed, which drops the buffered data. Another is that I'm not sure whether the resampler will do the right thing when applying dynamic speed changes.
45 lines
1.2 KiB
C
45 lines
1.2 KiB
C
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include "audio/chmap.h"
|
|
#include "filter.h"
|
|
|
|
// Resampler filter, wrapping libswresample or libavresample.
|
|
struct mp_swresample {
|
|
struct mp_filter *f;
|
|
// Desired output parameters. For unset parameters, passes through the
|
|
// format.
|
|
int out_rate;
|
|
int out_format;
|
|
struct mp_chmap out_channels;
|
|
double speed;
|
|
};
|
|
|
|
struct mp_resample_opts {
|
|
int filter_size;
|
|
int phase_shift;
|
|
int linear;
|
|
double cutoff;
|
|
int normalize;
|
|
int allow_passthrough;
|
|
double max_output_frame_size;
|
|
char **avopts;
|
|
};
|
|
|
|
#define MP_RESAMPLE_OPTS_DEF { \
|
|
.filter_size = 16, \
|
|
.cutoff = 0.0, \
|
|
.phase_shift = 10, \
|
|
.normalize = 0, \
|
|
.max_output_frame_size = 40,\
|
|
}
|
|
|
|
// Create the filter. If opts==NULL, use the global options as defaults.
|
|
// Free with talloc_free(mp_swresample.f).
|
|
struct mp_swresample *mp_swresample_create(struct mp_filter *parent,
|
|
struct mp_resample_opts *opts);
|
|
|
|
// Internal resampler delay. Does not include data buffered in mp_pins and such.
|
|
double mp_swresample_get_delay(struct mp_swresample *s);
|