One could wonder, why not just use the zimg wrapper directly?
Unified · Split
| @@ -244,6 +244,8 @@ int mp_sws_reinit(struct mp_sws_context *ctx) · 243 unmodified lines | ||
| 244 | 244 | ctx->zimg->log = ctx->log; |
| 245 | 245 | ctx->zimg->src = *src; |
| 246 | 246 | ctx->zimg->dst = *dst; |
| 247 | + if (ctx->zimg_opts) | |
| 248 | + ctx->zimg->opts = *ctx->zimg_opts; | |
| 247 | 249 | if (mp_zimg_config(ctx->zimg)) { |
| 248 | 250 | ctx->zimg_ok = true; |
| 249 | 251 | MP_VERBOSE(ctx, "Using zimg.\n"); |
| @@ -44,6 +44,10 @@ struct mp_sws_context { · 43 unmodified lines | ||
| 44 | 44 | // This is unfortunately a hack: bypass command line choice |
| 45 | 45 | enum mp_sws_scaler force_scaler; |
| 46 | 46 | |
| 47 | + // If zimg is used. Need to manually invalidate cache (set force_reload). | |
| 48 | + // Conflicts with enabling command line opts. | |
| 49 | + struct zimg_opts *zimg_opts; | |
| 50 | + | |
| 47 | 51 | // Changing these requires setting force_reload=true. |
| 48 | 52 | // By default, they are NULL. |
| 49 | 53 | // Freeing the mp_sws_context will deallocate these if set. |
| @@ -43,6 +43,15 @@ static const struct m_opt_choice_alternatives mp_zimg_scalers[] = { · 42 unmodified lines | ||
| 43 | 43 | {0} |
| 44 | 44 | }; |
| 45 | 45 | |
| 46 | +const struct zimg_opts zimg_opts_defaults = { | |
| 47 | + .scaler = ZIMG_RESIZE_LANCZOS, | |
| 48 | + .scaler_params = {NAN, NAN}, | |
| 49 | + .scaler_chroma_params = {NAN, NAN}, | |
| 50 | + .scaler_chroma = ZIMG_RESIZE_BILINEAR, | |
| 51 | + .dither = ZIMG_DITHER_RANDOM, | |
| 52 | + .fast = 1, | |
| 53 | +}; | |
| 54 | + | |
| 46 | 55 | #define OPT_PARAM(var) OPT_DOUBLE(var), .flags = M_OPT_DEFAULT_NAN |
| 47 | 56 | |
| 48 | 57 | #define OPT_BASE_STRUCT struct zimg_opts |
| @@ -63,14 +72,7 @@ const struct m_sub_options zimg_conf = { · 14 unmodified lines | ||
| 63 | 72 | {0} |
| 64 | 73 | }, |
| 65 | 74 | .size = sizeof(struct zimg_opts), |
| 66 | − .defaults = &(const struct zimg_opts){ | |
| 67 | − .scaler = ZIMG_RESIZE_LANCZOS, | |
| 68 | − .scaler_params = {NAN, NAN}, | |
| 69 | − .scaler_chroma_params = {NAN, NAN}, | |
| 70 | − .scaler_chroma = ZIMG_RESIZE_BILINEAR, | |
| 71 | − .dither = ZIMG_DITHER_RANDOM, | |
| 72 | − .fast = 1, | |
| 73 | − }, | |
| 75 | + .defaults = &zimg_opts_defaults, | |
| 74 | 76 | }; |
| 75 | 77 | |
| 76 | 78 | struct mp_zimg_repack { |
| @@ -22,6 +22,8 @@ struct zimg_opts { · 21 unmodified lines | ||
| 22 | 22 | int fast; |
| 23 | 23 | }; |
| 24 | 24 | |
| 25 | +extern const struct zimg_opts zimg_opts_defaults; | |
| 26 | + | |
| 25 | 27 | struct mp_zimg_context { |
| 26 | 28 | // Can be set for verbose error printing. |
| 27 | 29 | struct mp_log *log; |