[FFmpeg-devel] [PATCH] lavfi/vf_libplacebo: allow linking to shared library with dllimport

Niklas Haas ffmpeg at haasn.xyz
Thu May 18 22:48:59 EEST 2023


On Wed, 17 May 2023 21:45:03 +0200 Kacper Michajłow <kasper93 at gmail.com> wrote:
> Address of dll imported variables can't be used for constant
> initialization in C language modes.
> ---
>  libavfilter/vf_libplacebo.c | 39 ++++++++++++++++++++-----------------
>  1 file changed, 21 insertions(+), 18 deletions(-)
> 
> diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
> index 94e49aa465..f26d0126be 100644
> --- a/libavfilter/vf_libplacebo.c
> +++ b/libavfilter/vf_libplacebo.c
> @@ -56,23 +56,6 @@ enum {
>      TONE_MAP_COUNT,
>  };
>  
> -static const struct pl_tone_map_function * const tonemapping_funcs[TONE_MAP_COUNT] = {
> -    [TONE_MAP_AUTO]      = &pl_tone_map_auto,
> -    [TONE_MAP_CLIP]      = &pl_tone_map_clip,
> -#if PL_API_VER >= 246
> -    [TONE_MAP_ST2094_40] = &pl_tone_map_st2094_40,
> -    [TONE_MAP_ST2094_10] = &pl_tone_map_st2094_10,
> -#endif
> -    [TONE_MAP_BT2390]    = &pl_tone_map_bt2390,
> -    [TONE_MAP_BT2446A]   = &pl_tone_map_bt2446a,
> -    [TONE_MAP_SPLINE]    = &pl_tone_map_spline,
> -    [TONE_MAP_REINHARD]  = &pl_tone_map_reinhard,
> -    [TONE_MAP_MOBIUS]    = &pl_tone_map_mobius,
> -    [TONE_MAP_HABLE]     = &pl_tone_map_hable,
> -    [TONE_MAP_GAMMA]     = &pl_tone_map_gamma,
> -    [TONE_MAP_LINEAR]    = &pl_tone_map_linear,
> -};
> -
>  static const char *const var_names[] = {
>      "in_w", "iw",   ///< width  of the input video frame
>      "in_h", "ih",   ///< height of the input video frame
> @@ -269,6 +252,26 @@ static void pl_av_log(void *log_ctx, enum pl_log_level level, const char *msg)
>      av_log(log_ctx, av_lev, "%s\n", msg);
>  }
>  
> +static const struct pl_tone_map_function *pl_get_tonemapping_func(int tm) {
> +    switch (tm) {
> +    case TONE_MAP_AUTO:       return &pl_tone_map_auto;
> +    case TONE_MAP_CLIP:       return &pl_tone_map_clip;
> +#if PL_API_VER >= 246
> +    case TONE_MAP_ST2094_40:  return &pl_tone_map_st2094_40;
> +    case TONE_MAP_ST2094_10:  return &pl_tone_map_st2094_10;
> +#endif
> +    case TONE_MAP_BT2390:     return &pl_tone_map_bt2390;
> +    case TONE_MAP_BT2446A:    return &pl_tone_map_bt2446a;
> +    case TONE_MAP_SPLINE:     return &pl_tone_map_spline;
> +    case TONE_MAP_REINHARD:   return &pl_tone_map_reinhard;
> +    case TONE_MAP_MOBIUS:     return &pl_tone_map_mobius;
> +    case TONE_MAP_HABLE:      return &pl_tone_map_hable;
> +    case TONE_MAP_GAMMA:      return &pl_tone_map_gamma;
> +    case TONE_MAP_LINEAR:     return &pl_tone_map_linear;
> +    default: av_assert0(0);
> +    }
> +}
> +
>  static int parse_shader(AVFilterContext *avctx, const void *shader, size_t len)
>  {
>      LibplaceboContext *s = avctx->priv;
> @@ -365,7 +368,7 @@ static int update_settings(AVFilterContext *ctx)
>      s->color_map_params = *pl_color_map_params(
>          .intent = s->intent,
>          .gamut_mode = gamut_mode,
> -        .tone_mapping_function = tonemapping_funcs[s->tonemapping],
> +        .tone_mapping_function = pl_get_tonemapping_func(s->tonemapping),
>          .tone_mapping_param = s->tonemapping_param,
>          .tone_mapping_mode = tonemapping_mode,
>          .inverse_tone_mapping = s->inverse_tonemapping,
> -- 
> 2.34.1
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".

Patch LGTM but may want to wait until http://ffmpeg.org/pipermail/ffmpeg-devel/2023-May/309638.html


More information about the ffmpeg-devel mailing list