# HG changeset patch # User reimar # Date 1344777894 0 # Node ID df138f843ebc90c2cf4b5d5c325f13f60c55a0a5 # Parent 3891a9f2f36bc9025da600bbdd5011aecf108df8 Prefer converting 9/10 bit formats to 16 bit, this is a simple left-shift. Should make -vo gl behave nicer/run faster for cases where 9/10 bit is not supported. Only some old r200 class cards running on little-endian could still have issues with 16-bit YUV and I neither have an idea nor hardware to improve this. diff -r 3891a9f2f36b -r df138f843ebc libmpcodecs/img_format.h --- a/libmpcodecs/img_format.h Sat Aug 11 16:42:43 2012 +0000 +++ b/libmpcodecs/img_format.h Sun Aug 12 13:24:54 2012 +0000 @@ -215,6 +215,18 @@ #define IMGFMT_IS_YUVP16_BE(fmt) (((fmt - 0x34000051) & 0xff0000fc) == 0) #define IMGFMT_IS_YUVP16(fmt) (IMGFMT_IS_YUVP16_LE(fmt) || IMGFMT_IS_YUVP16_BE(fmt)) +/** + * \brief Find the corresponding full 16 bit format, i.e. IMGFMT_420P10_LE -> IMGFMT_420P16_LE + * \return normalized format ID or 0 if none exists. + */ +static inline int normalize_yuvp16(int fmt) { + if (IMGFMT_IS_YUVP16_LE(fmt)) + return (fmt & 0x00ffffff) | 0x51000000; + if (IMGFMT_IS_YUVP16_LE(fmt)) + return (fmt & 0xffffff00) | 0x00000051; + return 0; +} + /* Packed YUV Formats */ #define IMGFMT_IUYV 0x56595549 // Interlaced UYVY diff -r 3891a9f2f36b -r df138f843ebc libmpcodecs/vf_scale.c --- a/libmpcodecs/vf_scale.c Sat Aug 11 16:42:43 2012 +0000 +++ b/libmpcodecs/vf_scale.c Sun Aug 12 13:24:54 2012 +0000 @@ -168,15 +168,16 @@ static unsigned int find_best_out(vf_instance_t *vf, int in_format){ unsigned int best=0; int i = -1; - int j = -1; + int normalized_format = normalize_yuvp16(in_format); + int j = normalized_format ? -2 : -1; int format = 0; // find the best outfmt: while (1) { int ret; if (j < 0) { - format = in_format; - j = 0; + format = j == -1 && normalized_format ? normalized_format : in_format; + j++; } else if (i < 0) { while (preferred_conversions[j][0] && preferred_conversions[j][0] != in_format)