SSE4+AVX2: Transcoding MPEG2 > AVC1 (Question/ Bug (?) and suggestion)

Started by guju, December 26, 2022, 11:26:39 AM

Previous topic - Next topic

guju

By chance recently I discovered the SIMD settings in Avidemux.
I checked my CPU's abilities (Intel i7-6700 @ 3.4 GHz)
and enabled SSE4, SSE4.2, AVX and AVX2.
I was curious how much time I would have spared if I would
have discovered it earlier.
I tried on pulp fiction from MPG2 to AVC1.

The difference was disappointing small:
Just about 4 min (= 2.2%).
(Complete time with all SIMD: 2h42m17s / 8 threads all at 100%).

So my question:
Is it correct to have only such a small acceleration
when enabling SSE4, SSE4.2, AVX and AVX2?

And my suggestion:
It would be very desirable if Avidemux would autodetect and set
the CPU's SIMD capabilities. As maybe I'm not the only one to
overlook it for ... years.

Win7 SP1-64, Avidemux v.2.8.1

szlldm

SIMD settings in Avidemux does not affect encoder SIMD usage. The encoders automatically use the best available SIMD instruction set.

guju

What kind of operations do Avidemux' SIMD settings affect then?
(As I wonder what my 2.2% come from. I do only transcode)

eumagga0x2a

A brief search of Avidemux source code for "hasMMX" and "hasSSE" shows that these SIMD extensions are used in the SoundTouch library (only MMX and SSE, not beyond these) used by some audio filters in Avidemux, by Dolby ProLogic audio downmixer (SSE2), by some core functions converting between pixel formats (only MMX), by some functions related to downloading OpenGL textures to the main memory and by some video filters (Yadif: SSSE3 and SSE2; imageStab, resampleFps in motion estimation mode, eq2, itvcDupeRemover and vidMSharpen: MMX).

But the main component at the core of the application which extensively uses advanced SIMD are FFmpeg libraries which provide a major part of Avidemux functionality in the areas of audio / video decoding and picture scaling and conversion.

Quote from: guju on December 26, 2022, 11:26:39 AMI tried on pulp fiction from MPG2 to AVC1.

Implementing support for Intel HW video encoder for H.264 and HEVC on Windows is high on the todo list. On Linux and on macOS, using hw video encoders can increase encoding speed by order of magnitude (depending on video properties, of course) compared to x264. On Windows, this is possible only with NVIDIA graphics cards (not too old).

guju

Thank you very much for your detailed answer.  :)
(Hopefully this will provide some clearance for further dev).

So, in my situation (only transcode) the reason for the 2.2% speed up
will be the decoding by ffmpeg (if I get you right).

2.2% is better than nothing, so I still do suggest to have the
SIMD abilities autodetected.
(If the codecs can do this, Avidemux should do it too).
Maybe still optional.

Greetings!

BTW:
If the codecs for encoding use SIMD automatically, why doesn't ffmpeg when decoding?

eumagga0x2a

Quote from: guju on December 26, 2022, 06:15:56 PMSo, in my situation (only transcode) the reason for the 2.2% speed up
will be the decoding by ffmpeg (if I get you right).

As SSE4, SSE4.2, AVX and AVX2 are not used by Avidemux directly, then you are (almost) correct, the slightly improved performance must be attributed mainly to faster FFmpeg-internal routines which can be indirectly invoked by Avidemux through video decoding and image operations (scaling, colorspace and pixel format conversion).

Quote from: guju on December 26, 2022, 06:15:56 PM2.2% is better than nothing, so I still do suggest to have the SIMD abilities autodetected.

They are autodetected (those which are unavailable cannot be clicked on). They are not enabled by means of overriding user settings.

Quote from: guju on December 26, 2022, 06:15:56 PMIf the codecs for encoding use SIMD automatically, why doesn't ffmpeg when decoding?

It does. It obeys restrictions (possibly) imposed by user.

The list of SIMD we can disable was expanded some time ago, your Avidemux profile might have simply inherited an old configuration.

guju

Again thank you very much for your assistance!

You're probably right, that by updating from former versions I inherited the settings.

Concerning SIMD:
I'm impressed how good the things are made in Avidemux.