Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@

} // namespace qsv

namespace amf {

/**
* @brief Enumerates supported coder options for AMF encoder.
*/
enum class coder_e : int {
auto_ = 0, ///< Auto coder mode
cabac = 1, ///< CABAC entropy coding
cavlc = 2, ///< CAVLC entropy coding
};

} // namespace amf

/**
* @brief Create an FFmpeg hardware device buffer for D3D11VA input.
*
Expand Down Expand Up @@ -1022,9 +1035,22 @@
{"rc"s, &config::video.amd.amd_rc_h264},
{"usage"s, &config::video.amd.amd_usage_h264},
{"vbaq"s, &config::video.amd.amd_vbaq},
{"coder"s, &config::video.amd.amd_coder},
{"enforce_hrd"s, &config::video.amd.amd_enforce_hrd},
},
{}, // SDR-specific options
{
// SDR-specific options
{"profile"s, [](const config_t &) {
switch (config::video.amd.amd_coder) {
case (int) amf::coder_e::cavlc:

Check warning on line 1045 in src/video.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use "std::to_underlying" to cast enums to their underlying type.

See more on https://sonarcloud.io/project/issues?id=LizardByte_Sunshine&issues=AZ-NPey0485lOTQ5TmFP&open=AZ-NPey0485lOTQ5TmFP&pullRequest=4927
return "constrained_baseline"s;
case (int) amf::coder_e::cabac:

Check warning on line 1047 in src/video.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use "std::to_underlying" to cast enums to their underlying type.

See more on https://sonarcloud.io/project/issues?id=LizardByte_Sunshine&issues=AZ-NPey0485lOTQ5TmFQ&open=AZ-NPey0485lOTQ5TmFQ&pullRequest=4927
return "high"s;
default:
return "main"s;
}
}},
},
Comment on lines +1042 to +1053

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to GPT 5.6,

Baseline profile is never applied. This new profile option is an AMF-private option, but Sunshine already sets AVCodecContext::profile to High for H.264 at line 1994. FFmpeg gives that public profile precedence and only consults the private option when no recognized public profile was supplied, as shown in FFmpeg’s AMF initializer. Consequently, CAVLC is enabled but the stream remains High Profile; the claimed PSP/legacy-decoder fix does not work. The AMF CAVLC path needs to set AVCodecContext::profile to constrained baseline instead.

So, I put up an alternate approach to this. Can you check if #5442 solves your issues? I also added some tests and resolved some existing sonar issues that were highlighted in this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Physically tested PR #5442 on an AMD host PC streaming to real PSP hardware. Setting amd_coder = cavlc initialized in Constrained Baseline mode. PR #5442 works!

{}, // HDR-specific options
{}, // YUV444 SDR-specific options
{}, // YUV444 HDR-specific options
Expand Down
Loading