vp8cx_init_mbrthread_data(cpi, x, cpi->mb_row_ei,
cpi->encoding_thread_count);
+ if (cpi->mt_current_mb_col_size != cm->mb_rows) {
+ vpx_free(cpi->mt_current_mb_col);
+ cpi->mt_current_mb_col = NULL;
+ cpi->mt_current_mb_col_size = 0;
+ CHECK_MEM_ERROR(
+ &cpi->common.error, cpi->mt_current_mb_col,
+ vpx_malloc(sizeof(*cpi->mt_current_mb_col) * cm->mb_rows));
+ cpi->mt_current_mb_col_size = cm->mb_rows;
+ }
for (i = 0; i < cm->mb_rows; ++i)
vpx_atomic_store_release(&cpi->mt_current_mb_col[i], -1);
cpi->b_lpf_running = 0;
/* free thread related resources */
+ vpx_free(cpi->mt_current_mb_col);
+ cpi->mt_current_mb_col = NULL;
+ cpi->mt_current_mb_col_size = 0;
vpx_free(cpi->h_event_start_encoding);
cpi->h_event_start_encoding = NULL;
vpx_free(cpi->h_event_end_encoding);
vpx_free(cpi->mb.pip);
cpi->mb.pip = 0;
-
-#if CONFIG_MULTITHREAD
- vpx_free(cpi->mt_current_mb_col);
- cpi->mt_current_mb_col = NULL;
-#endif
}
static void enable_segmentation(VP8_COMP *cpi) {
} else {
cpi->mt_sync_range = 16;
}
-
- if (cpi->oxcf.multi_threaded > 1) {
- int i;
-
- vpx_free(cpi->mt_current_mb_col);
- CHECK_MEM_ERROR(&cpi->common.error, cpi->mt_current_mb_col,
- vpx_malloc(sizeof(*cpi->mt_current_mb_col) * cm->mb_rows));
- for (i = 0; i < cm->mb_rows; ++i)
- vpx_atomic_init(&cpi->mt_current_mb_col[i], 0);
- }
-
#endif
vpx_free(cpi->tplist);
last_h = cpi->oxcf.Height;
prev_number_of_layers = cpi->oxcf.number_of_layers;
- if (cpi->initial_width) {
- // TODO(https://crbug.com/1486441): Allow changing thread counts; the
- // allocation is done once in vp8_create_compressor().
- oxcf->multi_threaded = cpi->oxcf.multi_threaded;
- }
cpi->oxcf = *oxcf;
switch (cpi->oxcf.Mode) {
#if CONFIG_MULTITHREAD
/* multithread data */
vpx_atomic_int *mt_current_mb_col;
+ int mt_current_mb_col_size;
int mt_sync_range;
vpx_atomic_int b_multi_threaded;
int encoding_thread_count;
ctx->cfg = *cfg;
set_vp8e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg, NULL);
vp8_change_config(ctx->cpi, &ctx->oxcf);
+ // TODO(https://crbug.com/1486441): Change thread counts;
+ // vp8cx_create_encoder_threads() is called once in vp8_create_compressor().
ctx->cpi->common.error.setjmp = 0;
return VPX_CODEC_OK;
}