[x264-devel] commit: Ignore XYSCSS in y4m if the newer standard C tag is present ( David Conrad )

git at videolan.org git at videolan.org
Sun Mar 28 04:44:18 CEST 2010


x264 | branch: master | David Conrad <lessen42 at gmail.com> | Sun Feb 28 20:34:09 2010 -0500| [279c9d9dd90f18f229719ba09c4fab33f87b3f16] | committer: Jason Garrett-Glaser 

Ignore XYSCSS in y4m if the newer standard C tag is present

Apparently y4mscaler will generate 4:2:0 files with XYSCSS set to 444

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=279c9d9dd90f18f229719ba09c4fab33f87b3f16
---

 input/y4m.c |   35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/input/y4m.c b/input/y4m.c
index 8645ff7..3e9c9aa 100644
--- a/input/y4m.c
+++ b/input/y4m.c
@@ -43,6 +43,8 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
     int  i, n, d;
     char header[MAX_YUV4_HEADER+10];
     char *tokstart, *tokend, *header_end;
+    int colorspace = X264_CSP_NONE;
+    int alt_colorspace = X264_CSP_NONE;
     if( !h )
         return -1;
 
@@ -92,11 +94,10 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
                 tokstart=tokend;
                 break;
             case 'C': /* Color space */
-                if( strncmp( "420", tokstart, 3 ) )
-                {
-                    fprintf( stderr, "y4m [error]: colorspace unhandled\n" );
-                    return -1;
-                }
+                if( !strncmp( "420", tokstart, 3 ) )
+                    colorspace = X264_CSP_I420;
+                else
+                    colorspace = X264_CSP_MAX;      ///< anything other than 420 since we don't handle it
                 tokstart = strchr( tokstart, 0x20 );
                 break;
             case 'I': /* Interlace type */
@@ -135,19 +136,29 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
                 {
                     /* Older nonstandard pixel format representation */
                     tokstart += 6;
-                    if( strncmp( "420JPEG",tokstart, 7 ) &&
-                        strncmp( "420MPEG2",tokstart, 8 ) &&
-                        strncmp( "420PALDV",tokstart, 8 ) )
-                    {
-                        fprintf( stderr, "y4m [error]: unsupported extended colorspace\n" );
-                        return -1;
-                    }
+                    if( !strncmp( "420",tokstart, 3 ) )
+                        alt_colorspace = X264_CSP_I420;
+                    else
+                        alt_colorspace = X264_CSP_MAX;
                 }
                 tokstart = strchr( tokstart, 0x20 );
                 break;
         }
     }
 
+    if( colorspace == X264_CSP_NONE )
+        colorspace = alt_colorspace;
+
+    // default to 4:2:0 if nothing is specified
+    if( colorspace == X264_CSP_NONE )
+        colorspace = X264_CSP_I420;
+
+    if( colorspace != X264_CSP_I420 )
+    {
+        fprintf( stderr, "y4m [error]: colorspace unhandled\n" );
+        return -1;
+    }
+
     *p_handle = h;
     return 0;
 }



More information about the x264-devel mailing list