Skip to content

Commit b249650

Browse files
committed
Actually add the opt parameter
Forgot to add it in the VapourSynth bindings
1 parent 270bffd commit b249650

2 files changed

Lines changed: 35 additions & 15 deletions

File tree

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ The plugin itself supports every constant input format. If the format is subsamp
88
The included python wrapper, contrary to using the plugin directly, doesn't descale the chroma planes but scales them normally with `Spline36`.
99

1010
```
11-
descale.Debilinear(clip src, int width, int height, float src_left=0.0, float src_top=0.0, float src_width=width, float src_height=height)
11+
descale.Debilinear(clip src, int width, int height, float src_left=0.0, float src_top=0.0, float src_width=width, float src_height=height, int opt=0)
1212
13-
descale.Debicubic(clip src, int width, int height, float b=0.0, float c=0.5, float src_left=0.0, float src_top=0.0, float src_width=width, float src_height=height)
13+
descale.Debicubic(clip src, int width, int height, float b=0.0, float c=0.5, float src_left=0.0, float src_top=0.0, float src_width=width, float src_height=height, int opt=0)
1414
15-
descale.Delanczos(clip src, int width, int height, int taps=3, float src_left=0.0, float src_top=0.0, float src_width=width, float src_height=height)
15+
descale.Delanczos(clip src, int width, int height, int taps=3, float src_left=0.0, float src_top=0.0, float src_width=width, float src_height=height, int opt=0)
1616
17-
descale.Despline16(clip src, int width, int height, float src_left=0.0, float src_top=0.0, float src_width=width, float src_height=height)
17+
descale.Despline16(clip src, int width, int height, float src_left=0.0, float src_top=0.0, float src_width=width, float src_height=height, int opt=0)
1818
19-
descale.Despline36(clip src, int width, int height, float src_left=0.0, float src_top=0.0, float src_width=width, float src_height=height)
19+
descale.Despline36(clip src, int width, int height, float src_left=0.0, float src_top=0.0, float src_width=width, float src_height=height, int opt=0)
2020
21-
descale.Despline64(clip src, int width, int height, float src_left=0.0, float src_top=0.0, float src_width=width, float src_height=height)
21+
descale.Despline64(clip src, int width, int height, float src_left=0.0, float src_top=0.0, float src_width=width, float src_height=height, int opt=0)
2222
23-
descale.Descale(clip src, int width, int height, str kernel, int taps=3, float b=0.0, float c=0.0, float src_left=0.0, float src_top=0.0, float src_width=width, float src_height=height)
23+
descale.Descale(clip src, int width, int height, str kernel, int taps=3, float b=0.0, float c=0.0, float src_left=0.0, float src_top=0.0, float src_width=width, float src_height=height, int opt=0)
2424
```
2525

2626
## How does this work?

src/vsplugin.c

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,17 @@ static void VS_CC descale_create(const VSMap *in, VSMap *out, void *user_data, V
213213
if (err)
214214
d.dd.active_height = (double)d.dd.dst_height;
215215

216+
DescaleOpt opt_enum;
217+
int opt = int64ToIntS(vsapi->propGetInt(in, "opt", 0, &err));
218+
if (err)
219+
opt = 0;
220+
if (opt == 1)
221+
opt_enum = DESCALE_OPT_NONE;
222+
else if (opt == 2)
223+
opt_enum = DESCALE_OPT_AVX2;
224+
else
225+
opt_enum = DESCALE_OPT_AUTO;
226+
216227
if (d.dd.dst_width < 1) {
217228
vsapi->setError(out, "Descale: width must be greater than 0.");
218229
vsapi->freeNode(d.node);
@@ -329,6 +340,7 @@ static void VS_CC descale_create(const VSMap *in, VSMap *out, void *user_data, V
329340
vsapi->propSetFloat(map1, "src_top", d.dd.shift_v, paReplace);
330341
vsapi->propSetFloat(map1, "src_width", d.dd.active_width, paReplace);
331342
vsapi->propSetFloat(map1, "src_height", d.dd.active_height, paReplace);
343+
vsapi->propSetInt(map1, "opt", (int)opt_enum, paReplace);
332344
map2 = vsapi->invoke(descale_plugin, "Descale", map1);
333345
vsapi->freeNode(tmp_node);
334346
vsapi->freeMap(map1);
@@ -363,7 +375,8 @@ static void VS_CC descale_create(const VSMap *in, VSMap *out, void *user_data, V
363375
return;
364376
}
365377

366-
d.dd.dsapi = get_descale_api(DESCALE_OPT_AUTO);
378+
379+
d.dd.dsapi = get_descale_api(opt_enum);
367380
d.initialized = false;
368381
pthread_mutex_init(&d.lock, NULL);
369382

@@ -385,7 +398,8 @@ VS_EXTERNAL_API(void) VapourSynthPluginInit(VSConfigPlugin config_func, VSRegist
385398
"src_left:float:opt;"
386399
"src_top:float:opt;"
387400
"src_width:float:opt;"
388-
"src_height:float:opt",
401+
"src_height:float:opt;"
402+
"opt:int:opt",
389403
descale_create, (void *)(DESCALE_MODE_BILINEAR), plugin);
390404

391405
register_func("Debicubic",
@@ -397,7 +411,8 @@ VS_EXTERNAL_API(void) VapourSynthPluginInit(VSConfigPlugin config_func, VSRegist
397411
"src_left:float:opt;"
398412
"src_top:float:opt;"
399413
"src_width:float:opt;"
400-
"src_height:float:opt",
414+
"src_height:float:opt;"
415+
"opt:int:opt",
401416
descale_create, (void *)(DESCALE_MODE_BICUBIC), plugin);
402417

403418
register_func("Delanczos",
@@ -408,7 +423,8 @@ VS_EXTERNAL_API(void) VapourSynthPluginInit(VSConfigPlugin config_func, VSRegist
408423
"src_left:float:opt;"
409424
"src_top:float:opt;"
410425
"src_width:float:opt;"
411-
"src_height:float:opt",
426+
"src_height:float:opt;"
427+
"opt:int:opt",
412428
descale_create, (void *)(DESCALE_MODE_LANCZOS), plugin);
413429

414430
register_func("Despline16",
@@ -418,7 +434,8 @@ VS_EXTERNAL_API(void) VapourSynthPluginInit(VSConfigPlugin config_func, VSRegist
418434
"src_left:float:opt;"
419435
"src_top:float:opt;"
420436
"src_width:float:opt;"
421-
"src_height:float:opt",
437+
"src_height:float:opt;"
438+
"opt:int:opt",
422439
descale_create, (void *)(DESCALE_MODE_SPLINE16), plugin);
423440

424441
register_func("Despline36",
@@ -428,7 +445,8 @@ VS_EXTERNAL_API(void) VapourSynthPluginInit(VSConfigPlugin config_func, VSRegist
428445
"src_left:float:opt;"
429446
"src_top:float:opt;"
430447
"src_width:float:opt;"
431-
"src_height:float:opt",
448+
"src_height:float:opt;"
449+
"opt:int:opt",
432450
descale_create, (void *)(DESCALE_MODE_SPLINE36), plugin);
433451

434452
register_func("Despline64",
@@ -438,7 +456,8 @@ VS_EXTERNAL_API(void) VapourSynthPluginInit(VSConfigPlugin config_func, VSRegist
438456
"src_left:float:opt;"
439457
"src_top:float:opt;"
440458
"src_width:float:opt;"
441-
"src_height:float:opt",
459+
"src_height:float:opt;"
460+
"opt:int:opt",
442461
descale_create, (void *)(DESCALE_MODE_SPLINE64), plugin);
443462

444463
register_func("Descale",
@@ -452,6 +471,7 @@ VS_EXTERNAL_API(void) VapourSynthPluginInit(VSConfigPlugin config_func, VSRegist
452471
"src_left:float:opt;"
453472
"src_top:float:opt;"
454473
"src_width:float:opt;"
455-
"src_height:float:opt",
474+
"src_height:float:opt;"
475+
"opt:int:opt",
456476
descale_create, NULL, plugin);
457477
}

0 commit comments

Comments
 (0)