Skip to content

AMD Intra Refresh (GDR) for HEVC not working (Xbox user) #256

Description

@Eftimin70

Bug Symptoms

In the latest versions of Vibeshine/Vibepollo AMD Intra Refresh (GDR) for HEVC does not work, even though the log reads otherwise. It looks like die AMF encoder is not configured correctly for that purpose and the infamous artefacts in still/slow moving scenes still occur.

As a suggestion of how to fix it I made a prove of concept. I took the most recent Vibeshine (1.18.3) as the basis and with the help of Google I came up with 2 inserts for amf_d3d11.cpp. My prototype now works perfectly for me, 4k HDR 60fps, real AMF GDR intra refresh is at work and no additional stutters have been introduced. The dreaded Xbox artefacts in slow moving scenes are gone.

In the following are the changes I made, but keep in mind that this version is not polished in any way and has intra refresh hard coded and not as an option:

First part:

  if (config.pa_initial_qp_after_scene_change &&
      !set_verified_int64(
        AMF_PA_INITIAL_QP_AFTER_SCENE_CHANGE,
        *config.pa_initial_qp_after_scene_change,
        "PA initial scene-change QP")) return false;
  if (config.pa_activity_type && !set_verified_int64(AMF_PA_ACTIVITY_TYPE, *config.pa_activity_type, "PA activity type")) return false;
}

//BEGIN INSERT1
BOOST_LOG(info) << "AMF: Force encoder into HEVC Intra-Refresh (GDR) Mode (gop_size = 120 und ctu_size = 64)";

encoder->SetProperty(AMF_VIDEO_ENCODER_IDR_PERIOD, 0);

int64_t gop_size = 120; 
encoder->SetProperty(AMF_VIDEO_ENCODER_HEVC_GOP_SIZE, gop_size);

int64_t ctu_size = 64;
int64_t ctu_height = (encode_height + (ctu_size - 1)) / ctu_size;

int64_t ctu_rows_per_frame = (ctu_height + gop_size - 1) / gop_size;
if (ctu_rows_per_frame < 1) ctu_rows_per_frame = 1; // Mindestens eine Zeile pro Frame

encoder->SetProperty(AMF_VIDEO_ENCODER_HEVC_INTRA_REFRESH_NUM_CTBS_PER_SLOT, ctu_rows_per_frame);
// END INSERT1

// NOTE: LOWLATENCY_MODE is intentionally NOT forced here.
//
// Previously this block hard-coded AMF_VIDEO_ENCODER_(HEVC_)LOWLATENCY_MODE = true

Second part:

    if (effective_ltr_slots_snapshot > 1) {
      next_ltr_slot_to_commit = current_ltr_slot + 1;
      if (next_ltr_slot_to_commit >= effective_ltr_slots_snapshot) {
        next_ltr_slot_to_commit = 1;
      }
    }
  }
}

//BEGIN INSERT2
if (force_idr) {
  surface->SetProperty(AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_NONE);
  surface->SetProperty(AMF_VIDEO_ENCODER_HEVC_INSERT_HEADER, true);
} else {
  surface->SetProperty(AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_NONE);
}
// =========================================================================
//END INSERT2


auto disable_rfi_after_property_failure = [&](const char *property_label, AMF_RESULT property_result) {
  BOOST_LOG(warning) << "AMF: failed to apply " << property_label << " (error=" << property_result

Expected Behavior

Working Intra Refresh for AMD HEVC

Windows Version

22H2

Package

Windows - exe installer

GPU Type

AMD

GPU Model

RX 9070

GPU Driver Version

32.0.31035.1003

Capture Method

None

Apps

Logs (Optional but Recommended)

No response

Screenshot (Optional)


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions