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 7th November 2016, 13:01   #2581  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,256
Quote:
Originally Posted by jpsdr View Post
A little question.
If i am with an YUVA 4:4:4 mode (for exemple), will IsYV24() still be true ?
No. There is an Is444() which is bit-depth independent and also works for YUVA.
When using my latest Avisynth.h, this Is444 call is mapped silently to IsYV24 if the relevant avisynth host has no Is444() implemented.
pinterf is offline   Reply With Quote
Old 7th November 2016, 13:08   #2582  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 1,765
Ah... Ok i've seen

So, it means there is no 4:1:1 with alpha channel ?
jpsdr is offline   Reply With Quote
Old 7th November 2016, 13:10   #2583  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,256
Quote:
Originally Posted by jpsdr View Post
Ah... Ok i've seen

So, it means there is no 4:1:1 with alpha channel ?
No. We are lucky then
pinterf is offline   Reply With Quote
Old 7th November 2016, 15:04   #2584  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,117
Feature request

Can we add a straightforward way to get the chroma width and height? Right now we have to do something like UToY8().Width(). Maybe something like Width(chroma=true) or uv=true. Thoughts?
Reel.Deel is offline   Reply With Quote
Old 7th November 2016, 19:42   #2585  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,256
Avisynth arrays status report:

Implemented empty arrays and [] syntax for array creation

Code:
clip=ffms2(film).ConvertBits(16)

empty_array = []
empty_array_2 = empty_array
#n3 = empty_array_2.ArrayGet(0) # array index out of range error!

black_yuv_16 = [0,32768,32768] # or black_yuv_16 = Array(    0,32768,32768)
grey_yuv_16  = [32768,32768,32768]
white_yuv_16 = [65535,32768,32768]
# getting deeper: nested arrays
aSelectColors = [\
  ["black", black_yuv_16],\
  ["grey",  grey_yuv_16],\
  ["white", white_yuv_16],\
  ["empty", empty_array]\
]
test_array = [99, 1.0, "this is a string"] # mixed types
test_array2 = [199, 2.0, "This is a string"]

n = ArraySize(test_array) # 3
n2 = ArraySize(empty_array_2) # 0

clip = clip.SubTitle("Array size = " + String(n) +\
 " Empty array size = " + String(n2) +\
 " [0]=" + String(ArrayGet(test_array,0)) + \
 " [1]=" + String(ArrayGet(test_array,1)) + \
 " [2]=" + ArrayGet(test_array,2))

black=blankClip(clip, length=1, colors = ArrayGet(aSelectColors,"black")) # value lookup by name
white=blankClip(clip, length=1, colors = aSelectColors.ArrayGet("white")) # value lookup by name
grey=blankClip(clip, length=1, colors = [32768,32768,32768]) # or direct array

blackwhite = black+grey+white+black+grey+white
n=3
clip = clip.Trim(0,n) + blackwhite + clip.Trim(n+1,499)
clip
Back to work. It would be nice to have indexing with []
pinterf is offline   Reply With Quote
Old 8th November 2016, 09:52   #2586  |  Link
mcjordan
Registered User
 
Join Date: Nov 2010
Posts: 100
3> limiter.cpp
3>C:\AviSynthPlus\avs_core\filters\limiter.cpp(107): error C3861: '_mm_max_epu16': identifier not found
3>C:\AviSynthPlus\avs_core\filters\limiter.cpp(108): error C3861: '_mm_min_epu16': identifier not found
...
//min and max values are 16-bit unsigned integers
inline void limit_plane_uint16_sse4(BYTE *ptr, unsigned int min_value, unsigned int max_value, int pitch, int height) {
__m128i min_vector = _mm_set1_epi16(min_value);
__m128i max_vector = _mm_set1_epi16(max_value);
BYTE* end_point = ptr + pitch * height;

while(ptr < end_point) {
__m128i src = _mm_load_si128(reinterpret_cast<const __m128i*>(ptr));
src = _mm_max_epu16(src, min_vector);
src = _mm_min_epu16(src, max_vector);
_mm_store_si128(reinterpret_cast<__m128i*>(ptr), src);
ptr += 16;
}
}
...
This break compilation process ?! Help?
mcjordan is offline   Reply With Quote
Old 8th November 2016, 10:21   #2587  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,256
Quote:
Originally Posted by mcjordan View Post
3> limiter.cpp
3>C:\AviSynthPlus\avs_core\filters\limiter.cpp(107): error C3861: '_mm_max_epu16': identifier not found
3>C:\AviSynthPlus\avs_core\filters\limiter.cpp(108): error C3861: '_mm_min_epu16': identifier not found
...

