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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 14th May 2018, 15:40   #1  |  Link
Stereodude
Registered User
 
Join Date: Dec 2002
Location: Region 0
Posts: 973
Color adjustments in RGB colorspace supporting ConditionalReader?

Is there any color adjusting plugin that works in RGB colorspace that supports ConditionalReader (or a similar way to vary parameters on a frame by frame basis) and high bit depth (>8-bit)?

Basically I'm looking for a RGB equivalent to the built in AVIsynth filter ColorYUV. RGBAdjust is similar and built in, but doesn't have a conditional argument.

My quick search for such a filter didn't find anything even ignoring my desire to work in >8-bit RGB color.
Stereodude is offline   Reply With Quote
Old 14th May 2018, 22:37   #2  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,377
You can use RGBAdjust inside ScriptClip, something like this (not tested)
Code:
ScriptClip("""
RGBAdjust(r=xyx_r, rg=xyx_rg)
""")
ConditionalReader("r.txt", "xyx_r", false)
ConditionalReader("rg.txt", "xyx_rg", false)
Edit - remember the variables are global, so give them names that are unique within the script (and any Imported scripts too)

Last edited by raffriff42; 14th May 2018 at 22:56. Reason: global
raffriff42 is offline   Reply With Quote
Old 14th May 2018, 23:53   #3  |  Link
Stereodude
Registered User
 
