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 11th January 2020, 13:09   #5061  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: 36 Chambers
Posts: 5,918
Yes, I tried negative pitch, causes a crash, height is defined as UINT32.

edit:

I can research if Direct2D can flip it faster.

Last edited by stax76; 11th January 2020 at 13:26.
stax76 is offline   Reply With Quote
Old 11th January 2020, 15:42   #5062  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,378
Quote:
it also invokes FlipVertical, no clue why AviSynth/VapourSynth RGB32 isn't directly D2D compatible without FlipVertical.
RGB is upside down compared to YUV, top line is usually got via something like
Code:
    int x=0,y=0;
    int step =( vi.IsRGB24() ) ? 3 : 4;    // RGB24 or RGB32
    BYTE *dp = dst->GetWritePtr() + ((height-1 - y) * pitch) + (x*step);
    // ...
    dp -= pitch; // down 1 line
__________________
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   Reply With Quote
Old 11th January 2020, 19:52   #5063  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: 36 Chambers
Posts: 5,918
Quote:
The pixel array is a block of 32-bit DWORDs, that describes the image pixel by pixel. Usually pixels are stored "bottom-up", starting in the lower left corner, going from left to right, and then row by row from the bottom to the top of the image.[4] Unless BITMAPCOREHEADER is used, uncompressed Windows bitmaps also can be stored from the top to bottom, when the Image Height value is negative.
https://en.wikipedia.org/wiki/BMP_fi...#Pixel_storage

I tried negative height in source and target rect and everywhere else where a height is defined and it's not working. On StackOverflow it's unanswered:

https://stackoverflow.com/questions/...textdrawbitmap
stax76 is offline   Reply With Quote
Old 12th January 2020, 08:18   #5064  |  Link
v0lt
Registered User
 
Join Date: Dec 2008
Posts: 1,225
Hello.

Now if I open the script in video players, I get the wrong colors in many situations.

Is it possible to use the structure VIDEOINFOHEADER2 instead of VIDEOINFOHEADER? This will make it possible to use the dwControlFlags field. If you set AMCONTROL_COLORINFO_PRESENT, you can use DXVA_ExtendedFormat to specify additional parameters (nominal range, transfer matrix) for the video stream.
v0lt is offline   Reply With Quote
Old 12th January 2020, 14:47   #5065  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,378
V0lt,
Quote:
Now if I open the script in video players, I get the wrong colors in many situations.
What script ???

Quote:
Originally Posted by Sharc View Post
Here the script:
Code:
AviSource("h:\Tape 1\capture_1.avi")
converttoyv12(interlaced=true)
assumeTFF()
separatefields()
temporalsoften(4,4,8,10,mode=2)
fluxsmoothST(3,3)
weave()
assumefps(25)
It works when I put temporalsoften AFTER fluxsmooth.

Edit:
It also works when I put crop(2,0,-0,-0) before temporalsoften. (The frame then becomes 718x576).

Edit2:
It looks like temporalsoften must not be the first filter after separatefields()
Verified Access Violation with below script.
Code:
Colorbars(pixel_type="YV12")
#BilinearResize(720,576)
#converttoyv12(interlaced=true)
#assumeTFF()
separatefields()
temporalsoften(4,4,8,10,mode=2)
#fluxsmoothST(3,3)
#weave()
#assumefps(25)
removing comments (Access Violation)
Code:
Colorbars(pixel_type="YV12")    # 640x480
separatefields()                # 640x240
temporalsoften(4,4,8,10,mode=2)
EDIT: Avs+ v3.4.0

EDIT: No Access Violation
Code:
BlankClip(width=640,height=240,pixel_type="YV12")
AssumeFieldBased
temporalsoften(4,4,8,10,mode=2)
EDIT: Also Access Violation
Code:
BlankClip(pixel_type="YV12")    # 640x480
separatefields()                # 640x240
temporalsoften(4,4,8,10,mode=2)
EDIT: Also Access Violation
Code:
BlankClip(pixel_type="YV12")    # 640x480
separatefields()                # 640x240
AssumeFrameBased
temporalsoften(4,4,8,10,mode=2)
__________________
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; 13th January 2020 at 12:52.
StainlessS is offline   Reply With Quote
Old 12th January 2020, 16:09   #5066  |  Link
v0lt
Registered User
 
