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 1st April 2023, 13:48   #1  |  Link
Argaricolm
Registered User
 
Join Date: Apr 2018
Posts: 23
ImageSourceNV plugin

I'v made a plugin that uses nvjpeg api to decode jpeg source files and convert their color space to YUV444. That is CUDA accelerated.
You will need CUDA toolkit 12.2 (or 11.8) installed and MS C++ redistributables.

Usage:
ImageSourceNV("C:\Folder1\Folder2","jpg",1,34609,24000,1001)

1: Folder path without ending slash.
2: Files extension.
3: First frame.
4: Last frame (included).
5: FPS numerator.
6: FPS denumerator.

File names should be 6 numbers with leading zeroes (%06d).

Download link

Source included.

Update 1:
Added two new CUDA functions:
ConvertToRGBNV()
ConvertToYUVNV()


ConvertToRGBNV function converts YUV444 or YUV420 to RGB 32 bit (technically BGR in avisynth).

ConvertToYUVNV converts RGB32 to YUV420.
I'v made them because of the need to use RGB filters.
YUV<->RGB conversion is done with formula published on MS site.
Nvidia NPP functions use different formula, that makes incorrect (brighter) RGB results and also outputs BGR pixels in reversed order, that makes image flipped. So they were not used.

Update 07.07.2023:
Fixed one bug that caused last (bottom) row to be black line in convert RGV<->YUV functions.
Recompiled with CUDA 12.2.

Last edited by Argaricolm; 7th July 2023 at 02:18. Reason: Bugfix.
Argaricolm is offline   Reply With Quote
Old 1st April 2023, 18:26   #2  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 2,153
your plugin for x86 or x64??
kedautinh12 is offline   Reply With Quote
Old 1st April 2023, 18:32   #3  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,664
It's x64.

@Argaricolm

Thank you for the plugin. Any chance of a CUDA 11.8 compile for us Windows 7 users?
Reel.Deel is offline   Reply With Quote
Old 1st April 2023, 19:24   #4  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
A VapourSynth version would be nice.
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 1st April 2023, 20:11   #5  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,664
If you're reluctant to install the 3GB CUDA toolkit, you can the individual files also. According to DependencyWalker it only needs these two files:
Reel.Deel is offline   Reply With Quote
Old 2nd April 2023, 00:22   #6  |  Link
Argaricolm
Registered User
 
Join Date: Apr 2018
Posts: 23
But these 2 dlls are surely have other dependencies...
Added CUDA 11.8 version. Redownload archive.

Last edited by Argaricolm; 2nd April 2023 at 00:43.
Argaricolm is offline   Reply With Quote
Old 2nd April 2023, 01:39   #7  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,664
Quote:
Originally Posted by Argaricolm View Post
But these 2 dlls are surely have other dependencies...
Added CUDA 11.8 version. Redownload archive.
Tried out the 11.8 version but it seems that it requires nvjpeg from Cuda 12?



If not too much trouble, maybe a static build would be better.
Reel.Deel is offline   Reply With Quote
Old 2nd April 2023, 14:21   #8  |  Link
Argaricolm
Registered User
 
Join Date: Apr 2018
Posts: 23
Quote:
Originally Posted by Reel.Deel View Post
Tried out the 11.8 version but it seems that it requires nvjpeg from Cuda 12?
Fixed. Redownload.
Made static linking. But it links only C++ library functions. Cuda is still needed.
Argaricolm is offline   Reply With Quote
Old 2nd April 2023, 18:08   #9  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,664
Quote:
Originally Posted by Argaricolm View Post
Fixed. Redownload.
Made static linking. But it links only C++ library functions. Cuda is still needed.
Thanks for the update. I got it to run but the output is only a green image:

Code:
ImageSourceNV("E:\Images", "jpg", 1, 6, 24000, 1001)


Dimensions, frame count and frame rate are correct, though.

I did have to fetch two additional dependencies for cudart64_110.dll (api-ms-win-core-libraryloader-l1-2-0.dll and api-ms-win-security-systemfunctions-l1-1-0.dll). I'm not sure why they're missing or if they are meant for Win10.
Reel.Deel is offline   Reply With Quote
Old 2nd April 2023, 21:37   #10  |  Link
Argaricolm
Registered User
 
Join Date: Apr 2018
Posts: 23
Image width & height are got using nvjpeg. So - it is working.
I'v tested it with 1048 height and working here.
What software are you using to open avs? And which version of avisynth?