Join Date: Dec 2002
Location: Region 0
Posts: 973
Quote:
Originally Posted by raffriff42 View Post
You can use RGBAdjust inside ScriptClip, something like this (not tested)
Code:
ScriptClip("""
RGBAdjust(r=xyx_r, rg=xyx_rg)
""")
ConditionalReader("r.txt", "xyx_r", false)
ConditionalReader("rg.txt", "xyx_rg", false)
Edit - remember the variables are global, so give them names that are unique within the script (and any Imported scripts too)
Thanks. The idea works. I think you have too many "" though. This is what I got to work.
Code:
ScriptClip(clip, "
RGBAdjust(rb=(xyx_rb), gb=(xyx_gb), bb=(xyx_bb))
")
ConditionalReader("r_levels_t2.txt", "xyx_rb", false)
ConditionalReader("b_levels_t2.txt", "xyx_gb", false)
ConditionalReader("g_levels_t2.txt", "xyx_bb", false)
Stereodude is offline   Reply With Quote
Old 15th May 2018, 00:09   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 5,657
Quote:
The idea works. I think you have too many "" though.
As provided by RaffRiff42, triple quotes allows for use of single quoted strings within Scriptclip, otherwise not allowed.
Raff was just making it a bit more bullet proof for you.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 15th May 2018, 00:13   #5  |  Link
Stereodude
Registered User
 
Join Date: Dec 2002
Location: Region 0
Posts: 973
Quote:
Originally Posted by StainlessS View Post
As provided by RaffRiff42, triple quotes allows for use of single quoted strings within Scriptclip, otherwise not allowed.
Raff was just making it a bit more bullet proof for you.
I couldn't get it to work as he wrote it with the triple quotes. However, after being prompted by your post to take another look at it I see the triple quotes are messing with MP_Pipeline, which nests the entire script inside of triple quotes.
Stereodude is offline   Reply With Quote
Old 15th May 2018, 00:13   #6  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,377
Cool, glad it worked. The triple quotes (""") are legit actually. They are for nested quotations. Example:
Code:
ScriptClip("""
Subtitle("Current frame = " + String(current_frame), 
\ align=5)
""")
raffriff42 is offline   Reply With Quote
Old 15th May 2018, 00:18   #7  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 5,657
Avisynth does not support eg 5 pairs of quotes (so as to be able to enclose both triple and single quotes), which can make things awkward.
(Other languages eg BASIC allow for 5 pairs [EDIT: and maybe 7 pairs of double] quotes [methinks]).

Code:
SSS="""
Subtitle("Current frame = " + String(current_frame), align=5)
"""
Scriptclip(SSS)
So can use as above, for use with your MP_Pipeline thing.

EDIT: Not sure how you use the mp_pipeline thing, maybe something like so
Code:
SSS="""
Subtitle("Current frame = " + String(current_frame), align=5)
"""
mp_pipeline("Scriptclip(SSS)")
EDIT: I sometimes use the Multi-Instance template model developed by Gavino and Martin53, to get around the missing 5 pairs of double quotes thing.

EDIT: And the SSS= """ ... """ thing is nothing to do with the 'ssS' on the end of my username, I usually use to signify a triple quoted string,
although some times as 'main source string' where S used for a substring of it.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 16th May 2018 at 13:35.
StainlessS is offline   Reply With Quote
Old 15th May 2018, 20:39   #8  |  Link
davidhorman
I'm the Doctor
 
Join Date: Jan 2004
Posts: 1,414
Does Avisynth need an <<<EOF type delimiter (heredoc)?
__________________
My AviSynth filters / I'm the Doctor
davidhorman is offline   Reply With Quote
Old 16th May 2018, 01:53   #9  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,377
I dunno, it might be nicer to work with (triple quotes mess with my editor's syntax highlighting) but unless the strings can be nested, you will have the same problem.
raffriff42 is offline   Reply With Quote
Old 16th May 2018, 10:44   #10  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,020
Most modern languages provide facilities for both line breaks and various quote characters inside string literals, and usually some form of variable interpolation as well. Heredocs provide the first in languages such as Perl (and in Perl also the third), but what Avisynth script really lacks is an escape character (e.g. backslash) to provide the second. In languages that don’t have heredocs, multi-line string literals are sometimes provided via some special quote character (c.f. JavaScript, which uses `backticks` for this). The triple quote serves the same purpose in Avisynth script, but you can’t escape it.

Last edited by TheFluff; 16th May 2018 at 10:47.
TheFluff is offline   Reply With Quote
Old 4th June 2018, 10:23   #11  |  Link
Stereodude
Registered User
 
Join Date: Dec 2002
Location: Region 0
Posts: 973
Does using Scriptclip + RGBAdjust leak memory for anyone else? Both 32-bit and 64-bit Avisynth+ leak memory for me when used on 16-bit RGB. With DVD res (720x480) by about 10,000 frames in it has grown to about 4GB. In 32-bit it either crashes or simply stops adjusting the levels passing the video through unaffected. In 64-bit it just keeps growing.

I'm out of town and only discovered this as I was packing so I didn't have a lot of time to troubleshoot it or try to make a simple script showing the issue. I'm pretty sure it is the Scriptclip + RGB adjust portion that's the problem as the same script with ColorYUV (using conditional processing) doesn't have the issue.
Stereodude is offline   Reply With Quote
Old 4th June 2018, 10:54   #12  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 964
Good catch, I could reproduce the leak. It's there even at 8 bits but the internal lookup table for 16 bit is 128k, so it eats your memory faster.
EDIT: leak stopped
EDIT: conditional=true supported, like in colorYUV
EDIT: works now with 32 bit float (but no 'dither', and no 'analyze')
EDIT: check Avs+ r2700 test build

Last edited by pinterf; 4th June 2018 at 15:05. Reason: problem fixed
pinterf is offline   Reply With Quote
Old 5th June 2018, 06:55   #13  |  Link
Stereodude
Registered User
 
Join Date: Dec 2002
Location: Region 0
Posts: 973
Quote:
Originally Posted by pinterf View Post
Good catch, I could reproduce the leak. It's there even at 8 bits but the internal lookup table for 16 bit is 128k, so it eats your memory faster.
EDIT: leak stopped
EDIT: conditional=true supported, like in colorYUV
EDIT: works now with 32 bit float (but no 'dither', and no 'analyze')
EDIT: check Avs+ r2700 test build
Very cool, thanks!

I'll check it out when I'm back in town, but that won't be a few days.
Stereodude is offline   Reply With Quote
Old 9th June 2018, 21:26   #14  |  Link
Stereodude
Registered User
 
Join Date: Dec 2002
Location: Region 0
Posts: 973
Quote:
Originally Posted by pinterf View Post
Good catch, I could reproduce the leak. It's there even at 8 bits but the internal lookup table for 16 bit is 128k, so it eats your memory faster.
EDIT: leak stopped
EDIT: conditional=true supported, like in colorYUV
EDIT: works now with 32 bit float (but no 'dither', and no 'analyze')
EDIT: check Avs+ r2700 test build
I confirm the leak is fixed.

IMHO, RGBAdjust is still missing at least one argument. Some sort of bit depth or scaling argument that can be used to scale the values in the file for the bias values. The ability to apply a formula would be useful too.

When using ScriptClip I can do this:

Code:
ScriptClip(source, "
RGBAdjust(rb=(xyx_b*256), gb=(xyx_b*256), bb=(xyx_b*256), r=(1-xyx_b/256), g=(1-xyx_b/256), b=(1-xyx_b/256))
")
ConditionalReader("levels_t.txt", "xyx_b", false)
Even using the new conditional = true argument there's no way to do something equivalent like:
Code:
RGBAdjust(source, conditional=true
ConditionalReader(("levels_t.txt"*256), "rgbadjust_rb", false)
ConditionalReader(("levels_t.txt"*256), "rgbadjust_gb", false)
ConditionalReader(("levels_t.txt"*256), "rgbadjust_bb", false)
ConditionalReader((1-"levels_t.txt"/256), "rgbadjust_r", false)
ConditionalReader((1-"levels_t.txt"/256), "rgbadjust_g", false)
ConditionalReader((1-"levels_t.txt"/256), "rgbadjust_b", false)
Stereodude is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 16:02.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.