Fix crash in --fullhelp when compiled against recent ffmpeg
authorAnton Mitrofanov <BugMaster@narod.ru>
Wed, 7 Dec 2011 15:14:52 +0000 (19:14 +0400)
committerJason Garrett-Glaser <jason@x264.com>
Thu, 8 Dec 2011 00:37:50 +0000 (16:37 -0800)
Don't assume all pixel formats have a description.

x264.c

diff --git a/x264.c b/x264.c
index 54359c6..35b1f10 100644 (file)
--- a/x264.c
+++ b/x264.c
@@ -350,19 +350,22 @@ static void print_csp_names( int longhelp )
     size_t line_len = strlen( INDENT );
     for( enum PixelFormat i = PIX_FMT_NONE+1; i < PIX_FMT_NB; i++ )
     {
-        const char *pfname = av_pix_fmt_descriptors[i].name;
-        size_t name_len = strlen( pfname );
-        if( line_len + name_len > (80 - strlen( ", " )) )
+        const char *pfname = av_get_pix_fmt_name( i );
+        if( pfname )
         {
-            printf( "\n" INDENT );
-            line_len = strlen( INDENT );
-        }
-        printf( "%s", pfname );
-        line_len += name_len;
-        if( i+1 < PIX_FMT_NB )
-        {
-            printf( ", " );
-            line_len += 2;
+            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 < PIX_FMT_NB )
+            {
+                printf( ", " );
+                line_len += 2;
+            }
         }
     }
 #endif