// Reconfigure the filter chain according to decoder output. // probe_only: don't force fallback to software when doing hw decoding, and // the filter chain couldn't be configured static void filter_reconfig(struct MPContext *mpctx, bool probe_only) { struct dec_video *d_video = mpctx->d_video; struct mp_image_params params = d_video->decoder_output; mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL); set_allowed_vo_formats(d_video->vfilter, mpctx->video_out); if (video_reconfig_filters(d_video, ¶ms) < 0) { // Most video filters don't work with hardware decoding, so this // might be the reason why filter reconfig failed. if (!probe_only && video_vd_control(d_video, VDCTRL_FORCE_HWDEC_FALLBACK, NULL) == CONTROL_OK) { // Fallback active; decoder will return software format next // time. Don't abort video decoding. d_video->vfilter->initialized = 0; mp_image_unrefp(&d_video->waiting_decoded_mpi); d_video->decoder_output = (struct mp_image_params){0}; MP_VERBOSE(mpctx, "hwdec falback due to filters.\n"); } return; } if (d_video->vfilter->initialized < 1) return; if (params.rotate && (params.rotate % 90 == 0)) { if (!(mpctx->video_out->driver->caps & VO_CAP_ROTATE90)) { // Try to insert a rotation filter. char *args[] = {"angle", "auto", NULL}; if (try_filter(mpctx, params, "rotate", "autorotate", args) >= 0) { params.rotate = 0; } else { MP_ERR(mpctx, "Can't insert rotation filter.\n"); } } } if (params.stereo_in != params.stereo_out && params.stereo_in > 0 && params.stereo_out >= 0) { char *to = (char *)MP_STEREO3D_NAME(params.stereo_out); if (to) { char *args[] = {"in", "auto", "out", to, NULL, NULL}; if (try_filter(mpctx, params, "stereo3d", "stereo3d", args) < 0) MP_ERR(mpctx, "Can't insert 3D conversion filter.\n"); } } }
void set_playback_speed(struct MPContext *mpctx, double new_speed) { struct MPOpts *opts = mpctx->opts; // Adjust time until next frame flip for nosound mode mpctx->time_frame *= opts->playback_speed / new_speed; opts->playback_speed = new_speed; if (!mpctx->d_audio) return; if (new_speed > 1.0 && opts->pitch_correction) { if (!af_control_any_rev(mpctx->d_audio->afilter, AF_CONTROL_SET_PLAYBACK_SPEED, &new_speed)) { if (try_filter(mpctx, "scaletempo", "playback-speed", NULL) < 0) return; } } else { if (af_remove_by_label(mpctx->d_audio->afilter, "playback-speed") < 0) return; } recreate_audio_filters(mpctx); }