I apologize for being python ignorant – a small push would help.
Suppose there’s a python video processing function, Super().
configSuper, a string, is one of a number of Super() call parameters.
I seek to make configuring configSuper a user-selection matrix, sort of like this:
configSuper = "{"
# To configure, add/move/remove lefthand '#'s"
# + "gpu:1,full:true," # Use GPU; set precision to whole pixels.
# + "gpu:1,full:false," # Use GPU; whole pixels; limits memory demand when processing very large (e.g. 4K) frames.
# + "gpu:0,pel:1," # whole pixels.
# + "gpu:0,pel:1,full:true," # whole pixels.
# + "gpu:0,pel:1,full:false." # whole pixels; limits memory demand when processing very large (e.g. 4K) frames.
+ "gpu:0,pel:2,scale:{" # -default- half pixels (i.e. upscale clipSuper to clipSource via 1x1-to-2x2 pixel duplication).
# + "gpu:0,pel:4,scale:{" # quarter pixels (i.e. upscale clipSuper to clipSource via 1x1-to-4x4 pixel duplication); not recommended.
# + "up:0," # Upscale interim clip method: Bilinear.
# + "up:1," # Bicubic, 4 tap Catmull-Rom.
+ "up:2," # -default- Bicubic, 6 tap Wiener -- like Lanczos; sharper.
# + "down:0}," # Downscale result method: Simple 4-pixel average -- like AviSynth's unfiltered SimpleResize; minimum anti-aliasing.
# + "down:1}," # Triangle (shifted) -- like ReduceBy2; moderate anti-aliasing.
# + "down:2}," # Triangle -- like BilinearResize; more anti-aliasing.
# + "down:3}," # Quadratic -- even more anti-aliasing.
+ "down:4}," # -default- Cubic -- like BicubicResize(b=1,c=0); maximum anti-aliasing.
+ "rc:0}" # The 'rc' attribute is required by Super(); this merely creates it.
But of course that doesn’t work because of varying indentation (that throws exceptions) and line-spanning concatination (that throws exceptions).
As you can see by the console session below, I can craft something that works and produces the right result (bottom line), but, oh my, it is ugly.
How can I craft a selection matrix that isn’t so ugly? Got any bright ideas/tricks?
>>> configSuper = "{"
>>> #To configure, add/move/remove lefthand '#'s"
>>> #configSuper = configSuper + "gpu:1,full:true," # Use GPU; set precision to whole pixels.
>>> #configSuper = configSuper + "gpu:1,full:false," # Use GPU; whole pixels; limits memory demand when processing very large (e.g. 4K) frames.
>>> #configSuper = configSuper + "gpu:0,pel:1," # whole pixels.
>>> #configSuper = configSuper + "gpu:0,pel:1,full:true," # whole pixels.
>>> #configSuper = configSuper + "gpu:0,pel:1,full:false." # whole pixels; limits memory demand when processing very large (e.g. 4K) frames.
>>> configSuper = configSuper + "gpu:0,pel:2,scale:{" # -default- half pixels (i.e. upscale clipSuper to clipSource via 1x1-to-2x2 pixel duplication).
>>> #configSuper = configSuper + "gpu:0,pel:4,scale:{" # quarter pixels (i.e. upscale clipSuper to clipSource via 1x1-to-4x4 pixel duplication); not recommended.
>>> #configSuper = configSuper + "up:0," # Upscale interim clip method: Bilinear.
>>> #configSuper = configSuper + "up:1," # Bicubic, 4 tap Catmull-Rom.
>>> configSuper = configSuper + "up:2," # -default- Bicubic, 6 tap Wiener -- like Lanczos; sharper.
>>> #configSuper = configSuper + "down:0}," # Downscale result method: Simple 4-pixel average -- like AviSynth's unfiltered SimpleResize; minimum anti-aliasing.
>>> #configSuper = configSuper + "down:1}," # Triangle (shifted) -- like ReduceBy2; moderate anti-aliasing.
>>> #configSuper = configSuper + "down:2}," # Triangle -- like BilinearResize; more anti-aliasing.
>>> #configSuper = configSuper + "down:3}," # Quadratic -- even more anti-aliasing.
>>> configSuper = configSuper + "down:4}," # -default- Cubic -- like BicubicResize(b=1,c=0); maximum anti-aliasing.
>>> configSuper = configSuper + "rc:0}" # The 'rc' attribute is required by Super(); this merely creates it.
>>> configSuper
'{gpu:0,pel:2,scale:{up:2,down:4},rc:0}'