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 Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 12th June 2018, 15:50   #4121  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 964
Perhaps a rec601-709 mismatch happening somewhere in the conversion chain? (red cast)
pinterf is online now   Reply With Quote
Old 13th June 2018, 14:22   #4122  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,377
Quote:
Originally Posted by `Orum View Post
I've noticed what I think is some color shift toward Cb-/Cr- with the ColorYUV(levels="TV->PC") / ColorYUV(levels="PC->TV")...
There is an offset-by-negative-one for each round trip.
That's not a bug, it's a consequence of 8-bit math doing something (round trip) it wasn't designed to do.
Attempting to fix it results in a slightly worse one-way conversion.
Increasing the source bit depth decreases the error; with 32-bit float it's un-measureable.
Alternatively, when you know you are doing a round trip, you could add an offset manually:
Code:
function s(clip c) {
    return c.ColorYUV(levels="TV->PC")
    \ .ColorYUV(levels="PC->TV", off_y=1, off_u=1, off_v=1)
}
raffriff42 is offline   Reply With Quote
Old 15th June 2018, 09:01   #4123  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 964
New build r2719
https://drive.google.com/open?id=1gA...Zn31Z8JLfZJ3yo
And a test masktools2 (2.2.15) that matches this avisynth version
https://drive.google.com/open?id=1H0...0hVlXCwd2c-afI

I'm posting both test builds here, because they are tightly connected.

real.finder, who is responsible with many old scripts, asked me for these features for a long time. And I resisted because I was against such autoconversion. Anyway, you can start experimenting but you have to understand when you can use this feature safely (but maybe it's less prone to errors than mis-using scaleb and scalef)

- LUT functions in masktools2 and Expr in Avisynth+ have now two new parameters: scale_inputs and clamp_float (see below). In same cases they allow a quite a convenient way of using old 8 bit lut expressions to be used for generic bit-depth.

- The other feature in masktools2 is the new 'use_expr' parameter.
This parameter allows passing the whole expression to Avisynth+ when the lut filter would use the slow interpreted realtime way of expression calculation (for 16 bits no xy lut table exists because it is too big to fit in the memory). Try setting use_expr=1 for mt_lutxy (that will pass the expression to Avisynth for 10 or more bits) will drastically speed up a 16bit mt_lutxy.

Avisynth:
Code:
- New: Expr: implement 'clip' three operand operator like in masktools2
  Description: clips (clamps) value: x minvalue maxvalue clip -> max(min(x, maxvalue), minvalue)
- New: Expr: Parameter "clamp_float"
    True: clamps 32 bit float to valid ranges, which is 0..1 for Luma or for RGB color space and -0.5..0.5 for YUV chroma UV channels
    Default false, ignored (treated as true) when scale_inputs scales float
- New: Expr: parameter "scale_inputs" (default "none")

    Autoscale any input bit depths to 8-16 bit for internal expression use, the conversion method is either full range or limited YUV range.
    
    Feature is similar to the one in masktools2 v2.2.15

    The primary reason of this feature is the "easy" usage of formerly written expressions optimized for 8 bits.

    Use
    - "int" : scales limited range videos, only integer formats (8-16bits) to 8 (or bit depth specified by 'i8'..'i16')
    - "intf": scales full range videos, only integer formats (8-16bits) to 8 (or bit depth specified by 'i8'..'i16')
    - "float" or "floatf" : only scales 32 bit float format to 8 bit range (or bit depth specified by 'i8'..'i16')
    - "all": scales videos to 8 (or bit depth specified by 'i8'..'i16') - conversion uses limited_range logic (mul/div by two's power)
    - "allf": scales videos to 8 (or bit depth specified by 'i8'..'i16') - conversion uses full scale logic (stretch)
    - "none": no magic

    Usually limited range is for normal YUV videos, full scale is for RGB or known-to-be-fullscale YUV

    By default the internal conversion target is 8 bits, so old expressions written for 8 bit videos will probably work.
    This internal working bit-depth can be overwritten by the i8, i10, i12, i14, i16 specifiers.

    When using autoscale mode, scaleb and scalef keywords are meaningless, because there is nothing to scale.

    How it works:
    - This option scales all 8-32 bit inputs to a common bit depth value, which bit depth is 8 by default and can be 
      set to 10, 12, 14 and 16 bits by the 'i10'..'i16' keywords
      For example: scale_inputs="all" converts any inputs to 8 bit range. No truncation occurs however (no precision loss), 
      because even a 16 bit data is converted to 8 bit in floating point precision, using division by 256.0 (2^16/2^8). 
      So the conversion is _not_ a simple shift-right-8 in the integer domain, which would lose precision.
    - Calculates expression (lut, lut_xy, lut_xyz, lut_xyza)
    - Scales the result back to the original video bit depth.
      Clamping (clipping to valid range) and converting to integer occurs here.

    The predefined constants such as 'range_max', etc. will behave according to the internal working bit depth

    Warning#1 
    This feature was created for easy porting earlier 8-bit-video-only lut expressions.
    You have to understand how it works internally.

    Let's see a 16bit input in "all" and "allf" mode (target is the default 8 bits)

    Limited range 16->8 bits conversion has a factor of 1/256.0 (Instead of shift right 8 in integer domain, float-division is used or else it would lose presision)

    Full range 16->8 bits conversion has a factor of 255.0/65535

    Using bit shifts (really it's division and multiplication by 2^8=256.0): 
      result = calculate_lut_value(input / 256.0) * 256.0
    Full scale 16-8-16 bit mode ('intf', 'allf')
      result = calculate_lut_value(input / 65535.0 * 255.0 ) / 255.0 * 65535.0

    Use scale_inputs = "all" ("int", "float") for YUV videos with 'limited' range e.g. in 8 bits: Y=16..235, UV=16..240).
    Use scale_inputs = "allf" (intf, floatf) for RGB or YUV videos with 'full' range e.g. in 8 bits: channels 0..255.

    When input is 32bit float, the 0..1.0 (luma) and -0.5..0.5 (chroma) channel is scaled
    to 0..255 (8 bits), 0..1023 (i10 mode), 0..4095 (i12 mode), 0..16383(i14 mode), 0..65535(i16 mode) then back.

    Warning#2
    One cannot specify different conversion methods for converting before and after the expression.
    Neither can you specify different methods for different input clips (e.g. x is full, y is limited is not supported).
masktools2:
Code:
- 32 bit float U and V chroma channels are now zero based (+/-0.5 for full scale). Was: 0..1, same as luma
  (Following the change in Avisynth+ over r2664: use this plugin with r2996 or newer)
  Affected predefined expression constants when plane is U or V: 
  cmin and cmax (limited range (16-128)/255 and (240-128)/255 instead of 16/255.0 and 240/255.0
  range_max: 0.5 instead of 1.0
  new: introduce range_min: -0.5 for float U/V chroma, 0 otherwise
  range_half (0.0 instead of 0.5)
  (range_size remained 1.0)
- New expression syntax for Lut expressions: autoscale any input (x,y,z,a) bit depths to 8-16 bits for internal 
  expression use. The primary reason of this feature is the "easy" usage of formerly written 8 bit optimized expressions.

  New parameters for lut functions: 
    String "scale_inputs": "all","allf","int","intf","float","floatf","none", default "none"
  and 
    Boolean "clamp_float": default false, but treated as always true (and thus ignored) when scale_inputs involves a float autoscale.
  and 
    Boolean "use_expr": default 0, calls fast JIT-compiled "Expr" in Avisynth+ for mt_lut, lutxy, lutxyz, lutxyza
    0: no Expr, use slow internal realtime calc if needed (as before)
    1: call Expr for bits>8 or lutxyza
    2: call Expr, when masktools would do its slow realtime calc (see 'realtime' column in the table above)

  Extends and replaces experimental clamp_xxxx keywords.

Last edited by pinterf; 15th June 2018 at 11:47.
pinterf is online now   Reply With Quote
Old 15th June 2018, 10:37   #4124  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 917
Quote:
Originally Posted by pinterf View Post
real.finder, who is responsible with many old scripts, asked me for these features for a long time.
Can we use this builds with his older scripts or any processed video will turn into a LSD trip?
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 15th June 2018, 10:46   #4125  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 964
Quote:
Originally Posted by tormento View Post
Can we use this builds with his older scripts or any processed video will turn into a LSD trip?
I suppose these versions are backward compatible. But will show no gain until you specify the parameters that enable the features. Again, you have to know what you are doing. And check the results.
pinterf is online now   Reply With Quote
Old 15th June 2018, 11:33   #4126  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 993
expr scale seems work fine

but I got mt_lutXX does not have a named argument "scale_inputs" in xp I used in VM, same for use_expr

I did check the dll date and it seems very old!
__________________
My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 15th June 2018, 11:38   #4127  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 964
Quote:
Originally Posted by real.finder View Post
expr scale seems work fine

but I got mt_lutXX does not have a named argument "scale_inputs" in xp I used in VM, same for use_expr

I did check the dll date and it seems very old!
Weird, all dlls in the 7z package are from yesterday.
pinterf is online now   Reply With Quote
Old 15th June 2018, 11:44   #4128  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 993
Quote:
Originally Posted by pinterf View Post
Weird, all dlls in the 7z package are from yesterday.


google drive maybe give the 1st test you did not the overwritten new one
__________________
My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 15th June 2018, 11:49   #4129  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 964
Quote:
Originally Posted by real.finder View Post
google drive maybe give the 1st test you did not the overwritten new one
Sorry, please check the fixed link again. Seems I have novice file copying problems nowadays.
pinterf is online now   Reply With Quote
Old 15th June 2018, 14:10   #4130  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 917
Quote:
Originally Posted by pinterf View Post
And check the results.
No mushroom effect yet.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 16th June 2018, 12:51   #4131  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 993
Quote:
Originally Posted by pinterf View Post
Sorry, please check the fixed link again. Seems I have novice file copying problems nowadays.
thank you it work now, but there are some small problems check here https://forum.doom9.org/showthread.php?p=1844631
__________________
My Avisynth Stuff
real.finder is offline   Reply With Quote
Old Yesterday, 21:11   #4132  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 964
Thanks, real.finder for the report. scale_inputs "float" with input bit depth integer was misinterpreted. r2721 fixes that problem.

AviSynth+ r2721 test build (hopefully one of the last tests):
https://drive.google.com/open?id=1Qk...wN9QyQMK-vHhG6
Matching masktools2 2.2.15 test 5 (not changed since last version)
https://drive.google.com/open?id=1H0...0hVlXCwd2c-afI

Last edited by pinterf; Yesterday at 21:22.
pinterf is online now   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 10:43.


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