[x265] CLI: allow monochrome y4m input

Mateusz mateuszb at poczta.onet.pl
Mon Jun 20 19:25:02 CEST 2016


This patch should be applied after patch 13312: https://patches.videolan.org/patch/13312/

# HG changeset patch
# User Ma0 <mateuszb at poczta.onet.pl>
# Date 1466441386 -7200
#      Mon Jun 20 18:49:46 2016 +0200
# Node ID 645b07a14c18436aecb1f75bb75a02d878909656
# Parent  354638efc8f5073881d571df4a3da209534e8502
CLI: allow monochrome y4m input

diff -r 354638efc8f5 -r 645b07a14c18 source/input/y4m.cpp
--- a/source/input/y4m.cpp    Wed May 11 10:07:51 2016 +0200
+++ b/source/input/y4m.cpp    Mon Jun 20 18:49:46 2016 +0200
@@ -296,13 +296,37 @@
                         }
                         break;
                     }
+                    else if (c == 'm')
+                    {
+                        // example: Cmono16
+                        c = fgetc(ifs);
+                        if (c != 'o')
+                            break;
+                        c = fgetc(ifs);
+                        if (c != 'n')
+                            break;
+                        c = fgetc(ifs);
+                        if (c != 'o')
+                            break;
+                        csp = 400;
+                        while (!ferror(ifs))
+                        {
+                            c = fgetc(ifs);
+
+                            if (c <= '9' && c >= '0')
+                                d = d * 10 + (c - '0');
+                            else
+                                break;
+                        }
+                        break;
+                    }
                     else
                         break;
                 }
 
                 if (d >= 8 && d <= 16)
                     depth = d;
-                colorSpace = (csp == 444) ? X265_CSP_I444 : (csp == 422) ? X265_CSP_I422 : X265_CSP_I420;
+                colorSpace = (csp == 444) ? X265_CSP_I444 : (csp == 422) ? X265_CSP_I422 : (csp == 400) ? X265_CSP_I400 : X265_CSP_I420;
                 break;
 
             default:
@@ -324,7 +348,7 @@
     if (width < MIN_FRAME_WIDTH || width > MAX_FRAME_WIDTH ||
         height < MIN_FRAME_HEIGHT || height > MAX_FRAME_HEIGHT ||
         (rateNum / rateDenom) < 1 || (rateNum / rateDenom) > MAX_FRAME_RATE ||
-        colorSpace <= X265_CSP_I400 || colorSpace >= X265_CSP_COUNT)
+        colorSpace < X265_CSP_I400 || colorSpace >= X265_CSP_COUNT)
         return false;
 
     return true;



More information about the x265-devel mailing list