summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-01-23 19:00:09 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-01-23 19:00:09 +0000
commitcbcae4856c9693952e32d5239eb1f1e8e811473e (patch)
tree4cafe4a6cf5dfff6d0e2dcf37417f703ed22e792
parent86f1430a590e1f017556a94281a9f81aef4413cf (diff)
downloadmpv-cbcae4856c9693952e32d5239eb1f1e8e811473e.tar.bz2
mpv-cbcae4856c9693952e32d5239eb1f1e8e811473e.tar.xz
Make the scale filter prefer yuv conversions that do not need chroma scaling.
Also always try keeping input and output format the same first. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30409 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--libmpcodecs/vf_scale.c48
1 files changed, 41 insertions, 7 deletions
diff --git a/libmpcodecs/vf_scale.c b/libmpcodecs/vf_scale.c
index 4bc32fc442..ec18aa82fe 100644
--- a/libmpcodecs/vf_scale.c
+++ b/libmpcodecs/vf_scale.c
@@ -94,14 +94,48 @@ static unsigned int outfmt_list[]={
0
};
-static unsigned int find_best_out(vf_instance_t *vf){
+/**
+ * A list of preferred conversions, in order of preference.
+ * This should be used for conversions that e.g. involve no scaling
+ * or to stop vf_scale from choosing a conversion that has no
+ * fast assembler implementation.
+ */
+static int preferred_conversions[][2] = {
+ {IMGFMT_YUY2, IMGFMT_UYVY},
+ {IMGFMT_YUY2, IMGFMT_422P},
+ {IMGFMT_UYVY, IMGFMT_YUY2},
+ {IMGFMT_UYVY, IMGFMT_422P},
+ {IMGFMT_422P, IMGFMT_YUY2},
+ {IMGFMT_422P, IMGFMT_UYVY},
+ {0, 0}
+};
+
+static unsigned int find_best_out(vf_instance_t *vf, int in_format){
unsigned int best=0;
- int i;
+ int i = -1;
+ int j = -1;
+ int format = 0;
// find the best outfmt:
- for(i=0; outfmt_list[i]; i++){
- const int format= outfmt_list[i];
- int ret = vf_next_query_format(vf, format);
+ while (1) {
+ int ret;
+ if (j < 0) {
+ format = in_format;
+ j = 0;
+ } else if (i < 0) {
+ while (preferred_conversions[j][0] &&
+ preferred_conversions[j][0] != in_format)
+ j++;
+ format = preferred_conversions[j++][1];
+ // switch to standard list
+ if (!format)
+ i = 0;
+ }
+ if (i >= 0)
+ format = outfmt_list[i++];
+ if (!format)
+ break;
+ ret = vf_next_query_format(vf, format);
mp_msg(MSGT_VFILTER,MSGL_DBG2,"scale: query(%s) -> %d\n",vo_format_name(format),ret&3);
if(ret&VFCAP_CSP_SUPPORTED_BY_HW){
@@ -117,7 +151,7 @@ static unsigned int find_best_out(vf_instance_t *vf){
static int config(struct vf_instance_s* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
- unsigned int best=find_best_out(vf);
+ unsigned int best=find_best_out(vf, outfmt);
int vo_flags;
int int_sws_flags=0;
int round_w=0, round_h=0;
@@ -490,7 +524,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){
case IMGFMT_RGB48LE:
case IMGFMT_RGB48BE:
{
- unsigned int best=find_best_out(vf);
+ unsigned int best=find_best_out(vf, fmt);
int flags;
if(!best) return 0; // no matching out-fmt
flags=vf_next_query_format(vf,best);