[x264-devel] CLI: Avoid redundant 16-bit upconversions in piped raw input
Henrik Gramner
git at videolan.org
Tue Jan 21 22:51:25 CET 2014
x264 | branch: master | Henrik Gramner <henrik at gramner.com> | Fri Dec 20 22:44:28 2013 +0100| [e8358911cdebf0ee49fe165190aea02bf4bee6e4] | committer: Jason Garrett-Glaser
CLI: Avoid redundant 16-bit upconversions in piped raw input
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.
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=e8358911cdebf0ee49fe165190aea02bf4bee6e4
---
input/raw.c | 8 ++++----
input/y4m.c | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/input/raw.c b/input/raw.c
index 3213435..9d21c59 100644
--- a/input/raw.c
+++ b/input/raw.c
@@ -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;
diff --git a/input/y4m.c b/input/y4m.c
index da8f980..bf62e83 100644
--- a/input/y4m.c
+++ b/input/y4m.c
@@ -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;
More information about the x264-devel
mailing list