Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-11-15avcodec/pthread_frame: remove usage of AVCodecContext accessorsJames Almer
Signed-off-by: James Almer <jamrial@gmail.com>
2017-10-23Merge commit '5182a28b5de060c51c21b36053ab205bfbbbbe31'James Almer
* commit '5182a28b5de060c51c21b36053ab205bfbbbbe31': lavc: Drop deprecated global afd field Merged-by: James Almer <jamrial@gmail.com>
2017-08-25avcodec: add missing FF_API_DEBUG_MV wrappersJames Almer
Signed-off-by: James Almer <jamrial@gmail.com>
2017-07-28pthread_frame: revert 2e664b9c1e73c80aab91070c1eb7676f04bdd12d.Wan-Teh Chang
The patch does not fix the tsan warning it was intended to fix. Reverting the patch moves the av_log() back to the outside of the lock. Signed-off-by: Wan-Teh Chang <wtc@google.com> Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2017-07-12pthread_frame: save the FF_DEBUG_THREADS option in PerThreadContext.Wan-Teh Chang
Add the debug_threads boolean field to PerThreadContext. For PerThreadContext *p, p->debug_threads records whether the FF_DEBUG_THREADS bit is set in p->avctx->debug, and p->debug_threads and p->avctx->debug are kept in sync. The debug_threads field is defined as an atomic_int to allow atomic read by another thread in ff_thread_await_progress(). This fixes the tsan warning that 2e664b9c1e73c80aab91070c1eb7676f04bdd12d attempted to fix: WARNING: ThreadSanitizer: data race (pid=452658) Write of size 4 at 0x7b640003f4fc by main thread (mutexes: write M248499): #0 update_context_from_user [..]/libavcodec/pthread_frame.c:335:19 (5ab42bb1a6f4b068d7863dabe9b2bacc+0xe73859) [..] Previous read of size 4 at 0x7b640003f4fc by thread T130 (mutexes: write M248502, write M248500): #0 ff_thread_await_progress [..]/libavcodec/pthread_frame.c:591:26 (5ab42bb1a6f4b068d7863dabe9b2bacc+0xe749a1) Signed-off-by: Wan-Teh Chang <wtc@google.com> Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2017-04-30avcodec/pthread_frame, decode: allow errors to happen on drainingMuhammad Faiz
So, all frames and errors are correctly reported in order. Also limit the numbers of error during draining to prevent infinite loop. This fix fate failure with THREADS>=4: make fate-h264-attachment-631 THREADS=4 This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f. Suggested-by: wm4, Ronald S. Bultje, Marton Balint Reviewed-by: w4 <nfxjfg@googlemail.com> Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
2017-04-23Merge commit '549d0bdca53af7a6e0c612ab4b03baecf3a5878f'James Almer
* commit '549d0bdca53af7a6e0c612ab4b03baecf3a5878f': decode: be more explicit about storing the last packet properties Also copy pkt->size in extract_packet_props(), as it's needed for AVFrame.pkt_size Merged-by: James Almer <jamrial@gmail.com>
2017-04-07pthread_frame: make accesses to debug field be protected by owner lock.Ronald S. Bultje
The av_log() is done outside the lock, but this way the accesses to the field (reads and writes) are always protected by a mutex. The av_log() is not run inside the lock context because it may involve user callbacks and doing that in performance-sensitive code is probably not a good idea. This should fix occasional tsan warnings when running fate-h264, like: WARNING: ThreadSanitizer: data race (pid=10916) Write of size 4 at 0x7d64000174fc by main thread (mutexes: write M2313): #0 update_context_from_user src/libavcodec/pthread_frame.c:335 (ffmpeg+0x000000df7b06) [..] Previous read of size 4 at 0x7d64000174fc by thread T1 (mutexes: write M2311): #0 ff_thread_await_progress src/libavcodec/pthread_frame.c:592 (ffmpeg+0x000000df8b3e)
2017-04-06pthread_frame: don't return stale error codes after flushwm4
Consider the following sequence of events: - open a codec without AV_CODEC_CAP_DELAY - decode call fails with an error - ff_thread_flush() is called - drain packet is sent Then the last step would make ff_thread_decode_frame() return an error, because p->result can still be set to an error value. This is because submit_packet returns immediately if AV_CODEC_CAP_DELAY is not set, and no worker thread gets the chance to reset p->result, yet its value is trusted by ff_thread_decode_frame(). Fix this by clearing the error fields on flush.
2017-04-06pthread_frame: allow per-field ThreadFrame owners.Ronald S. Bultje
This tries to handle cases where separate invocations of decode_frame() (each running in separate threads) write to respective fields in the same AVFrame->data[]. Having per-field owners makes interaction between readers (the referencing thread) and writers (the decoding thread) slightly more optimal if both accesses are field-based, since they will use the respective producer's thread objects (mutex/cond) instead of sharing the thread objects of the first field's producer. In practice, this fixes the following tsan-warning in fate-h264: WARNING: ThreadSanitizer: data race (pid=21615) Read of size 4 at 0x7d640000d9fc by thread T2 (mutexes: write M1006): #0 ff_thread_report_progress pthread_frame.c:569 (ffmpeg:x86_64+0x100f7cf54) [..] Previous write of size 4 at 0x7d640000d9fc by main thread (mutexes: write M1004): #0 update_context_from_user pthread_frame.c:335 (ffmpeg:x86_64+0x100f81abb)
2017-04-03pthread_frame: call update_context_from_user() after acquiring lock.Ronald S. Bultje
Otherwise the thread may still be in the middle of decoding a previous frame, which would effectively trigger a race condition on any field concurrently read and written. In practice, this fixes tsan warnings like the following: WARNING: ThreadSanitizer: data race (pid=17380) Write of size 4 at 0x7d64000160fc by main thread: #0 update_context_from_user src/libavcodec/pthread_frame.c:335 (ffmpeg+0x000000dca515) [..] Previous read of size 4 at 0x7d64000160fc by thread T2 (mutexes: write M1821): #0 ff_thread_report_progress src/libavcodec/pthread_frame.c:565 (ffmpeg+0x000000dcb08a)
2017-03-31pthread_frame: Propagate sw_pix_fmt across threadsMark Thompson
This is required by the VP9 hwaccels (both DXVA2 and VAAPI) when threads are enabled. Tested-by: Hendrik Leppkes <h.leppkes@gmail.com>
2017-03-29pthread_frame: minor simplification to error handlingwm4
Get rid of the "ret" variable, and always use err. Report the packet as consumed if err is unset. This should be equivalent to the old code, which obviously required err=0 for p->result>=0 (and otherwise, p->result must have had the value err was last set to). The code block added by commit 32a5b631267 is also not needed anymore, because the new code strictly returns err if it's >=0. Reviewed-by: "Ronald S. Bultje" <rsbultje@gmail.com>
2017-03-29pthread_frame: don't sync items between threads for intra-only codecs.Ronald S. Bultje
Intra-only codecs should either be able to read these items from the bitstream, or they should be set upon codec initialization. In both cases, syncing these items at runtime is unnecessary. In practice, this fixes race conditions for decoders that read these values from the bitstream.
2017-03-27pthread_frame: fix uninitialized variable readwm4
Could lead to random behavior. This possibly happened due to commit 32a5b631267. This should/could probably be simplified, but for no apply a minimal fix to quell the errors. Tested-by: Michael Niedermayer <michael@niedermayer.cc> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
2017-03-27pthread_frame: do not attempt to unlock a mutex on the wrong threadwm4
async_mutex has is used in a very strange but intentional way: it is locked by default, and unlocked only in regions that can be run concurrently. If the user was calling API functions to the same context from different threads (in a safe way), this could unintentionally unlock the mutex on a different thread than the previous lock operation. It's not allowed by the pthread API. Fix this by emulating a binary semaphore using a mutex and condition variable. (Posix semaphores are not available on all platforms.) Tested-by: Michael Niedermayer <michael@niedermayer.cc> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
2017-03-23lavc: Drop deprecated global afd fieldVittorio Giovara
Deprecated in 08/2014.
2017-03-23lavc: Add hwaccel_flags field to AVCodecContextwm4
This "reuses" the flags introduced for the av_vdpau_bind_context() API function, and makes them available to all hwaccels. This does not affect the current vdpau API, as av_vdpau_bind_context() should obviously override the AVCodecContext.hwaccel_flags flags for the sake of compatibility. Cherry-picked from Libav commit 16a163b5. Reviewed-by: Mark Thompson <sw@jkqxz.net>
2017-03-21pthread_frame: remove some dead codewm4
Whatever it was supposed to do.
2017-03-21pthread_frame: do not run hwaccel decoding asynchronously unless it's safeAnton Khirnov
Certain hardware decoding APIs are not guaranteed to be thread-safe, so having the user access decoded hardware surfaces while the decoder is running in another thread can cause failures (this is mainly known to happen with DXVA2). For such hwaccels, only allow the decoding thread to run while the user is inside a lavc decode call (avcodec_send_packet/receive_frame). Merges Libav commit d4a91e65. Signed-off-by: wm4 <nfxjfg@googlemail.com> Tested-by: Michael Niedermayer <michael@niedermayer.cc>
2017-03-21pthread_frame: ensure the threads don't run simultaneously with hwaccelAnton Khirnov
Merges Libav commit 8dfba25c. Signed-off-by: wm4 <nfxjfg@googlemail.com>
2017-03-21pthread_frame: use better memory orders for frame progressWan-Teh Chang
This improves commit 59c70227405c214b29971e6272f3a3ff6fcce3d0. In ff_thread_report_progress(), the fast code path can load progress[field] with the relaxed memory order, and the slow code path can store progress[field] with the release memory order. These changes are mainly intended to avoid confusion when one inspects the source code. They are unlikely to have measurable performance improvement. ff_thread_report_progress() and ff_thread_await_progress() form a pair. ff_thread_await_progress() reads progress[field] with the acquire memory order (in the fast code path). Therefore, one expects to see ff_thread_report_progress() write progress[field] with the matching release memory order. In the fast code path in ff_thread_report_progress(), the atomic load of progress[field] doesn't need the acquire memory order because the calling thread is trying to make the data it just decoded visible to the other threads, rather than trying to read the data decoded by other threads. In ff_thread_get_buffer(), initialize progress[0] and progress[1] using atomic_init(). Signed-off-by: Wan-Teh Chang <wtc@google.com> Signed-off-by: Anton Khirnov <anton@khirnov.net> Merges Libav commit 343e2833. Signed-off-by: wm4 <nfxjfg@googlemail.com>
2017-03-21pthread_frame: Unreference hw_frames_ctx on per-thread codec contextsMark Thompson
When decoding with threads enabled, the get_format callback will be called with one of the per-thread codec contexts rather than with the outer context. If a hwaccel is in use too, this will add a reference to the hardware frames context on that codec context, which will then propagate to all of the other per-thread contexts for decoding. Once the decoder finishes, however, the per-thread contexts are not freed normally, so these references leak. Merges Libav commit fd0fae60. Signed-off-by: wm4 <nfxjfg@googlemail.com>
2017-03-21pthread_frame: properly propagate the hw frame context across frame threadsAnton Khirnov
Merges Libav commit 84f22568. Signed-off-by: wm4 <nfxjfg@googlemail.com>
2017-03-21pthread_frame: use atomics for frame progressAnton Khirnov
Merges Libav commit 59c70227. Signed-off-by: wm4 <nfxjfg@googlemail.com>
2017-03-21pthread_frame: use atomics for PerThreadContext.stateAnton Khirnov
Merges Libav commit 64a31b28. Signed-off-by: wm4 <nfxjfg@googlemail.com>
2017-03-21lavc: Add hwaccel_flags field to AVCodecContextwm4
This "reuses" the flags introduced for the av_vdpau_bind_context() API function, and makes them available to all hwaccels. This does not affect the current vdpau API, as av_vdpau_bind_context() should obviously override the AVCodecContext.hwaccel_flags flags for the sake of compatibility.
2017-02-06avcodec/pthread_frame: Check av_packet_ref() for failureMichael Niedermayer
Fixes CID1396242
2017-01-16lavc/pthread_frame: protect read state access in setup finish functionClément Bœsch
2016-12-19pthread_frame: do not run hwaccel decoding asynchronously unless it's safeAnton Khirnov
Certain hardware decoding APIs are not guaranteed to be thread-safe, so having the user access decoded hardware surfaces while the decoder is running in another thread can cause failures (this is mainly known to happen with DXVA2). For such hwaccels, only allow the decoding thread to run while the user is inside a lavc decode call (avcodec_send_packet/receive_frame).
2016-12-19pthread_frame: ensure the threads don't run simultaneously with hwaccelAnton Khirnov
2016-12-14pthread_frame: use better memory orders for frame progressWan-Teh Chang
This improves commit 59c70227405c214b29971e6272f3a3ff6fcce3d0. In ff_thread_report_progress(), the fast code path can load progress[field] with the relaxed memory order, and the slow code path can store progress[field] with the release memory order. These changes are mainly intended to avoid confusion when one inspects the source code. They are unlikely to have measurable performance improvement. ff_thread_report_progress() and ff_thread_await_progress() form a pair. ff_thread_await_progress() reads progress[field] with the acquire memory order (in the fast code path). Therefore, one expects to see ff_thread_report_progress() write progress[field] with the matching release memory order. In the fast code path in ff_thread_report_progress(), the atomic load of progress[field] doesn't need the acquire memory order because the calling thread is trying to make the data it just decoded visible to the other threads, rather than trying to read the data decoded by other threads. In ff_thread_get_buffer(), initialize progress[0] and progress[1] using atomic_init(). Signed-off-by: Wan-Teh Chang <wtc@google.com> Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-12-14decode: be more explicit about storing the last packet propertiesAnton Khirnov
The current code stores a pointer to the packet passed to the decoder, which is then used during get_buffer() for timestamps and side data passthrough. However, since this is a pointer to user data which we do not own, storing it is potentially dangerous. It is also ill defined for the new decoding API with split input/output. Fix this problem by making an explicit internally owned copy of the packet properties.
2016-11-10pthread_frame: Unreference hw_frames_ctx on per-thread codec contextsMark Thompson
When decoding with threads enabled, the get_format callback will be called with one of the per-thread codec contexts rather than with the outer context. If a hwaccel is in use too, this will add a reference to the hardware frames context on that codec context, which will then propagate to all of the other per-thread contexts for decoding. Once the decoder finishes, however, the per-thread contexts are not freed normally, so these references leak.
2016-11-10pthread_frame: properly propagate the hw frame context across frame threadsAnton Khirnov
2016-10-02pthread_frame: use atomics for frame progressAnton Khirnov
2016-10-02pthread_frame: use atomics for PerThreadContext.stateAnton Khirnov
2016-10-02pthread_frame: use a thread-safe way for signalling threads to dieAnton Khirnov
Current code uses a plain int in a racy way, which is UB.
2016-03-15avcodec/pthread_frame: Remove unused variableMichael Niedermayer
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-01Move the |die| member of FrameThreadContext to PerThreadContext.Wan-Teh Chang
This fixes a data race warning by ThreadSanitizer. FrameThreadContext.die is read by all the worker threads but is not protected by any mutex. Move it to PerThreadContext so that each worker thread reads its own copy of |die|, which can then be protected with PerThreadContext.mutex. Signed-off-by: Wan-Teh Chang <wtc@google.com> Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2015-12-07lavc, lavu: use avutil/thread.h instead of redundant conditional includesClément Bœsch
2015-10-09avcodec/pthread_frame: update doxygen for update_context_from_threadGanesh Ajjanagadde
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com> Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2015-09-05Merge commit '9f90b24877016e7140b9b14e4b1acee663bb6d8a'Hendrik Leppkes
* commit '9f90b24877016e7140b9b14e4b1acee663bb6d8a': lavc: Drop deprecated get_buffer related functions Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-08-28lavc: Drop deprecated get_buffer related functionsVittorio Giovara
Deprecated in 11/2012.
2015-08-22disable deprecation warnings in deprecated codeAndreas Cadhalpun
Reviewed-by: wm4 <nfxjfg@googlemail.com> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-07-27Merge commit 'def97856de6021965db86c25a732d78689bd6bb0'Michael Niedermayer
* commit 'def97856de6021965db86c25a732d78689bd6bb0': lavc: AV-prefix all codec capabilities Conflicts: cmdutils.c ffmpeg.c ffplay.c libavcodec/8svx.c libavcodec/aacenc.c libavcodec/ac3dec.c libavcodec/adpcm.c libavcodec/alac.c libavcodec/atrac3plusdec.c libavcodec/bink.c libavcodec/dnxhddec.c libavcodec/dvdec.c libavcodec/dvenc.c libavcodec/ffv1dec.c libavcodec/ffv1enc.c libavcodec/fic.c libavcodec/flacdec.c libavcodec/flacenc.c libavcodec/flvdec.c libavcodec/fraps.c libavcodec/frwu.c libavcodec/gifdec.c libavcodec/h261dec.c libavcodec/hevc.c libavcodec/iff.c libavcodec/imc.c libavcodec/libopenjpegdec.c libavcodec/libvo-aacenc.c libavcodec/libvorbisenc.c libavcodec/libvpxdec.c libavcodec/libvpxenc.c libavcodec/libx264.c libavcodec/mjpegbdec.c libavcodec/mjpegdec.c libavcodec/mpegaudiodec_float.c libavcodec/msmpeg4dec.c libavcodec/mxpegdec.c libavcodec/nvenc_h264.c libavcodec/nvenc_hevc.c libavcodec/pngdec.c libavcodec/qpeg.c libavcodec/ra288.c libavcodec/rv10.c libavcodec/s302m.c libavcodec/sp5xdec.c libavcodec/takdec.c libavcodec/tiff.c libavcodec/tta.c libavcodec/utils.c libavcodec/v210dec.c libavcodec/vp6.c libavcodec/vp9.c libavcodec/wavpack.c libavcodec/yop.c Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-27lavc: AV-prefix all codec capabilitiesVittorio Giovara
Express bitfields more simply. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-21Merge commit '40cf1bbacc6220a0aa6bed5c331871d43f9ce370'Michael Niedermayer
* commit '40cf1bbacc6220a0aa6bed5c331871d43f9ce370': Deprecate avctx.coded_frame Conflicts: ffmpeg.c libavcodec/a64multienc.c libavcodec/asvenc.c libavcodec/cljrenc.c libavcodec/dpxenc.c libavcodec/gif.c libavcodec/mpegvideo_enc.c libavcodec/nvenc.c libavcodec/proresenc_kostya.c libavcodec/pthread_frame.c libavcodec/rawenc.c libavcodec/sunrastenc.c libavcodec/tiffenc.c libavcodec/version.h libavcodec/xbmenc.c libavcodec/xwdenc.c libavdevice/v4l2.c Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-20Deprecate avctx.coded_frameVittorio Giovara
The rationale is that coded_frame was only used to communicate key_frame, pict_type and quality to the caller, as well as a few other random fields, in a non predictable, let alone consistent way. There was agreement that there was no use case for coded_frame, as it is a full-sized AVFrame container used for just 2-3 int-sized properties, which shouldn't even belong into the AVCodecContext in the first place. The appropriate AVPacket flag can be used instead of key_frame, while quality is exported with the new AVPacketSideData quality factor. There is no replacement for the other fields as they were unreliable, mishandled or just not used at all. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-16avcodec/pthread_frame: clear priv_data, avoid stale pointer in error caseMichael Niedermayer
Fixes: b4b47bc2b3fb7ca710bfffe5aa969e37_signal_sigabrt_7ffff70eccc9_744_nc_sample2.avi with memlimit of 4194304 Found-by: Samuel Groß, Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>