ConvertStacked

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
 
(41 intermediate revisions by 3 users not shown)
Line 6: Line 6:
  
 
<div style="max-width:42em" >
 
<div style="max-width:42em" >
These conversion filters are to allow filters that [[High_bit-depth_Support_with_Avisynth#Processing_High_Bit-depth_Video_with_AviSynth|use 16-bit video in a pseudo-8-bit colorspace]] to interact with [[Avisynthplus_color_formats|AviSyth+ high bit depth formats]]. They are intended to serve as a stopgap until more plugins appear supporting true high bit depth.
+
These conversion filters are to allow filters that [[High_bit-depth_Support_with_Avisynth#Processing_High_Bit-depth_Video_with_AviSynth|use 16-bit video in a pseudo-8-bit colorspace]] aka stacked (or lsb) and interleaved format to interact with [[Avisynthplus_color_formats|AviSyth+ high bit depth formats]] aka HBD. '''''They are intended to serve as a stopgap for plugins that not supporting true high bit depth yet so you shouldn't use them nowadays unless with some rare filters that work only with these High-bit-depth hacks'''''.
 
</div>
 
</div>
  
Line 12: Line 12:
 
==== Notes ====
 
==== Notes ====
 
<div style="max-width:42em" >
 
<div style="max-width:42em" >
*In '''[[Stack16]]''', the picture is made of two parts: one containing the highest 8 bits (MSB) for each pixel, stacked on top of another containing the lowest 8 bits (LSB). it's used in [[Dither tools]] and many others.
+
*In '''[[Stack16]]''' (Stacked 16bit) aka Double Height, the picture is made of two parts: one containing the highest 8 bits (MSB) for each pixel, stacked on top of another containing the lowest 8 bits (LSB), hence the name "Double Height". It's used in [[Dither tools]] and many others. (Sometimes in filters is referred as "lsb" only).
*the '''Double-Width''' is similar to Stack16, but the MSBs and LSBs are horizontally ''interleaved'' which is like Native HBD, and it's faster than lsb. the know examples of it existing in [[flash3kyuu_deband]]\F3kdb\f3kdb_dither in input/output_Mode=2, [[LSMASHSource]] (not in the last updates) and some dither package functions like [[Dither_out()]], [[TODO|TODO:&nbsp;verify]].
+
</div>
+
  
 +
*The '''Interleaved 16bit''' aka Double Width is similar to Stack16, but the MSBs and LSBs are horizontally ''interleaved'' which is like Native HBD, and it's faster than lsb. It's used in [[https://www.videoartifact.com/hdr/ HDRCore]] and it was also used in [[flash3kyuu_deband]], [[LSMASHSource]] and other filters before they were updated to support 16bit planar (native HBD).
  
==== Syntax and Parameters ====
+
*both can be between 9-16 bits not only 16bit
<div style="max-width:62em" >
+
</div>
 +
 
 +
== Syntax and Parameters ==
  
Accepts a 16-bit clip and returns a stacked 8-bit clip.<br>
+
{{FuncDef|ConvertToStacked(clip ''clip'' ] )}} Accepts a 16-bit (HBD) clip and returns 16bit stacked (MSB and LSB stacked one on top of the other in a fake double height "8bit" stream).<br>
{{FuncDef|ConvertToStacked(clip ''clip'' ] )}}<br>
+
{{FuncDef|ConvertToDoubleWidth(clip ''clip'' ] )}} Accepts a 16-bit (HBD) clip and returns 16bit interleaved (MSB and LSB interleaved together in a fake double width "8-bit" stream).<br>
{{FuncDef|ConvertToDoubleWidth(clip ''clip'' ] )}}
+
  
 
:{{Par2|clip|clip|}}
 
:{{Par2|clip|clip|}}
Line 28: Line 28:
  
  
Accepts a stacked 8-bit clip and returns a HBD clip.<br>
+
{{FuncDef|ConvertFromStacked(clip ''clip'', int ''bits'' ] )}} Accepts a stacked clip and returns a HBD clip.<br>
{{FuncDef|ConvertFromStacked(clip ''clip'', int ''bits'' ] )}}<br>
+
{{FuncDef|ConvertFromDoubleWidth(clip ''clip'', int ''bits'' ] )}} Accepts a Double-Width clip and returns a HBD clip.<br>
{{FuncDef|ConvertFromDoubleWidth(clip ''clip'', int ''bits'' ] )}}
+
  
 
:{{Par2|clip|clip|}}
 
:{{Par2|clip|clip|}}
Line 36: Line 35:
  
 
:{{Par2|bits|int|16}}
 
:{{Par2|bits|int|16}}
::Bit depth of returned clip. Must match the original bit depth. For example,
+
::Bit depth of returned clip. Must match the original bit depth. see the 1st examples of both Stacked and DoubleWidth below.
 +
 
 +
== Examples ==
 +
 
 +
=== Stacked / lsb ===
 +
<div style="max-width:62em" >
 +
 
 +
::1st example,
 
<div {{BoxWidthIndent|46|4}} >
 
<div {{BoxWidthIndent|46|4}} >
 
  ## Decoding 10bit, YUV 4:2:0 source
 
  ## Decoding 10bit, YUV 4:2:0 source
 +
## this is not needed nowadays since LSMASHSource added HBD support
 +
## so nowadays only [[LSMASHSource/LWLibavVideoSource|LWLibavVideoSource]](<''path''>) will did the job
 +
## but just for example, keep in mind that lsb is the slowest
 
  [[LSMASHSource/LWLibavVideoSource|LWLibavVideoSource]](<''path''>, stacked=true, format="YUV420P10")
 
  [[LSMASHSource/LWLibavVideoSource|LWLibavVideoSource]](<''path''>, stacked=true, format="YUV420P10")
 
  '''ConvertFromStacked'''(bits=10)
 
  '''ConvertFromStacked'''(bits=10)
  [[ConvertBits]](8, dither=0) ## '0' means on, '-1' means off
+
## the line below is only if you need to down to 8bit
 +
  [[ConvertBits]](8, dither=0) # '0' means on, '-1' means off
 
</div>
 
</div>
  
::Double-Width example,
+
 
 +
::2nd example,
 
<div {{BoxWidthIndent|46|4}} >
 
<div {{BoxWidthIndent|46|4}} >
 +
## this not needed since Dfttest support HBD, but just for example
 +
## some 16bit HBD clip here
 +
'''ConvertToStacked'''()
 +
[[Dfttest]](lsb_in=true, lsb=true)
 +
'''ConvertFromStacked'''()
 +
## Continue filtering with 16bit HBD
 +
</div>
 +
 +
 +
=== Double-Width / interleaved format ===
 +
<div style="max-width:62em" >
 +
 +
::1st example (F3KDB can work with lsb but Double-Width is faster than lsb),
 +
<div {{BoxWidthIndent|56|4}} >
 +
## this not needed since neo_f3kdb support HBD, but just for example
 
  ## 10bit clip here
 
  ## 10bit clip here
  [[ConvertBits]](16, truerange=false)
+
  [[ConvertBits]](16, truerange=false) #convey 10bit clip on 16bit clip with truerange=false
 
  '''ConvertToDoubleWidth'''()
 
  '''ConvertToDoubleWidth'''()
  [[F3KDB]](Input_Mode=2,Input_Depth=10,Output_Mode=2,Output_Depth=10)
+
  [[f3kdb]](Input_Mode=2, Input_Depth=10, Output_Mode=2, Output_Depth=10)
 
  '''ConvertFromDoubleWidth'''(bits=10)
 
  '''ConvertFromDoubleWidth'''(bits=10)
 
</div>
 
</div>
  
  
==== Changes ====
+
::2nd example,
<div style="max-width:62em" >
+
<div {{BoxWidthIndent|56|4}} >
 +
## 16bit clip here
 +
'''ConvertToDoubleWidth'''()
 +
