diff options
Diffstat (limited to 'hevc-vaapi.diff')
-rw-r--r-- | hevc-vaapi.diff | 81 |
1 files changed, 14 insertions, 67 deletions
diff --git a/hevc-vaapi.diff b/hevc-vaapi.diff index 445dbeeff223..bcb9b23d8e6c 100644 --- a/hevc-vaapi.diff +++ b/hevc-vaapi.diff @@ -2,7 +2,7 @@ diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-vaapi.c b/plugins/obs-ffmpeg/obs-ffmp index 445c5a792..a7a96d819 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-vaapi.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-vaapi.c -@@ -69,10 +69,35 @@ struct vaapi_encoder { +@@ -69,10 +69,35 @@ bool initialized; }; @@ -41,7 +41,7 @@ index 445c5a792..a7a96d819 100644 } static inline bool valid_format(enum video_format format) -@@ -170,15 +195,15 @@ typedef struct { +@@ -170,15 +195,15 @@ bool maxrate; } rc_mode_t; @@ -64,7 +64,7 @@ index 445c5a792..a7a96d819 100644 const rc_mode_t *rc_mode = RC_MODES; while (!!rc_mode && strcmp(rc_mode->name, name) != 0) -@@ -278,6 +303,7 @@ static bool vaapi_update(void *data, obs_data_t *settings) +@@ -278,6 +303,7 @@ info("settings:\n" "\tdevice: %s\n" @@ -72,7 +72,7 @@ index 445c5a792..a7a96d819 100644 "\trate_control: %s\n" "\tprofile: %d\n" "\tlevel: %d\n" -@@ -288,9 +314,9 @@ static bool vaapi_update(void *data, obs_data_t *settings) +@@ -288,9 +314,9 @@ "\twidth: %d\n" "\theight: %d\n" "\tb-frames: %d\n", @@ -85,7 +85,7 @@ index 445c5a792..a7a96d819 100644 return vaapi_init_codec(enc, device); } -@@ -344,9 +370,12 @@ static void *vaapi_create(obs_data_t *settings, obs_encoder_t *encoder) +@@ -344,9 +370,12 @@ if (vaapi_codec == AV_CODEC_ID_H264) { enc->vaapi = avcodec_find_encoder_by_name("h264_vaapi"); @@ -100,7 +100,7 @@ index 445c5a792..a7a96d819 100644 blog(LOG_INFO, "---------------------------------"); -@@ -482,7 +511,10 @@ static bool vaapi_encode(void *data, struct encoder_frame *frame, +@@ -482,7 +511,10 @@ packet->data = enc->buffer.array; packet->size = enc->buffer.num; packet->type = OBS_ENCODER_VIDEO; @@ -112,7 +112,7 @@ index 445c5a792..a7a96d819 100644 *received_packet = true; } else { *received_packet = false; -@@ -503,19 +535,20 @@ static void set_visible(obs_properties_t *ppts, const char *name, bool visible) +@@ -503,19 +535,20 @@ obs_property_set_visible(p, visible); } @@ -140,7 +140,7 @@ index 445c5a792..a7a96d819 100644 obs_data_set_default_int(settings, "qp", 20); obs_data_set_default_int(settings, "maxrate", 0); } -@@ -538,9 +571,13 @@ static bool rate_control_modified(obs_properties_t *ppts, obs_property_t *p, +@@ -538,9 +571,13 @@ return true; } @@ -155,7 +155,7 @@ index 445c5a792..a7a96d819 100644 obs_properties_t *props = obs_properties_create(); obs_property_t *list; -@@ -561,43 +598,46 @@ static obs_properties_t *vaapi_properties(void *unused) +@@ -561,40 +598,36 @@ } } @@ -193,9 +193,6 @@ index 445c5a792..a7a96d819 100644 - obs_module_text("RateControl"), - OBS_COMBO_TYPE_LIST, - OBS_COMBO_FORMAT_STRING); -- obs_property_list_add_string(list, "CBR (default)", "CBR"); -- obs_property_list_add_string(list, "CQP", "CQP"); -- obs_property_list_add_string(list, "VBR", "VBR"); + if (codec->id == AV_CODEC_ID_H264) { + list = obs_properties_add_list(props, "profile", + obs_module_text("Profile"), @@ -226,20 +223,10 @@ index 445c5a792..a7a96d819 100644 + obs_module_text("RateControl"), + OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_STRING); -+ -+ for (const rc_mode_t *rc_mode = RC_MODES; rc_mode; rc_mode++) { -+ /* Identify the default choice */ -+ char *def = strcmp(rc_mode->name, codec->rate_control) == 0 -+ ? " (default)" -+ : ""; -+ -+ dstr_printf(&name, "%s%s", rc_mode->name, def); -+ obs_property_list_add_string(list, name.array, rc_mode->name); -+ } - - obs_property_set_modified_callback(list, rate_control_modified); - -@@ -616,6 +656,7 @@ static obs_properties_t *vaapi_properties(void *unused) + obs_property_list_add_string(list, "CBR (default)", "CBR"); + obs_property_list_add_string(list, "CQP", "CQP"); + obs_property_list_add_string(list, "VBR", "VBR"); +@@ -616,6 +649,7 @@ obs_module_text("KeyframeIntervalSec"), 0, 20, 1); @@ -247,7 +234,7 @@ index 445c5a792..a7a96d819 100644 return props; } -@@ -645,11 +686,26 @@ struct obs_encoder_info vaapi_encoder_info = { +@@ -645,11 +679,26 @@ .create = vaapi_create, .destroy = vaapi_destroy, .encode = vaapi_encode, @@ -276,43 +263,3 @@ index 445c5a792..a7a96d819 100644 }; #endif -diff --git a/plugins/obs-ffmpeg/obs-ffmpeg.c b/plugins/obs-ffmpeg/obs-ffmpeg.c -index b7a17095d..9d8397e68 100644 ---- a/plugins/obs-ffmpeg/obs-ffmpeg.c -+++ b/plugins/obs-ffmpeg/obs-ffmpeg.c -@@ -35,6 +35,7 @@ extern struct obs_encoder_info nvenc_encoder_info; - - #ifdef LIBAVUTIL_VAAPI_AVAILABLE - extern struct obs_encoder_info vaapi_encoder_info; -+extern struct obs_encoder_info vaapi_hevc_encoder_info; - #endif - - #ifndef __APPLE__ -@@ -210,9 +211,9 @@ finish: - #endif - - #ifdef LIBAVUTIL_VAAPI_AVAILABLE --static bool vaapi_supported(void) -+static bool vaapi_supported(const char *codec_name) - { -- AVCodec *vaenc = avcodec_find_encoder_by_name("h264_vaapi"); -+ AVCodec *vaenc = avcodec_find_encoder_by_name(codec_name); - return !!vaenc; - } - #endif -@@ -253,10 +254,14 @@ bool obs_module_load(void) - obs_register_encoder(&nvenc_encoder_info); - } - #if !defined(_WIN32) && defined(LIBAVUTIL_VAAPI_AVAILABLE) -- if (vaapi_supported()) { -+ if (vaapi_supported("h264_vaapi")) { - blog(LOG_INFO, "FFMPEG VAAPI supported"); - obs_register_encoder(&vaapi_encoder_info); - } -+ if (vaapi_supported("hevc_vaapi")) { -+ blog(LOG_INFO, "FFMPEG HEVC VAAPI supported"); -+ obs_register_encoder(&vaapi_hevc_encoder_info); -+ } - #endif - #endif - |