Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qsv: d3d11 enabling #2291

Merged
merged 1 commit into from
Sep 22, 2019
Merged

qsv: d3d11 enabling #2291

merged 1 commit into from
Sep 22, 2019

Conversation

galinart
Copy link
Contributor

@galinart galinart commented Sep 4, 2019

Replaced d3d9 to d3d11 to support multiple device configuration e.g. discrete GPU card + integrated GPU.

@sr55
Copy link
Contributor

sr55 commented Sep 4, 2019

Some initial feedback:

- QSV Decode + Encode:

image

Seems to work fine

- QSV Decode + Software Encode:
Hangs. Doesn't look like that path is hooked up?
https://gist.github.com/sr55/63e4cd7ab1047732eda5952aaf459ff0

Is there any possibility we can avoid disabling filters when using QSV decode?
I.e
Software Filters = No Zero Copy
No Filters => Zero Copy

At least until such time we get qsv filters operational. A few users have been caught out by this.

Hows things going with the ffmpeg patch being submitted upstream? Have they accepted yet?

@sr55 sr55 requested review from maximd33, bradleysepos, jstebbins and a user September 4, 2019 19:13
@galinart
Copy link
Contributor Author

galinart commented Sep 6, 2019

"QSV Decode + Software Encode" issue has been reproduced, thanks! I will start looking into this.

In regards to filters, I think yes. Is it possible to use "No Filters" configuration by default when output resolution is the same as input?

The patch to ffmpeg has not been submitted yet, I am finalizing it.

@sr55
Copy link
Contributor

sr55 commented Sep 6, 2019

Thanks.

In regards to filters, I think yes. Is it possible to use "No Filters" configuration by default when output resolution is the same as input?

Don't see why not, but since most of HandBrakes presets include software filters, in practice it won't happen.

In effect, we should check the filters list before setting zero-copy up. If there is nothing valid there, we use zero copy.

If we eventually get QSV filters, we'll over them as options in the GUI so the end-user can choose either software or hardware filters. If they are using only hardware filters, then again, zero copy can apply.

As it stands, when we turn stuff on, the code turns it off again which mis-leads the user. Even down scaling as far as I know.

@sr55 sr55 added this to the 1.3.0 milestone Sep 6, 2019
@maximd33
Copy link
Contributor

maximd33 commented Sep 8, 2019

thanks, Artem for sharing your work

In effect, we should check the filters list before setting zero-copy up.

generally, it would be good always to use only relevant and needed filters, I will check this.

If we eventually get QSV filters...

this will come for sure as next step, QSV exposes many different ones and common ones, like re-size will be the first ones..

ffmpeg will be updated with related implementation changes, step by step approach.
Its DirectX surfaces/pool management for DX9 and DX11 is different therefore resource management is quite different as well: many surfaces VS one surface with slices inside.

@sr55
Copy link
Contributor

sr55 commented Sep 8, 2019

generally, it would be good always to use only relevant and needed filters, I will check this.

Basically, we should always honour user choice. Thus, we can check and enable zero-copy only when no software filters (decomb, deinterlace, denoise etc) are being used.

When we eventually get QSV alternatives, we can do something in the UI to encourage the usage of the QSV variants assuming they're a reasonable option which in turn would increase the likelyhood of using zero copy.

Crop/Scale is the only special case I know where we can probably disable it if there is 0 change.

@maximd33
Copy link
Contributor

maximd33 commented Sep 9, 2019

@sr55

QSV Decode + Software Encode:

does it always hang in your case?
can you please update driver to : https://downloadcenter.intel.com/download/29058/Intel-Graphics-Windows-10-DCH-Drivers?product=126790

and to all:
filter related question per #2301

@galinart
Copy link
Contributor Author

galinart commented Sep 9, 2019

@sr55 could you please share your command line? Are you able to reproduce it with latest driver for both console binary and GUI binary?

@sr55
Copy link
Contributor

sr55 commented Sep 9, 2019

Driver Updated:

