[FFmpeg-devel] [PATCH v1] avcodec/libvpxenc: add a way to set VP9E_SET_SVC_REF_FRAME_CONFIG.

James Zern jzern at google.com
Wed Nov 18 23:04:49 EET 2020


Hi,

On Mon, Nov 16, 2020 at 2:36 PM Wonkap Jang
<wonkap-at-google.com at ffmpeg.org> wrote:
>
> In order to fine-control referencing schemes in VP9 encoding, there
> is a need to use VP9E_SET_SVC_REF_FRAME_CONFIG method. This commit
> provides a way to use the API through frame metadata.
> ---
>  libavcodec/libvpxenc.c | 77 ++++++++++++++++++++++++++++++++++++++++++

The documentation could use an update too. Maybe some of the earlier
per-frame metadata was missed.

>  1 file changed, 77 insertions(+)
>
> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> index a7c76eb835..dbe399bf72 100644
> --- a/libavcodec/libvpxenc.c
> +++ b/libavcodec/libvpxenc.c
> @@ -125,6 +125,11 @@ typedef struct VPxEncoderContext {
>       * encounter a frame with ROI side data.
>       */
>      int roi_warned;
> +
> +#if (VPX_ENCODER_ABI_VERSION >= 12) && CONFIG_LIBVPX_VP9_ENCODER
> +    vpx_svc_ref_frame_config_t ref_frame_config;
> +    AVDictionary *vpx_ref_frame_config;
> +#endif
>  } VPxContext;
>
>  /** String mappings for enum vp8e_enc_control_id */
> @@ -152,6 +157,7 @@ static const char *const ctlidstr[] = {
>      [VP9E_SET_SVC_LAYER_ID]            = "VP9E_SET_SVC_LAYER_ID",
>  #if VPX_ENCODER_ABI_VERSION >= 12

This check isn't sufficient since the vpx_svc_ref_frame_config_t
struct was changed a few times after this point.

>      [VP9E_SET_SVC_PARAMETERS]          = "VP9E_SET_SVC_PARAMETERS",
> +    [VP9E_SET_SVC_REF_FRAME_CONFIG]    = "VP9E_SET_SVC_REF_FRAME_CONFIG",
>  #endif
>      [VP9E_SET_SVC]                     = "VP9E_SET_SVC",
>  #if VPX_ENCODER_ABI_VERSION >= 11
> @@ -394,6 +400,18 @@ static void vp8_ts_parse_int_array(int *dest, char *value, size_t value_len, int
>      }
>  }
>
> +static void vp8_ts_parse_int64_array(int64_t *dest, char *value, size_t value_len, int max_entries)
> +{
> +    int dest_idx = 0;
> +    char *saveptr = NULL;
> +    char *token = av_strtok(value, ",", &saveptr);
> +
> +    while (token && dest_idx < max_entries) {
> +        dest[dest_idx++] = strtoul(token, NULL, 10);

int64 seems like it was overkill in the api, but you probably want
strtoull here.


More information about the ffmpeg-devel mailing list