From 24d074b126cc93f89401d930c316c9b452fe4967 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Thu, 19 Oct 2017 17:13:09 +0200 Subject: [PATCH] Bug 1366201 - P1. Revert "Bug 1274256 - TSan: data race gfx/layers/client/TextureClient.cpp:1161 in mozilla::layers::MappedYCbCrChannelData::CopyInto." r=gerald This reverts commit f69e779a1903 FFmpeg 3.4 no longer requires this change. --HG-- extra : rebase_source : 4767a08e886e17df2144e182105a29b0475d6367 --- media/ffvpx/README_MOZILLA | 7 ----- media/ffvpx/libavcodec/pthread_frame.c | 41 ++++++++++---------------- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/media/ffvpx/README_MOZILLA b/media/ffvpx/README_MOZILLA index 5d3a6037efe0..d7b178b65b2b 100644 --- a/media/ffvpx/README_MOZILLA +++ b/media/ffvpx/README_MOZILLA @@ -30,10 +30,3 @@ replace: s/HAVE_SYSCTL 1/HAVE_SYSCTL 0 config_win32/64.h/asm: add to configure command: --toolchain=msvc - -23 Sept 2016: libavcodec/pthread_frame.c has been patched so as to avoid -generating large numbers of warnings from TSan (Thread Sanitizer) when -decoding vp9 streams. This will likely be fixed upstream sometime soon. -When resyncing with upstream, first un-apply the patch shown at -https://bugzilla.mozilla.org/show_bug.cgi?id=1274256#c60, then resync, -then assess whether the patch is still necessary. diff --git a/media/ffvpx/libavcodec/pthread_frame.c b/media/ffvpx/libavcodec/pthread_frame.c index a10fcbfe714d..7ef5e9f6be92 100644 --- a/media/ffvpx/libavcodec/pthread_frame.c +++ b/media/ffvpx/libavcodec/pthread_frame.c @@ -43,29 +43,9 @@ #include "libavutil/opt.h" #include "libavutil/thread.h" -#if defined(MOZ_TSAN) -typedef _Atomic(int) atomic_int; -#else -typedef volatile int atomic_int; -#endif - /** * Context used by codec threads and stored in their AVCodecInternal thread_ctx. */ -typedef enum { - STATE_INPUT_READY, ///< Set when the thread is awaiting a packet. - STATE_SETTING_UP, ///< Set before the codec has called ff_thread_finish_setup(). - STATE_GET_BUFFER, /**< - * Set when the codec calls get_buffer(). - * State is returned to STATE_SETTING_UP afterwards. - */ - STATE_GET_FORMAT, /**< - * Set when the codec calls get_format(). - * State is returned to STATE_SETTING_UP afterwards. - */ - STATE_SETUP_FINISHED ///< Set after the codec has called ff_thread_finish_setup(). -} State; - typedef struct PerThreadContext { struct FrameThreadContext *parent; @@ -86,7 +66,19 @@ typedef struct PerThreadContext { int got_frame; ///< The output of got_picture_ptr from the last avcodec_decode_video() call. int result; ///< The result of the last codec decode/encode() call. - atomic_int state; + enum { + STATE_INPUT_READY, ///< Set when the thread is awaiting a packet. + STATE_SETTING_UP, ///< Set before the codec has called ff_thread_finish_setup(). + STATE_GET_BUFFER, /**< + * Set when the codec calls get_buffer(). + * State is returned to STATE_SETTING_UP afterwards. + */ + STATE_GET_FORMAT, /**< + * Set when the codec calls get_format(). + * State is returned to STATE_SETTING_UP afterwards. + */ + STATE_SETUP_FINISHED ///< Set after the codec has called ff_thread_finish_setup(). + } state; /** * Array of frames passed to ff_thread_release_buffer(). @@ -366,8 +358,7 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt) while (p->state == STATE_SETTING_UP) pthread_cond_wait(&p->progress_cond, &p->progress_mutex); - State p_state = (State)p->state; - switch (p_state) { + switch (p->state) { case STATE_GET_BUFFER: p->result = ff_get_buffer(p->avctx, p->requested_frame, p->requested_flags); break; @@ -480,7 +471,7 @@ int ff_thread_decode_frame(AVCodecContext *avctx, void ff_thread_report_progress(ThreadFrame *f, int n, int field) { PerThreadContext *p; - atomic_int *progress = f->progress ? (atomic_int*)f->progress->data : NULL; + volatile int *progress = f->progress ? (int*)f->progress->data : NULL; if (!progress || progress[field] >= n) return; @@ -498,7 +489,7 @@ void ff_thread_report_progress(ThreadFrame *f, int n, int field) void ff_thread_await_progress(ThreadFrame *f, int n, int field) { PerThreadContext *p; - atomic_int *progress = f->progress ? (atomic_int*)f->progress->data : NULL; + volatile int *progress = f->progress ? (int*)f->progress->data : NULL; if (!progress || progress[field] >= n) return;