This break compilation process ?! Help?
Indeed, until I update it, put
#include <smmintrin.h> // for sse41
at the top of limiter.cpp
pinterf is offline   Reply With Quote
Old 8th November 2016, 12:02   #2588  |  Link
mcjordan
Registered User
 
Join Date: Nov 2010
Posts: 100
Thank you, pinterf! Works like a charm!
mcjordan is offline   Reply With Quote
Old 8th November 2016, 13:12   #2589  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,384
Quote:
Originally Posted by pinterf View Post
It would be nice to have indexing with []
I would do this by changing the parser's ParseOOP() function - in the two places it currently calls ParseFunction(), it would instead call a new function ParseIndex(), which would look like this:
Code:
PExpression ScriptParser::Parseindex(PExpression context)
{
    PExpression result = ParseFunction(context);
    while (tokenizer.IsOperator('[') {
        tokenizer.NextToken();
        result = new ExpIndex(result, ParseConditional());
        Expect(']');
    }
    return result;
}
This allows things like:
- x.f(2)[3], where f is a function returning an array (no need to put brackets round x.f(2))
- a[1]["white"], where a is a multi-dimensional array
- a[1].f(2), equivalent to f(a[1], 2)

ExpIndex is a new Expression subtype whose Evaluate() function calls the built-in ArrayIndex function.
__________________
GScript and GRunT - complex Avisynth scripting made easier

Last edited by Gavino; 8th November 2016 at 13:25.
Gavino is offline   Reply With Quote
Old 8th November 2016, 13:55   #2590  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,256
Quote:
Originally Posted by Gavino View Post
I would do this by changing the parser's ParseOOP() function - in the two places it currently calls ParseFunction(), it would instead call a new function ParseIndex(), which would look like this:
Code:
PExpression ScriptParser::Parseindex(PExpression context)
{
    PExpression result = ParseFunction(context);
    while (tokenizer.IsOperator('[') {
        tokenizer.NextToken();
        result = new ExpIndex(result, ParseConditional());
        Expect(']');
    }
    return result;
}
This allows things like:
- x.f(2)[3], where f is a function returning an array (no need to put brackets round x.f(2))
- a[1]["white"], where a is a multi-dimensional array
- a[1].f(2), equivalent to f(a[1], 2)

ExpIndex is a new Expression subtype whose Evaluate() function calls the built-in ArrayIndex function.
Thanks, I'm doing it with inserting ParseOOP an additional '[' check, that can call ParseFunction with either . or [, plus the context. If it works, I try to separate it, to be nice (like your proposed ParseIndex.
All other things are done, now I'm doing compound index formats e.g. a[1,2,3]; a[1][2][3] is working already
pinterf is offline   Reply With Quote
Old 8th November 2016, 15:28   #2591  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 1,765
I've looked on post #2484, but don't find an answer.

If i have a planar YUV mode with alpha channel, and i'm doing the following :
Code:
vu = env->Invoke("UtoY8",v).AsClip();
vv = env->Invoke("VtoY8",v).AsClip();
v = env->Invoke("ConvertToY8",v).AsClip();
Where is my alpha channel ?
Is it still on v ?
If still on Y, is doing the following, putting everything back :
Code:
AVSValue ytouvargs[3] = {vu,vv,v};
v=env->Invoke("YtoUV",AVSValue(ytouvargs,3)).AsClip();
If not, what should i do when handling this case ?
jpsdr is offline   Reply With Quote
Old 8th November 2016, 17:50   #2592  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,256
Quote:
Originally Posted by jpsdr View Post
I've looked on post #2484, but don't find an answer.

If i have a planar YUV mode with alpha channel, and i'm doing the following :
Code:
vu = env->Invoke("UtoY8",v).AsClip();
vv = env->Invoke("VtoY8",v).AsClip();
v = env->Invoke("ConvertToY8",v).AsClip();
Where is my alpha channel ?
Is it still on v ?
If still on Y, is doing the following, putting everything back :
Code:
AVSValue ytouvargs[3] = {vu,vv,v};
v=env->Invoke("YtoUV",AVSValue(ytouvargs,3)).AsClip();
If not, what should i do when handling this case ?
UtoY8, VtoY8 and ConvertToY8 functions create greyscale image.

Then there became too much color formats after having Planar RGB and A channel.
Instead of making AtoY8, RtoY8, GtoY8, BtoY8, there is a PlaneToY(plane_string) in Avisynth+ that creates a greyscale clip from the relevant channel.

E.g. PlaneToY("A), PlaneToY("R")
PlaneToY accepts any plane identifier (Y,U,V,A,R,G,B)

PlaneToY("U") is equivalent to UToY8
PlaneToY("V") is equivalent to VToY8
PlaneToY("Y") is equivalent to ConvertToY (ConvertToY8)

All the above functions keep the current bitdepth, the Y8 ending is just because UToY and VToY was already existing functions.

Regarding the back conversion, YtoUV only has U,V and an optional Y clip parameter. To answer on your question, it seems, there is no function for putting A channel back to a YUVA clip.

I always wanted to make a general way mixing together arbitrary planes, something like ShufflePlanes in VapourSynth.

Albeit there is MergeRGB and MergeARGB for packed and planar RGB, it seems that making the same for YUV is missing.
On more reason for implementing a general MergePlanes or something like that. Now I'm considering that.
pinterf is offline   Reply With Quote
Old 9th November 2016, 09:58   #2593  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 1,765
Ok. Meaning that for now, in nnedi3 i can only support YUVA 4:4:4, because for YUV other than 4:4:4 i have to split the planes to process them, and pull back after.
jpsdr is offline   Reply With Quote
Old 9th November 2016, 10:30   #2594  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,256
Quote:
Originally Posted by jpsdr View Post
Ok. Meaning that for now, in nnedi3 i can only support YUVA 4:4:4, because for YUV other than 4:4:4 i have to split the planes to process them, and pull back after.
What is the reason that you have to split the planes then put them together? Bacause nnedi3 can only work internally with identical plane dimensions?
pinterf is offline   Reply With Quote
Old 9th November 2016, 12:58   #2595  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 1,765
Because there is shift to make on chroma only for other modes than 4:4:4, and use of turnleft/right, so need to separate planes in 4:2:2 to have things done properly.
But, this is only for nnedi3_rpow indeed, not nnedi3.

Last edited by jpsdr; 9th November 2016 at 13:02.
jpsdr is offline   Reply With Quote
Old 9th November 2016, 13:50   #2596  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 1,765
Just to be sure, according from what i've understood, IsYUY2 is not only for 8 bits.
jpsdr is offline   Reply With Quote
Old 9th November 2016, 14:04   #2597  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,256
Quote:
Originally Posted by jpsdr View Post
Just to be sure, according from what i've understood, IsYUY2 is not only for 8 bits.
YUY2 is a non-friendly format, and only exists as 8 bit.
pinterf is offline   Reply With Quote
Old 9th November 2016, 14:37   #2598  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 1,765
Ok, thanks for all of these tips.
Now, just 'waiting' (and it will happen when it happens...) for a way to put back alpha channel in YUV mode.
jpsdr is offline   Reply With Quote
Old 10th November 2016, 21:35   #2599  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,256
Quote:
Originally Posted by jpsdr View Post
Ok, thanks for all of these tips.
Now, just 'waiting' (and it will happen when it happens...) for a way to put back alpha channel in YUV mode.
Preliminary information on some future avisynth plus features.
Driven by the popular demand I prepared some new stuffs for those who are mixing planes as a daily routine.

Since it is still not released, you can comment it freely and make wish-list.

20161110 Avisynth plus additions

New functions
  • AToY8 , same as PlaneToY("A") for planar RGBA or YUVA
  • RToY8 , same as PlaneToY("R") for planar RGB
  • GToY8 , same as PlaneToY("G") for planar RGB
  • BToY8 , same as PlaneToY("B") for planar RGB
They work the same way as UToY8 and VToY8 and ConvertToY did.
The functions convert to greyscale, keeping the original bit-depth, not only 8 bits!
Y8 naming was kept, because UToY and VToY already existed.

Extended function syntax
old: YToUV(clip clipU, clip clipV [, clip clipY ] )
new: YToUV(clip clipU, clip clipV [, clip clipY [, clip clipA] ] )

YToUV accepts optional alpha clip after Y clip

Example
Code:
    U = source.UToY8()
    V = source.VToY8()
    Y = source.ConvertToY()
    A = source.AddAlphaPlane(128).AToY8()
    # swaps V, U and A, Y
    YToUV(V,U,A,Y).Histogram("levels").Info().RemoveAlphaPlane()
New function
CombinePlanes(clip1 [,clip2, clip3, clip4], string planes [, string source_planes, string pixel_type, string sample_clip])

Combines planes of source clip(s) into a target clip.
Similar to ShufflePlanes in Vapoursynth.

clip sample_clip (optional)
If sample_clip is given, target clip properties are copied from that clip
If no sample_clip is provided, then clip1 provides the template for target clip

string pixel_type (optional)
An optional pixel_type string (e.g."YV24", "YUV420PS", "RGBP8") can override the base video format.

clip clip1, ... clip4
If the source clip count is less than the given planes defined, then the last available clip is used as a source for all later planes

string planes
the target plane order (e.g. "YVU", "YYY", "RGB")
missing target planes will be undefined in the target

string source_planes (optional)
the source plane order, defaulting to "YUVA" or "RGBA" depending on the video format

Source clips can even be mixed from greyscale, YUV, YUVA, planar RGB(A), the only rule that the relevant source plane character should match with the clip format, respectively.

Example#1
Code:
    #combine greyscale clips into YUVA clip
    source=source.AddAlphaPlane(128)
    U8 = source.UToY8()
    V8 = source.VToY8()
    Y8 = source.ConvertToY()
    A8 = source.AToY8()
    CombinePlanes(Y8, U8, V8, A8, planes="YUVA", source_planes="YYYY", sample_clip=source) #pixel_type="YUVA420P8"
Example#2
Code:
    # Copy planes between planar RGB(A) and YUV(A) without any conversion
    # useful if you have a filter that accepts only YUV input
    # yuv 4:4:4 <-> planar rgb
    source = last.ConvertBits(32) # 4:4:4
    cast_to_planarrgb = CombinePlanes(source, planes="RGB", source_planes="YUV", pixel_type="RGBPS")
    # get back a clip identical with "source"
    cast_to_yuv = CombinePlanes(cast_to_planarrgb, planes="YUV", source_planes="RGB", pixel_type="YUV444PS")
Example#3
Code:
    #create a black and white planar RGB clip using Y channel
    #source is a YUV clip
    grey = CombinePlanes(source, planes="RGB", source_planes="YYY", pixel_type="RGBP8")
Example#4
Code:
    #copy luma from one clip, U and V from another
    #source is the template
    #sourceY is a Y or YUV clip
    #sourceUV is a YUV clip
    clip = CombinePlanes(sourceY, sourceUV, planes="YUV", source_planes="YUV", sample_clip = source)
pinterf is offline   Reply With Quote
Old 11th November 2016, 13:22   #2600  |  Link
ajp_anton
Registered User
 
ajp_anton's Avatar
 
Join Date: Aug 2006
Location: Stockholm/Helsinki
Posts: 782
"RToY8" etc, don't they already exist in "ShowRed" etc?
And since they all end with Y8, does this mean they only work for 8bit?
ajp_anton 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 11:58.


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