[x264-devel] commit: Change priority handling on some OSs (Steven Walters )
git version control
git at videolan.org
Thu Sep 3 01:11:22 CEST 2009
x264 | branch: master | Steven Walters <kemuri9 at gmail.com> | Wed Sep 2 12:33:50 2009 -0700| [b3efbe51032a0e953140f86423b533b2b6f7101c] | committer: Jason Garrett-Glaser
Change priority handling on some OSs
Instead of setting the lookahead thread to max priority, lower all the other threads' priorities instead.
This is particularly useful when the "max priority" is "realtime", as in Windows, which can cause some problems.
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=b3efbe51032a0e953140f86423b533b2b6f7101c
---
common/osdep.h | 14 +++++++++++++-
encoder/lookahead.c | 16 +---------------
2 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/common/osdep.h b/common/osdep.h
index 9d6a1e6..cb61b14 100644
--- a/common/osdep.h
+++ b/common/osdep.h
@@ -222,9 +222,21 @@ static int ALWAYS_INLINE x264_clz( uint32_t x )
}
#endif
-#if defined(SYS_LINUX) && defined(HAVE_PTHREAD)
+#ifdef USE_REAL_PTHREAD
+#ifdef SYS_MINGW
+#define x264_lower_thread_priority(p)\
+{\
+ x264_pthread_t handle = pthread_self();\
+ struct sched_param sp;\
+ int policy = SCHED_OTHER;\
+ pthread_getschedparam( handle, &policy, &sp );\
+ sp.sched_priority -= p;\
+ pthread_setschedparam( handle, policy, &sp );\
+}
+#else
#include <unistd.h>
#define x264_lower_thread_priority(p) { UNUSED int nice_ret = nice(p); }
+#endif /* USE_REAL_PTHREAD */
#else
#define x264_lower_thread_priority(p)
#endif
diff --git a/encoder/lookahead.c b/encoder/lookahead.c
index 9df0ce3..35ed729 100644
--- a/encoder/lookahead.c
+++ b/encoder/lookahead.c
@@ -153,22 +153,8 @@ int x264_lookahead_init( x264_t *h, int i_slicetype_length )
if( x264_macroblock_cache_init( look_h ) )
goto fail;
- UNUSED x264_pthread_attr_t attr;
- if( x264_pthread_attr_init( &attr ) )
+ if( x264_pthread_create( &look_h->thread_handle, NULL, (void *)x264_lookahead_thread, look_h ) )
goto fail;
-#if defined(USE_REAL_PTHREAD) && !defined(SYS_LINUX)
- int offset = sched_get_priority_max( SCHED_OTHER );
- x264_log( h, X264_LOG_DEBUG, "setting priority of lookahead thread to %d\n", offset );
- struct sched_param sp;
- pthread_attr_getschedparam( &attr, &sp );
- sp.sched_priority = offset;
- pthread_attr_setschedparam( &attr, &sp );
-#endif
-
- if( x264_pthread_create( &look_h->thread_handle, &attr, (void *)x264_lookahead_thread, look_h ) )
- goto fail;
-
- x264_pthread_attr_destroy( &attr );
return 0;
fail:
More information about the x264-devel
mailing list