changeset 34982:df138f843ebc

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.
author reimar
date Sun, 12 Aug 2012 13:24:54 +0000
parents 3891a9f2f36b
children 0034a2bf7b42
files libmpcodecs/img_format.h libmpcodecs/vf_scale.c
diffstat 2 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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)