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

Closed Thread
 
Thread Tools Search this Thread Display Modes
Old 10th February 2017, 20:58   #3001  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,209
Quote:
Originally Posted by JoeyMonco View Post
Why do you need a whole class simply to write a utility function? Just write a simple function that just uses a switch statement to return the value based on the integer.
Switch or if's is what I used to do, but with all the new data formats, it's getting very messy.
MysteryX is offline  
Old 10th February 2017, 21:00   #3002  |  Link
JoeyMonco
Registered User
 
Join Date: Jan 2017
Posts: 24
Quote:
Originally Posted by MysteryX View Post
Switch or if's is what I used to do, but with all the new data formats, it's getting very messy.
I fail to see how it's less messy than your solution which is an over-engineered mess. The switch statement in C is entirely created to do what you want which is to map some action to an integeral value.

This isn't Java where you need an abstract factory factory builder simply to create a one-off utility function.

Last edited by JoeyMonco; 10th February 2017 at 21:05.
JoeyMonco is offline  
Old 10th February 2017, 21:05   #3003  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,209
Quote:
Originally Posted by JoeyMonco View Post
I fail to see how it's less messy than your solution which is an over-engineered mess. The switch statement in C is entirely created to do what you want which is to map some action to an integeral value.
I want to know BitsPerComponent of the destination format passed as a string. How am I to know whether it's 8-bit, 10-bit or 16-bit? It could be YV12, YUV444P10, YUVAP16... doing it the "if" or "switch" way is a direct road to hell. If you want to write long series of conditions each time you want to do such an operation, then go ahead, but I'm not going down that road.
MysteryX is offline  
Old 10th February 2017, 21:41   #3004  |  Link
JoeyMonco
Registered User
 
Join Date: Jan 2017
Posts: 24
And why do you need to pass the format as a string? What are you doing that you actually need the string for? What purpose is the string serving that can't be served by passing through the enum value? It sounds like you're inventing an over-complicated solution to an imaginary problem.

Last edited by JoeyMonco; 10th February 2017 at 21:56.
JoeyMonco is offline  
Old 10th February 2017, 21:45   #3005  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,008
Quote:
So you want the integer output of BitsPerComponent to be turned into a string? Ok.
I think he meant "I want to know BitsPerComponent of the [destination format passed as a string]", not "I want to know [BitsPerComponent of the destination format] passed as a string."
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline  
Old 10th February 2017, 21:49   #3006  |  Link
JoeyMonco
Registered User
 
Join Date: Jan 2017
Posts: 24
Quote:
Originally Posted by davidhorman View Post
I think he meant "I want to know BitsPerComponent of the [destination format passed as a string]", not "I want to know [BitsPerComponent of the destination format] passed as a string."
Okay.

Still failing to see the reason why strings need to be passed around instead of the enum value, though.
JoeyMonco is offline  
Old 10th February 2017, 22:02   #3007  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,209
There are many standard functions that take a format as parameter ... or is there? Actually, there is ConvertToY8, ConvertToYV24, ConvertToYUV444, ConvertToRGB32... many different functions, sometimes taking only BitsPerComponent as a parameter. There's got to be other filters taking the format as a string ...

oh yeah, ColorBars, AviSource and CombinePlanes take pixel_type as a string.

Last edited by MysteryX; 10th February 2017 at 22:38.
MysteryX is offline  
Old 10th February 2017, 22:19   #3008  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,209
Pinterf, ConvertFromDoubleWidth and ConvertToDoubleWidth don't support RGB24 and RGB32.

In ConvertToDoubleWidth, add
Code:
else if (vi.IsColorSpace(VideoInfo::CS_BGR48)) vi.pixel_type = VideoInfo::CS_BGR24;
else if (vi.IsColorSpace(VideoInfo::CS_BGR64)) vi.pixel_type = VideoInfo::CS_BGR32;
In ConvertFromDoubleWidth, add
Code:
else if (vi.IsRGB24())
	vi.pixel_type = VideoInfo::CS_BGR48;
else if (vi.IsRGB32())
	vi.pixel_type = VideoInfo::CS_BGR64;
I hope you don't mind if I copy/paste ConvertStacked.cpp into my project to avoid dependency?

Last edited by MysteryX; 10th February 2017 at 22:47.
MysteryX is offline  
Old 10th February 2017, 23:49   #3009  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,209
Bug in ConvertBits. If I call ConvertBits(14, dither=-1), it says "dithering is allowed only for 8 bit targets". If I do not specify "dither=-1", then it works.

Also, ConvertFromDoubleWidth supports 10-16 bit, while ConvertToDoubleWidth only supports 16-bit. Code needs to be replaced with this:
Code:
if (vi.BitsPerComponent() < 10 || vi.BitsPerComponent() > 16)
	env->ThrowError("ConvertToDoubleWidth: Input clip must be 10-16bit format");
else if (vi.Is420()) vi.pixel_type = VideoInfo::CS_YV12;
else if (vi.Is422()) vi.pixel_type = VideoInfo::CS_YV16;
else if (vi.Is444()) vi.pixel_type = VideoInfo::CS_YV24;
else if (vi.IsY()) vi.pixel_type = VideoInfo::CS_Y8;
else if (vi.IsColorSpace(VideoInfo::CS_BGR48)) vi.pixel_type = VideoInfo::CS_BGR24;
else if (vi.IsColorSpace(VideoInfo::CS_BGR64)) vi.pixel_type = VideoInfo::CS_BGR32;
else env->ThrowError("ConvertToDoubleWidth: Input clip must be 10-16bit format");
MysteryX is offline  
Old 11th February 2017, 00:14   #3010  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,209
This code causes a crash: "cannot decompress video frame: the video data is too short"
Code:
ConvertToYV24()
AddAlphaPlane()
CombinePlanes(planes="RGBA", source_planes="YUVA", pixel_type="RGBAP8")
ConvertToYV24()
This also gives the same error
Code:
ConvertToPlanarRGBA()
CombinePlanes(planes="YUVA", source_planes="RGBA", pixel_type="YUVA444P8")
Also, is it normal that CombinePlanes doesn't only cast the planes but inverts the image? If so, that means I have to call FlipVertical again.

