Thread: Avisynth+
View Single Post
Old 7th October 2017, 11:49   #3654  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Quote:
Originally Posted by bxyhxyh View Post
Then this is the result ...is it a bug or something?
It does look like a bug. The problem seems to be in ConvertTo8bit; its output is aprox. 1 step darker after each pass, probably a rounding issue. Using dither seems to fix it:
Code:
Function YV12toRGB32(clip c)
{
  c.convertTo16bit()
  converttorgb64(matrix="Rec709")
  convertto8bit(dither=0)
}

Function RGB32toYV24(clip c)
{
  c.ConvertTo16bit()
  ConvertToYUV444(matrix="Rec709")
  convertto8bit(dither=0)
}
however this does add a dither pattern, invisible in normal footage but apparent in Colorbars etc. Adding a fixed offset also seems to work:
Code:
Function YV12toRGB32(clip c)
{
  c.convertTo16bit()
  converttorgb64(matrix="Rec709")
  RGBAdjust(rb=127, gb=127, bb=127)
  convertto8bit()
}

Function RGB32toYV24(clip c)
{
  c.ConvertTo16bit()
  RGBAdjust(rb=127, gb=127, bb=127)
  ConvertToYUV444(matrix="Rec709")
  convertto8bit()
}
Offset set to 127 because 0.5 (8bit) ≈ 127 (16bit).

Last edited by raffriff42; 7th October 2017 at 12:06.
raffriff42 is offline