Join Date: Dec 2008
Posts: 1,225
Quote:
Originally Posted by StainlessS View Post
What script ???
Code:
ImageSource("1000px-SMPTE_Color_Bars_16x9.png")
AddBorders(0, 3, 0, 2)
ConvertToYUV420(matrix="Rec601")
# or
#ConvertToYUV420(matrix="Rec709")
# or
#ConvertToYUV420(matrix="Rec2020")
I get different colors on the player depending on the matrix parameter in the script. The video player is not able to find out what parameters were used when converting the frame from RGB to YV12.
v0lt is offline   Reply With Quote
Old 12th January 2020, 16:25   #5067  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,046
Quote:
Originally Posted by v0lt View Post
Code:
ImageSource("1000px-SMPTE_Color_Bars_16x9.png")
AddBorders(0, 3, 0, 2)
ConvertToYUV420(matrix="Rec601")
# or
#ConvertToYUV420(matrix="Rec709")
# or
#ConvertToYUV420(matrix="Rec2020")
I get different colors on the player depending on the matrix parameter in the script. The video player is not able to find out what parameters were used when converting the frame from RGB to YV12.


Avisynth frameserves uncompressed audio and video. No metadata is passed . Also, the video player does not "see" what is in the script; it only "sees" the final output as uncompressed video

How the video converts from YUV to RGB for display varies by the player, and renderer setup, sometimes drivers. Many assume Rec709 for height >576
poisondeathray is offline   Reply With Quote
Old 12th January 2020, 16:54   #5068  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,378
There is no colorspace matrix info embedded in AVI.
I guess defaults are player dependant (I dont ever bother with such stuff).

Here looks like relevant for PotPlayer


EDIT: PDR beat me.
__________________
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   Reply With Quote
Old 13th January 2020, 15:48   #5069  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: 36 Chambers
Posts: 5,918
Quote:
Avisynth frameserves uncompressed audio and video. No metadata is passed . Also, the video player does not "see" what is in the script; it only "sees" the final output as uncompressed video
A video player can't know what exactly a script does (at least not easily), it could however parse the script to find out some basic parameters like the original source file or even a matrix parameter, with regex that's not 100% reliable but fairly simple to do. VapourSynth maybe has better metadata capabilities.
stax76 is offline   Reply With Quote
Old 13th January 2020, 16:39   #5070  |  Link
v0lt
Registered User
 
Join Date: Dec 2008
Posts: 1,225
When AviSynth converts the color space from RGB to YUV, then another filter can find out which matrix was used for this?
v0lt is offline   Reply With Quote
Old 13th January 2020, 16:47   #5071  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,046
Quote:
Originally Posted by v0lt View Post
When AviSynth converts the color space from RGB to YUV, then another filter can find out which matrix was used for this?
Not automatically .

You have to do it "manually" with something like colorbars or known colors. If you get back the original colors when you convert back to RGB (or very close, due to rounding errors , and RGB<=>YUV gamut errors, clipping) then it's the correct matrix

This is true for any RGB<=>YUV conversion with any program, not just avisynth
poisondeathray is offline   Reply With Quote
Old 13th January 2020, 17:08   #5072  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,046
Quote:
Originally Posted by stax76 View Post
VapourSynth maybe has better metadata capabilities.
It does... but it's pros/cons IMO . Easy to get burned if not careful

If file is tagged correctly, the source filters read and pass on various metadata as clip "props" or properites

All manipulations "automatically" assume or take on those values, unless otherwise specified . e.g. if you resize or RGB preview ,everything is done correctly as per the metadata. e.g. if file was interlaced, tagged interlaced, then the resizing and conversion to RGB will be done interlaced aware

If file was tagged correctly, great. Everything just works(TM)

