~siretart/x264/trunk

« back to all changes in this revision

Viewing changes to common/osdep.h

  • Committer: Fiona Glaser
  • Author(s): Steven Walters
  • Date: 2009-09-02 04:06:20 UTC
  • Revision ID: git-v1:6940dcaef140d8a0c43c9a62db158e9d71a8fdeb
Threaded lookahead
Move lookahead into a separate thread, set to higher priority than the other threads, for optimal performance.
Reduces the amount that lookahead bottlenecks encoding, greatly increasing performance with lookahead-intensive settings (e.g. b-adapt 2) on many-core CPUs.
Buffer size can be controlled with --sync-lookahead, which defaults to auto (threads+bframes buffer size).
Note that this buffer is separate from the rc-lookahead value.
Note also that this does not split lookahead itself into multiple threads yet; this may be added in the future.
Additionally, split frames into "fdec" and "fenc" frame types and keep the two separate.
This split greatly reduces memory usage, which helps compensate for the larger lookahead size.
Extremely special thanks to Michael Kazmier and Alex Giladi of Avail Media, the original authors of this patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
#define x264_pthread_cond_destroy    pthread_cond_destroy
138
138
#define x264_pthread_cond_broadcast  pthread_cond_broadcast
139
139
#define x264_pthread_cond_wait       pthread_cond_wait
 
140
#define x264_pthread_attr_t          pthread_attr_t
 
141
#define x264_pthread_attr_init       pthread_attr_init
 
142
#define x264_pthread_attr_destroy    pthread_attr_destroy
140
143
#else
141
144
#define x264_pthread_mutex_t         int
142
145
#define x264_pthread_mutex_init(m,f) 0
148
151
#define x264_pthread_cond_destroy(c)
149
152
#define x264_pthread_cond_broadcast(c)
150
153
#define x264_pthread_cond_wait(c,m)
 
154
#define x264_pthread_attr_t          int
 
155
#define x264_pthread_attr_init(a)    0
 
156
#define x264_pthread_attr_destroy(a)
151
157
#endif
152
158
 
153
159
#define WORD_SIZE sizeof(void*)
216
222
}
217
223
#endif
218
224
 
 
225
#if defined(SYS_LINUX) && defined(HAVE_PTHREAD)
 
226
#include <unistd.h>
 
227
#define x264_lower_thread_priority(p) { UNUSED int nice_ret = nice(p); }
 
228
#else
 
229
#define x264_lower_thread_priority(p)
 
230
#endif
 
231
 
219
232
#endif /* X264_OSDEP_H */