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
Register FAQ Calendar Today's Posts Search

Closed Thread
 
Thread Tools Search this Thread Display Modes
Old 3rd March 2020, 16:56   #5181  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,666
Thank you pinterf and qyot27. Awesome job!
Reel.Deel is offline  
Old 3rd March 2020, 16:58   #5182  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,314
Quote:
Originally Posted by StainlessS View Post
Nearly

Code:
Blankclip(width=120,height=120,Color=$808080)
/*
Text "cs[x]f[y]f[first_frame]i[last_frame]i[font]s[size]f[text_color]i[halo_color]i[align]i[spc]i[lsp]i[font_width]f[font_angle]f[interlaced]b[font_filename]s[utf8]b"
*/

Text("Hello\nWorld",lsp=0,align=5)
You are so right. I'm getting old. Seems that I have really done it
pinterf is offline  
Old 3rd March 2020, 17:10   #5183  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,314
Quote:
Originally Posted by poisondeathray View Post
pinterf's test version had fixed the errors in this post with the internal avs conversion
https://forum.doom9.org/showthread.php?p=1897686

pinterf test version
https://forum.doom9.org/showthread.php?p=1898860

But using the recent 3.5, r3043 , some differences are back. 12bits again "fixes" it

avsresize/zimg/zlib works using 10bits with either version
I can see the same small differences which are normal I think. The big differences are over.
pinterf is offline  
Old 3rd March 2020, 17:47   #5184  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
Quote:
Originally Posted by pinterf View Post
I can see the same small differences which are normal I think. The big differences are over.
It's an improvement, but it should be lossless

PSNR r:99.994716 g:inf b:73.777761 average:78.538609 min:78.538609 max:78.538609

infinity with vapoursynth / avsresize / zlib/zimg
PSNR r:inf g:inf b:inf average:inf min:inf max:inf
poisondeathray is offline  
Old 3rd March 2020, 17:57   #5185  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by pinterf View Post
You are so right. I'm getting old. Seems that I have really done it
Good memory you did really do it.

Code:
class SimpleText : public GenericVideoFilter
  /**
    * SimpleText creation class
   **/
{
public:
  SimpleText(PClip _child, const char _text[], int _x, int _y, int _firstframe, int _lastframe,
    const char _fontname[], int _size, int _textcolor, int _halocolor, int _align,
    int _spc, bool _multiline, int _lsp, int _font_width, int _font_angle, bool _interlaced, const char _font_filename[], const bool _utf8, IScriptEnvironment* env);
  virtual ~SimpleText(void);
  PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);

  static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env);

  int __stdcall SetCacheHints(int cachehints, int frame_range) override {
    AVS_UNUSED(frame_range);
    return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0;
  }

private:
  const int x, y, firstframe, lastframe;
  const int size; // n/a
  const int lsp;
  const int font_width, font_angle; // n/a
  const bool multiline;
  const bool interlaced; // n/a
  const int textcolor, halocolor, align;
  const int spc; // n/a
  const int halocolor_orig;
  const char* const fontname; // n/a
  const char* const text;
  const char* const font_filename; // n/a
  const bool utf8;
};
Only the names were changed to protect the innocent
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline  
Old 3rd March 2020, 18:03   #5186  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,314
Quote:
Originally Posted by poisondeathray View Post
It's an improvement, but it should be lossless

PSNR r:99.994716 g:inf b:73.777761 average:78.538609 min:78.538609 max:78.538609

infinity with vapoursynth / avsresize / zlib/zimg
PSNR r:inf g:inf b:inf average:inf min:inf max:inf
The algorithm has no more flaws I think. I have to check the coefficient accuracy.
pinterf is offline  
Old 3rd March 2020, 18:26   #5187  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
Quote:
Originally Posted by pinterf View Post
The algorithm has no more flaws I think. I have to check the coefficient accuracy.
PSNR (according to ffmpeg psnr) it's actually the same value with r2944 test version or r3043 (neither were lossless) ; so I was wrong , it wasn't "fixed" with that test version

pre r2944
[Parsed_psnr_4 @ 000000f905391940] PSNR r:59.321403 g:87.953516 b:73.777761 average:63.933949 min:63.933949 max:63.933949

r2944, r3043 - improved
[Parsed_psnr_4 @ 00000049feda2dc0] PSNR r:99.994716 g:inf b:73.777761 average:78.538609 min:78.538609 max:78.538609

It's "inf" with vapoursynth or avsresize in all cases
[Parsed_psnr_4 @ 00000014ab642a00] PSNR r:inf g:inf b:inf average:inf min:inf max:inf

Results do not change if I test a written out bmp, or pipe into ffmpeg




