]> git.sesse.net Git - x264/commitdiff
CLI: Avoid redundant 16-bit upconversions in piped raw input
authorHenrik Gramner <henrik@gramner.com>
Fri, 20 Dec 2013 21:44:28 +0000 (22:44 +0100)
committerFiona Glaser <fiona@x264.com>
Wed, 8 Jan 2014 19:15:44 +0000 (11:15 -0800)
It's not possible to seek in pipes, so if we want to skip frames we have to read and
discard unused ones. It's pointless to do bit-depth upconversions in those frames.

input/raw.c
input/y4m.c

index 32134358c7eac00e0656225be8fd93220f3f255b..9d21c5965a63c8f4115cf8fbd542fffd24f276e2 100644 (file)
@@ -99,14 +99,14 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
     return 0;
 }
 
-static int read_frame_internal( cli_pic_t *pic, raw_hnd_t *h )
+static int read_frame_internal( cli_pic_t *pic, raw_hnd_t *h, int bit_depth_uc )
 {
     int error = 0;
     int pixel_depth = x264_cli_csp_depth_factor( pic->img.csp );
     for( int i = 0; i < pic->img.planes && !error; i++ )
     {
         error |= fread( pic->img.plane[i], pixel_depth, h->plane_size[i], h->fh ) != h->plane_size[i];
-        if( h->bit_depth & 7 )
+        if( bit_depth_uc )
         {
             /* upconvert non 16bit high depth planes to 16bit using the same
              * algorithm as used in the depth filter. */
@@ -131,13 +131,13 @@ static int read_frame( cli_pic_t *pic, hnd_t handle, int i_frame )
         else
             while( i_frame > h->next_frame )
             {
-                if( read_frame_internal( pic, h ) )
+                if( read_frame_internal( pic, h, 0 ) )
                     return -1;
                 h->next_frame++;
             }
     }
 
-    if( read_frame_internal( pic, h ) )
+    if( read_frame_internal( pic, h, h->bit_depth & 7 ) )
         return -1;
 
     h->next_frame = i_frame+1;
index da8f980384d87ace2fe689b4dfaa80e6623de21c..bf62e8376991ed92f4837dbd24b8d15afc077876 100644 (file)
@@ -223,7 +223,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
     return 0;
 }
 
-static int read_frame_internal( cli_pic_t *pic, y4m_hnd_t *h )
+static int read_frame_internal( cli_pic_t *pic, y4m_hnd_t *h, int bit_depth_uc )
 {
     size_t slen = strlen( Y4M_FRAME_MAGIC );
     int pixel_depth = x264_cli_csp_depth_factor( pic->img.csp );
@@ -249,7 +249,7 @@ static int read_frame_internal( cli_pic_t *pic, y4m_hnd_t *h )
     for( i = 0; i < pic->img.planes && !error; i++ )
     {
         error |= fread( pic->img.plane[i], pixel_depth, h->plane_size[i], h->fh ) != h->plane_size[i];
-        if( h->bit_depth & 7 )
+        if( bit_depth_uc )
         {
             /* upconvert non 16bit high depth planes to 16bit using the same
              * algorithm as used in the depth filter. */
@@ -274,13 +274,13 @@ static int read_frame( cli_pic_t *pic, hnd_t handle, int i_frame )
         else
             while( i_frame > h->next_frame )
             {
-                if( read_frame_internal( pic, h ) )
+                if( read_frame_internal( pic, h, 0 ) )
                     return -1;
                 h->next_frame++;
             }
     }
 
-    if( read_frame_internal( pic, h ) )
+    if( read_frame_internal( pic, h, h->bit_depth & 7 ) )
         return -1;
 
     h->next_frame = i_frame+1;