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

AMD hardware accelerated h264 encoding: VCE Video Codec Engine #511

Open
totaam opened this issue Feb 4, 2014 · 8 comments
Open

AMD hardware accelerated h264 encoding: VCE Video Codec Engine #511

totaam opened this issue Feb 4, 2014 · 8 comments
Labels
Milestone

Comments

@totaam
Copy link
Collaborator

totaam commented Feb 4, 2014

AMD Open-Sources VCE Video Encode Engine Code and AMD Publishes New Code For Open-Source VCE Video Encode

initial VCE support based on OpenMAX

@totaam
Copy link
Collaborator Author

totaam commented Jul 29, 2017

2017-07-29 20:06:43: nathan-renniewaldock commented


What's the status on this? Is AMD VCE still not supported?

@totaam
Copy link
Collaborator Author

totaam commented Jul 29, 2017

No progress, as I don't have the hardware. (or the time)

@totaam
Copy link
Collaborator Author

totaam commented Jul 5, 2020

meh, #451 will do for now.

@totaam totaam added this to the future milestone Jan 23, 2021
@totaam
Copy link
Collaborator Author

totaam commented Mar 26, 2023

The easier way of supporting this is via #3706

@totaam totaam closed this as not planned Won't fix, can't repro, duplicate, stale Mar 26, 2023
@totaam
Copy link
Collaborator Author

totaam commented Nov 18, 2024

That said, on MS Windows (ie: #4418), it may be easier to implement native bindings.
Some links:

Apparently, my new AMD 5700G is a "Cezanne" part, which means it supports VCN 2.2

@totaam totaam reopened this Dec 2, 2024
@totaam
Copy link
Collaborator Author

totaam commented Jan 15, 2025

I've tried again on Fedora because that's a much more comfortable environment for me, so here are some notes:

  • AMF is part of the proprietary components
  • vainfo shows:
    Trying display: wayland
    libva info: VA-API version 1.22.0
    libva info: Trying to open /usr/lib64/dri-nonfree/radeonsi_drv_video.so
    libva info: Trying to open /usr/lib64/dri-freeworld/radeonsi_drv_video.so
    libva info: Trying to open /usr/lib64/dri/radeonsi_drv_video.so
    libva info: Found init function __vaDriverInit_1_22
    libva info: va_openDriver() returns 0
    vainfo: VA-API version: 1.22 (libva 2.22.0)
    vainfo: Driver version: Mesa Gallium driver 24.3.2 for AMD Radeon Graphics (radeonsi, renoir, LLVM 19.1.5, DRM 3.59, 6.12.7-200.fc41.x86_64)
    vainfo: Supported profile and entrypoints
          VAProfileMPEG2Simple            :	VAEntrypointVLD
          VAProfileMPEG2Main              :	VAEntrypointVLD
          VAProfileJPEGBaseline           :	VAEntrypointVLD
          VAProfileVP9Profile0            :	VAEntrypointVLD
          VAProfileVP9Profile2            :	VAEntrypointVLD
          VAProfileNone                   :	VAEntrypointVideoProc
    
    so the H264 encoder is missing via libva..
  • AMDGPU Driver Installation on Linux
  • AMF probably is not used much on Linux, because the repository contains outdated paths
  • the fedora repos have AMF-devel-1.4.35-1.fc41.noarch and AMF-samples-1.4.35-1.fc41.noarch but they're a bit broken and require paths to be mangled before we can build the samples
  • amdgpu-install can be installed from the radeon RHEL repos: https://repo.radeon.com/amdgpu-install/latest/el/
    just choose the latest RHEL9 release and then edit the repo files to hardcode the RHEL version (at time of writing I used 9.6) since Fedora is at 41, but the proprietary repo is missing, and amdgpu-install -y --usecase=amf wants to install amf-amdgpu-pro which does not exist.. Similar instructions can be found here: Install AMDGPU HiP, OpenCL on Fedora 40
  • https://github.com/CosmicFusion/fedora-amdgpu-pro says AMD proprietary AMF is virtually useless on AMD hardware ... it's now actually universally useless and The only requirement to use the AMF encoder is that it requires the PRO driver to be used

That said, the docs seem pretty good:
Advanced Media Framework – Practical Guide for Video CODEC Encoder App Developers
GPU and APU HW Features and Support: All codecs are 4:2:0 Ouch!

My Ryzen 5700G is listed as : Ryzen 5xxx, Cezanne, VCN, 2.0, 1 VCN - this can support AVC and HEVC at 4K, but not AV1.

totaam added a commit that referenced this issue Jan 17, 2025
totaam added a commit that referenced this issue Jan 17, 2025
this is useful on MS Windows, where things are unlikely to be installed in a regular include dir
totaam added a commit that referenced this issue Jan 17, 2025
totaam added a commit that referenced this issue Jan 18, 2025
totaam added a commit that referenced this issue Jan 19, 2025
totaam added a commit that referenced this issue Jan 21, 2025
totaam added a commit that referenced this issue Jan 21, 2025
totaam added a commit that referenced this issue Jan 21, 2025
totaam added a commit that referenced this issue Jan 21, 2025
This was referenced Jan 22, 2025
totaam added a commit that referenced this issue Jan 22, 2025
I have tried hard to use the CPU buffer directly as it is,
but can't seem to be able to map it properly so that CopyResource will accept it
@totaam
Copy link
Collaborator Author

totaam commented Jan 22, 2025

Mostly working, just not as efficiently as I would like:

  • extra pixel copy to CPU buffer - I can't figure out how to avoid it, maybe CreateTexture2D requires specific values to interoperate with AMF? "staging usage" perhaps?
  • busy wait for completion - not sure what else we can do since we want blocking behaviour

Still TODO:

  • handle more pixel formats
  • avoid scary warnings when probing for encodings that aren't supported by the GPU
  • do enable those that work after probing, which may require specific pixel formats to enable
  • AMF Display Capture #4479 and AMD Video Decoding #4480
  • port to Linux + OpenGL buffers - test on AlmaLinux 9, should work: AMD sponsors AlmaLinux
  • unroll [do]_compress_image
  • packaging updates
  • enable it on the MS Windows build machine

@totaam
Copy link
Collaborator Author

totaam commented Jan 23, 2025

For MS Windows builds:

cat > /mingw64/lib/pkgconfig/amf.pc << EOF
amf_prefix=E:/AMF-1.4.35/amf/public

Name: amf
Description: AMF codec implementation
Version: 1.0
Requires:
Conflicts:
# Libs: -L${libdir} -lamf
Cflags: -I${amf_prefix}/include/
EOF

totaam added a commit that referenced this issue Feb 22, 2025
totaam added a commit that referenced this issue Feb 22, 2025
not the 'colorspace' - this is all a bit confusing really: conflating different things into a single string used for different purposes..
totaam added a commit that referenced this issue Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant