History

sws_utils: allow setting zimg options directly

One could wonder, why not just use the zimg wrapper directly?

wm4 committed 6 years ago

Commit d61ced31 parent 43591ba4 files · +18 −8Browse files

Unified · Split

4 files
  1. video/sws_utils.c +2 −0
  2. video/sws_utils.h +4 −0
  3. video/zimg.c +10 −8
  4. video/zimg.h +2 −0
video/sws_utils.c+2−0
@@ -244,6 +244,8 @@ int mp_sws_reinit(struct mp_sws_context *ctx) · 243 unmodified lines
244244 ctx->zimg->log = ctx->log;
245245 ctx->zimg->src = *src;
246246 ctx->zimg->dst = *dst;
247+ if (ctx->zimg_opts)
248+ ctx->zimg->opts = *ctx->zimg_opts;
247249 if (mp_zimg_config(ctx->zimg)) {
248250 ctx->zimg_ok = true;
249251 MP_VERBOSE(ctx, "Using zimg.\n");
video/sws_utils.h+4−0
@@ -44,6 +44,10 @@ struct mp_sws_context { · 43 unmodified lines
4444 // This is unfortunately a hack: bypass command line choice
4545 enum mp_sws_scaler force_scaler;
4646
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+
4751 // Changing these requires setting force_reload=true.
4852 // By default, they are NULL.
4953 // Freeing the mp_sws_context will deallocate these if set.
video/zimg.c+10−8
@@ -43,6 +43,15 @@ static const struct m_opt_choice_alternatives mp_zimg_scalers[] = { · 42 unmodified lines
4343 {0}
4444 };
4545
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+
4655 #define OPT_PARAM(var) OPT_DOUBLE(var), .flags = M_OPT_DEFAULT_NAN
4756
4857 #define OPT_BASE_STRUCT struct zimg_opts
@@ -63,14 +72,7 @@ const struct m_sub_options zimg_conf = { · 14 unmodified lines
6372 {0}
6473 },
6574 .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,
7476 };
7577
7678 struct mp_zimg_repack {
video/zimg.h+2−0
@@ -22,6 +22,8 @@ struct zimg_opts { · 21 unmodified lines
2222 int fast;
2323 };
2424
25+extern const struct zimg_opts zimg_opts_defaults;
26+
2527 struct mp_zimg_context {
2628 // Can be set for verbose error printing.
2729 struct mp_log *log;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t