Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
18th October 2021, 16:52 | #6 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,377
|
You might have to blur or process image with something - because of "stray" pixels (maybe less of an issue for U, V planes than Y) - but the absolute min/max will probably give you not ideal results
(Another less favorable option would be loading an avs plugin...) |
18th October 2021, 17:04 | #7 | Link | |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
|
Quote:
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
|
18th October 2021, 19:51 | #8 | Link |
Registered User
Join Date: Sep 2006
Posts: 1,657
|
I run into a problem with the invoking sequence. The normal order for invoking multiple filters would be like:
Code:
output_node -> invoke_function1 -> invoke_function2 -> get_frame -> display Code:
output_node -> invoke_PlaneStats -> get_frame -> get_frame_prop -> invoke_Levels -> get_frame -> display |
19th October 2021, 03:29 | #9 | Link |
Registered User
Join Date: Jan 2016
Posts: 162
|
with builtins
Code:
def f(n, f, clip=src): min_in = f.props["PlaneStatsMin"] max_in = f.props["PlaneStatsMax"] return clip.std.Levels(min_in, max_in, min_out=0, max_out=255, planes=[0]) stats = core.std.PlaneStats(src, plane=0) flt = core.std.FrameEval(src, f, stats) Code:
stats = core.std.PlaneStats(src, plane=0) expr = "x {min_in} - {max_in} {min_in} - / {max_out} {min_out} - * {min_out} +".format(min_in="x.PlaneStatsMin", max_in="x.PlaneStatsMax", min_out=0, max_out=255) flt = core.akarin.Expr(stats, [expr, ""]) |
19th October 2021, 08:21 | #10 | Link | |
Registered User
Join Date: Sep 2006
Posts: 1,657
|
Quote:
Code:
VSPlugin * pStdPlugin = m_cpVSAPI->getPluginByID("com.vapoursynth.std", m_pCore); m_cpVSAPI->mapConsumeNode(pArgumentMap, "clip", a_pVideoNode, maReplace); m_cpVSAPI->mapSetFunction(pArgumentMap, "eval", "???", maReplace); VSMap * pResultMap = m_cpVSAPI->invoke(pStdPlugin, "FrameEval", pArgumentMap); |
|
19th October 2021, 11:04 | #11 | Link |
Registered User
Join Date: Jan 2016
Posts: 162
|
For the second one,
Code:
#include <sstream> auto min_in = "x.PlaneStatsMin"; auto max_in = "x.PlaneStatsMax"; auto min_out = 0; auto max_out = 255; std::ostringstream expr_stream {}; expr_stream << "x " << min_in << " - " << max_in << " " << min_in << " - / " << max_out - min_out << " * " << min_out << " +"; auto expr = expr_stream.str(); vsapi->mapSetData(args, "expr", expr, std::size(expr), dtBinary, maReplace); // Y plane vsapi->mapSetData(args, "expr", "", 0, dtBinary, maAppend); // U plane vsapi->mapSetData(args, "expr", "", 0, dtBinary, maAppend); // V plane |
20th October 2021, 18:55 | #12 | Link |
Registered User
Join Date: Sep 2006
Posts: 1,657
|
Thanks it works. I modified the string a little because the vsapi function was looking for "const * char" instead of string.
Code:
std::ostringstream expr_stream {}; expr_stream << "x " << min_in << " - " << max_in << " " << min_in << " - / " << max_out - min_out << " * " << min_out << " +"; auto expr = _strdup(expr_stream.str().c_str()); vsapi->mapSetData(args, "expr", expr, strlen(expr), dtBinary, maReplace); // Y plane Last edited by lansing; 20th October 2021 at 18:58. |
Tags |
autolevels |
|
|