Skip to content

AMF decoder initilizes context on resolution or format changes - #8241

Merged
galad87 merged 1 commit into
HandBrake:masterfrom
Hotactioncop:amf_decoder_reinitilize_context_on_resolution_or_format_changes
Nov 9, 2026
Merged

galad87 merged 1 commit into
HandBrake:masterfrom
Hotactioncop:amf_decoder_reinitilize_context_on_resolution_or_format_changes

Conversation

@Hotactioncop

Copy link
Copy Markdown
Contributor

Before Posting:

  • Create an issue describing the change. If an issue already exists, please use this.
  • Discuss the issue with the HandBrake team to ensure that the idea has been accepted. (An open enhancement request does not equal acceptance). This will avoid any time wasted on features that are outside the project scope!

Description of Change:
Related discussion: #8223

Description of Change:
This patch improves the handling of the hardware frames context in the FFmpeg AMF decoder.
Previously, the hardware frames context could be initialized with insufficient dimensions or an incompatible pixel format, potentially causing issues during hardware decoding.

The patch introduces the following changes:

  • Initialize decoder dimensions before converting the first AMF surface to an AVFrame.
  • Check the hardware frames context dimensions and pixel format when processing decoded frames.
  • Reinitialize the hardware frames context if the required dimensions exceed the current allocation or the pixel format changes.
  • Reuse the existing context when its allocation is sufficient.

This addresses the issue discussed in #8223 and improves the robustness of AMF hardware decoding beyond the specific HandBrake use case.

Tested on:

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

Screenshots (If relevant):

Log file output (If relevant):

@galad87

galad87 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Thanks!

A question, is the hwframes context created in decavcodec.c:1606 needed? All the other hardware decoders don't need it, and create the hwframes context internally. The AMF decoder does too when used in the scan phase.

@sr55 sr55 added the Bug label Nov 5, 2026
@sr55 sr55 added this to the 1.12.0 milestone Nov 5, 2026
@galad87
galad87 merged commit 539fe76 into HandBrake:master Nov 9, 2026
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.

3 participants