216 points · by coldpie · 4y ago · 108 comments
What you should really look at on dav1d is the fact that the code has now around 186 kLoC of hand-written assembly in .S and .asm files…
I think this is quite a feat (this is more asm than the whole FFmpeg) and this is very rare those days to write so much asm.
One of the bugs found by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11464
There's cpu = 'i686' in the config file which would in fact seem to imply none of the modern archs mentioned in a different subthread here ("x86_64(SSE3, AVX2), ARMv7 and ARMv8") are fuzzed.
That's for x86_64(SSE3, AVX2), ARMv7 and ARMv8 right? Is the 186kLoC equally distributed between those arch or is there one arch that has most of the optimization focus?
Is it all hand-written, or do you have some kind of script/macros to create a good part of this assembly (like OpenSSL does IIRC)?
Hand written with some macros, notably for the x86 mess (windows calling convention, ssse being 32 and 64b).
but having a look at clang or GCC, I can confirm. still baby steps, years ahead for proper optims.
This reads to me as it being a PITA to maintain. Cross platform code is usually a pain, cross platform with assembly optimizations is more of a pain. Optimization nearly always makes things harder to maintain, and this sounds like it was optimized to hell and back...
People don't really get how complex video codecs are.
An AV1 example at 1080p50: https://www.youtube.com/watch?v=YhXtJWi2PjI
You can verify if YouTube videos are playing back in AV1 by right clicking on the video and choosing Stats for Nerds. The codec is av01 for AV1 video.
I know so little about this space so not sure how helpful the comparison is, but it is like magic what we are able to do with math.
I'm using Chrome on macOS, which seemingly supports this as well: Codecs av01.0.08M.08 (398) / opus (251)
What decoder is Chrome using?
How are you testing? Is that dav1d 1.0? 8bit or 10bit content?
If you tested before 1.0 and 10bit content, you should run it again, since we pushed new optimizations for this.
I should have included in the original comment this machines needs 60% to 70% CPU to play VP9 on similar bitrate / bit / frames. i.e Decoding on VP9 and AV1 are on a similar level of CPU usage. Considering the complexity of AV1, I thought this was an incredible achievement. ( It actually blows my mind this can be done )
I tested it on with 8 and 10 bit content the result aren't that much different. ( This is just eyeballing CPU usage in Activity Monitor ) The 3.3 Ghz was turbo, so it really should be 2.9Ghz Dual Core Broadwell CPU.
I didn't see benchmarks mentioned in TFA, please let me know if I've missed or overlooked something.
I just transcoded some movies with vmaf of 98% from 4k hdr blurays this last week. Takes about two days of mostly single core work with cpu-used=4 on a 5950x but they get average bitrates of around 4400 kbps. Which is like, really, really good for hitting that quality target.
The trick is that since its mostly single core I just do 16 movies at a time, or 24 on my server.
Turns out it's $NFLXs OSS automated encoding quality assessment tool. Pretty cool!
https://github.com/Netflix/vmaf
p.s. zanny, nice casual stealth drop you did there ;)
If Netflix wants to hire me, dm me, lol.
It's good and getting gooder.
Just give it a try using https://github.com/Alkl58/NotEnoughAV1Encodes or whatever, svt-6 is fairly quick.
It’s physically disabled in new CPUs
https://www.tomshardware.com/news/intel-nukes-alder-lake-avx...
We should be seeing better AVX-512 support with CPUs in the coming years though.
(disclaimer: I used to work there)
Even the newest Shield Pro is based on a 2015 SoC (Tegra-X1) with an integrated 2014 Nvidia GPU (Maxwell). Not surprising it doesnt support av1.
The danger is this block only implementing the decoding of a non-royalty free/patent encumbered format à la mpeg, presuming the "intellectual property" was not globally fixed and still toxic like nowdays.
To a certain extent it's just a place holder so folks can start writing software against it so that when the CPU vendors ship everyone can hit the ground running.
This is the description the dav1d page gives:
dav1d is the fastest AV1 decoder on all platforms :)
Targeted to be small, portable and very fast.
Since they use the word fast twice I was wondering how fast.
Which is cool, but if you have hardware decode then you may not care, though software decode gets used in all sorts of weird places that you might not expect.
Depends on SoC. A15? or low end UniSoC SoC? But generally speaking a modern Smartphone should be able to play 1080P 25fps 1mbps AV1 video on their phone without dropping frames. You will just be burning away your battery life.
Core 2 Duo are processors from 16 years ago...
Mobile phones are more powerful than those machines...
I like open and free standards, and I dislike royalties, but the political aspect is best foregone when one of the alternatives really is objectively so much better for everyone.
I do not know what phone you have but an iPhone 12 ( as an example ) is under 1300 pixels on the short dimension. So you are not getting much more than 1080 pixels no matter what. It seems any experiential difference would have more to do with compression quality than with resolution.
Speaking for myself, I do not think I could tell the difference between 4K and 1080p on a phone ( on a decent AV1 clip ).
SMPTE suggest that 4k for viewing is only worthwhile for people with 20/20 vision once the viewing angle increases beyond 30 degrees.
I'm currently looking at a 40cm wide screen, I'm 80cm away from it, which is about 30 degrees.
For my phone to fill that amount of space it would have to be about 10cm in front of my eyes due to binocular vision (if I just use one eye it's a bit further
When I watch something on my phone it's typically 50cm away, about 15-20 degrees viewing. 720p is more than enough at that size, 1080p if you have particularly good eyesight.
In modern codebases his has the effect of micro-optimization of the "rewrite in assembly" sort mattering a great deal in heavy lifting library code like codecs, CPU emulation, rasterizers, VMs etc, and not at all in other areas. Emulation is a decent candidate in this regard but it also massively benefits from higher level simplifying assumptions(e.g. not polling for I/O changes at the true device frequency). It can be hard to notice differences in emulation quality where high level techniques are applied well.
On old 8-bit architectures it was rather the opposite: you couldn't be high level about anything because you had to design towards micro-efficiency. Therefore most of your problems were solved with very simple data structures and algorithms that heavily favored either space(by recomputing the intermediate results) or time (by precomputing all answers in a LUT), and then given a very tight cycle-shaving, code-golfing implementation.
Eventually computing overcomes the need for optimized assembly and understandable code become more desired.
It could be that they are waiting to see if AV1 will actually get a marketshare outside Youtube or not.
...to bad that they (in the usual Apple fashion) don't support it in a standard container which everyone else supports and require you to package it in their special snowflake .caf container, so even though in theory everyone supports Opus you still need to use MP3 if you don't want to deal with having to support multiple formats/codecs at the same time.