Skip to content

Fix AMF hwcontext transfer format selection - #8280

Open
Hotactioncop wants to merge 1 commit into
HandBrake:masterfrom
Hotactioncop:amf_dec_fix_transfer_format_selection
Open

Hotactioncop wants to merge 1 commit into
HandBrake:masterfrom
Hotactioncop:amf_dec_fix_transfer_format_selection

Conversation

@Hotactioncop

Copy link
Copy Markdown
Contributor

Description of Change

Add a contrib/ffmpeg patch to fix AMF transfer format selection.

Previously, the AMF backend returned its full list of supported transfer formats.
FFmpeg selected the first entry, NV12, even when downloading a P010 surface.
The AMF transfer handler rejected this mismatch with EINVAL, causing HDR10+ preview generation to fail in HandBrake.

Return only the frames context's software pixel format, matching the AMF approach.
Return ENOSYS if that format is not supported for transfers.

Github Issue

AMF Decode - "error transferring data to system memory" #8265

AI Usage

  • No AI used.
  • AI-assisted: I wrote the changes and used AI for guidance, review, or troubleshooting.
  • AI-generated: AI produced most of the code or content in this pull request, even if I subsequently edited it.

Details:
I identified the root cause through debugging.
AI helped compare existing FFmpeg hardware backends and applied a small change following the existing implementation.

Testing

Confirmed that the fix resolves the reported HDR10+ preview failure in HandBrake with AMF decoding.

  • Windows 10+ (via MinGW)
  • macOS 10.13+
  • Ubuntu Linux

Screenshots / Activity logs (If Relevant)

HandBrake Nightly 20261118123653-28cae12c0-amf_dec_fix_transfer_format_selection (2026111901)
OS: Microsoft Windows NT 10.0.19045.0
CPU: AMD Ryzen 5 5600X 6-Core Processor             
Ram: 32714 MB, 
GPU Information:
  Parsec Virtual Display Adapter - 0.45.0.0
  AMD Radeon RX 9070 XT - 32.0.32029.2010
Screen: 2560x1440
Temp Dir: C:\Users\aiusubov.DESKTOP-QMVCP5N\AppData\Local\Temp\
Install Dir: C:\HandBrake_20.10\win\CS\HandBrakeWPF\bin\Debug\
Data Dir: C:\Users\aiusubov.DESKTOP-QMVCP5N\AppData\Roaming\HandBrake\Nightly

-------------------------------------------
[14:47:35] hb_init: starting libhb thread

 # Starting Scan ...

[14:47:35] OS: Windows 10.0 (19045)
[14:47:35] CPU: AMD Ryzen 5 5600X 6-Core Processor
[14:47:35]  - logical processor count: 12
[14:47:35] Intel Quick Sync Video support: no
[14:47:35] hb_scan: path=C:\HandBrake_20.10\hdr10+test_lake_2021_02_01.mp4, title_index=0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\HandBrake_20.10\hdr10+test_lake_2021_02_01.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.47.100
  Duration: 00:00:59.87, start: 0.000000, bitrate: 69798 kb/s
  Stream #0:0[0x1](und): Video: hevc (Main 10) (hev1 / 0x31766568), yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x2160 [SAR 1:1 DAR 16:9], 70248 kb/s, 60 fps, 60 tbr, 15360 tbn, start 0.400000 (default)
    Metadata:
      handler_name    : VideoHandler
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 5 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[14:47:35] scan: decoding previews for title 1
[14:47:36] scan: audio 0x1: aac, rate=48000Hz, bitrate=5824 Unknown (AAC LC, 2.0 ch, 5 kbps)
[14:47:36] adapter: updating filters
[14:47:36] adapter: converting video pixel format from p010le
[14:47:37] using container PAR 1:1
[14:47:37] scan: 10 previews, 3840x2160, 60.000 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 1:1, color profile: 9-16-9, chroma location: topleft
[14:47:37] scan: supported video decoders: avcodec amfdec
[14:47:37] libhb: scan thread found 1 valid title(s)

 # Scan Finished ...

@bradleysepos bradleysepos mentioned this pull request Nov 20, 2026
2 of 7 tasks
@Hotactioncop
Hotactioncop force-pushed the amf_dec_fix_transfer_format_selection branch from e7341cf to 5cf63fe Compare November 20, 2026 15:44
@Hotactioncop
Hotactioncop marked this pull request as draft November 20, 2026 15:45
@Hotactioncop
Hotactioncop marked this pull request as ready for review November 20, 2026 15:45
@sr55 sr55 added this to the 1.12.0 milestone Nov 20, 2026
@sr55 sr55 added the Bug label Nov 20, 2026

This branch has not been deployed

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

Labels

Development

Successfully merging this pull request may close these issues.

2 participants