Storing a value from a loop

I'm trying to combine a filter from FFmpeg with the speed control function of mpv-player. I'm trying to use the photosensitivity filter to trigger a speed change in the playback in the scenes where there is a lot of movement and/or flashy /chaotic, elements. I was able to do it by getting the relevant value from vf_photosensitivity.c and copying it into a global variable which i use in the audio.c file to control the speed of the playback. It works, but at the moment i'm forced to used fixed values, for example, 0.5 speed when above the threshold and 1.0 when below.

this is line 175 of audio.c

void update_playback_speed(struct MPContext *mpctx) { mpctx->audio_speed = mpctx->opts->playback_speed * mpctx->speed_factor_a; mpctx->video_speed = mpctx->opts->playback_speed * mpctx->speed_factor_v;

update_speed_filters(mpctx); } By giving a value to mpctx->opts->playback_speed i can modify the speed. I would like it to be 0.5 when above the threshold, but when below the threshold it should return to whatever speed was before, and i can't find a way to store the value of mpctx->opts->playback_speed without it getting updated again into 0.5 (or whatever the speed would be when the above the threshold) i'm a beginner, any help please? thanks

I have no idea what the bigger context of that all is. That's the reason why I can't write anything helpful. You would have to describe in more details and provide your complete code as an attachement with some hints

best regards Stefan

As StefanL38 remarks, hard to see what the issue is without specifics, but naively, wouldn't a couple of globals with the previous audio settings be helpful?