// Extremely stupid; can be dropped when the internal filter is dropped, // and OPT_CHOICE_C() can be used instead. static int opt_to_stereo3dmode(int val) { // Find x for name == MP_STEREO3D_NAME(x) const char *name = m_opt_choice_str(stereo_code_names, val); for (int n = 0; n < MP_STEREO3D_COUNT; n++) { const char *o = MP_STEREO3D_NAME(val); if (name && o && strcmp(o, name) == 0) return n; } return MP_STEREO3D_INVALID; }
// 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"); } } }
static int lavfi_reconfig(struct vf_instance *vf, struct mp_image_params *in, struct mp_image_params *out) { struct vf_priv_s *p = vf_lw_old_priv(vf); if (p->auto_in) { const char *inf = MP_STEREO3D_NAME(in->stereo_in); if (!inf) { MP_ERR(vf, "Unknown/unsupported 3D mode.\n"); return -1; } vf_lw_update_graph(vf, "stereo3d", "%s:%s", inf, m_opt_choice_str(stereo_code_names, p->out_fmt)); out->stereo_in = out->stereo_out = opt_to_stereo3dmode(p->out_fmt); } return 0; }