Anton Khirnov
cc14ee03a7
lavc: split slice and frame threading functions into separate files
11 years ago
Anton Khirnov
5cd6513f5b
pthread: drop avcodec_ prefixes from static functions
11 years ago
Anton Khirnov
a1504eee41
lavc: deprecate AVCodecContext.debug_mv
...
It has been unused since 37045e4229
.
11 years ago
Mickaël Raulet
e146c326b9
avcodec/pthread: add wpp api
...
cherry picked from commit c7765f3295fe7dc0653161c6a3d3e1778b76ee67
cherry picked from commit 0008c4979fc1d1bc24d4d2c791715f6dd017563c
Conflicts:
libavcodec/utils.c
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11 years ago
Ben Jackson
5152196b2b
pthread: Avoid spurious wakeups
...
pthread_wait_cond can wake up unexpectedly (Wikipedia: Spurious_wakeup).
The FF_THREAD_SLICE thread mechanism could spontaneously execute
jobs or allow the caller of avctx->execute to return before all
jobs were complete.
Test both cases to ensure the wakeup is real.
Signed-off-by: Ben Jackson <ben@ben.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
11 years ago
Derek Buitenhuis
eb90a2091f
pthread: Fix deadlock during thread initialization
...
Sometimes, if pthread_create() failed, then pthread_cond_wait() could
accidentally be called in the worker threads after the uninit function
had already called pthread_cond_broadcast(), leading to a deadlock.
Don't call pthread_cond_wait() if c->done is set.
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
11 years ago
Diego Biurrun
7950e519bb
Disable deprecation warnings for cases where a replacement is available
12 years ago
Sean McGovern
50612484e0
pthread: Rename thread_init to avoid symbol collision
...
The AIX threads library exposes a function with the same name.
Signed-off-by: Martin Storsjö <martin@martin.st>
12 years ago
Carl Eugen Hoyos
674d8a9629
Rename thread_init() in libavcodec and libavfilter as library_thread_init().
...
The aix header sys/thread.h contains a definition for thread_init().
12 years ago
Paul B Mahol
d5f7f1fef1
audio frame multi-threaded decoding
...
Signed-off-by: Paul B Mahol <onemda@gmail.com>
12 years ago
Dave Yeo
e615a77799
os2threads: move from lavc to compat/
...
For useage in other places besides lavc. Needed after commit
90f9a5830b
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12 years ago
Michael Niedermayer
4cf7b87551
av_cpu_count: factorize "detected %d logical cores" message
...
Also print the message just once
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12 years ago
Michael Niedermayer
42bb3e4db6
avcodec: remove ff_get_logical_cpus()
...
This simplifies the code
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12 years ago
Anton Khirnov
2a6eaeaa85
Move get_logical_cpus() from lavc/pthread to lavu/cpu.
...
It will be useful in lavfi, and could conceivably be useful to the user
applications as well.
12 years ago
Anton Khirnov
90f9a5830b
w32pthreads: move from lavc to compat/
...
It will be used in other places than lavc.
12 years ago
Anton Khirnov
db8e336e5f
pthread: reindent
12 years ago
Anton Khirnov
30e256430e
lavc/pthread: remove obsolete checks
...
Those were useful when avcodec_thread_init() was a public functions. It
was deprecated and removed some time ago, so those checks are not needed
anymore.
12 years ago
Michael Niedermayer
ab074ab9fe
avcodec/pthread: fix ffv1 with 2 threads
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12 years ago
Michael Niedermayer
a0c0900e47
ffv1dec: Support frame threading with gop > 1
...
This is about 20-30% faster than slice threading
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12 years ago
Michael Niedermayer
8f0db04b08
avcodec/pthread: use THREAD_SAFE_CALLBACKS() to simplifx more code
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12 years ago
Michael Niedermayer
94b3a666fa
avcodec/pthread: Make sure ff_thread_finish_setup() conditions match
...
Prevents warning from being shown due to multiple calls.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12 years ago
Janne Grunau
94660c3524
threads: always call thread_finish_setup for intra codecs
...
Intra codecs do not need an update_thread_context() function and never
call ff_thread_finish_setup(). They rely on ff_thread_get_buffer()
calling it. So call it even if the get_buffer2 function pointer is
avcodec_default_get_buffer2 and it has not been called before.
12 years ago
Reimar Döffinger
c10d498bfd
Add thread-safe wrapper for get_format().
...
Just like get_buffer, get_format should not be called from a different
thread if thread_safe_callbacks is not set.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
12 years ago
Janne Grunau
05fa79b844
hwaccel: fix use with frame based multithreading
...
Allows use of AVHWAccel based decoders with frame based multithreading.
The decoders will be forced into an non-concurrent mode by delaying
ff_thread_finish_setup() calls after decoding of the current frame
is finished.
This wastes memory by unnecessarily using multiple threads and thus
copies of the decoder context but allows seamless switching between
hardware accelerated and frame threaded software decoding when the
hardware decoder does not support the stream.
12 years ago
Hendrik Leppkes
c71c80f53b
pthread: unref already decoded frames when flushing the decoder
...
Signed-off-by: Anton Khirnov <anton@khirnov.net>
12 years ago
Hendrik Leppkes
97f8c6e147
pthread: update all get_buffer checks for get_buffer2
...
This restores the performance of simple frame-threaded codecs back to
their pre-merge levels.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12 years ago
Clément Bœsch
1ec94b0f06
lavc: factorize ff_{thread_,re,}get_buffer error messages.
...
Coccinelle profile used:
@@
expression r, ctx, f, loglevel, str, flags;
@@
-if ((r = ff_get_buffer(ctx, f, flags)) < 0) {
- av_log(ctx, loglevel, str);
- return r;
-}
+if ((r = ff_get_buffer(ctx, f, flags)) < 0)
+ return r;
@@
expression r, ctx, f, loglevel, str;
@@
-if ((r = ff_reget_buffer(ctx, f)) < 0) {
- av_log(ctx, loglevel, str);
- return r;
-}
+if ((r = ff_reget_buffer(ctx, f)) < 0)
+ return r;
@@
expression r, ctx, f, loglevel, str, flags;
@@
-if ((r = ff_thread_get_buffer(ctx, f, flags)) < 0) {
- av_log(ctx, loglevel, str);
- return r;
-}
+if ((r = ff_thread_get_buffer(ctx, f, flags)) < 0)
+ return r;
...along with some manual patches for the remaining ones.
12 years ago
Michael Niedermayer
6b6b0e9dae
pthread: fix unused variable warning
12 years ago
Anton Khirnov
fce68c9355
pthread: unref the decoded but not returned frames on close.
...
Fixes memleaks when frame mt is used and the decoder is not flushed at
the end.
12 years ago
Anton Khirnov
759001c534
lavc decoders: work with refcounted frames.
12 years ago
Anton Khirnov
1a5e913016
pthread: avoid copying input packets when possible.
12 years ago
Anton Khirnov
e6b1c3bbe7
pthread: make ff_thread_release_buffer idempotent.
...
I.e. don't do anything on already released frames.
12 years ago
Michael Niedermayer
a6e4796fbf
pthread: Do not use a half updated context as master for deallocation.
...
Fixes assertion failure
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12 years ago
Clément Bœsch
98dc25672f
lavc/pthread: do not re-define _GNU_SOURCE if already defined.
...
This fixes the following warning with GCC:
libavcodec/pthread.c:35:0: warning: _GNU_SOURCE redefined [enabled by default]
<command-line>::0: note: this is the location of the previous definition
The reason of the presence of this flag is:
% pkg-config --cflags sdl
-D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL
12 years ago
Anton Khirnov
594d4d5df3
lavc: add a wrapper for AVCodecContext.get_buffer().
...
It will be useful in the upcoming transition to refcounted AVFrames.
12 years ago
Michael Niedermayer
ebf4750200
pthreads: increase MAX_BUFFERS due to 24c043c98e
...
This might fix a hypothetical memleak
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12 years ago
Anton Khirnov
7a1a9dd56c
pthread: make sure AVFrame.extended_data is set properly.
...
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
12 years ago
Ben Jackson
e3329474a3
pthread: Avoid crashes/odd behavior caused by spurious wakeups
...
pthread_wait_cond can wake up for no reason (Wikipedia: Spurious_wakeup).
The FF_THREAD_SLICE thread mechanism could spontaneously execute jobs or
allow the caller of avctx->execute to return before all jobs were complete.
This adds tests to both cases to ensure the wakeup is real.
Signed-off-by: Ben Jackson <ben@ben.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12 years ago
Mans Rullgard
11434c9b13
pthread: add const to AVCodec pointers
...
Signed-off-by: Mans Rullgard <mans@mansr.com>
13 years ago
Martin Storsjö
1d9c2dc89a
Don't include common.h from avutil.h
...
Signed-off-by: Martin Storsjö <martin@martin.st>
13 years ago
Michael Niedermayer
7c71f8e0ec
pthread: mark lockless thread synchronization variables as volatile
...
No speed difference was meassureable
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
13 years ago
Clément Bœsch
55ed91c856
threads: fix a potential race spotted by helgrind.
13 years ago
Michael Niedermayer
0c851e4642
threads: make get_logical_cpus() available outside pthread.c
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
13 years ago
Diego Biurrun
d246c18ea6
Avoid C99 variable declarations within for statements.
...
We generally do not declare variables within for statements and
there are compilers that choke on such constructs.
13 years ago
Sean McGovern
b68c4ac293
pthread: warn on high thread counts
...
Signed-off-by: Diego Biurrun <diego@biurrun.de>
13 years ago
Mans Rullgard
95510be8c3
avcodec: remove AVCodecContext.dsp_mask
...
This removes all references to AVCodecContext.dsp_mask and marks
it for eviction at the next version bump. It has been superseded
by av_set_cpu_flag_mask() which, unlike this field, works everywhere.
Signed-off-by: Mans Rullgard <mans@mansr.com>
13 years ago
Dale Curtis
a9d114dc8a
pthread: Fix crash due to fctx->delaying not being cleared.
...
corrects invalid return when avpkt->size == 0.
Reproducible with test case and ffplay -threads 2. Stack trace:
http://pastebin.com/PexZ4Uc0
Test case:
http://commondatastorage.googleapis.com/dalecurtis-shared/crash.ogm
Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
13 years ago
Dale Curtis
97ae370078
pthread: Fix crash due to fctx->delaying not being cleared.
...
Reproducible with test case and ffplay -threads 2. Stack trace:
http://pastebin.com/PexZ4Uc0
Test case:
http://commondatastorage.googleapis.com/dalecurtis-shared/crash.ogm
Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
13 years ago
Aaron Colwell
aa9c2e41b6
pthread : Remove lock/unlock pairs in worker loop to avoid unexpected state changes.
...
Reviewed-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
13 years ago
Marton Balint
5420523ae3
pthread: return proper error code on pthread_create failure
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
13 years ago