The next call to decode() will update from an invalid index, which will
either lead to a memcpy() where dest==src (2 threads), or lead to a
crash (>2 threads).
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
This fixes a compile error on mingw32 when using p->thread
directly (as if it were a pointer) to track thread existence,
because the type is opaque and may be a non-pointer.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
Adding the thread count in frame level multithreading to has_b_frames
as an additional delay causes more problems than it solves.
For example inconsistent behaviour during timestamp calculation in
libavformat.
Thread count and frame level multithreading are both set by the user.
If the additional delay caused by frame level multithreading needs
to be considered in the calling code it has all information to take
it into account.
Should it become necessary to calculate a maximum delay inside
libavcodec it should be exported as its own field and not reusing
an existing field.
Based on a patch by Michael Niedermayer.
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
A new field, AVCodecContext.internal is used to hold a new struct
AVCodecInternal, which has private fields that are not codec-specific and are
used by general libavcodec functions.
Moved internal_buffer, internal_buffer_count, and is_copy.
not to mention race conditions and that its used for stream copy, used to determine IPB type by
applications and other things.
Fixes various frame drop/timestamp issues with frame multithreading.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Replace our incomplete w32threads implementation with x264's pthreads
w32threads wrapper.
Relicensed to LGPL with kind permission by Pegasys Inc.
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
The thread_type API allows you to request only FF_THREAD_FRAME (instead of
FRAME | SLICE), but it was being ignored.
We don't implement both of them at the same time, so there isn't an effect
on current codecs, except that you can request no kinds of threading now
(a bit useless).
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
* ffmpeg-mt/master:
DUPLICATE mingw32 compilation after 'unbreak avcodec_thread_init'
pthread: validate_thread_parameters() ignored slice-threading being intentionally off
DUPLICATE Remove unnecessary parameter from ff_thread_init() and fix behavior
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
thread_count passed to ff_thread_init() is only used to set AVCodecContext.
thread_count, and can be removed. Instead move it to the legacy implementation
of avcodec_thread_init().
This also fixes the problem that calling avcodec_thread_init() with pthreads
enabled did not set it since ff1efc524c.
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
This moves setting the thread count to a minimum of 1 to
frame_thread_init(), allowing a value of zero to propagate
through to the codec if frame threading is not used. This
makes auto-threads work in libx264.
Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit ff1efc524c)
For intra codecs, ff_thread_finish_setup() is called before decoding starts
automatically. However, get_buffer can only be used before it's called, so
adding this requirement broke frame threading for them. Fixed by moving the
call until after get_buffer is finished.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
(cherry picked from commit ad9791e12b)
This moves setting the thread count to a minimum of 1 to
frame_thread_init(), allowing a value of zero to propagate
through to the codec if frame threading is not used. This
makes auto-threads work in libx264.
Signed-off-by: Mans Rullgard <mans@mansr.com>
For intra codecs, ff_thread_finish_setup() is called before decoding starts
automatically. However, get_buffer can only be used before it's called, so
adding this requirement broke frame threading for them. Fixed by moving the
call until after get_buffer is finished.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
As a side effect of the last commit, avcodec_open() now calls it automatically,
so there is no longer any need for clients to call it.
Instead they should set AVCodecContext.thread_count.
avcodec_thread_free() is deprecated, and will be removed from avcodec.h at the
next MAJOR libavcodec bump.
Rename the functions to ff_thread_init/free, since they are now internal.
Wrappers are provided to maintain API compatibility.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
(cherry picked from commit c0b102ca03)
As a side effect of the last commit, avcodec_open() now calls it automatically,
so there is no longer any need for clients to call it.
Instead they should set AVCodecContext.thread_count.
avcodec_thread_free() is deprecated, and will be removed from avcodec.h at the
next MAJOR libavcodec bump.
Rename the functions to ff_thread_init/free, since they are now internal.
Wrappers are provided to maintain API compatibility.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
The various avcodec_thread_init() functions are updated to return
immediately after setting avctx->thread_count. This allows -threads 0
to pass through to codecs. It also simplifies the usage for apps
using libavcodec.
Originally committed as revision 21358 to svn://svn.ffmpeg.org/ffmpeg/trunk
processing with jobs > threads without wasting too much memory.
It also avoids needing a separate int array when the only additional data
the jobs needs is a single int running from 0 to count-1.
Originally committed as revision 20210 to svn://svn.ffmpeg.org/ffmpeg/trunk
Necessary for systems that don't align by default to 16 bytes, required by some
SSE instructions.
Requires GCC >= 4.2.
Based on patch by Gaël Chardon.
Originally committed as revision 10106 to svn://svn.ffmpeg.org/ffmpeg/trunk