If it's not, trouble. e.g. if you get file from somewhere else. e.g handbrake often tags incorrectly . eg. progressive PAL DVD's are tagged interlaced. You end up having to double check everything.
poisondeathray is offline   Reply With Quote
Old 14th January 2020, 15:59   #5073  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,077
Quote:
Originally Posted by stax76 View Post
https://en.wikipedia.org/wiki/BMP_fi...#Pixel_storage

I tried negative height in source and target rect and everywhere else where a height is defined and it's not working. On StackOverflow it's unanswered:

https://stackoverflow.com/questions/...textdrawbitmap
BITMAPINFOHEADER and friends are old GDI stuff. D2D exclusively uses unsigned coordinates growing left to right, top to bottom. You're not supposed to use clever tricks like negative pitch or height anymore, presumably because these coordinates are getting increasingly abstract and they don't want you to think in terms of pointers and offsets anymore, even though it happens to make sense in the context of plain old RGB bitmaps. You don't really just push raw memory areas to the screen anymore anyway at this high of an API level - D2D supports UI scaling, for example.

Instead the intended way of doing it is manipulating how the input coordinates are mapped to the output coordinates by setting a transformation matrix on the render target using ID2D1RenderTarget::SetTransform().

D2D doesn't come with a vertical mirroring matrix convenience method (rotation around a point isn't the same thing), but you can just create your own 3x2 transform, like so:

Code:
1    0
0   -1
0    0
which should give you a vertical flip.

Quote:
Originally Posted by stax76 View Post
no clue why AviSynth/VapourSynth RGB32 isn't directly D2D compatible without FlipVertical.
Avisynth predates D2D by over a decade, so that's sort of a silly question. Avisynth directly supports VfW and GDI, which is what was available at the time. VS on the other hand only supports packed RGB32 as a backwards compatibility thing, where the thing it's backwards compatible with is mostly Avisynth.

Last edited by TheFluff; 14th January 2020 at 16:22.
TheFluff is offline   Reply With Quote
Old 14th January 2020, 18:09   #5074  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: 36 Chambers
Posts: 5,918
@TheFluff

Thanks for the hint, I will have to do some math research to understand it.
stax76 is offline   Reply With Quote
Old 14th January 2020, 18:57   #5075  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,077
Here's a quick cheat sheet, first hit on duckduckgo: https://code-industry.net/masterpdfe...mation-matrix/

e: It's not really necessary to confuse yourself with cross products in this case if you don't want to. Basically what you're doing here is just multiplying horizontal coordinates (X axis) by 1 (top left of the matrix) and vertical coordinates (Y axis) by -1 (middle right of the matrix). This is effectively the same thing as setting a negative height, so the topmost row of pixels in the input becomes the bottom row in the output - a vertical flip, in other words.

Last edited by TheFluff; 14th January 2020 at 19:10.
TheFluff is offline   Reply With Quote
Old 15th January 2020, 16:30   #5076  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,258
Quote:
Originally Posted by Sharc View Post
Here the script:
Code:
AviSource("h:\Tape 1\capture_1.avi")
converttoyv12(interlaced=true)
assumeTFF()
separatefields()
temporalsoften(4,4,8,10,mode=2)
fluxsmoothST(3,3)
weave()
assumefps(25)
It works when I put temporalsoften AFTER fluxsmooth.

Edit:
It also works when I put crop(2,0,-0,-0) before temporalsoften. (The frame then becomes 718x576).

Edit2:
It looks like temporalsoften must not be the first filter after separatefields()
Happy New Year!
Temporalsoften bug is fixed. Changes are merged into main repository.
pinterf is offline   Reply With Quote
Old 15th January 2020, 17:39   #5077  |  Link
Sharc
Registered User
 
Join Date: May 2006
Posts: 3,525
Quote:
Originally Posted by pinterf View Post
Happy New Year!
Temporalsoften bug is fixed. Changes are merged into main repository.
Happy New Year! Thank you for the fix
Sharc is offline   Reply With Quote
Old 15th January 2020, 23:19   #5078  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,378
Cheers P, you are a sweetie.
__________________
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   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 07:06.


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