vp8:fix threading issues

1 - stops de allocating before threads are closed.
2 - limits threads to mb_rows when mb_rows < partitions

BUG=webm:851

Change-Id: I7ead53e80cc0f8c2e4c1c53506eff8431de2a37e
This commit is contained in:
Jim Bankoski 2016-07-21 09:20:10 -07:00 committed by James Bankoski
parent 930773a1ed
commit 0fff2fb34c
3 changed files with 50 additions and 52 deletions

View File

@ -798,6 +798,9 @@ static void setup_token_decoder(VP8D_COMP *pbi,
if (pbi->decoding_thread_count > num_token_partitions - 1) {
pbi->decoding_thread_count = num_token_partitions - 1;
}
if (pbi->decoding_thread_count > pbi->common.mb_rows - 1) {
pbi->decoding_thread_count = pbi->common.mb_rows - 1;
}
#endif
}

View File

@ -331,7 +331,6 @@ int vp8dx_receive_compressed_data(VP8D_COMP *pbi, size_t size,
if (cm->fb_idx_ref_cnt[cm->new_fb_idx] > 0) {
cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
}
goto decode_exit;
}
@ -464,9 +463,6 @@ int vp8_remove_decoder_instances(struct frame_buffers *fb) {
if (!pbi) return VPX_CODEC_ERROR;
#if CONFIG_MULTITHREAD
if (pbi->b_multithreaded_rd) {
vp8mt_de_alloc_temp_buffers(pbi, pbi->common.mb_rows);
}
vp8_decoder_remove_threads(pbi);
#endif

View File

@ -631,65 +631,63 @@ void vp8_decoder_create_threads(VP8D_COMP *pbi) {
void vp8mt_de_alloc_temp_buffers(VP8D_COMP *pbi, int mb_rows) {
int i;
if (pbi->b_multithreaded_rd) {
vpx_free(pbi->mt_current_mb_col);
pbi->mt_current_mb_col = NULL;
vpx_free(pbi->mt_current_mb_col);
pbi->mt_current_mb_col = NULL;
/* Free above_row buffers. */
if (pbi->mt_yabove_row) {
for (i = 0; i < mb_rows; ++i) {
vpx_free(pbi->mt_yabove_row[i]);
pbi->mt_yabove_row[i] = NULL;
}
vpx_free(pbi->mt_yabove_row);
pbi->mt_yabove_row = NULL;
/* Free above_row buffers. */
if (pbi->mt_yabove_row) {
for (i = 0; i < mb_rows; ++i) {
vpx_free(pbi->mt_yabove_row[i]);
pbi->mt_yabove_row[i] = NULL;
}
vpx_free(pbi->mt_yabove_row);
pbi->mt_yabove_row = NULL;
}
if (pbi->mt_uabove_row) {
for (i = 0; i < mb_rows; ++i) {
vpx_free(pbi->mt_uabove_row[i]);
pbi->mt_uabove_row[i] = NULL;
}
vpx_free(pbi->mt_uabove_row);
pbi->mt_uabove_row = NULL;
if (pbi->mt_uabove_row) {
for (i = 0; i < mb_rows; ++i) {
vpx_free(pbi->mt_uabove_row[i]);
pbi->mt_uabove_row[i] = NULL;
}
vpx_free(pbi->mt_uabove_row);
pbi->mt_uabove_row = NULL;
}
if (pbi->mt_vabove_row) {
for (i = 0; i < mb_rows; ++i) {
vpx_free(pbi->mt_vabove_row[i]);
pbi->mt_vabove_row[i] = NULL;
}
vpx_free(pbi->mt_vabove_row);
pbi->mt_vabove_row = NULL;
if (pbi->mt_vabove_row) {
for (i = 0; i < mb_rows; ++i) {
vpx_free(pbi->mt_vabove_row[i]);
pbi->mt_vabove_row[i] = NULL;
}
vpx_free(pbi->mt_vabove_row);
pbi->mt_vabove_row = NULL;
}
/* Free left_col buffers. */
if (pbi->mt_yleft_col) {
for (i = 0; i < mb_rows; ++i) {
vpx_free(pbi->mt_yleft_col[i]);
pbi->mt_yleft_col[i] = NULL;
}
vpx_free(pbi->mt_yleft_col);
pbi->mt_yleft_col = NULL;
/* Free left_col buffers. */
if (pbi->mt_yleft_col) {
for (i = 0; i < mb_rows; ++i) {
vpx_free(pbi->mt_yleft_col[i]);
pbi->mt_yleft_col[i] = NULL;
}
vpx_free(pbi->mt_yleft_col);
pbi->mt_yleft_col = NULL;
}
if (pbi->mt_uleft_col) {
for (i = 0; i < mb_rows; ++i) {
vpx_free(pbi->mt_uleft_col[i]);
pbi->mt_uleft_col[i] = NULL;
}
vpx_free(pbi->mt_uleft_col);
pbi->mt_uleft_col = NULL;
if (pbi->mt_uleft_col) {
for (i = 0; i < mb_rows; ++i) {
vpx_free(pbi->mt_uleft_col[i]);
pbi->mt_uleft_col[i] = NULL;
}
vpx_free(pbi->mt_uleft_col);
pbi->mt_uleft_col = NULL;
}
if (pbi->mt_vleft_col) {
for (i = 0; i < mb_rows; ++i) {
vpx_free(pbi->mt_vleft_col[i]);
pbi->mt_vleft_col[i] = NULL;
}
vpx_free(pbi->mt_vleft_col);
pbi->mt_vleft_col = NULL;
if (pbi->mt_vleft_col) {
for (i = 0; i < mb_rows; ++i) {
vpx_free(pbi->mt_vleft_col[i]);
pbi->mt_vleft_col[i] = NULL;
}
vpx_free(pbi->mt_vleft_col);
pbi->mt_vleft_col = NULL;
}
}
@ -760,7 +758,6 @@ void vp8_decoder_remove_threads(VP8D_COMP *pbi) {
/* shutdown MB Decoding thread; */
if (pbi->b_multithreaded_rd) {
int i;
pbi->b_multithreaded_rd = 0;
/* allow all threads to exit */
@ -786,6 +783,8 @@ void vp8_decoder_remove_threads(VP8D_COMP *pbi) {
vpx_free(pbi->de_thread_data);
pbi->de_thread_data = NULL;
vp8mt_de_alloc_temp_buffers(pbi, pbi->common.mb_rows);
}
}