[x265] [PATCH] input/y4m: support all bit depths from 'mono9' to 'mono16' in y4m

Mateusz mateuszb at poczta.onet.pl
Sun Oct 8 10:12:11 CEST 2017


ffmpeg is going to add gray9/10/12 support to y4m.

This patch supports any one digit or two digits number after 'mono' in y4m
-- it works as in 420pXX case.

Please review.

Mateusz

-------------- next part --------------
# HG changeset patch
# User Ma0 <mateuszb at poczta.onet.pl>
# Date 1507448003 -7200
#      Sun Oct 08 09:33:23 2017 +0200
# Node ID 1cbcfc4aae8fe3dc622582da518282df6f89d9a9
# Parent  4b95f82c9fb1f210d31acdd93370bfddbecea828
input/y4m: support all bit depths from 'mono9' to 'mono16' in y4m

diff -r 4b95f82c9fb1 -r 1cbcfc4aae8f source/input/y4m.cpp
--- a/source/input/y4m.cpp	Thu Oct 05 17:25:58 2017 +0530
+++ b/source/input/y4m.cpp	Sun Oct 08 09:33:23 2017 +0200
@@ -307,23 +307,26 @@
                         break;
                 }
 
-                switch (csp)
+                if (csp / 100 == ('m'-'0')*1000 + ('o'-'0')*100 + ('n'-'0')*10 + ('o'-'0'))
                 {
-                case ('m'-'0')*100000 + ('o'-'0')*10000 + ('n'-'0')*1000 + ('o'-'0')*100 + 16:
                     colorSpace = X265_CSP_I400;
-                    depth = 16;
-                    break;
-
-                case ('m'-'0')*1000 + ('o'-'0')*100 + ('n'-'0')*10 + ('o'-'0'):
+                    d = csp % 100;
+                }
+                else if (csp / 10 == ('m'-'0')*1000 + ('o'-'0')*100 + ('n'-'0')*10 + ('o'-'0'))
+                {
                     colorSpace = X265_CSP_I400;
-                    depth = 8;
-                    break;
-                   
-                default:
-                    if (d >= 8 && d <= 16)
-                        depth = d;
+                    d = csp % 10;
+                }
+                else if (csp == ('m'-'0')*1000 + ('o'-'0')*100 + ('n'-'0')*10 + ('o'-'0'))
+                {
+                    colorSpace = X265_CSP_I400;
+                    d = 8;
+                }
+                else
                     colorSpace = (csp == 444) ? X265_CSP_I444 : (csp == 422) ? X265_CSP_I422 : X265_CSP_I420;
-                }
+
+                if (d >= 8 && d <= 16)
+                    depth = d;
                 break;
 
             default:


More information about the x265-devel mailing list