[x264-devel] Limit autodetection of threads number according to the source height
Anton Mitrofanov
git at videolan.org
Sun Jul 26 22:26:33 CEST 2015
x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Fri Jul 17 00:22:29 2015 +0300| [9140ee1fb39bd4a4ccace28091398e8a96704f07] | committer: Henrik Gramner
Limit autodetection of threads number according to the source height
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=9140ee1fb39bd4a4ccace28091398e8a96704f07
---
encoder/encoder.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/encoder/encoder.c b/encoder/encoder.c
index 4450d70..7e946bf 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -537,7 +537,13 @@ static int x264_validate_parameters( x264_t *h, int b_open )
}
if( h->param.i_threads == X264_THREADS_AUTO )
+ {
h->param.i_threads = x264_cpu_num_processors() * (h->param.b_sliced_threads?2:3)/2;
+ /* Avoid too many threads as they don't improve performance and
+ * complicate VBV. Capped at an arbitrary 2 rows per thread. */
+ int max_threads = X264_MAX( 1, (h->param.i_height+15)/16 / 2 );
+ h->param.i_threads = X264_MIN( h->param.i_threads, max_threads );
+ }
int max_sliced_threads = X264_MAX( 1, (h->param.i_height+15)/16 / 4 );
if( h->param.i_threads > 1 )
{
More information about the x264-devel
mailing list