diff options
author | wm4 <wm4@nowhere> | 2016-05-30 20:01:44 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-05-30 20:03:01 +0200 |
commit | 9009601c2d3b2a6d7806d63346c900e0a4c9e2ca (patch) | |
tree | 4ce07777136de65ec20ba405e2531fb40d312777 /video/filter | |
parent | 4853eca8c619dfc9a942d250add5ecc22ceafa90 (diff) | |
download | mpv-9009601c2d3b2a6d7806d63346c900e0a4c9e2ca.tar.bz2 mpv-9009601c2d3b2a6d7806d63346c900e0a4c9e2ca.tar.xz |
vf: fix filter auto-insertion
Commit 0348cd08 was too naive/simple, and always inserted the d3d11vpp
filter if any d3d11 output image formats were supported, even if it
makes no sense. For example --vf=format=rgb8 already breaks it.
It needs to take the set of supported input formats into account. the
weird format negotiation makes this hard. As a simple and cheap
solution, make some assumptions about the supported formats of a filter.
I hope to simplify this one day by using another format negotiation
algorithm, but this can probably wait.
Diffstat (limited to 'video/filter')
-rw-r--r-- | video/filter/vf.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/video/filter/vf.c b/video/filter/vf.c index b59dcca76b..176ac95b70 100644 --- a/video/filter/vf.c +++ b/video/filter/vf.c @@ -521,13 +521,13 @@ static bool is_conv_filter(struct vf_instance *vf) return vf && (strcmp(vf->info->name, "scale") == 0 || vf->autoinserted); } -static const char *find_conv_filter(uint8_t *fmts_out) +static const char *find_conv_filter(uint8_t *fmts_in, uint8_t *fmts_out) { for (int n = 0; filter_list[n]; n++) { if (filter_list[n]->test_conversion) { for (int a = IMGFMT_START; a < IMGFMT_END; a++) { for (int b = IMGFMT_START; b < IMGFMT_END; b++) { - if (fmts_out[b - IMGFMT_START] && + if (fmts_in[a - IMGFMT_START] && fmts_out[b - IMGFMT_START] && filter_list[n]->test_conversion(a, b)) return filter_list[n]->name; } @@ -555,7 +555,17 @@ static void update_formats(struct vf_chain *c, struct vf_instance *vf, // filters after vf work, but vf can't output any format the filters // after it accept), try to insert a conversion filter. MP_INFO(c, "Using conversion filter.\n"); - const char *filter = find_conv_filter(vf->last_outfmts); + // Determine which output formats the filter _could_ accept. For this + // to work after the conversion filter is inserted, it is assumed that + // conversion filters have a single set of in/output formats that can + // be converted to each other. + uint8_t out_formats[IMGFMT_END - IMGFMT_START]; + for (int n = IMGFMT_START; n < IMGFMT_END; n++) { + out_formats[n - IMGFMT_START] = vf->last_outfmts[n - IMGFMT_START]; + vf->last_outfmts[n - IMGFMT_START] = 1; + } + query_formats(fmts, vf); + const char *filter = find_conv_filter(fmts, out_formats); struct vf_instance *conv = vf_open(c, filter, NULL); if (conv) { conv->autoinserted = true; |