summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-18 13:16:02 +0200
committerwm4 <wm4@nowhere>2013-07-18 13:16:02 +0200
commita012e484dcc7ffc3f2b668774bbaee1d6e0586ad (patch)
tree5f211537209499a64d3243206231896ba84ad3eb /video
parent02528a293348060fe2a13000e547b3767439775d (diff)
downloadmpv-a012e484dcc7ffc3f2b668774bbaee1d6e0586ad.tar.bz2
mpv-a012e484dcc7ffc3f2b668774bbaee1d6e0586ad.tar.xz
vf_scale: try to support all pixel formats
Until now, vf_scale only tried formats listed in the outfmt_list array. Extend this and try every pixel format supported by mpv if trying outfmt_list doesn't lead to success. Also add some checks whether swscale really supports a given input or output format. This was implicitly done with outfmt_list before.
Diffstat (limited to 'video')
-rw-r--r--video/filter/vf_scale.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/video/filter/vf_scale.c b/video/filter/vf_scale.c
index 20277ad554..223c619fef 100644
--- a/video/filter/vf_scale.c
+++ b/video/filter/vf_scale.c
@@ -158,6 +158,14 @@ static int preferred_conversions[][2] = {
{0, 0}
};
+static int check_outfmt(vf_instance_t *vf, int outfmt)
+{
+ enum AVPixelFormat pixfmt = imgfmt2pixfmt(outfmt);
+ if (pixfmt == PIX_FMT_NONE || sws_isSupportedOutput(pixfmt) < 1)
+ return 0;
+ return vf_next_query_format(vf, outfmt);
+}
+
static unsigned int find_best_out(vf_instance_t *vf, int in_format)
{
unsigned int best = 0;
@@ -184,7 +192,8 @@ static unsigned int find_best_out(vf_instance_t *vf, int in_format)
format = outfmt_list[i++];
if (!format)
break;
- ret = vf_next_query_format(vf, format);
+
+ ret = check_outfmt(vf, format);
mp_msg(MSGT_VFILTER, MSGL_DBG2, "scale: query(%s) -> %d\n",
vo_format_name(
@@ -196,6 +205,19 @@ static unsigned int find_best_out(vf_instance_t *vf, int in_format)
if (ret & VFCAP_CSP_SUPPORTED && !best)
best = format; // best with conversion
}
+ if (!best) {
+ // Try anything else. outfmt_list is just a list of preferred formats.
+ for (int format = IMGFMT_START; format < IMGFMT_END; format++) {
+ int ret = check_outfmt(vf, format);
+
+ if (ret & VFCAP_CSP_SUPPORTED_BY_HW) {
+ best = format; // no conversion -> bingo!
+ break;
+ }
+ if (ret & VFCAP_CSP_SUPPORTED && !best)
+ best = format; // best with conversion
+ }
+ }
return best;
}
@@ -480,6 +502,8 @@ error_out:
static int query_format(struct vf_instance *vf, unsigned int fmt)
{
if (!IMGFMT_IS_HWACCEL(fmt) && imgfmt2pixfmt(fmt) != PIX_FMT_NONE) {
+ if (sws_isSupportedInput(imgfmt2pixfmt(fmt)) < 1)
+ return 0;
unsigned int best = find_best_out(vf, fmt);
int flags;
if (!best)