summaryrefslogtreecommitdiff
path: root/libavcodec/pthread_slice.c
Commit message (Collapse)AuthorAgeFilesLines
* avcodec/pthread_slice: Reuse buffer if possibleAndreas Rheinhardt2022-07-251-2/+4
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/pthread_slice: Combine allocating and zeroing entriesAndreas Rheinhardt2022-07-251-7/+1
| | | | | | | | | Actually, ff_slice_thread_allocz_entries() always already allocates zeroed entries, so ff_reset_entries() was already unnecessary. Make this more clear by renaming it to ff_slice_thread_allocz_entries(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/pthread_slice: Don't reinitialise initialised mutexAndreas Rheinhardt2022-07-011-31/+52
| | | | | | | | | | | | | | It results in undefined behaviour. Instead initialize the mutexes and condition variables once during init (and check these initializations). Also combine the corresponding mutex and condition variable into one structure so that one can allocate their array jointly. Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se> Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Add FFCodec, hide internal part of AVCodecAndreas Rheinhardt2022-03-211-1/+1
| | | | | | | | | | | | | | | | Up until now, codec.h contains both public and private parts of AVCodec. This exposes the internals of AVCodec to users and leads them into the temptation of actually using them and forces us to forward-declare structures and types that users can't use at all. This commit changes this by adding a new structure FFCodec to codec_internal.h that extends AVCodec, i.e. contains the public AVCodec as first member; the private fields of AVCodec are moved to this structure, leaving codec.h clean. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.hAndreas Rheinhardt2022-03-211-0/+1
| | | | | | | | | | Also move FF_CODEC_TAGS_END as well as struct AVCodecDefault. This reduces the amount of files that have to include internal.h (which comes with quite a lot of indirect inclusions), as e.g. most encoders don't need it. It is furthemore in preparation for moving the private part of AVCodec out of the public codec.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Replace all occurences of av_mallocz_array() by av_calloc()Andreas Rheinhardt2021-09-201-1/+1
| | | | | | | They do the same. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/pthread_slice: Don't use static variable, fix raceAndreas Rheinhardt2020-12-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | ff_slice_thread_init() uses a static variable to hold a function pointer, although the value of said pointer needn't be saved between different runs of this function at all. The reason for this being so is probably that said pointer points to a static function (if used); but storage class specifiers like "static" are not part of the type of an object and so including it in the pointer declaration is wrong (anyway, "static" means different things in both contexts: for the function declaration it affects linkage, for the variable storage duration). Using a static variable here can lead to races, e.g. when initializing VP9 (for which said function pointer was added) and H.264 with slice threading. The latter has the FF_CODEC_CAP_INIT_THREADSAFE flag set and is therefore unaffected by the lock guarding initializations of decoders. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* w32pthreads: always use Vista+ API, drop XP supportwm42017-12-261-4/+0
| | | | | | | | | | | This removes the XP compatibility code, and switches entirely to SWR locks, which are available starting at Windows Vista. This removes CRITICAL_SECTION use, which allows us to add PTHREAD_MUTEX_INITIALIZER, which will be useful later. Windows XP is hereby not a supported build target anymore. It was decided in a project vote that this is OK.
* avcodec/pthread_slice: add ff_slice_thread_execute_with_mainfunc()Ilia Valiakhmetov2017-09-081-2/+20
| | | | | Signed-off-by: Ilia Valiakhmetov <zakne0ne@gmail.com> Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
* avcodec/pthread_slice: use slice threading from avutilMuhammad Faiz2017-07-191-102/+20
| | | | | | | | | | | | | | | | | | | | | | | | Also remove pthread_cond_broadcast(progress_cond) on uninit. Broadcasting it is not required because workers are always parked when they are not in thread_execute. So it is imposible that a worker is waiting on progress_cond when uninitialized. Benchmark: ./ffmpeg -threads $threads -thread_type slice -i 10slices.mp4 -f null null threads=2: old: 70.212s 70.525s 70.877s new: 65.219s 65.377s 65.484s threads=3: old: 65.086s 66.306s 66.409s new: 63.229s 65.026s 65.116s threads=4: old: 60.993s 61.482s 62.123s new: 59.224s 59.441s 59.667s threads=5: old: 57.576s 57.860s 58.832s new: 53.032s 53.948s 54.086s Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
* lavc/pthread_slice: remove pointless conditionClément Bœsch2017-03-291-5/+1
|
* avcodec/mpeg12enc: Move high resolution thread check to before initializing ↵Michael Niedermayer2016-01-211-0/+6
| | | | | | | | threads Cleaner solution is welcome! Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavc,lavfi: use avutil/thread.h instead of redundant conditional includesClément Bœsch2016-01-201-8/+1
| | | | This was somehow forgotten in a8bb81a05c519dd3f36cc341e5fb448f6d17fa73.
* avcodec/pthread_slice: Allow calling ff_alloc_entries() multiple times to ↵Michael Niedermayer2015-11-271-2/+11
| | | | | | readjust the entry count Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/pthread_slice: Remove rets_countMichael Niedermayer2015-11-261-4/+1
| | | | | | It appears rets_count is redundant Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/pthread_slice: remove dummy_ret hackMichael Niedermayer2015-11-191-4/+6
| | | | | | | This should avoid some tsan warnings Found-by: Chris Cunningham <chcunningham@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavc/pthread_slice: release entriesChristophe Gisquet2015-02-241-0/+12
| | | | | | | | | When calling ff_alloc_entries, a number of entries are created. They are never freed, as running fate with slice threading and several frames on e.g. fate-hevc-conformance-ENTP_A_Qualcomm_1 would show. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* avcodec/pthread_slice: Use av_freep() to avoid leaving stale pointers in memoryMichael Niedermayer2014-11-011-1/+1
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* avcodec/pthread_slice: Check for malloc failureMichael Niedermayer2014-07-311-4/+7
| | | | | Found-by: CSA Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* avcodec/pthread_slice: Use av_malloc(z)_array()Michael Niedermayer2014-06-081-4/+4
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* Merge commit '38ecc3702dabbea09230f6d6333f59e74f5d1c12'Michael Niedermayer2013-11-041-10/+10
|\ | | | | | | | | | | | | | | | | | | | | * commit '38ecc3702dabbea09230f6d6333f59e74f5d1c12': pthread: store thread contexts in AVCodecInternal instead of AVCodecContext Conflicts: libavcodec/internal.h libavcodec/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * pthread: store thread contexts in AVCodecInternal instead of AVCodecContextAnton Khirnov2013-11-041-6/+6
| | | | | | | | | | | | It's a private field, it should not be visible to callers. Deprecate AVCodecContext.thread_opaque
* | Merge commit 'daa7a1d4431b6acf1f93c4a98b3de123abf4ca18'Michael Niedermayer2013-11-041-13/+13
|\ \ | |/ | | | | | | | | | | | | | | | | * commit 'daa7a1d4431b6acf1f93c4a98b3de123abf4ca18': pthread_slice: rename ThreadContext -> SliceThreadContext Conflicts: libavcodec/pthread_slice.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * pthread_slice: rename ThreadContext -> SliceThreadContextAnton Khirnov2013-11-041-9/+9
| | | | | | | | This should prevent confusion with frame threading.
* | Merge commit 'cc14ee03a7b91c69343f8d60c9e089a1950eeadb'Michael Niedermayer2013-11-041-5/+73
|/ | | | | | | | | | | * commit 'cc14ee03a7b91c69343f8d60c9e089a1950eeadb': lavc: split slice and frame threading functions into separate files Conflicts: libavcodec/Makefile libavcodec/pthread.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
* lavc: split slice and frame threading functions into separate filesAnton Khirnov2013-11-041-0/+224