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 21st March 2011, 22:46   #41  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
Quote:
Originally Posted by tritical View Post
Under what [arbitrary] definition of close?
If the avisynth linear interpolators could use an infinite sinc kernel, and and the input to the interpolator is a perfectly bandlimited signal capable of being properly sampled at the destination resolution, then the support width calculations used by avisynth guarantee perfect reconstruction at the destination resolution, and any other arbitrary resolution that does not cause sub-critical sampling to occur.

Quote:
Originally Posted by tritical View Post
Certainly it does not completely capture the only thing that really matters for image processing - the perceived quality of the person doing the resizing.
In my opinion, it is overall the best compromise. Avisynth resizers certainly look much better then the abysmal interpolators used on most dvds; said dvds either being blurred to hell, with accompanying gibbs artifacts or have aliasing everywhere.
*.mp4 guy is offline   Reply With Quote
Old 23rd March 2011, 13:30   #42  |  Link
Sapo84
Registered User
 
Join Date: May 2008
Posts: 40
I think that YV12 output is a bit broken at the moment, and there are visible artefacts, in particular they are pretty obvious near reds border.
But, well, let's make screenshots speak.

ResampleHQ(1280,720,"YV12","TV.709","TV.709",false,198,22,-48,-164)
http://www.cbland.net/images4/ResampleHQYV12.png
around the red circle there are obvious problems with the resampler output

Spline36Resize(1280,720,198,22,-48,-164)
http://www.cbland.net/images4/SplineYV12.png
on the other hand Spline36's output is perfect

and if we convert to RGB32
ResampleHQ(1280,720,"RGB32","TV.709","TV.709",false,198,22,-48,-164)
http://www.cbland.net/images4/ResampleHQRGB32.png
there are no more artefacts

Spline36Resize(1280,720,198,22,-48,-164).ConverttoRGB32(matrix="Rec709")
http://www.cbland.net/images4/SplineRGB32.png
Spline is good as well.

Using different matrix/crop/dither did not change the outcome at all.
Sapo84 is offline   Reply With Quote
Old 23rd March 2011, 18:13   #43  |  Link
PhrostByte
Grand Fruitioner
 
PhrostByte's Avatar
 
Join Date: Mar 2004
Location: Chicago, IL
Posts: 115
Quote:
Originally Posted by Sapo84 View Post
I think that YV12 output is a bit broken at the moment, and there are visible artefacts, in particular they are pretty obvious near reds border.
Confirmed. I'll look for a solution. Chroma sub-sampling is evil.
PhrostByte is offline   Reply With Quote
Old 24th March 2011, 03:37   #44  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
Sapo84, can we have the original picture for comparsion? And what program do you use to extract the PNG file from a YV12 AVS?
henryho_hk is offline   Reply With Quote
Old 24th March 2011, 10:22   #45  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,352
Yes, I can confirm it, YV12 is totally broken. Even the next line outputs wrong results:
# converting from RGB to YV12
ResampleHQ(DSTCOLORSPACE="YV12",dither=false)
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 24th March 2011 at 11:32.
Dogway is offline   Reply With Quote
Old 24th March 2011, 10:35   #46  |  Link
Sapo84
Registered User
 
Join Date: May 2008
Posts: 40
Quote:
Originally Posted by henryho_hk View Post
Sapo84, can we have the original picture for comparsion?
Sure.
http://www.cbland.net/images4/notresampled.png

Quote:
Originally Posted by henryho_hk View Post
And what program do you use to extract the PNG file from a YV12 AVS?
AvsPmod.
Now that you can even specify the matrix used to convert from YV12 to RGB32 during playback is basically the swiss knife of avisynth ^^
Sapo84 is offline   Reply With Quote
Old 25th March 2011, 01:07   #47  |  Link
PhrostByte
Grand Fruitioner
 
PhrostByte's Avatar
 
Join Date: Mar 2004
Location: Chicago, IL
Posts: 115
This is turning out to be a tricky problem to solve. It occurs whenever sub-sampled YUV is converted between gamma-compressed and linear.

You can't go directly from YUV -> linear YUV. You need to do YUV -> RGB -> linear RGB -> linear YUV.

When it is sub-sampled, you run into the same problem run-of-the-mill renderers do: when converting to RGB the chroma isn't rescaled nicely, but simply point sampled.

