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 > Video Encoding > High Efficiency Video Coding (HEVC)

Reply
 
Thread Tools Search this Thread Display Modes
Old 21st April 2023, 19:30   #1  |  Link
HD MOVIE SOURCE
Registered User
 
HD MOVIE SOURCE's Avatar
 
Join Date: Mar 2021
Location: North Carolina
Posts: 138
Placebo vs Very Slow & merange

Hi,

I tend to encode a lot of shorter content on Placebo, but I was just looking at the differences between that and Very Slow, and one thing that I saw (as a major difference) is the merange values.

Placebo uses 92 for merange and Very Slow and everything else uses 57.

It basically says in the docs that anything above 57 really may not be worth the cost.

So, is merange=92 beneficial, and is it worth it? I know there are a few more things that are affected by Placebo, but I'm really just wondering about this. Is 57 always the best no matter the content? Is it this number content-based?

Thanks.
HD MOVIE SOURCE is offline   Reply With Quote
Old 21st April 2023, 21:46   #2  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,770
Quote:
Originally Posted by HD MOVIE SOURCE View Post
Hi,

I tend to encode a lot of shorter content on Placebo, but I was just looking at the differences between that and Very Slow, and one thing that I saw (as a major difference) is the merange values.

Placebo uses 92 for merange and Very Slow and everything else uses 57.

It basically says in the docs that anything above 57 really may not be worth the cost.

So, is merange=92 beneficial, and is it worth it? I know there are a few more things that are affected by Placebo, but I'm really just wondering about this. Is 57 always the best no matter the content? Is it this number content-based?
Higher numbers aren't harmful to quality, just for speed. In general a higher range will find better matches. 57 is totally fine as a default; placebo is aptly named.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 22nd April 2023, 03:26   #3  |  Link
HD MOVIE SOURCE
Registered User
 
HD MOVIE SOURCE's Avatar
 
Join Date: Mar 2021
Location: North Carolina
Posts: 138
Quote:
Originally Posted by benwaggoner View Post
Higher numbers aren't harmful to quality, just for speed. In general a higher range will find better matches. 57 is totally fine as a default; placebo is aptly named.
Thanks Ben.
HD MOVIE SOURCE is offline   Reply With Quote
Old 6th May 2023, 04:06   #4  |  Link
HD MOVIE SOURCE
Registered User
 
HD MOVIE SOURCE's Avatar
 
Join Date: Mar 2021
Location: North Carolina
Posts: 138
Quote:
Originally Posted by benwaggoner View Post
Higher numbers aren't harmful to quality, just for speed. In general a higher range will find better matches. 57 is totally fine as a default; placebo is aptly named.
Let's say this, if the ctu is 32, is it beneficial to use a merange larger than the ctu? I'm probably misunderstanding what merange is. The real question is, is it ever worthwhile searching beyond the current size of your ctu?

Could you set your ctu to 32 and set merange to 64? If so, does the search only go right to the next ctu? Could it search to the next line of ctu's underneath or only in one direction? I'm asking this because I believe ctu's are built from top to bottom, and left to right.
HD MOVIE SOURCE is offline   Reply With Quote
Old 6th May 2023, 07:44   #5  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,770
Quote:
Originally Posted by HD MOVIE SOURCE View Post
Let's say this, if the ctu is 32, is it beneficial to use a merange larger than the ctu? I'm probably misunderstanding what merange is. The real question is, is it ever worthwhile searching beyond the current size of your ctu?
There's no real connection between CTU size and motion vector distance. You can mix and match safely.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 8th May 2023, 04:13   #6  |  Link
HD MOVIE SOURCE
Registered User
 
HD MOVIE SOURCE's Avatar
 
Join Date: Mar 2021
Location: North Carolina
Posts: 138
Quote:
Originally Posted by benwaggoner View Post
There's no real connection between CTU size and motion vector distance. You can mix and match safely.
Good to know, thank you Ben.
HD MOVIE SOURCE is offline   Reply With Quote
Old 8th May 2023, 04:26   #7  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,845
Quote:
Originally Posted by benwaggoner View Post
There's no real connection between CTU size and motion vector distance. You can mix and match safely.
Actually, maximum merange is calculated as "CTU size - 4(luma) - 2(chroma) (-1 if me=hex is used)"

So the default of 57 comes from the fact that default CTU size in x265 is 64 and default ME is hex. 64 - 4 - 2 - 1 = 57

If using a CTU of 32, the max would be: 32 - 4 - 2 = 26 (or 25 if me=hex is used)
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 11th May 2023, 06:14   #8  |  Link
HD MOVIE SOURCE
Registered User
 
HD MOVIE SOURCE's Avatar
 
Join Date: Mar 2021
Location: North Carolina
Posts: 138
Quote:
Originally Posted by microchip8 View Post
Actually, maximum merange is calculated as "CTU size - 4(luma) - 2(chroma) (-1 if me=hex is used)"

So the default of 57 comes from the fact that default CTU size in x265 is 64 and default ME is hex. 64 - 4 - 2 - 1 = 57

If using a CTU of 32, the max would be: 32 - 4 - 2 = 26 (or 25 if me=hex is used)
So what happens if you use 58 with CTU 64 and 27 with CTU 32? Does it require more processing time because the encoder is moving into another CTU row? Is it always best to be at the exact size of the CTU with merange, obviously, negating the luma and chroma too?

Are there benefits to going outside the CTU range?
HD MOVIE SOURCE is offline   Reply With Quote
Old 11th May 2023, 06:37   #9  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,845
Quote:
Originally Posted by HD MOVIE SOURCE View Post
So what happens if you use 58 with CTU 64 and 27 with CTU 32? Does it require more processing time because the encoder is moving into another CTU row? Is it always best to be at the exact size of the CTU with merange, obviously, negating the luma and chroma too?

Are there benefits to going outside the CTU range?
It gets internally clipped by x265
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 11th May 2023, 06:54   #10  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,730
It's not clipped at all, the encoder does use a value you set there. A different question is if it's meaningful to use a bigger value than the CTU size

x265.h does have a conflicting comment regarding the default, which is 57 as calculated in the earlier post. It's pointed out that the range should be lowered is CTU is lower.

Code:
    /* The maximum distance from the motion prediction that the full pel motion
     * search is allowed to progress before terminating. This value can have an
     * effect on frame parallelism, as referenced frames must be at least this
     * many rows of reconstructed pixels ahead of the referencee at all times.
     * (When considering reference lag, the motion prediction must be ignored
     * because it cannot be known ahead of time).  Default is 60, which is the
     * default max CU size (64) minus the luma HPEL half-filter length (4). If a
     * smaller CU size is used, the search range should be similarly reduced */
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 11th May 2023, 07:08   #11  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,845
I haven't looked at the code, but I do think it gets clipped. That's why you see no speed difference between 57 or 58 and say 128
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 11th May 2023, 07:28   #12  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,730
I ended up at that part of code by searcing for "searchRange" in the repository, and I cannot see anything clipping the input. I have myself noticed a difference between 26 and 58 with CTU 32, which is why I initially assumed that any legal value is actually used.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 17th May 2023, 16:24   #13  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,770
Quote:
Originally Posted by microchip8 View Post
I haven't looked at the code, but I do think it gets clipped. That's why you see no speed difference between 57 or 58 and say 128
Motion vectors can be longer than CTU size! Otherwise the maximum vector length would be 64.

The --merange value means different things in different modes, and doesn't match with the actual search range at full resolutions.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 18th May 2023, 18:46   #14  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,845
Quote:
Originally Posted by benwaggoner View Post
Motion vectors can be longer than CTU size! Otherwise the maximum vector length would be 64.

The --merange value means different things in different modes, and doesn't match with the actual search range at full resolutions.
I know that! The reason I thought it gets clipped is because years ago, I vaguely remember Dark Shikari mentioning that "something" gets clipped to a max value if the provided one is bigger than it. I don't recall exactly, but I "think" he was talking about merange in x264 and x265 is baed on its codebase.
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 18th May 2023, 20:15   #15  |  Link
rwill
Registered User
 
Join Date: Dec 2013
Posts: 347
Quote:
Originally Posted by microchip8 View Post
I know that! The reason I thought it gets clipped is because years ago, I vaguely remember Dark Shikari mentioning that "something" gets clipped to a max value if the provided one is bigger than it. I don't recall exactly, but I "think" he was talking about merange in x264 and x265 is baed on its codebase.
Sometimes "vertical down Y" is clipped to not slow down frame based threading.
rwill is offline   Reply With Quote
Old 18th May 2023, 22:46   #16  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,770
Quote:
Originally Posted by microchip8 View Post
I know that! The reason I thought it gets clipped is because years ago, I vaguely remember Dark Shikari mentioning that "something" gets clipped to a max value if the provided one is bigger than it. I don't recall exactly, but I "think" he was talking about merange in x264 and x265 is baed on its codebase.
Every codec I can recall of has a maximum motion vector length constraint that may be what you're thinking of. They're much bigger than 64x64 for everything modern. I think Cinepak was limited to 31x31.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner 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 03:42.


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