Last edited by Argaricolm; 2nd April 2023 at 21:43.
Argaricolm is offline   Reply With Quote
Old 2nd April 2023, 22:28   #11  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 1,531
My main system is down so I can only remote guess from a replacement system below the specified abilities:
The given commandline does not specify spaces and wants to see 000000.jpg, 000001.jpg ?
And any green frame would usually be YUV samples decoded as 0,0,0 (invalid, btw.)
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain)
"Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..."
Emulgator is offline   Reply With Quote
Old 3rd April 2023, 00:41   #12  |  Link
Argaricolm
Registered User
 
Join Date: Apr 2018
Posts: 23
Yes, it needs file names: 000001.jpg
6 numbers. Same as in input parameters.
It gets frame settings from first jpeg.
Argaricolm is offline   Reply With Quote
Old 3rd April 2023, 19:03   #13  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,664
Quote:
Originally Posted by Argaricolm View Post
Image width & height are got using nvjpeg. So - it is working.
I'v tested it with 1048 height and working here.
What software are you using to open avs? And which version of avisynth?
I'm using AviSynth 3.7.3 test 9 and tested with VDub2 and AvsPmod and both show the same result. Image is 4:2:0.

I also noticed that ImageSourceNV("E:\Images", "jpg") results in "ZeroDivisionError: float division by zero".
Reel.Deel is offline   Reply With Quote
Old 4th April 2023, 14:50   #14  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 1,531
System up again, success.
Threw the cuda 11.8 .dlls into system32, used the 11.8 plugin version.

From non-subsampled .jpg source filter returns frames decoded to YV24, 23.976fps
Tested folder with 5 frames starting 000001.jpg...000005.jpg
returns the 1st frame 000001, then repeats the same frame until framecount.

Tested folder with 5 frames starting 000000.jpg...000004.jpg
returns frame 000000, then 000001, then 000002, then repeats 000002, then 000000.
(My bad: I had given some pictures with differing width/height, first 3 were portrait, then 000003 was landscape X-}
00000.jpg: No video

Now a folder renamed to 000000.jpg to 000200.jpg, all same dimensions 4608x3456, orientation landscape.
These 4:2:2-subsampled .jpgs result in chroma planes with half width,
so resizing would be necessary afterwards, or better: chromaspace signalling should match.

ImageSourceNV() returns all frames decoded with unresized chroma planes to YV24, 23.976fps.

With prefetch(16,200) 4k frames can be decoded almost in film speed (RTX3080 @ 15..30%).
Not bad for flipping through albums.
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain)
"Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..."

Last edited by Emulgator; 4th April 2023 at 15:31.
Emulgator is offline   Reply With Quote
Old 4th April 2023, 18:29   #15  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,664
I used the oldest versions available (cudart 11.4.108 / nvjpeg 11.5.2.120) and now it works for me. I will go back and see what is the latest version that works for me since I'm on Windows 7. I think the problem may be that the newest 11.8 cudart requires api-ms-win-core-libraryloader-l1-2-0.dll and api-ms-win-security-systemfunctions-l1-1-0.dll while the oldest one does not.

Edit: the latest cudart that does not require those additional dependencies is 11.6.55.

Last edited by Reel.Deel; 4th April 2023 at 19:05.
Reel.Deel is offline   Reply With Quote
Old 4th April 2023, 23:13   #16  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 1,531
Thank you, good to know.
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain)
"Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..."
Emulgator is offline   Reply With Quote
Old 29th February 2024, 10:03   #17  |  Link
Genji
Registered User
 
Join Date: Oct 2023
Posts: 5
In an application called Amatsukaze (internally using Avisynth Neo), writing ConvertToRGBNV() immediately after OnCUDA(2) results in an error.

avs example 1 -> exits with error
...
KFMDeint(xxxxx)
OnCUDA(2)
ConvertToRGBNV()
xxxxxxx
ConvertToYUVNV()
OnCPU(2)
...

Output Error
Message: [CUDA Error] 77: an illegal memory access was encountered @919

ConvertToYUVNV() is processed normally without error.

avs example 2 -> successful completion
...
KFMDeint(xxxxxxx)
OnCUDA(2)
ConvertToYUVNV()
xxxxxxx
OnCPU(2)
...

Is this due to Amatsukaze(Avisynth Neo) or something different between ConvertToRGBNV() and ConvertToYUVNV()?
Genji is offline   Reply With Quote
Old 6th March 2024, 17:48   #18  |  Link
Argaricolm
Registered User
 
Join Date: Apr 2018
Posts: 23
I have not used Amatsukaze
Probably you should use OnCUDA(2) after Convert.
Convert functions work internally only on CUDA. So no need to specify anything.
If you don't have CUDA support by drivers that functions will not do anything.
Argaricolm 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 00:50.


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