From b122785bd1be33f951c935f1c8830a65043e6038 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sun, 17 Oct 2021 10:28:56 +0200 Subject: [PATCH] encoder/ffmpeg/nvenc: Fix migration code causing issues --- source/encoders/handlers/nvenc_shared.cpp | 39 +++++++++++++---------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/source/encoders/handlers/nvenc_shared.cpp b/source/encoders/handlers/nvenc_shared.cpp index 5c88953d..5f0a30ea 100644 --- a/source/encoders/handlers/nvenc_shared.cpp +++ b/source/encoders/handlers/nvenc_shared.cpp @@ -756,23 +756,28 @@ void nvenc::log_options(obs_data_t*, const AVCodec* codec, AVCodecContext* conte void streamfx::encoder::ffmpeg::handler::nvenc::migrate(obs_data_t* settings, uint64_t version, const AVCodec* codec, AVCodecContext* context) { - switch (static_cast(obs_data_get_int(settings, S_VERSION)) & STREAMFX_MASK_UPDATE) { - default: - case STREAMFX_MAKE_VERSION(0, 8, 0, 0): + // Only test for A.B.C in A.B.C.D + version = version & STREAMFX_MASK_UPDATE; - obs_data_set_int(settings, ST_KEY_RATECONTROL_LIMITS_BITRATE_TARGET, - obs_data_get_int(settings, "RateControl.Bitrate.Target")); - obs_data_set_int(settings, ST_KEY_RATECONTROL_LIMITS_BITRATE_MAXIMUM, - obs_data_get_int(settings, "RateControl.Bitrate.Maximum")); - obs_data_set_int(settings, ST_KEY_RATECONTROL_LIMITS_BUFFERSIZE, - obs_data_get_int(settings, "RateControl.BufferSize")); - obs_data_set_double(settings, ST_KEY_RATECONTROL_LIMITS_QUALITY, - obs_data_get_double(settings, "RateControl.Quality.Target")); - obs_data_set_int(settings, ST_KEY_RATECONTROL_QP_MINIMUM, - obs_data_get_int(settings, "RateControl.Quality.Minimum")); - obs_data_set_int(settings, ST_KEY_RATECONTROL_QP_MAXIMUM, - obs_data_get_int(settings, "RateControl.Quality.Maximum")); - - break; +#define COPY_UNSET(TYPE, OLDNAME, NEWNAME) \ + if (obs_data_has_user_value(settings, OLDNAME)) { \ + obs_data_set_##TYPE(settings, NEWNAME, obs_data_get_##TYPE(settings, OLDNAME)); \ + obs_data_unset_user_value(settings, OLDNAME); \ } + + if (version <= STREAMFX_MAKE_VERSION(0, 8, 0, 0)) { + COPY_UNSET(int, "RateControl.Bitrate.Target", ST_KEY_RATECONTROL_LIMITS_BITRATE_TARGET); + COPY_UNSET(int, "RateControl.Bitrate.Maximum", ST_KEY_RATECONTROL_LIMITS_BITRATE_TARGET); + COPY_UNSET(int, "RateControl.BufferSize", ST_KEY_RATECONTROL_LIMITS_BUFFERSIZE); + COPY_UNSET(int, "RateControl.Quality.Minimum", ST_KEY_RATECONTROL_QP_MINIMUM); + COPY_UNSET(int, "RateControl.Quality.Maximum", ST_KEY_RATECONTROL_QP_MAXIMUM); + COPY_UNSET(double, "RateControl.Quality.Target", ST_KEY_RATECONTROL_LIMITS_QUALITY); + } + + if (version <= STREAMFX_MAKE_VERSION(0, 11, 0, 0)) { + obs_data_unset_user_value(settings, "Other.AccessUnitDelimiter"); + obs_data_unset_user_value(settings, "Other.DecodedPictureBufferSize"); + } + +#undef COPY_UNSET }