GPU Information:
Intel(R) UHD Graphics 630 - 26.20.100.7158
NVIDIA GeForce GTX 1060 6GB - 26.21.14.3086

Source: https://download.blender.org/demo/movies/BBB/bbb_sunflower_1080p_60fps_normal.mp4


[Working] HandBrakeCLI.exe -i bbb_sunflower_1080p_60fps_normal.mp4 -o test.mp4 -e qsv_h264 --enable-qsv-decoding

[Not Working] HandBrakeCLI.exe -i bbb_sunflower_1080p_60fps_normal.mp4 -o test.mp4 -e x264 --enable-qsv-decoding


Just hangs at 0%

[18:40:41] D3D11: QSV adapter with id 1 has been found
[18:40:41] starting job
[18:40:41] job configuration:
[18:40:41] * source
[18:40:41] + bbb_sunflower_1080p_60fps_normal.mp4
[18:40:41] + title 1, chapter(s) 1 to 1
[18:40:41] + container: mov,mp4,m4a,3gp,3g2,mj2
[18:40:41] + data rate: 4486 kbps
[18:40:41] * destination
[18:40:41] + test.mp4
[18:40:41] + container: MPEG-4 (libavformat)
[18:40:41] * video track
[18:40:41] + decoder: h264_qsv
[18:40:41] + bitrate 4001 kbps
[18:40:41] + filters
[18:40:41] + Framerate Shaper (mode=0)
[18:40:41] + frame rate: same as source (around 60.000 fps)
[18:40:41] + Crop and Scale (width=1920:height=1080:crop-top=0:crop-bottom=0:crop-left=0:crop-right=0)
[18:40:41] + source: 1920 * 1080, crop (0/0/0/0): 1920 * 1080, scale: 1920 * 1080
[18:40:41] + Output geometry
[18:40:41] + storage dimensions: 1920 x 1080
[18:40:41] + pixel aspect ratio: 1 : 1
[18:40:41] + display dimensions: 1920 x 1080
[18:40:41] + encoder: H.264 (libx264)
[18:40:41] + preset: medium
[18:40:41] + profile: auto
[18:40:41] + level: auto
[18:40:41] + quality: 22.00 (RF)
[18:40:41] + color profile: 1-1-1
[18:40:41] * audio track 1
[18:40:41] + decoder: Unknown (MP3) (2.0 ch) (160 kbps) (track 1, id 0x1)
[18:40:41] + bitrate: 160 kbps, samplerate: 48000 Hz
[18:40:41] + mixdown: Stereo
[18:40:41] + dither: triangular
[18:40:41] + encoder: AAC (libfdk_aac)
[18:40:41] + bitrate: 128 kbps, samplerate: 48000 Hz
[18:40:41] sync: expecting 38071 video frames
[18:40:41] encx264: min-keyint: 60, keyint: 600
[18:40:41] encx264: encoding at constant RF 22.000000
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x264 [info]: profile High, level 4.2, 4:2:0, 8-bit
Encoding: task 1 of 1, 0.00 %[18:40:58] sync: first pts audio 0x1 is 0
Encoding: task 1 of 1, 0.00 %

If I terminate with ctrl-c, it does exist cleanly but notice it's showing decoder errors count for all frames.

[18:41:11] mp3float-decoder done: 321 frames, 0 decoder errors
[18:41:11] h264_qsv-decoder done: 0 frames, 474 decoder errors

@galinart
Copy link
Contributor Author

@sr55 could you please check the binary by link below?
https://drive.google.com/file/d/11inrIrvqS5pMFFXPAv-q3z-DCcqix0UD/view?usp=sharing

@sr55
Copy link
Contributor

sr55 commented Sep 11, 2019

As far as I can tell, no difference with the new binary.

@thx4ever
Copy link

Hi sr55 i'm about to get new Coffee Lake CPU i5 9400, can u share what features your CPU supports
with QSVEncc64 --check-features

Regards

@galinart
Copy link
Contributor Author

@sr55 please check the following binary https://drive.google.com/file/d/1akVlVpwfoJ53JnEz0q4mTKRnlJcR9hkS/view?usp=sharing