Historically, ffmpeg swscale had many issues in the past with YUV/RGB conversions; but even it gets this 8bit RGB => 10bit YUV444 => 8bit RGB conversion correct now (at least with this test image)

Code:
ffmpeg -i yuv_exprm_02_bird.png -vf scale=out_color_matrix=bt709,format=yuv444p10le,scale=in_color_matrix=bt709,format=gbrp ffmpeg_swscale.bmp
Code:
ffmpeg -r 24 -i ffmpeg_swscale.bmp -r 24 -i yuv_exprm_02_bird.png -lavfi  "[0:v]settb=1/AVTB,setpts=PTS-STARTPTS[main];[1:v]settb=1/AVTB,setpts=PTS-STARTPTS[ref];[main][ref]psnr="stats_file=ff_psnr_ffmpeg_swscale.log"" -f null -
[Parsed_psnr_4 @ 00000098089e2140] PSNR r:inf g:inf b:inf average:inf min:inf max:inf



Thanks for your work pinterf and qyot27

Last edited by poisondeathray; 3rd March 2020 at 22:05.
poisondeathray is offline  
Old 4th March 2020, 01:36   #5188  |  Link
frencher
French Love
 
Join Date: Oct 2008
Location: France
Posts: 456
Strange crash with 2 plugins

Hi all,

I search for works my two plugins x86 HDR_AGC and svpflow

With only HDR it's works
With only svpflow works
With both HDR_AGC and svpflow WMP crash

How fix it

Thank's for all

Plugins is
HDR > https://github.com/Anime4000/IFME/wi...nth--HDR-Video
SVP > https://www.svp-team.com/forum/viewt...d=57410#p57410

Attached Files
File Type: rar HDR+svpflow.rar (6.8 KB, 26 views)
__________________
2013-11-29 MVC Player Free v0.0.2.6 BD & 3D BD's Player, Demuxer v0.0.0.8b, Recoder. Tutorial
Demo for MVC Player Free: Trailer 3D

3DBD's Free - v0.0.0.0005.exe Old

Programing free for all.

Last edited by frencher; 4th March 2020 at 01:39.
frencher is offline  
Old 4th March 2020, 08:47   #5189  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,782
Quote:
Originally Posted by pinterf View Post
All I can say that Midnight Commander rulez
For Windows, the Far manager is my choice.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline  
Old 4th March 2020, 09:34   #5190  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,314
Quote:
Originally Posted by poisondeathray View Post
PSNR (according to ffmpeg psnr) it's actually the same value with r2944 test version or r3043 (neither were lossless) ; so I was wrong , it wasn't "fixed" with that test version

pre r2944
[Parsed_psnr_4 @ 000000f905391940] PSNR r:59.321403 g:87.953516 b:73.777761 average:63.933949 min:63.933949 max:63.933949

r2944, r3043 - improved
[Parsed_psnr_4 @ 00000049feda2dc0] PSNR r:99.994716 g:inf b:73.777761 average:78.538609 min:78.538609 max:78.538609
VapourSynth and avsresize is using the same library, they have to have the same results.

Avsresize has the advantage that it can convert _directly_ from 8 bit rgb to 10 bit YUV. I suppose that there is no 10 bit intermediate rgb result.

Test 1: I have tried ConvertBits(10) right before avsresize
Result: mixed ConvertBits - Avsresize chain stopped being lossless

Code:
a
ConvertToPlanarRGB()
ConvertBits(10) # Z advantage: single step 8 bit rgb 10 bit yuv
z_ConvertFormat(pixel_type="YUV444P10")
z_ConvertFormat(pixel_type="RGBP10")
ConvertToRGB24()
z1=last #RGBP10 step before RGB24 works
And finally: avsresize is possibly using float arithmetic internally.

There are several types of converters, their usage depends on bit depth and processor capability.

One method (SSE2) is using the usual 15 bit integer arithmetic. I'm using it for 10-14 bit targets.

The other is converting the pixels to float, do the matrix multiplication and then converts the result back to the integer domain. Now I'm using it only for 16 bit case because the first method's SIMD intrinsics support only signed data without any tricks (16 bit is unsigned).

Test2:
So I built a test version, where I was using the 32 bit float way for 10 bit data instead of the above mentioned integer arithmetics. Result: I only looked at the difference clips and visually (looking at rare dot distribution showing the non-losslessness) it had the same output as z_ConvertXXX (latter with the 10 bit input in order to compare apples to apples)

If I enable the internally float version for 10-14 bits, it can be a little bit slower* but of greater precision.
*no AVX implementation yet only SSE2/SSE4.1 so there is room for improvement to compensate the slowdown (which I think is not that much considering a whole big script)

