diff options
author | Alexander Potapenko <glider@google.com> | 2016-09-06 18:50:38 +0200 |
---|---|---|
committer | Alexander Potapenko <glider@google.com> | 2016-09-08 14:36:32 +0200 |
commit | 948a1f51d01f531e3e2b5d7e794d5f09c0b07cd5 (patch) | |
tree | aac9858db722954b4f8bd1be67273ab00faebf6b | |
parent | c892521b1d81d7d2f5f5fbd523aae88215cb979f (diff) | |
download | libvpx-948a1f51d01f531e3e2b5d7e794d5f09c0b07cd5.tar libvpx-948a1f51d01f531e3e2b5d7e794d5f09c0b07cd5.tar.gz libvpx-948a1f51d01f531e3e2b5d7e794d5f09c0b07cd5.tar.bz2 libvpx-948a1f51d01f531e3e2b5d7e794d5f09c0b07cd5.zip |
vp8: Remove TSAN warning around end of encode.
Tsan warns when run in one pass and there is a recode
loop.
Change-Id: Ice2ecb2270f09ebd49efbd49c0e4f77d32e23c0f
-rw-r--r-- | vp8/encoder/encodeframe.c | 11 | ||||
-rw-r--r-- | vp8/encoder/ethreading.c | 23 | ||||
-rw-r--r-- | vp8/encoder/onyx_int.h | 2 |
3 files changed, 19 insertions, 17 deletions
diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c index 0d0768934..e41d513c1 100644 --- a/vp8/encoder/encodeframe.c +++ b/vp8/encoder/encodeframe.c @@ -788,14 +788,11 @@ void vp8_encode_frame(VP8_COMP *cpi) { xd->mode_info_stride * cpi->encoding_thread_count; x->partition_info += xd->mode_info_stride * cpi->encoding_thread_count; x->gf_active_ptr += cm->mb_cols * cpi->encoding_thread_count; - - if (mb_row == cm->mb_rows - 1) { - sem_post(&cpi->h_event_end_encoding); /* signal frame encoding end */ - } } - - sem_wait( - &cpi->h_event_end_encoding); /* wait for other threads to finish */ + /* Wait for all the threads to finish. */ + for (i = 0; i < cpi->encoding_thread_count; ++i) { + sem_wait(&cpi->h_event_end_encoding[i]); + } for (mb_row = 0; mb_row < cm->mb_rows; ++mb_row) { cpi->tok_count += (unsigned int)(cpi->tplist[mb_row].stop - diff --git a/vp8/encoder/ethreading.c b/vp8/encoder/ethreading.c index ba05776a3..708002b1e 100644 --- a/vp8/encoder/ethreading.c +++ b/vp8/encoder/ethreading.c @@ -301,11 +301,9 @@ static THREAD_FUNCTION thread_encoding_proc(void *p_data) { xd->mode_info_stride * cpi->encoding_thread_count; x->partition_info += xd->mode_info_stride * cpi->encoding_thread_count; x->gf_active_ptr += cm->mb_cols * cpi->encoding_thread_count; - - if (mb_row == cm->mb_rows - 1) { - sem_post(&cpi->h_event_end_encoding); /* signal frame encoding end */ - } } + /* Signal that this thread has completed processing its rows. */ + sem_post(&cpi->h_event_end_encoding[ithread]); } } @@ -516,14 +514,14 @@ int vp8cx_create_encoder_threads(VP8_COMP *cpi) { vpx_malloc(sizeof(pthread_t) * th_count)); CHECK_MEM_ERROR(cpi->h_event_start_encoding, vpx_malloc(sizeof(sem_t) * th_count)); + CHECK_MEM_ERROR(cpi->h_event_end_encoding, + vpx_malloc(sizeof(sem_t) * th_count)); CHECK_MEM_ERROR(cpi->mb_row_ei, vpx_memalign(32, sizeof(MB_ROW_COMP) * th_count)); memset(cpi->mb_row_ei, 0, sizeof(MB_ROW_COMP) * th_count); CHECK_MEM_ERROR(cpi->en_thread_data, vpx_malloc(sizeof(ENCODETHREAD_DATA) * th_count)); - sem_init(&cpi->h_event_end_encoding, 0, 0); - cpi->b_multi_threaded = 1; cpi->encoding_thread_count = th_count; @@ -540,6 +538,7 @@ int vp8cx_create_encoder_threads(VP8_COMP *cpi) { vp8_setup_block_dptrs(&cpi->mb_row_ei[ithread].mb.e_mbd); sem_init(&cpi->h_event_start_encoding[ithread], 0, 0); + sem_init(&cpi->h_event_end_encoding[ithread], 0, 0); ethd->ithread = ithread; ethd->ptr1 = (void *)cpi; @@ -556,11 +555,12 @@ int vp8cx_create_encoder_threads(VP8_COMP *cpi) { for (--ithread; ithread >= 0; ithread--) { pthread_join(cpi->h_encoding_thread[ithread], 0); sem_destroy(&cpi->h_event_start_encoding[ithread]); + sem_destroy(&cpi->h_event_end_encoding[ithread]); } - sem_destroy(&cpi->h_event_end_encoding); /* free thread related resources */ vpx_free(cpi->h_event_start_encoding); + vpx_free(cpi->h_event_end_encoding); vpx_free(cpi->h_encoding_thread); vpx_free(cpi->mb_row_ei); vpx_free(cpi->en_thread_data); @@ -582,15 +582,17 @@ int vp8cx_create_encoder_threads(VP8_COMP *cpi) { cpi->b_multi_threaded = 0; for (--ithread; ithread >= 0; ithread--) { sem_post(&cpi->h_event_start_encoding[ithread]); + sem_post(&cpi->h_event_end_encoding[ithread]); pthread_join(cpi->h_encoding_thread[ithread], 0); sem_destroy(&cpi->h_event_start_encoding[ithread]); + sem_destroy(&cpi->h_event_end_encoding[ithread]); } - sem_destroy(&cpi->h_event_end_encoding); sem_destroy(&cpi->h_event_end_lpf); sem_destroy(&cpi->h_event_start_lpf); /* free thread related resources */ vpx_free(cpi->h_event_start_encoding); + vpx_free(cpi->h_event_end_encoding); vpx_free(cpi->h_encoding_thread); vpx_free(cpi->mb_row_ei); vpx_free(cpi->en_thread_data); @@ -611,21 +613,24 @@ void vp8cx_remove_encoder_threads(VP8_COMP *cpi) { for (i = 0; i < cpi->encoding_thread_count; ++i) { sem_post(&cpi->h_event_start_encoding[i]); + sem_post(&cpi->h_event_end_encoding[i]); + pthread_join(cpi->h_encoding_thread[i], 0); sem_destroy(&cpi->h_event_start_encoding[i]); + sem_destroy(&cpi->h_event_end_encoding[i]); } sem_post(&cpi->h_event_start_lpf); pthread_join(cpi->h_filter_thread, 0); } - sem_destroy(&cpi->h_event_end_encoding); sem_destroy(&cpi->h_event_end_lpf); sem_destroy(&cpi->h_event_start_lpf); /* free thread related resources */ vpx_free(cpi->h_event_start_encoding); + vpx_free(cpi->h_event_end_encoding); vpx_free(cpi->h_encoding_thread); vpx_free(cpi->mb_row_ei); vpx_free(cpi->en_thread_data); diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h index 6df8f81c4..32080eff7 100644 --- a/vp8/encoder/onyx_int.h +++ b/vp8/encoder/onyx_int.h @@ -518,7 +518,7 @@ typedef struct VP8_COMP { /* events */ sem_t *h_event_start_encoding; - sem_t h_event_end_encoding; + sem_t *h_event_end_encoding; sem_t h_event_start_lpf; sem_t h_event_end_lpf; #endif |