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

Question: Video HW Decoder #580

Closed
proconsule opened this issue Oct 15, 2021 · 9 comments
Closed

Question: Video HW Decoder #580

proconsule opened this issue Oct 15, 2021 · 9 comments

Comments

@proconsule
Copy link

Hi there is any chance to get Video HW decoder?
I know Tegra can decode h264/hevc in hw, any resarch on getting it in libnx?
Thanks

@MRiCEQB
Copy link

MRiCEQB commented Nov 5, 2022

Any update on this?

@Palidino
Copy link

Palidino commented Feb 6, 2023

Any plans for this ever?

@benwa
Copy link

benwa commented Apr 3, 2023

I've started a bounty for this to be implemented.
https://app.bountysource.com/issues/116504826-question-video-hw-decoder

@averne
Copy link
Contributor

averne commented Aug 19, 2023

I've released a FFmpeg fork enabling acceleration for all codecs supported by the hardware. I don't feel this really belongs in libnx, as most of it is not specific to the Switch/Horizon OS.
https://github.com/averne/FFmpeg/tree/tx1

@benwa
Copy link

benwa commented Aug 19, 2023

I agree that this shouldn't be in libnx. @proconsule, can you close this so I can award @averne the bounty?

@proconsule
Copy link
Author

I have to try this out on NXMP replacing the ffmpeg in use.

Thanks for this great result

@averne
Copy link
Contributor

averne commented Aug 19, 2023

I have to try this out on NXMP replacing the ffmpeg in use.

Thanks for this great result

You can contact me on discord @avhe if you run into issues.

Basic integration isn't hard, but for optimal performance you would need a deko3d graphics backend for mpv. In OpenGL, you are unable to directly import frames from the decoder, so the following happens:
decoder output (block linear) -> copied to staging buffer (pitch linear) using VIC -> copied to GPU texture (block linear) using GPU copy engine.

With deko3d, you just need to create a texture with DkImageFlags_UsageVideo over the frame data.

@WinterMute
Copy link
Contributor

I've released a FFmpeg fork enabling acceleration for all codecs supported by the hardware. I don't feel this really belongs in libnx, as most of it is not specific to the Switch/Horizon OS. https://github.com/averne/FFmpeg/tree/tx1

Would be awesome if you got this upstreamed to FFmpeg but also PR'd needed changes to dkP packages repo. I've put a quick test @ https://github.com/devkitPro/pacman-packages/tree/ffmpeg-update but I'm not 100% what configure options we need.

fwiw, that package can be installed using [sudo] [dkp-]pacman -U https://pkg.devkitpro.org/packages/switch-ffmpeg-6.0-1-any.pkg.tar.zst if anyone wants to test.

@averne
Copy link
Contributor

averne commented Aug 20, 2023

Would be awesome if you got this upstreamed to FFmpeg

I contacted the FFmpeg maintainers, not sure it could be upstreamed in its current state as it contains nvidia headers (even though they are under a permissive license). There are also a number of hacks, especially surface alignment, that would need some cleaning up.

I'm not 100% what configure options we need.

At minimum, you need to add --enable-gpl since the hwaccel is gated by this. I used the following flags, but I see the devkitPro package has some others. I'll merge those flags and put together a proper PR.

--cc=aarch64-none-elf-gcc --cxx=aarch64-none-elf-g++ --ar=aarch64-none-elf-ar --nm=aarch64-none-elf-nm --extra-cflags='-isystem /opt/devkitpro/libnx/include' --enable-asm --enable-gpl --enable-tx1 --enable-static --disable-shared --enable-zlib --enable-bzlib --enable-libass --enable-libfreetype --enable-libfribidi --disable-doc --disable-programs --target-os=horizon --enable-cross-compile --cross-prefix=aarch64-none-elf- --arch=aarch64 --cpu=cortex-a57 --enable-neon --enable-pic --disable-autodetect --disable-runtime-cpudetect --disable-debug

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

No branches or pull requests

6 participants