[[Hqdn3dY|Hqdn3d16Y]]()
 +
'''ConvertFromDoubleWidth'''()
 +
</div>
 +
 
 +
== Changes ==
 
{|border=1 cellspacing=1 cellpadding=4
 
{|border=1 cellspacing=1 cellpadding=4
 
|-
 
|-

Latest revision as of 00:51, 29 October 2021

AVS+
This feature is specific to AviSynthPlus.

It is not supported in other AviSynth versions.

Contents


These conversion filters are to allow filters that use 16-bit video in a pseudo-8-bit colorspace aka stacked (or lsb) and interleaved format to interact with AviSyth+ high bit depth formats aka HBD. They are intended to serve as a stopgap for plugins that not supporting true high bit depth yet so you shouldn't use them nowadays unless with some rare filters that work only with these High-bit-depth hacks.


[edit] Notes

  • In Stack16 (Stacked 16bit) aka Double Height, the picture is made of two parts: one containing the highest 8 bits (MSB) for each pixel, stacked on top of another containing the lowest 8 bits (LSB), hence the name "Double Height". It's used in Dither tools and many others. (Sometimes in filters is referred as "lsb" only).
  • The Interleaved 16bit aka Double Width is similar to Stack16, but the MSBs and LSBs are horizontally interleaved which is like Native HBD, and it's faster than lsb. It's used in [HDRCore] and it was also used in flash3kyuu_deband, LSMASHSource and other filters before they were updated to support 16bit planar (native HBD).
  • both can be between 9-16 bits not only 16bit

[edit] Syntax and Parameters

ConvertToStacked(clip clip ] ) Accepts a 16-bit (HBD) clip and returns 16bit stacked (MSB and LSB stacked one on top of the other in a fake double height "8bit" stream).
ConvertToDoubleWidth(clip clip ] ) Accepts a 16-bit (HBD) clip and returns 16bit interleaved (MSB and LSB interleaved together in a fake double width "8-bit" stream).

clip  clip =
Source clip. Must be native 16 bit: YUV420P16, YUV422P16, YUV444P16, Y16.


ConvertFromStacked(clip clip, int bits ] ) Accepts a stacked clip and returns a HBD clip.
ConvertFromDoubleWidth(clip clip, int bits ] ) Accepts a Double-Width clip and returns a HBD clip.

clip  clip =
Source clip. Must be YV12, YV16, YV24 or Y8.
int  bits = 16
Bit depth of returned clip. Must match the original bit depth. see the 1st examples of both Stacked and DoubleWidth below.

[edit] Examples

[edit] Stacked / lsb

1st example,
## Decoding 10bit, YUV 4:2:0 source
## this is not needed nowadays since LSMASHSource added HBD support
## so nowadays only LWLibavVideoSource(<path>) will did the job
## but just for example, keep in mind that lsb is the slowest 
LWLibavVideoSource(<path>, stacked=true, format="YUV420P10")
ConvertFromStacked(bits=10)
## the line below is only if you need to down to 8bit
ConvertBits(8, dither=0) # '0' means on, '-1' means off


2nd example,
## this not needed since Dfttest support HBD, but just for example
## some 16bit HBD clip here
ConvertToStacked()
Dfttest(lsb_in=true, lsb=true)
ConvertFromStacked()
## Continue filtering with 16bit HBD


[edit] Double-Width / interleaved format

1st example (F3KDB can work with lsb but Double-Width is faster than lsb),
## this not needed since neo_f3kdb support HBD, but just for example
## 10bit clip here
ConvertBits(16, truerange=false) #convey 10bit clip on 16bit clip with truerange=false
ConvertToDoubleWidth()
f3kdb(Input_Mode=2, Input_Depth=10, Output_Mode=2, Output_Depth=10)
ConvertFromDoubleWidth(bits=10)


2nd example,
## 16bit clip here
ConvertToDoubleWidth()
Hqdn3d16Y()
ConvertFromDoubleWidth()

[edit] Changes

20170310 r2440 first added
Personal tools