I wanted to avoid rescaling gamma-compressed chroma, but I'm not sure if that's possible now. Any clever ideas?
PhrostByte is offline   Reply With Quote
Old 25th March 2011, 02:47   #48  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
could the gamma resize be just done on the luma only? chroma exists in chroma-land where gamma makes no sense...

or perhaps the gamma can happen on the chroma channels using a correspondingly subsampled luma channel to convert them to intermediate chroma channels. that might work.
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 25th March 2011, 04:16   #49  |  Link
PhrostByte
Grand Fruitioner
 
PhrostByte's Avatar
 
Join Date: Mar 2004
Location: Chicago, IL
Posts: 115
Quote:
Originally Posted by Mug Funky View Post
could the gamma resize be just done on the luma only? chroma exists in chroma-land where gamma makes no sense...

or perhaps the gamma can happen on the chroma channels using a correspondingly subsampled luma channel to convert them to intermediate chroma channels. that might work.
Chromaticity is independent from luminance. Chroma is dependent on luma. Not the same thing

I thought of sub-sampling luma too, but I haven't tried it yet. Will report back in a bit
PhrostByte is offline   Reply With Quote
Old 25th March 2011, 07:54   #50  |  Link
madshi
Registered Developer
 
Join Date: Sep 2006
Posts: 9,140
Resampling luma will change the luma and chroma value of every pixel. So if you want resampling to be done with proper quality, I don't think you have any chance of avoiding doing proper chroma upsampling as a first step. Of course that means that the output of your filter should probably be either RGB or YCbCr 4:4:4 because otherwise chroma will lose quality. For chroma upsampling I'd suggest a soft filter to avoid aliasing artifacts.
madshi is offline   Reply With Quote
Old 25th March 2011, 14:25   #51  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
If the final output is to be YV12, the chroma accuracy could potentially be improved by having a separate chroma conversion path using resampled luma. Instead of effectively doing this:
YV12->YV24->sRGB->linear RGB->resample->sRGB->YV24->YV12
which involves chroma resampling as both the first and last steps, do this:

YV12->YV24->sRGB->linear RGB->resample->sRGB->luma
and
YV12->resample luma to chroma grid->sRGB->linear RGB->resample to destn chroma grid->sRGB->chroma

Whether this would make a visible difference, I don't know.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 26th March 2011, 19:03   #52  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
Quote:
Originally Posted by Sapo84 View Post
and if we convert to RGB32
ResampleHQ(1280,720,"RGB32","TV.709","TV.709",false,198,22,-48,-164)
http://www.cbland.net/images4/ResampleHQRGB32.png
there are no more artefacts

This has also chroma problems- not as visible as direct YV12, but visible enough.


Andrew
kolak is offline   Reply With Quote
Old 30th March 2011, 02:07   #53  |  Link
PhrostByte
Grand Fruitioner
 
PhrostByte's Avatar
 
Join Date: Mar 2004
Location: Chicago, IL
Posts: 115
Got caught up in Crysis 2 for most of this past week -- it's like a frakkin' Michael Bay movie in all the right ways.

I'm going full-speed on ResampleHQ now. Should have something new up in the next couple days.
PhrostByte is offline   Reply With Quote
Old 5th April 2011, 19:02   #54  |  Link
PhrostByte
Grand Fruitioner
 
PhrostByte's Avatar
 
Join Date: Mar 2004
Location: Chicago, IL
Posts: 115
Quote:
Originally Posted by madshi View Post
For chroma upsampling I'd suggest a soft filter to avoid aliasing artifacts.
I'm going to default it to bilinear like Avisynth does, but let it be customized. Can you post code for the SoftCubic kernel you use? I'd like to add support for it.
PhrostByte is offline   Reply With Quote
Old 5th April 2011, 19:09   #55  |  Link
madshi
Registered Developer
 
Join Date: Sep 2006
Posts: 9,140
Ok, here goes:

