1 /*
2 * Copyright (c) 2012 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
22
29
30 #if HAVE_PTHREADS
31 #include <pthread.h>
32 #elif HAVE_W32THREADS
34 #elif HAVE_OS2THREADS
36 #endif
37
38 #define MAX_THREADS 64
39 #define BUFFER_SIZE (2*MAX_THREADS)
40
47
51
55
59
62
66
67 static void * attribute_align_arg
worker(
void *
v){
71
76
78 if(!pkt) continue;
80
86 }
88 }
92
98 if(got_packet) {
100 } else {
103 }
109 }
116 return NULL;
117 }
118
120 int i=0;
122
123
126 return 0;
127
132 "Forcing thread count to 1 for MJPEG encoding, use -thread_type slice "
133 "or a constant quantizer if you want to use multiple cpu cores\n");
135 }
140 "MJPEG CBR encoding works badly with frame multi-threading, consider "
141 "using -threads 1, -thread_type slice or a constant quantizer.\n");
142
145 // huffyuv does not support these with multiple frame threads currently
148 "Forcing thread count to 1 for huffyuv encoding with first pass or context 1\n");
150 }
151 }
152
156 }
157
159 return 0;
160
163
166 if(!c)
168
170
173 goto fail;
174
180
183 void *tmpv;
185 if(!thread_avctx)
186 goto fail;
188 *thread_avctx = *avctx;
194
199 goto fail;
200 }
205 goto fail;
206 }
207 }
208
210
211 return 0;
212 fail:
216 return -1;
217 }
218
220 int i;
222
227
230 }
231
239 }
240
245
247
248 if(frame){
251 if(!new)
256 if(ret<0)
258 new->pts = frame->
pts;
263 frame = new;
264 }
265
267 task.
indata = (
void*)frame;
272
274
276 return 0;
277 }
278
280 return 0;
281
285 }
289 *got_packet_ptr = 1;
293
295 }