Last edited by MysteryX; 11th February 2017 at 00:29.
MysteryX is offline  
Old 11th February 2017, 09:31   #3011  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,376
Quote:
Originally Posted by MysteryX View Post
In C# I could easily convert a string to its enumeration value but that won't work in C++.
http://stackoverflow.com/questions/1...o-an-enum-in-c
Quote:
Note that the performance of Enum.Parse() is awful, because it is implemented via reflection. (The same is true of Enum.ToString, which goes the other way.)
If you need to convert strings to Enums in performance-sensitive code, your best bet is to create a Dictionary<String,YourEnum> at startup and use that to do your conversions.
not that much different here, uh?

I also like dynamic features a lot cuz they are handy to use, but I would just go with a completely dynamic programming language like Python if I'm gonna use dynamic features throughout my program
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated

Last edited by feisty2; 11th February 2017 at 09:37.
feisty2 is offline  
Old 11th February 2017, 15:47   #3012  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,209
Quote:
Originally Posted by feisty2 View Post
not that much different here, uh?
Good to know.

Then, I could create a generic class that automatically builds a dictionary from specified Enum on first use (via reflection), and then does the conversion though the dictionary on all subsequent calls.

But in the case of AviSynth, the Enum is a bit more complicated than that, with combinations of fields, and with names that don't always match format values, so here there's no way around listing all valid formats manually. Plus, it's only 1 Enum, and it's unlikely to change much. If it were 100 Enums that could change and evolve regularly, then it would be a different story.

Last edited by MysteryX; 11th February 2017 at 15:50.
MysteryX is offline  
Old 11th February 2017, 15:51   #3013  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,376
Quote:
Originally Posted by MysteryX View Post
But in the case of AviSynth, the Enum is a bit more complicated than that, with combinations of fields, and with names that don't always match format values, so here there's no way around listing all valid formats manually.
if you don't need portable C++ code, you could do reflection tricks in C++ as in C# with CLR under visual studio.
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is offline  
Old 11th February 2017, 15:55   #3014  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,209
Perhaps, but it's kind of getting off-topic -- not providing any value to the topic of Avisynth+. I got the code working already.
MysteryX is offline  
Old 12th February 2017, 10:54   #3015  |  Link
vinnytx
Registered User
 
Join Date: Jan 2012
Posts: 46
I have problems with Avisynth+ latest versions and Potplayer.
I use this script to resize my videos while playing
Code:
SetMemoryMax(512)
SetFilterMTMode("DEFAULT_MT_MODE", 2)
ffdshow_source()
dispWidth = 1920
dispHeight = 1080
mWidth = float(last.width)
mHeight = float(last.height)
ratio = (mWidth/mHeight)
newHeight= round((dispWidth/ratio)/2)*2
newHeight > dispHeight ? Eval("""
newHeight=dispHeight
newWidth=round((newHeight*ratio)/2)*2
""") : Eval("""
newWidth=dispWidth
""")
spline64resize(newWidth,newHeight)
Prefetch(4)
Videos are "flashing" at the first seconds of reproduction, then they are showed correctly
Here an example. https://www.mediafire.com/?4t75s2m74wuvzj3
The only Avisynth+ version that works well is r1779



Another problem with Potplayer is that I can't hear audio unless I remove TimeStretch.dll plugin.
It appears this error message




Also, I had to remove ImageSeq.dll plugin because I had many Potplayer crashes with it
vinnytx is offline  
Old 12th February 2017, 15:08   #3016  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,209
I'll also mention that I've been seeing an audio/video sync issue with the latest version.. not even sure if it's related to Avisynth version, but I'm just throwing it out there. Has anyone else experience audio/video sync issue? Might be related to VFR as I only have issues with a few videos, and I'm pretty sure it was working fine before. This is when I open the AVS script in MPC-HC to retune the audio to 432hz. That would require more investigation to identify where the issue comes from.
MysteryX is offline  
Old 12th February 2017, 17:59   #3017  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,209
CombinePlanes acts weird with a non-planar source such as RGB32. It should instead return an error and require planar input.
MysteryX is offline  
Old 12th February 2017, 21:55   #3018  |  Link
amayra
Quality Checker
 
amayra's Avatar
 
Join Date: Aug 2013
Posts: 271
Quote:
Originally Posted by MysteryX View Post
I'll also mention that I've been seeing an audio/video sync issue with the latest version.. not even sure if it's related to Avisynth version, but I'm just throwing it out there. Has anyone else experience audio/video sync issue?
i try few video no problem have been found with latest version so far
__________________
I love Doom9
amayra is offline  
Old 12th February 2017, 22:20   #3019  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,658
Quote:
Originally Posted by MysteryX View Post
CombinePlanes acts weird with a non-planar source such as RGB32. It should instead return an error and require planar input.
Weird means ........ /fill the missing words/
pinterf is offline  
Old 12th February 2017, 22:25   #3020  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,658
Quote:
Originally Posted by MysteryX View Post
Bug in ConvertBits. If I call ConvertBits(14, dither=-1), it says "dithering is allowed only for 8 bit targets". If I do not specify "dither=-1", then it works.
Thanks, fixed.

Converting String to VideoInfo:: pixel_type integer: Invoke this script function:
int ColorSpaceNameToPixelType (string ColorSpaceName)
pinterf is offline  
Closed Thread

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:32.


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