Argaricolm
1st April 2023, 13:48
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.4 (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 (https://disk.yandex.ru/d/ViCV8bgqSZltcA)
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 (https://learn.microsoft.com/ru-ru/windows/win32/medfound/recommended-8-bit-yuv-formats-for-video-rendering)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.
Update 22.04.2024:
Changed YUV<->RGB conversion formula. Previous one was only for limited color range. Now it will work for full color range too.
Update 04.10.2024:
1) Added option for ConvertToRGBNV function called "full".
Now you can convert from YUV to RGB without changing color range, so it will be limited range in RGB (if YUV was in limited).
This is useful if you don't need full range.
Like for example if you use some denoising RGB function you just do:
ConvertToRGBNV(full=1)
Denoise()
ConvertToYUVNV()
This way you will not do color range conversion twise.
2) ImageSourceNV function was fixed. The one before was returning a full range YUV. Now it will decode jpeg to RGB, then change range to limited, and then convert to YUV. So returned YUV will be in limited range. Rec.709 is used here for RGB->YUV conversion.
You will need CUDA toolkit 12.4 (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 (https://disk.yandex.ru/d/ViCV8bgqSZltcA)
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 (https://learn.microsoft.com/ru-ru/windows/win32/medfound/recommended-8-bit-yuv-formats-for-video-rendering)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.
Update 22.04.2024:
Changed YUV<->RGB conversion formula. Previous one was only for limited color range. Now it will work for full color range too.
Update 04.10.2024:
1) Added option for ConvertToRGBNV function called "full".
Now you can convert from YUV to RGB without changing color range, so it will be limited range in RGB (if YUV was in limited).
This is useful if you don't need full range.
Like for example if you use some denoising RGB function you just do:
ConvertToRGBNV(full=1)
Denoise()
ConvertToYUVNV()
This way you will not do color range conversion twise.
2) ImageSourceNV function was fixed. The one before was returning a full range YUV. Now it will decode jpeg to RGB, then change range to limited, and then convert to YUV. So returned YUV will be in limited range. Rec.709 is used here for RGB->YUV conversion.