But Avisynth resizer is not capable to chain bit depth conversion with rgb->yuv conversion so I'd say it'll never give such losslessness.
pinterf is offline  
Old 4th March 2020, 09:37   #5191  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,314
Quote:
Originally Posted by frencher View Post
With only HDR it's works
With only svpflow works
With both HDR_AGC and svpflow WMP crash

How fix it
Possibly HDRAGC source code is needed which is unfortunately not available (never published)
pinterf is offline  
Old 4th March 2020, 12:07   #5192  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by pinterf View Post
Avsresize has the advantage that it can convert _directly_ from 8 bit rgb to 10 bit YUV. I suppose that there is no 10 bit intermediate rgb result.
I don't think that's true, but this is:

Quote:
Originally Posted by pinterf View Post
And finally: avsresize is possibly using float arithmetic internally.
As far as I know zimg (avsresize) has no special direct conversions between any formats at all. Bitdepth changes, colorspace changes and resolution changes are separate filters internally and it builds a filter graph automatically to do the conversion you want. Depending on what you're doing, the graph builder may decide to start the processing by increasing the bitdepth, to reduce intermediate losses. Converting colorspace is one such case - if you do that, the first thing it'll do is convert the pixel type to float, then upscale the chroma if necessary, and only then proceed to convert to whatever target format and resolution you want.

See https://github.com/sekrit-twc/zimg/b...ilder.cpp#L669 for details, it has comments describing the process of building a filter chain for doing arbitrary conversions.

Last edited by TheFluff; 4th March 2020 at 12:11.
TheFluff is offline  
Old 4th March 2020, 16:21   #5193  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
Quote:
Originally Posted by pinterf View Post
VapourSynth and avsresize is using the same library, they have to have the same results.

I have seen implementation differences between vapoursynth's resize, ffmpeg -vf zscale, and avsresize. Despite being based the same library. It might be that the "snapshot" was based on different build or commits, I didn't look too closely. But this occurs for certain.


Quote:
Test 1: I have tried ConvertBits(10) right before avsresize
Result: mixed ConvertBits - Avsresize chain stopped being lossless

