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 int warn = 0;
147 warn = 1;
151 warn = !t || !t->
value || !atoi(t->
value) ? 1 : 0;
152 }
153 // huffyuv does not support these with multiple frame threads currently
154 if (warn) {
156 "Forcing thread count to 1 for huffyuv encoding with first pass or context 1\n");
158 }
159 }
160
164 }
165
167 return 0;
168
171
174 if(!c)
176
178
181 goto fail;
182
188
191 void *tmpv;
193 if(!thread_avctx)
194 goto fail;
196 *thread_avctx = *avctx;
202
207 goto fail;
208 }
213 goto fail;
214 }
215 }
216
218
219 return 0;
220 fail:
224 return -1;
225 }
226
228 int i;
230
235
238 }
239
247 }
248
253
255
256 if(frame){
259 if(!new)
264 if(ret<0)
266 new->pts = frame->
pts;
271 frame = new;
272 }
273
275 task.
indata = (
void*)frame;
280
282
284 return 0;
285 }
286
288 return 0;
289
293 }
297 *got_packet_ptr = 1;
301
303 }