[MPlayer-cvslog] r35076 - in trunk/libmpcodecs: img_format.h vf_scale.c

reimar subversion at mplayerhq.hu
Sun Aug 12 15:24:55 CEST 2012


Author: reimar
Date: Sun Aug 12 15:24:54 2012
New Revision: 35076

Log:
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.

Modified:
   trunk/libmpcodecs/img_format.h
   trunk/libmpcodecs/vf_scale.c

Modified: trunk/libmpcodecs/img_format.h
==============================================================================
--- trunk/libmpcodecs/img_format.h	Sat Aug 11 18:42:43 2012	(r35075)
+++ trunk/libmpcodecs/img_format.h	Sun Aug 12 15:24:54 2012	(r35076)
@@ -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

Modified: trunk/libmpcodecs/vf_scale.c
==============================================================================
--- trunk/libmpcodecs/vf_scale.c	Sat Aug 11 18:42:43 2012	(r35075)
+++ trunk/libmpcodecs/vf_scale.c	Sun Aug 12 15:24:54 2012	(r35076)
@@ -168,15 +168,16 @@ static int preferred_conversions[][2] = 
 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)


More information about the MPlayer-cvslog mailing list