1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-18 21:06:00 +00:00

af_scaletempo: minor simplification

This commit is contained in:
wm4 2015-03-06 21:51:18 +01:00
parent c30d5f79b5
commit ddbecd09b0

View File

@ -76,9 +76,9 @@ typedef struct af_scaletempo_s
float ms_stride;
float percent_overlap;
float ms_search;
#define SCALE_TEMPO 1
#define SCALE_PITCH 2
int speed_opt;
short speed_tempo;
short speed_pitch;
} af_scaletempo_t;
static int fill_queue(struct af_instance *af, struct mp_audio *data, int offset)
@ -282,7 +282,7 @@ static void update_speed(struct af_instance *af, float speed)
s->speed = speed;
double factor = s->speed_pitch ? 1.0 / s->speed : s->speed;
double factor = (s->speed_opt & SCALE_PITCH) ? 1.0 / s->speed : s->speed;
s->scale = factor * s->scale_nominal;
s->frames_stride_scaled = s->scale * s->frames_stride;
@ -434,11 +434,11 @@ static int control(struct af_instance *af, int cmd, void *arg)
}
case AF_CONTROL_SET_PLAYBACK_SPEED: {
double speed = *(double *)arg;
if (s->speed_tempo) {
if (s->speed_pitch)
if (s->speed_opt & SCALE_TEMPO) {
if (s->speed_opt & SCALE_PITCH)
break;
update_speed(af, speed);
} else if (s->speed_pitch) {
} else if (s->speed_opt & SCALE_PITCH) {
update_speed(af, speed);
break; // do not signal OK
}
@ -464,21 +464,12 @@ static void uninit(struct af_instance *af)
free(s->table_window);
}
#define SCALE_TEMPO 1
#define SCALE_PITCH 2
// Allocate memory and set function pointers
static int af_open(struct af_instance *af)
{
af_scaletempo_t *s = af->priv;
af->control = control;
af->uninit = uninit;
af->filter_frame = filter;
s->speed_tempo = !!(s->speed_opt & SCALE_TEMPO);
s->speed_pitch = !!(s->speed_opt & SCALE_PITCH);
return AF_OK;
}