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
244 ctx->zimg->log = ctx->log;244 ctx->zimg->log = ctx->log;
245 ctx->zimg->src = *src;245 ctx->zimg->src = *src;
246 ctx->zimg->dst = *dst;246 ctx->zimg->dst = *dst;
247 if (ctx->zimg_opts)
248 ctx->zimg->opts = *ctx->zimg_opts;
247 if (mp_zimg_config(ctx->zimg)) {249 if (mp_zimg_config(ctx->zimg)) {
248 ctx->zimg_ok = true;250 ctx->zimg_ok = true;
249 MP_VERBOSE(ctx, "Using zimg.\n");251 MP_VERBOSE(ctx, "Using zimg.\n");
video/sws_utils.h+4−0
@@ -44,6 +44,10 @@ struct mp_sws_context { · 43 unmodified lines
44 // This is unfortunately a hack: bypass command line choice44 // This is unfortunately a hack: bypass command line choice
45 enum mp_sws_scaler force_scaler;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 // Changing these requires setting force_reload=true.51 // Changing these requires setting force_reload=true.
48 // By default, they are NULL.52 // By default, they are NULL.
49 // Freeing the mp_sws_context will deallocate these if set.53 // 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
43 {0}43 {0}
44};44};
45 45
46const 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#define OPT_PARAM(var) OPT_DOUBLE(var), .flags = M_OPT_DEFAULT_NAN55#define OPT_PARAM(var) OPT_DOUBLE(var), .flags = M_OPT_DEFAULT_NAN
47 56
48#define OPT_BASE_STRUCT struct zimg_opts57#define OPT_BASE_STRUCT struct zimg_opts
@@ -63,14 +72,7 @@ const struct m_sub_options zimg_conf = { · 14 unmodified lines
63 {0}72 {0}
64 },73 },
65 .size = sizeof(struct zimg_opts),74 .size = sizeof(struct zimg_opts),
66 .defaults = &(const struct zimg_opts){75 .defaults = &zimg_opts_defaults,
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 },
74};76};
75 77
76struct mp_zimg_repack {78struct mp_zimg_repack {
video/zimg.h+2−0
@@ -22,6 +22,8 @@ struct zimg_opts { · 21 unmodified lines
22 int fast;22 int fast;
23};23};
24 24
25extern const struct zimg_opts zimg_opts_defaults;
26
25struct mp_zimg_context {27struct mp_zimg_context {
26 // Can be set for verbose error printing.28 // Can be set for verbose error printing.
27 struct mp_log *log;29 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