Code:
float Cubic(float distance, float param1, float param2)
// return cubic weight coefficients
{
  float P0, P1, P2, P3;
  float result = 0;

  if (distance <= 2.0f)
  {
    if (distance < 1.0f)
    {
      P0 = (+ 1.0f - 1.0f/3.0f * param1 - 0.0f * param2);
      P1 = 0;
      P2 = (- 3.0f + 2.0f      * param1 + 1.0f * param2);
      P3 = (+ 2.0f - 3.0f/2.0f * param1 - 1.0f * param2);
    } else {
      P0 = (- 0.0f + 4.0f/3.0f * param1 + 4.0f * param2);
      P1 = (+ 0.0f - 2.0f      * param1 - 8.0f * param2);
      P2 = (- 0.0f + 1.0f      * param1 + 5.0f * param2);
      P3 = (+ 0.0f - 1.0f/6.0f * param1 - 1.0f * param2);
    }
    result = P0 + P1 * distance + P2 * distance * distance + P3 * distance * distance * distance;
  }
  return result;
}

float GetFilterCoeffs(float distance, RESAMPLING_FILTER filter)
// return coeffecients for the specified resampling filter
{
  float result = 0;

  switch (filter)
  {
    case rfCatmullRom     :
    case rfBicubic50      : result = Cubic(distance, 0.00f, 0.50f); break;
    case rfBicubic60      : result = Cubic(distance, 0.00f, 0.60f); break;
    case rfBicubic75      : result = Cubic(distance, 0.00f, 0.75f); break;
    case rfSoftCubic100   : result = Cubic(distance, 1.00f, 0.00f); break;
    case rfSoftCubic80    : result = Cubic(distance, 0.80f, 0.20f); break;
    case rfSoftCubic70    : result = Cubic(distance, 0.70f, 0.30f); break;
    case rfSoftCubic60    : result = Cubic(distance, 0.60f, 0.40f); break;
    case rfSoftCubic50    : result = Cubic(distance, 0.50f, 0.50f); break;
    case rfMitchell       : result = Cubic(distance, 1.0f/3.0f, 1.0f/3.0f); break;
    [...]

Last edited by madshi; 5th April 2011 at 19:13.
madshi is offline   Reply With Quote
Old 5th April 2011, 19:37   #56  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by madshi View Post
Code:
float Cubic(float distance, float param1, float param2)
Looks like that is just the same as Avisynth's BicubicResize, where param1 and param2 represent the b and c arguments.
Then, in the 'soft' settings, used with 0.5<= b <=1 and c = 1-b.
Quote:
Code:
    case rfSoftCubic100   : result = Cubic(distance, 1.00f, 0.00f); break;
    case rfSoftCubic80    : result = Cubic(distance, 0.80f, 0.20f); break;
    case rfSoftCubic70    : result = Cubic(distance, 0.70f, 0.30f); break;
    case rfSoftCubic60    : result = Cubic(distance, 0.60f, 0.40f); break;
    case rfSoftCubic50    : result = Cubic(distance, 0.50f, 0.50f); break;
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 5th April 2011, 20:44   #57  |  Link
madshi
Registered Developer
 
Join Date: Sep 2006
Posts: 9,140
Quote:
Originally Posted by Gavino View Post
Looks like that is just the same as Avisynth's BicubicResize
Is it? Well, there's only one way to do the math correctly, I guess...
madshi is offline   Reply With Quote
Old 5th April 2011, 21:50   #58  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by madshi View Post
Is it? Well, there's only one way to do the math correctly, I guess...
Actually, there is more than one way of doing it. In the Avisynth implementation, your line:
Quote:
Originally Posted by madshi View Post
Code:
    result = P0 + P1 * distance + P2 * distance * distance + P3 * distance * distance * distance;
is effectively replaced by:
Code:
    result = P0 + distance * (P1 + distance * (P2 + distance * P3));
which is marginally faster (fewer multiplies).
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 6th April 2011, 05:24   #59  |  Link
PhrostByte
Grand Fruitioner
 
PhrostByte's Avatar
 
Join Date: Mar 2004
Location: Chicago, IL
Posts: 115
Quote:
Originally Posted by madshi View Post
Ok, here goes:
Thanks!

Quote:
Originally Posted by Gavino View Post
Looks like that is just the same as Avisynth's BicubicResize, where param1 and param2 represent the b and c arguments.
Then, in the 'soft' settings, used with 0.5<= b <=1 and c = 1-b.
So it does.
PhrostByte is offline   Reply With Quote
Old 7th April 2011, 03:18   #60  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
Found an interesting diagram about cubic resizers: http://www.imagemagick.org/Usage/resize/#mitchell
henryho_hk 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 17:55.


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