int vp8cx_create_encoder_threads(VP8_COMP *cpi) {
const VP8_COMMON *cm = &cpi->common;
-
- vpx_atomic_init(&cpi->b_multi_threaded, 0);
- cpi->encoding_thread_count = 0;
- cpi->b_lpf_running = 0;
+ int th_count = 0;
if (cm->processor_core_count > 1 && cpi->oxcf.multi_threaded > 1) {
- int ithread;
- int th_count = cpi->oxcf.multi_threaded - 1;
- int rc = 0;
+ th_count = cpi->oxcf.multi_threaded - 1;
/* don't allocate more threads than cores available */
if (cpi->oxcf.multi_threaded > cm->processor_core_count) {
if (th_count > ((cm->mb_cols / cpi->mt_sync_range) - 1)) {
th_count = (cm->mb_cols / cpi->mt_sync_range) - 1;
}
+ }
+ if (th_count == cpi->encoding_thread_count) return 0;
- if (th_count == 0) return 0;
+ vp8cx_remove_encoder_threads(cpi);
+ if (th_count != 0) {
+ int ithread;
+ int rc = 0;
CHECK_MEM_ERROR(&cpi->common.error, cpi->h_encoding_thread,
vpx_malloc(sizeof(pthread_t) * th_count));
#include "vpx_ports/static_assert.h"
#include "vpx_ports/system_state.h"
#include "vpx_util/vpx_timestamp.h"
+#if CONFIG_MULTITHREAD
+#include "vp8/encoder/ethreading.h"
+#endif
#include "vp8/encoder/onyx_int.h"
#include "vpx/vp8cx.h"
#include "vp8/encoder/firstpass.h"
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().
+#if CONFIG_MULTITHREAD
+ if (vp8cx_create_encoder_threads(ctx->cpi)) return VPX_CODEC_ERROR;
+#endif
ctx->cpi->common.error.setjmp = 0;
return VPX_CODEC_OK;
}