[FFmpeg-devel] [PATCH 4/5] avcodec/libsvtav1: support cores and socket options for svt av1
James Almer
jamrial at gmail.com
Sat Aug 1 16:15:02 EEST 2020
On 8/1/2020 8:22 AM, lance.lmwang at gmail.com wrote:
> From: Limin Wang <lance.lmwang at gmail.com>
>
> Signed-off-by: Limin Wang <lance.lmwang at 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).
>
> + at 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.
> +
> + at 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},
> + { "socket", "Target socket to run on. -1: unset", OFFSET(socket), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE},
>
> {NULL},
> };
There's a WIP merge request that attempts to introduce a threads option
that maps well with our AVCodecContext->threads field in
https://github.com/OpenVisualCloud/SVT-AV1/pull/1367, so i personally
think it's best to wait for it instead.
Also, there's work to introduce a key=value option parsing API, which
would let us add a x264-params style option and avoid adding a hundred
options for every single EbSvtAv1EncConfiguration field.
More information about the ffmpeg-devel
mailing list