On 01/08/2020 12:22, lance.lmw...@gmail.com wrote:
From: Limin Wang <lance.lmw...@gmail.com>

Signed-off-by: Limin Wang <lance.lmw...@gmail.com>
---
  doc/encoders.texi      | 9 +++++++++
  libavcodec/libsvtav1.c | 9 +++++++++
  2 files changed, 18 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 2f5457f..da0b68d 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1747,6 +1747,15 @@ Set log2 of the number of rows of tiles to use (0-6).
  @item tile_columns
  Set log2 of the number of columns of tiles to use (0-4).
+@item cores
+Set the number of logical processor which encoder threads run on. Default is: 0
+which is unset. If cores and socket are not set, threads are managed by OS 
thread
+scheduler.
+
+@item socket
+Set which target socket to run on. For multiple socket systems, this can 
specify which
+socket the encoder runs on. Default is: -1 which is unset.
+
  @end table
@section libkvazaar
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 3e3b907..78e0ee5 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -71,6 +71,9 @@ typedef struct SvtContext {
int tile_columns;
      int tile_rows;
+
+    int cores;
+    int socket;
  } SvtContext;
static const struct {
@@ -204,6 +207,10 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
*param,
param->tile_columns = svt_enc->tile_columns;
      param->tile_rows    = svt_enc->tile_rows;
+    if (svt_enc->cores > 0)
+        param->logical_processors = svt_enc->cores;
+    if (svt_enc->socket >= 0)
+        param->target_socket      = svt_enc->socket;
return 0;
  }
@@ -519,6 +526,8 @@ static const AVOption options[] = {
{ "tile_columns", "Log2 of number of tile columns to use", OFFSET(tile_columns), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VE},
      { "tile_rows", "Log2 of number of tile rows to use", OFFSET(tile_rows), 
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 6, VE},
+    { "cores", "Number of logical cores, 0: unset",   OFFSET(cores),  
AV_OPT_TYPE_INT, {.i64 = 0},   0, INT_MAX, VE},

I think you'd be better using the standard option -threads 
(AVCodecContext.thread_count) rather than inventing a special one for this 
encoder only.

+    { "socket", "Target socket to run on. -1: unset", OFFSET(socket), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE},

This sort of thing has always been supported by OS-level tools, so it's not 
obvious to me that a special crude option here is helpful.

Why would you use this rather than your favourite OS-level tool? E.g. the Linux tools (taskset, numactl) and APIs (sched_setaffinity(), set_mempolicy()) are more flexible than this option and also work on all other encoders.

{NULL},
  };


- Mark
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to