obs-ffmpeg: Fix B-frame offset calculation in AMF

AVC and AV1 encoders in AMF that support B-frames were incrementing
`dts_offset` even when B-frames were set to 0. For AVC, adjust the
`dts_offset` only when B-frames are supported and are greater than 0,
and clamp to maximum supported.

For AV1, remove the dts_offset code completely because it is being
ignored anyway. AV1 handles B-frames and offsets differently; refer
to [1] for details.

[1]: https://github.com/obsproject/obs-studio/pull/10996
This commit is contained in:
Alex Luccisano
2026-08-06 11:38:49 -04:00
committed by Ryan Foster
parent 6d0083dd61
commit 0969e43a83
+2 -14
View File
@@ -1720,8 +1720,8 @@ static void amf_avc_create_internal(amf_base *enc, obs_data_t *settings)
amf_int64 b_max = 0;
if (get_avc_property(enc, B_PIC_PATTERN, &b_frames) &&
get_avc_property(enc, MAX_CONSECUTIVE_BPICTURES, &b_max)) {
enc->dts_offset = b_frames + 1;
get_avc_property(enc, MAX_CONSECUTIVE_BPICTURES, &b_max) && b_frames > 0) {
enc->dts_offset = std::min(b_frames, b_max) + 1;
} else {
enc->dts_offset = 0;
}
@@ -2543,18 +2543,6 @@ static void amf_av1_create_internal(amf_base *enc, obs_data_t *settings)
if (res == AMF_OK && p.type == AMF_VARIANT_INTERFACE) {
enc->header = AMFBufferPtr(p.pInterface);
}
if (enc->bframes_supported) {
amf_int64 b_frames = 0;
amf_int64 b_max = 0;
if (get_av1_property(enc, B_PIC_PATTERN, &b_frames) &&
get_av1_property(enc, MAX_CONSECUTIVE_BPICTURES, &b_max)) {
enc->dts_offset = b_frames + 1;
} else {
enc->dts_offset = 0;
}
}
}
static void *amf_av1_create_texencode(obs_data_t *settings, obs_encoder_t *encoder)