From 62b2d60580a3e708b6dbbc7bbd2cb8b2ebde0a9d Mon Sep 17 00:00:00 2001 From: jp9000 Date: Fri, 17 Apr 2015 14:37:33 -0700 Subject: [PATCH] obs-x264: Call video info func to get format Call the video information function to determine the video format that needs to be used to prevent having to use the same code in the update function. --- plugins/obs-x264/obs-x264.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/plugins/obs-x264/obs-x264.c b/plugins/obs-x264/obs-x264.c index aaab60089..02333bd28 100644 --- a/plugins/obs-x264/obs-x264.c +++ b/plugins/obs-x264/obs-x264.c @@ -346,11 +346,20 @@ static inline int get_x264_cs_val(enum video_colorspace cs, return 0; } +static void obs_x264_video_info(void *data, struct video_scale_info *info); + static void update_params(struct obs_x264 *obsx264, obs_data_t *settings, char **params) { video_t *video = obs_encoder_video(obsx264->encoder); const struct video_output_info *voi = video_output_get_info(video); + struct video_scale_info info; + + info.format = voi->format; + info.colorspace = voi->colorspace; + info.range = voi->range; + + obs_x264_video_info(obsx264, &info); int bitrate = (int)obs_data_get_int(settings, "bitrate"); int buffer_size = (int)obs_data_get_int(settings, "buffer_size"); @@ -381,13 +390,13 @@ static void update_params(struct obs_x264 *obsx264, obs_data_t *settings, obsx264->params.i_log_level = X264_LOG_WARNING; obsx264->params.vui.i_transfer = - get_x264_cs_val(voi->colorspace, x264_transfer_names); + get_x264_cs_val(info.colorspace, x264_transfer_names); obsx264->params.vui.i_colmatrix = - get_x264_cs_val(voi->colorspace, x264_colmatrix_names); + get_x264_cs_val(info.colorspace, x264_colmatrix_names); obsx264->params.vui.i_colorprim = - get_x264_cs_val(voi->colorspace, x264_colorprim_names); + get_x264_cs_val(info.colorspace, x264_colorprim_names); obsx264->params.vui.b_fullrange = - voi->range == VIDEO_RANGE_FULL; + info.range == VIDEO_RANGE_FULL; /* use the new filler method for CBR to allow real-time adjusting of * the bitrate */ @@ -405,11 +414,11 @@ static void update_params(struct obs_x264 *obsx264, obs_data_t *settings, obsx264->params.rc.f_rf_constant = (float)crf; } - if (voi->format == VIDEO_FORMAT_NV12) + if (info.format == VIDEO_FORMAT_NV12) obsx264->params.i_csp = X264_CSP_NV12; - else if (voi->format == VIDEO_FORMAT_I420) + else if (info.format == VIDEO_FORMAT_I420) obsx264->params.i_csp = X264_CSP_I420; - else if (voi->format == VIDEO_FORMAT_I444) + else if (info.format == VIDEO_FORMAT_I444) obsx264->params.i_csp = X264_CSP_I444; else obsx264->params.i_csp = X264_CSP_NV12;