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.
--- a/media/ffvpx/README_MOZILLA
+++ b/media/ffvpx/README_MOZILLA
@@ -25,15 +25,8 @@ add to configure command: --disable-asm
replace: s/HAVE_SYSCTL 1/HAVE_SYSCTL 0/ and s/HAVE_MEMALIGN 1/HAVE_MEMALIGN 0/ and s/HAVE_POSIX_MEMALIGN 1/HAVE_POSIX_MEMALIGN 0/
config_unix64.h/config_unix64.asm:
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.
--- a/media/ffvpx/libavcodec/pthread_frame.c
+++ b/media/ffvpx/libavcodec/pthread_frame.c
@@ -38,39 +38,19 @@
#include "libavutil/cpu.h"
#include "libavutil/frame.h"
#include "libavutil/internal.h"
#include "libavutil/log.h"
#include "libavutil/mem.h"
#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;
pthread_t thread;
int thread_init;
pthread_cond_t input_cond; ///< Used to wait for a new packet from the main thread.
pthread_cond_t progress_cond; ///< Used by child threads to wait for progress to change.
pthread_cond_t output_cond; ///< Used by the main thread to wait for frames to finish.
@@ -81,17 +61,29 @@ typedef struct PerThreadContext {
AVCodecContext *avctx; ///< Context used to decode packets passed to this thread.
AVPacket avpkt; ///< Input packet (for decoding) or output (for encoding).
AVFrame *frame; ///< Output frame (for decoding) or input (for encoding).
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().
* Frames are released after all threads referencing them are finished.
*/
AVFrame *released_buffers;
int num_released_buffers;
int released_buffers_allocated;
@@ -361,18 +353,17 @@ static int submit_packet(PerThreadContex
p->avctx->get_format != avcodec_default_get_format ||
p->avctx->get_buffer2 != avcodec_default_get_buffer2)) {
while (p->state != STATE_SETUP_FINISHED && p->state != STATE_INPUT_READY) {
int call_done = 1;
pthread_mutex_lock(&p->progress_mutex);
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;
case STATE_GET_FORMAT:
p->result_format = ff_get_format(p->avctx, p->available_formats);
break;
default:
call_done = 0;
@@ -475,17 +466,17 @@ int ff_thread_decode_frame(AVCodecContex
/* return the size of the consumed packet if no error occurred */
return (p->result >= 0) ? avpkt->size : p->result;
}
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;
p = f->owner->internal->thread_ctx;
if (f->owner->debug&FF_DEBUG_THREADS)
av_log(f->owner, AV_LOG_DEBUG, "%p finished %d field %d\n", progress, n, field);
@@ -493,17 +484,17 @@ void ff_thread_report_progress(ThreadFra
progress[field] = n;
pthread_cond_broadcast(&p->progress_cond);
pthread_mutex_unlock(&p->progress_mutex);
}
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;
p = f->owner->internal->thread_ctx;
if (f->owner->debug&FF_DEBUG_THREADS)
av_log(f->owner, AV_LOG_DEBUG, "thread awaiting %d field %d from %p\n", n, field, progress);