1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 /**
20 * @file
21 * Slice multithreading support functions
22 * @see doc/multithreading.txt
23 */
24
25 #include "config.h"
26
27 #if HAVE_PTHREADS
28 #include <pthread.h>
29 #elif HAVE_W32THREADS
31 #elif HAVE_OS2THREADS
33 #endif
34
39
43
46
56
63
70
71 static void* attribute_align_arg
worker(
void *
v)
72 {
75 unsigned last_execute = 0;
78 int self_id;
79
82 for (;;){
86
90 our_job = self_id;
91
94 return NULL;
95 }
96 }
98
100 c->
func2(avctx, c->
args, our_job, self_id);
101
104 }
105 }
106
108 {
110 int i;
111
116
119
125 }
126
128 {
132 }
133
135 {
137 int dummy_ret;
138
141
142 if (job_count <= 0)
143 return 0;
144
146
152 if (ret) {
155 } else {
156 c->
rets = &dummy_ret;
158 }
161
163
164 return 0;
165 }
166
168 {
172 }
173
175 {
176 int i;
179
180 #if HAVE_W32THREADS
182 #endif
183
184 if (!thread_count) {
188 // use number of cores + 1 as thread count if there is more than one
189 if (nb_cpus > 1)
191 else
193 }
194
195 if (thread_count <= 1) {
197 return 0;
198 }
199
201 if (!c)
202 return -1;
203
207 return -1;
208 }
209
219 for (i=0; i<thread_count; i++) {
224 return -1;
225 }
226 }
227
229
232 return 0;
233 }
234
236 {
239
244 }
245
247 {
250
251 if (!entries || !field) return;
252
254
256 while ((entries[field - 1] - entries[field]) < shift){
258 }
260 }
261
263 {
264 int i;
265
270
273 }
274
278
282 }
283 }
284
285 return 0;
286 }
287
289 {
292 }