Could you please share GPU physical locations from Task Manager? Where does the monitor plug into?

@galinart
Copy link
Contributor Author

@sr55 In case of iGPU only machine, no difference as well?

@galinart
Copy link
Contributor Author

@sr55 I have updated decoder initialization step. Could you please check binary and share log? https://drive.google.com/file/d/1Dt83kqPRJBQQz9OUOn77ehDZNF3tBK9u/view?usp=sharing

@sr55
Copy link
Contributor

sr55 commented Sep 17, 2019

Just re-tested:

  1. I just moved one of my monitors over to the iGPU and Hardware decode works with x264
  2. With both monitors on the Nvidia GPU, hardware decode only works on quicksync.

With your new HandBrakeCLI:

Both scenarios appear to work:

[19:38:20] D3D11: QSV adapter with id 1 has been found
[19:38:20] starting job
[19:38:20] job configuration:
[19:38:20]  * source
[19:38:20]    + bbb_sunflower_1080p_60fps_normal.mp4
[19:38:20]    + title 1, chapter(s) 1 to 1
[19:38:20]    + container: mov,mp4,m4a,3gp,3g2,mj2
[19:38:20]    + data rate: 4486 kbps
[19:38:20]  * destination
[19:38:20]    + test.mp4
[19:38:20]    + container: MPEG-4 (libavformat)
[19:38:20]  * video track
[19:38:20]    + decoder: h264_qsv
[19:38:20]      + bitrate 4001 kbps
[19:38:20]    + filters
[19:38:20]      + Framerate Shaper (mode=0)
[19:38:20]        + frame rate: same as source (around 60.000 fps)
[19:38:20]      + Crop and Scale (width=1920:height=1080:crop-top=0:crop-bottom=0:crop-left=0:crop-right=0)
[19:38:20]        + source: 1920 * 1080, crop (0/0/0/0): 1920 * 1080, scale: 1920 * 1080
[19:38:20]    + Output geometry
[19:38:20]      + storage dimensions: 1920 x 1080
[19:38:20]      + pixel aspect ratio: 1 : 1
[19:38:20]      + display dimensions: 1920 x 1080
[19:38:20]    + encoder: H.264 (libx264)
[19:38:20]      + preset:  medium
[19:38:20]      + profile: auto
[19:38:20]      + level:   auto
[19:38:20]      + quality: 22.00 (RF)
[19:38:20]      + color profile: 1-1-1
[19:38:20]  * audio track 1
[19:38:20]    + decoder: Unknown (MP3) (2.0 ch) (160 kbps) (track 1, id 0x1)
[19:38:20]      + bitrate: 160 kbps, samplerate: 48000 Hz
[19:38:20]    + mixdown: Stereo
[19:38:20]    + dither: triangular
[19:38:20]    + encoder: AAC (libavcodec)
[19:38:20]      + bitrate: 128 kbps, samplerate: 48000 Hz
[19:38:20] sync: expecting 38071 video frames
[19:38:20] encx264: min-keyint: 60, keyint: 600
[19:38:20] encx264: encoding at constant RF 22.000000
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x264 [info]: profile High, level 4.2, 4:2:0, 8-bit
[h264_qsv @ 0000000037dab5c0] Initialized an internal MFX session using hardware accelerated implementation
Encoding: task 1 of 1, 0.00 %[19:38:21] sync: first pts audio 0x1 is 0
[19:38:21] sync: first pts video is 3000
[19:38:21] sync: Chapter 1 at frame 1 time 3000
Encoding: task 1 of 1, 5.01 % (118.93 fps, avg 125.70 fps, ETA 00h04m47s)

@galinart
Copy link
Contributor Author

@sr55 Thanks for the complex hw setup! I have updated pull request. The QSV filter changes will be in separate pull request iteratively.

@sr55 sr55 merged commit 2c23033 into HandBrake:master Sep 22, 2019
@sr55
Copy link
Contributor

sr55 commented Sep 22, 2019

No build issues on other platforms.
Testing it in various configs here seems OK.

Merging Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants