]> granicus.if.org Git - libx264/commitdiff
cli: Improve the --fullhelp raw demuxer input-csp listing
authorHenrik Gramner <henrik@gramner.com>
Sun, 29 Jan 2017 21:58:24 +0000 (22:58 +0100)
committerHenrik Gramner <henrik@gramner.com>
Sun, 21 May 2017 20:41:06 +0000 (22:41 +0200)
Use the same logic for indentation as the lavf demuxer.

x264.c

diff --git a/x264.c b/x264.c
index 41f94e441d162d6ab341578e651672e36cf50b02..93f2d5813b2046984dbbfa47387bbb4476dfd40d 100644 (file)
--- a/x264.c
+++ b/x264.c
@@ -420,47 +420,47 @@ static char *stringify_names( char *buf, const char * const names[] )
     return buf;
 }
 
+#define INDENT "                                "
+#define INDENT_LEN 32 // strlen( INDENT )
+#define SEPARATOR ", "
+#define SEPARATOR_LEN 2 // strlen( SEPARATOR )
+
+static void print_csp_name_internal( const char *name, size_t *line_len, int last )
+{
+    if( name )
+    {
+        size_t name_len = strlen( name );
+        if( *line_len + name_len > (80 - SEPARATOR_LEN) )
+        {
+            printf( "\n" INDENT );
+            *line_len = INDENT_LEN;
+        }
+        printf( "%s", name );
+        *line_len += name_len;
+        if( !last )
+        {
+            printf( SEPARATOR );
+            *line_len += SEPARATOR_LEN;
+        }
+    }
+}
+
 static void print_csp_names( int longhelp )
 {
     if( longhelp < 2 )
         return;
-#   define INDENT "                                "
     printf( "                              - valid csps for `raw' demuxer:\n" );
     printf( INDENT );
+    size_t line_len = INDENT_LEN;
     for( int i = X264_CSP_NONE+1; i < X264_CSP_CLI_MAX; i++ )
-    {
-        if( x264_cli_csps[i].name )
-        {
-            printf( "%s", x264_cli_csps[i].name );
-            if( i+1 < X264_CSP_CLI_MAX )
-                printf( ", " );
-        }
-    }
+        print_csp_name_internal( x264_cli_csps[i].name, &line_len, i == X264_CSP_CLI_MAX-1 );
 #if HAVE_LAVF
     printf( "\n" );
     printf( "                              - valid csps for `lavf' demuxer:\n" );
     printf( INDENT );
-    size_t line_len = strlen( INDENT );
+    line_len = INDENT_LEN;
     for( enum AVPixelFormat i = AV_PIX_FMT_NONE+1; i < AV_PIX_FMT_NB; i++ )
-    {
-        const char *pfname = av_get_pix_fmt_name( i );
-        if( pfname )
-        {
-            size_t name_len = strlen( pfname );
-            if( line_len + name_len > (80 - strlen( ", " )) )
-            {
-                printf( "\n" INDENT );
-                line_len = strlen( INDENT );
-            }
-            printf( "%s", pfname );
-            line_len += name_len;
-            if( i+1 < AV_PIX_FMT_NB )
-            {
-                printf( ", " );
-                line_len += 2;
-            }
-        }
-    }
+        print_csp_name_internal( av_get_pix_fmt_name( i ), &line_len, i == AV_PIX_FMT_NB-1 );
 #endif
     printf( "\n" );
 }
@@ -636,7 +636,7 @@ static void help( x264_param_t *defaults, int longhelp )
         "                                  - grain (psy tuning):\n"
         "                                    --aq-strength 0.5 --no-dct-decimate\n"
         "                                    --deadzone-inter 6 --deadzone-intra 6\n"
-        "                                    --deblock -2:-2 --ipratio 1.1 \n"
+        "                                    --deblock -2:-2 --ipratio 1.1\n"
         "                                    --pbratio 1.1 --psy-rd <unset>:0.25\n"
         "                                    --qcomp 0.8\n"
         "                                  - stillimage (psy tuning):\n"