And ConvertBits(12) was NOT enough to "fix" it, yet 12bits is "enough" for internal resizer (for amplified visual differences, I didn't check PSNR). It doesn't entirely make sense, could something else be going on there?


Quote:
Test2:
So I built a test version, where I was using the 32 bit float way for 10 bit data instead of the above mentioned integer arithmetics. Result: I only looked at the difference clips and visually (looking at rare dot distribution showing the non-losslessness) it had the same output as z_ConvertXXX (latter with the 10 bit input in order to compare apples to apples)

If I enable the internally float version for 10-14 bits, it can be a little bit slower* but of greater precision.
*no AVX implementation yet only SSE2/SSE4.1 so there is room for improvement to compensate the slowdown (which I think is not that much considering a whole big script)

But Avisynth resizer is not capable to chain bit depth conversion with rgb->yuv conversion so I'd say it'll never give such losslessness.

Thanks for taking the time to investigate this

Does that imply ffmpeg swscale is using float internally too? I'd imagine that it didn't for speed purposes

My memory is a bit rusty, but once upon a time, I recall someone did some matlab calculations and +2 bits was supposedly enough to cover this conversion (just like 12bit YUV444 was sufficient to cover 10bit RGB), but I should have looked into the details more thoroughly
poisondeathray is offline  
Old 4th March 2020, 17:22   #5194  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
Quote:
Originally Posted by pinterf View Post

Test 1: I have tried ConvertBits(10) right before avsresize
Result: mixed ConvertBits - Avsresize chain stopped being lossless
Actually, double checking this with PSNR, Z1 was not lossless to begin with .

[Parsed_psnr_4 @ 00000062fb042cc0] PSNR r:inf g:inf b:92.591089 average:97.362301 min:97.362301 max:97.362301

Code:
a
ConvertToPlanarRGB()
z_ConvertFormat(pixel_type="YUV444P10")
z_ConvertFormat(pixel_type="RGBP10")
ConvertToRGB24()
z1=last



Z2 was lossless
[Parsed_psnr_4 @ 0000005dfa5d2cc0] PSNR r:inf g:inf b:inf average:inf min:inf max:inf

Code:
a
ConvertToPlanarRGB()
z_ConvertFormat(pixel_type="YUV444P10")
z_ConvertFormat(pixel_type="RGBP")
ConvertToRGB24()
z2=last
If you add ConvertBits(10) after ConvertToPlanarRGB(), it's no longer lossless either
poisondeathray is offline  
Old 4th March 2020, 18:09   #5195  |  Link
zeropc
Registered User
 
Join Date: Mar 2007
Posts: 114
Quote:
Originally Posted by qyot27 View Post
AviSynth+ 3.5.0 has been released.

The big, shiny new feature this time around: native support for Linux, macOS, and BSD. Full list of changes:

New: Native macOS support.
Nice ... Where can I get the macOS version?
zeropc is offline  
Old 4th March 2020, 18:30   #5196  |  Link
Richard1485
Guest
 
Posts: n/a
There are build instructions here and a separate thread in this subforum for cross-platform support.
 
Old 4th March 2020, 20:19   #5197  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,314
Quote:
Originally Posted by TheFluff View Post
As far as I know zimg (avsresize) has no special direct conversions between any formats at all. Bitdepth changes, colorspace changes and resolution changes are separate filters internally and it builds a filter graph automatically to do the conversion you want.
Thanks, I see. So the advantage there is simply not having an integer (e.g. 10 bit) intermediate result but rather a 32 bit float one?
pinterf is offline  
Old 4th March 2020, 20:27   #5198  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,314
Quote:
Originally Posted by pinterf View Post
If I enable the internally float version for 10-14 bits, it can be a little bit slower* but of greater precision.
*no AVX implementation yet only SSE2/SSE4.1 so there is room for improvement to compensate the slowdown (which I think is not that much considering a whole big script)
Anyway, there are some RGBP->YUV444 enhancements in my development branch:
- Internal calculation method is changed to use floats for 10-14 bits as well (16 bit was already working like this) for greater precision
- much quicker AVX2 implementation for 10-16 bits (was: SSE2/SSE4)
pinterf is offline  
Old 7th March 2020, 16:43   #5199  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
BugRep:

From here[EDIT: LINK FIXED]:- https://forum.doom9.org/showthread.p...55#post1728455
Quote:
Originally Posted by StainlessS View Post
@Martin53,

For your version StrReplace,
Code:
    s=StrReplace("abc","","1")
ie replace "" with "1",
Causes silent crash due to stack exhaustion.
(Problem due to FindStr("abc","") returning result 1 [bit of a daft result, 0 not found would perhaps be more sensible]).
Should return source string s where StrLen(find)==0
Same here for Avs+ ReplaceStr().
Code:
Colorbars
S=ReplaceStr("hello","","1")
Subtitle(s)
EDIT: Script fix for StrReplace()

Code:
Function StrReplace(string base, string sought, string rep) { # http://avisynth.nl/index.php/HDColorBars
	pos = FindStr(base, sought)
	return (sought=="")||(pos==0)?base:StrReplace(LeftStr(base,pos-1)+rep+MidStr(base,pos+StrLen(sought)),sought,rep)
}
EDIT: Maybe this line on Wiki could stand some attention [meaning is inverted]:- http://avisynth.nl/index.php/Interna...ons#ReplaceStr
Quote:
sig if false (the default), search is case-sensitive; if true, search is not case-sensitive.
EDIT: By the way, RT_Stats RT_StrReplace has default Sig=True, but of course choice is yours.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 7th March 2020 at 18:25.
StainlessS is offline  
Old 8th March 2020, 18:29   #5200  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
New types.h prevents plugin compile on older versions of visual studio [missing header files].
Mine is VS 2008 Express with Windows SDK 7.0.

Previous Types.h
Code:
#ifndef AVS_TYPES_H
#define AVS_TYPES_H

// Define all types necessary for interfacing with avisynth.dll

#ifdef __cplusplus
  #include <cstddef>
#else
  #include <stddef.h>
#endif

// Raster types used by VirtualDub & Avisynth
typedef unsigned int    Pixel32;
typedef unsigned char   BYTE;

// Audio Sample information
typedef float SFLOAT;

#ifdef __GNUC__
typedef long long int INT64;
#else
typedef __int64 INT64;
#endif

#endif //AVS_TYPES_H
New one
Code:
#ifndef AVS_TYPES_H
#define AVS_TYPES_H

// Define all types necessary for interfacing with avisynth.dll
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
  #include <cstddef>
#else
  #include <stddef.h>
#endif

// Raster types used by VirtualDub & Avisynth
typedef uint32_t Pixel32;
typedef uint8_t  BYTE;

// Audio Sample information
typedef float SFLOAT;

#endif //AVS_TYPES_H
What is minimum compiler/SDK required for plugin builds for Avs+ and avs Std v2.60 using avs+ headers.

(You can probably get headers from eg VS 2017 community)

EDIT: stdint.h on github:- https://github.com/glfw/glfw/blob/ma...s2008/stdint.h
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 8th March 2020 at 18:46.
StainlessS is offline  
Closed Thread


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 06:30.


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