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 Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 10th November 2024, 22:52   #21  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,823
Thanks.

Why you didn't set the chroma default as top-left? Usually that's the one used for AVC/HEVC encoding.

Moreover: is there a way to make it work and output arbitrary bitdepth, such as 10/16/32?

Otherwise I need to put

z_ConvertFormat(resample_filter="spline64",dither_type="error_diffusion",pixel_type="yuv420p16")

before the Resize8 line and, on my slow cpu, it's stealing some cycles instead of having it done internally.
__________________
@turment on Telegram

Last edited by tormento; 10th November 2024 at 23:13.
tormento is offline   Reply With Quote
Old 11th November 2024, 04:16   #22  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,936
The default is left as it's the default for all chroma placement aware resizers, to the best of my knowledge. The native Avisynth functions that support chroma placement, such as ConvertToYUV420(), also default to left. It doesn't really matter though, as if the chroma placement is specified in frame properties it's the placement that's used.

The original version of the function was intended to correct the chroma shift while using Avisynth's resizers as they're (still) not chroma placement aware, but even though the updated version supports any resizer with the same named arguments for cropping as Avisynth's resizers, they don't necessarily have the ability to change the bitdepth, and when they do they have different arguments for specifying it. The only practical way for Resize8 to change the bitdepth would be to use ConvertBits(), but I'm not sure if there's much point when it's easy enough to add ConvertBits to a script.

Edit: If you're using a chroma placement aware resizer then it might be simpler to use it instead, especially if it can change the bitdepth. These should give you an identical output if the chroma location is "left".

Code:
ConvertBits(16).Resize8(940,540, kernel="z_Spline64Resize")
ConvertBits(16).z_Spline64Resize(940,540)
z_ConvertFormat(940,540, resample_filter="Spline64", pixel_type="YUV420P16")
For some reason though, you have to tell z_ConvertFormat to use the chroma location in frame properties otherwise it assumes "left", but for a "top_left" chroma location in frame properties these should produce an identical result. I'm not sure why the default chroma location for z_ConvertFormat isn't "auto" rather than left, but it appears not to be, so without chromaloc_op="auto=>same" the output isn't identical as Resize8 would use "top_left" but z_ConvertFormat wouldn't.

Code:
propSet("_ChromaLocation", 2) # top_left

A = ConvertBits(16).Resize8(940,540, kernel="z_Spline64Resize")
B = z_ConvertFormat(940,540, resample_filter="Spline64", pixel_type="YUV420P16", chromaloc_op="auto=>same")

Compare(A,B)

Last edited by hello_hello; 12th November 2024 at 18:47.
hello_hello is offline   Reply With Quote
Old 11th November 2024, 13:59   #23  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Posts: 207
"top_left" is not the default, default is "left", not only in all chroma placement aware resizers, but also true for virtually all encodings "below" UHD Bluray - they just somehow suddenly decided to change it to top_left

Last edited by Z2697; 11th November 2024 at 14:08.
Z2697 is offline   Reply With Quote
Old 11th November 2024, 18:27   #24  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,823
Quote:
Originally Posted by Z2697 View Post
"top_left" is not the default, default is "left", not only in all chroma placement aware resizers, but also true for virtually all encodings "below" UHD Bluray - they just somehow suddenly decided to change it to top_left
Is there a way to determine where chroma placement is?

I mean, without frame properties.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 11th November 2024, 23:25   #25  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,936
Quote:
Originally Posted by tormento View Post
Is there a way to determine where chroma placement is?

I mean, without frame properties.
I'm pretty sure FFMS2, lsmash and BestSource all write the chroma location to frame properties.
x264 and x265 both have a command line option --chromaloc so it's obviously saved as Video Usability Information, but I don't recall MediaInfo displaying it. That doesn't necessarily mean it doesn't, if it exists, as my memory isn't great.

https://x265.readthedocs.io/en/maste...mation-options

Last edited by hello_hello; 11th November 2024 at 23:40.
hello_hello is offline   Reply With Quote
Old 12th November 2024, 07:25   #26  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 3,115
Mediainfo doesn't explicitly mention it, however when it says 4:2:0 without anything it means left (the good old MPEG-2 standard) and when it says Type 2 it means top_left (the "new" H.265 standard). Other tools like ffprobe or indeed the two Avisynth indexers you mentioned display it explicitly.
FranceBB is offline   Reply With Quote
Old 12th November 2024, 15:34   #27  |  Link
StvG
Registered User
 
Join Date: Jul 2018
Posts: 503
Quote:
Originally Posted by hello_hello View Post
For some reason though, you have to tell z_ConvertFormat to use the chroma location in frame properties otherwise it assumes "left", but for a "top_left" chroma location in frame properties these should produce an identical result. I'm not sure why the default chroma location for z_ConvertFormat isn't "auto" rather than left, but it appears not to be, so without chromaloc_op="auto=>same" the output isn't identical as Resize8 would use "top_left" but z_ConvertFormat wouldn't.
The chroma location is "auto" when there is valid _ChromaLocation frame prop and reading frame props are enabled (use_props=-1*/1). In the rest cases a default value is used ("left").

* If the conditions are met.

Quote:
Originally Posted by hello_hello View Post
I'm pretty sure FFMS2, lsmash and BestSource all write the chroma location to frame properties.
Yes, when ffmpeg also signals (not always) the chroma location.
StvG is offline   Reply With Quote
Old 12th November 2024, 17:40   #28  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,936
Ah..... yes, these seem to produce the same result.

propSet("_ChromaLocation", 2) # top_left
A = z_ConvertFormat(940,540, resample_filter="Spline64", pixel_type="YUV420P16", use_props=1)
B = z_ConvertFormat(940,540, resample_filter="Spline64", pixel_type="YUV420P16", chromaloc_op="auto=>same")
Compare(A,B)

Could I ask why the default for use_props isn't 1 though?
Would it be more intuitive if the default for use_props was 1 but it automatically switched to -1 when the colorspace_op or chromaloc_op arguments are used? That way z_ConvertFormat would use any frame properties that exist without the user having to tell it to, but it'd ignore them and do something else when values for colorspace_op or chromaloc_op are specified. Maybe I'm missing something....

Cheers.
hello_hello is offline   Reply With Quote
Old 12th November 2024, 19:22   #29  |  Link
StvG
Registered User
 
Join Date: Jul 2018
Posts: 503
B = z_ConvertFormat(940,540, resample_filter="Spline64", pixel_type="YUV420P16", chromaloc_op="auto=>same") - is using use_props=1. From doc - "-1: If frame properties are supported - if every value of colorspace_op and every value of chromaloc_op is specified, and it's different than "auto", 0, otherwise 1."

So you're comparing the same processing.

Maybe you want - B = z_ConvertFormat(940,540, resample_filter="Spline64", pixel_type="YUV420P16", chromaloc_op="top_left=>top_left"). In this case use_props=0 is used.

The default use_props is -1 - meaning its auto selected between 0 and 1 depending on the used command. Compare the speed of A with the new B (with use_props=0). The reason for the default value of -1 - for some filtering one can completely ignore the frame props (changing only bit depth or just resizing RGB/YUV444 video...) and can benefit from the better speed.

Maybe I could add the case when a video with chroma subsampling is resized and use_props=-1 used, the frame props to be read.
StvG 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 09:31.


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