New upstream version 26.0.0+dfsg1
This commit is contained in:
parent
8e020cdacb
commit
240080891f
837 changed files with 41275 additions and 9196 deletions
|
|
@ -4,6 +4,20 @@ find_package(Libx264 REQUIRED)
|
|||
include_directories(${LIBX264_INCLUDE_DIRS})
|
||||
add_definitions(${LIBX264_DEFINITIONS})
|
||||
|
||||
set(obs-x264-util_HEADERS
|
||||
obs-x264-options.h)
|
||||
|
||||
set(obs-x264-util_SOURCES
|
||||
obs-x264-options.c)
|
||||
|
||||
add_library(obs-x264-util STATIC
|
||||
${obs-x264-util_HEADERS}
|
||||
${obs-x264-util_SOURCES})
|
||||
target_link_libraries(obs-x264-util PRIVATE libobs)
|
||||
set_target_properties(obs-x264-util PROPERTIES
|
||||
FOLDER "plugins"
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
set(obs-x264_SOURCES
|
||||
obs-x264.c
|
||||
obs-x264-plugin-main.c)
|
||||
|
|
@ -16,9 +30,17 @@ if(WIN32)
|
|||
endif()
|
||||
|
||||
add_library(obs-x264 MODULE
|
||||
${obs-x264_HEADERS}
|
||||
${obs-x264_SOURCES})
|
||||
target_link_libraries(obs-x264
|
||||
libobs
|
||||
obs-x264-util
|
||||
${LIBX264_LIBRARIES})
|
||||
set_target_properties(obs-x264 PROPERTIES FOLDER "plugins")
|
||||
|
||||
install_obs_plugin_with_data(obs-x264 data)
|
||||
|
||||
add_executable(obs-x264-test obs-x264-test.c)
|
||||
set_target_properties(obs-x264-test PROPERTIES FOLDER "plugins")
|
||||
target_link_libraries(obs-x264-test PRIVATE libobs obs-x264-util)
|
||||
add_test(NAME obs-x264-test COMMAND obs-x264-test)
|
||||
|
|
|
|||
2
plugins/obs-x264/data/locale/az-AZ.ini
Normal file
2
plugins/obs-x264/data/locale/az-AZ.ini
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
None="(Heç biri)"
|
||||
|
||||
6
plugins/obs-x264/data/locale/ba-RU.ini
Normal file
6
plugins/obs-x264/data/locale/ba-RU.ini
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
Bitrate="Битрейт"
|
||||
BufferSize="Буфер ҙурлығы"
|
||||
CRF="CRF"
|
||||
Tune="Көйләү"
|
||||
None="(Юҡ)"
|
||||
|
||||
|
|
@ -4,7 +4,7 @@ BufferSize="Puffergröße"
|
|||
RateControl="Qualitätsregulierungsmethode"
|
||||
CRF="CRF"
|
||||
KeyframeIntervalSec="Keyframeintervall in Sek. (0 = automatisch)"
|
||||
CPUPreset="Prozessorauslastungsvoreinstellung (höher = weniger CPU‐Auslastung)"
|
||||
CPUPreset="CPU‐Auslastungsvoreinstellung (höher = niedrigere CPU‐Auslastung)"
|
||||
Profile="Profil"
|
||||
Tune="Tune"
|
||||
None="(Nichts)"
|
||||
|
|
|
|||
13
plugins/obs-x264/data/locale/en-GB.ini
Normal file
13
plugins/obs-x264/data/locale/en-GB.ini
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
Bitrate="Bitrate"
|
||||
CustomBufsize="Use Custom Buffer Size"
|
||||
BufferSize="Buffer Size"
|
||||
RateControl="Rate Control"
|
||||
CRF="CRF"
|
||||
KeyframeIntervalSec="Keyframe Interval (seconds, 0=auto)"
|
||||
CPUPreset="CPU Usage Preset (higher = less CPU)"
|
||||
Profile="Profile"
|
||||
Tune="Tune"
|
||||
None="(None)"
|
||||
EncoderOptions="x264 Options (separated by space)"
|
||||
VFR="Variable Framerate (VFR)"
|
||||
|
||||
13
plugins/obs-x264/data/locale/id-ID.ini
Normal file
13
plugins/obs-x264/data/locale/id-ID.ini
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
Bitrate="Bitrate"
|
||||
CustomBufsize="Gunakan Ukuran Buffer Kustom"
|
||||
BufferSize="Ukuran Buffer"
|
||||
RateControl="Kontrol Rate"
|
||||
CRF="CRF"
|
||||
KeyframeIntervalSec="Interval Keyframe (detik, 0=otomatis)"
|
||||
CPUPreset="Preset Pemakaian CPU (lebih tinggi = lebih sedikit CPU)"
|
||||
Profile="Profil"
|
||||
Tune="Tune"
|
||||
None="(Tidak ada)"
|
||||
EncoderOptions="Opsi x264 (dipisah oleh spasi)"
|
||||
VFR="Framerate Variabel (VFR)"
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
Bitrate="Rată de biți"
|
||||
CustomBufsize="Folosește dimensiune personalizată pentru zona tampon"
|
||||
CustomBufsize="Folosește dimensiune personalizată pentru buffer"
|
||||
BufferSize="Dimensiune pentru buffer"
|
||||
RateControl="Controlul ratei"
|
||||
CRF="CRF"
|
||||
|
|
|
|||
6
plugins/obs-x264/data/locale/ta-IN.ini
Normal file
6
plugins/obs-x264/data/locale/ta-IN.ini
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
Bitrate="பிட்விகிதம்"
|
||||
CRF="CRF"
|
||||
Profile="சுயவிவரம்"
|
||||
None="(எதுவுமில்லை)"
|
||||
EncoderOptions="x264 விருப்பங்கள் (இடைவெளி விட்டு பிரிக்கப்பட்டவை)"
|
||||
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
Bitrate="บิตเรท"
|
||||
BufferSize="ขนาดของบัฟเฟอร์"
|
||||
Profile="โปรไฟล์"
|
||||
EncoderOptions="ตัวเลือก x264 (แบ่งโดยเว้นวรรค)"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
Bitrate="Бітрейт"
|
||||
CustomBufsize="Розмір буфера за користувачем"
|
||||
CustomBufsize="Використовувати настроюваний розмір буфера"
|
||||
BufferSize="Розмір буфера"
|
||||
RateControl="Керування потоком"
|
||||
RateControl="Керування бітрейтом"
|
||||
CRF="CRF"
|
||||
KeyframeIntervalSec="Інтервал ключових кадрів (секунд, 0 = авто)"
|
||||
CPUPreset="Профіль використання ЦП (вище = менше ЦП)"
|
||||
Profile="Профіль"
|
||||
Tune="Оптимізація"
|
||||
Tune="Настроювання"
|
||||
None="(Немає)"
|
||||
EncoderOptions="Параметри x264 (відокремлені пробілом)"
|
||||
VFR="Змінна частота кадрів (VFR)"
|
||||
|
|
|
|||
72
plugins/obs-x264/obs-x264-options.c
Normal file
72
plugins/obs-x264/obs-x264-options.c
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <util/bmem.h>
|
||||
#include <util/dstr.h>
|
||||
#include "obs-x264-options.h"
|
||||
|
||||
static bool getparam(const char *param, char **name, const char **value)
|
||||
{
|
||||
const char *assign;
|
||||
|
||||
if (!param || !*param || (*param == '='))
|
||||
return false;
|
||||
|
||||
assign = strchr(param, '=');
|
||||
if (!assign || !*assign || !*(assign + 1))
|
||||
return false;
|
||||
|
||||
*name = bstrdup_n(param, assign - param);
|
||||
*value = assign + 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
struct obs_x264_options obs_x264_parse_options(const char *options_string)
|
||||
{
|
||||
char **input_words = strlist_split(options_string, ' ', false);
|
||||
if (!input_words) {
|
||||
return (struct obs_x264_options){
|
||||
.count = 0,
|
||||
.options = NULL,
|
||||
.ignored_word_count = 0,
|
||||
.ignored_words = NULL,
|
||||
.input_words = NULL,
|
||||
};
|
||||
}
|
||||
size_t input_option_count = 0;
|
||||
for (char **input_word = input_words; *input_word; ++input_word)
|
||||
input_option_count += 1;
|
||||
char **ignored_words =
|
||||
bmalloc(input_option_count * sizeof(*ignored_words));
|
||||
char **ignored_word = ignored_words;
|
||||
struct obs_x264_option *out_options =
|
||||
bmalloc(input_option_count * sizeof(*out_options));
|
||||
struct obs_x264_option *out_option = out_options;
|
||||
for (char **input_word = input_words; *input_word; ++input_word) {
|
||||
if (getparam(*input_word, &out_option->name,
|
||||
(const char **)&out_option->value)) {
|
||||
++out_option;
|
||||
} else {
|
||||
*ignored_word = *input_word;
|
||||
++ignored_word;
|
||||
}
|
||||
}
|
||||
return (struct obs_x264_options){
|
||||
.count = out_option - out_options,
|
||||
.options = out_options,
|
||||
.ignored_word_count = ignored_word - ignored_words,
|
||||
.ignored_words = ignored_words,
|
||||
.input_words = input_words,
|
||||
};
|
||||
}
|
||||
|
||||
void obs_x264_free_options(struct obs_x264_options options)
|
||||
{
|
||||
for (size_t i = 0; i < options.count; ++i) {
|
||||
bfree(options.options[i].name);
|
||||
}
|
||||
bfree(options.options);
|
||||
bfree(options.ignored_words);
|
||||
strlist_free(options.input_words);
|
||||
}
|
||||
19
plugins/obs-x264/obs-x264-options.h
Normal file
19
plugins/obs-x264/obs-x264-options.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
struct obs_x264_option {
|
||||
char *name;
|
||||
char *value;
|
||||
};
|
||||
|
||||
struct obs_x264_options {
|
||||
size_t count;
|
||||
struct obs_x264_option *options;
|
||||
size_t ignored_word_count;
|
||||
char **ignored_words;
|
||||
char **input_words;
|
||||
};
|
||||
|
||||
struct obs_x264_options obs_x264_parse_options(const char *options_string);
|
||||
void obs_x264_free_options(struct obs_x264_options options);
|
||||
74
plugins/obs-x264/obs-x264-test.c
Normal file
74
plugins/obs-x264/obs-x264-test.c
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "obs-x264-options.h"
|
||||
|
||||
#define CHECK(condition) \
|
||||
do { \
|
||||
if (!(condition)) { \
|
||||
fprintf(stderr, "%s:%d: error: check failed: %s\n", \
|
||||
__FILE__, __LINE__, #condition); \
|
||||
exit(1); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static void test_obs_x264_parse_options()
|
||||
{
|
||||
struct obs_x264_options options;
|
||||
|
||||
options = obs_x264_parse_options(NULL);
|
||||
CHECK(options.count == 0);
|
||||
CHECK(options.ignored_word_count == 0);
|
||||
obs_x264_free_options(options);
|
||||
|
||||
options = obs_x264_parse_options("");
|
||||
CHECK(options.count == 0);
|
||||
CHECK(options.ignored_word_count == 0);
|
||||
obs_x264_free_options(options);
|
||||
|
||||
options = obs_x264_parse_options("ref=3");
|
||||
CHECK(options.count == 1);
|
||||
CHECK(strcmp(options.options[0].name, "ref") == 0);
|
||||
CHECK(strcmp(options.options[0].value, "3") == 0);
|
||||
CHECK(options.ignored_word_count == 0);
|
||||
obs_x264_free_options(options);
|
||||
|
||||
options = obs_x264_parse_options("ref=3 bframes=8");
|
||||
CHECK(options.count == 2);
|
||||
CHECK(strcmp(options.options[0].name, "ref") == 0);
|
||||
CHECK(strcmp(options.options[0].value, "3") == 0);
|
||||
CHECK(strcmp(options.options[1].name, "bframes") == 0);
|
||||
CHECK(strcmp(options.options[1].value, "8") == 0);
|
||||
CHECK(options.ignored_word_count == 0);
|
||||
obs_x264_free_options(options);
|
||||
|
||||
// Invalid options are ignored.
|
||||
options = obs_x264_parse_options(
|
||||
"ref=3 option_with_no_equal_sign bframes=8 1234");
|
||||
CHECK(options.count == 2);
|
||||
CHECK(strcmp(options.options[0].name, "ref") == 0);
|
||||
CHECK(strcmp(options.options[0].value, "3") == 0);
|
||||
CHECK(strcmp(options.options[1].name, "bframes") == 0);
|
||||
CHECK(strcmp(options.options[1].value, "8") == 0);
|
||||
CHECK(options.ignored_word_count == 2);
|
||||
CHECK(strcmp(options.ignored_words[0], "option_with_no_equal_sign") ==
|
||||
0);
|
||||
CHECK(strcmp(options.ignored_words[1], "1234") == 0);
|
||||
obs_x264_free_options(options);
|
||||
|
||||
// Extra whitespace is ignored between and around options.
|
||||
options = obs_x264_parse_options(" ref=3 bframes=8 ");
|
||||
CHECK(options.count == 2);
|
||||
CHECK(strcmp(options.options[0].name, "ref") == 0);
|
||||
CHECK(strcmp(options.options[0].value, "3") == 0);
|
||||
CHECK(strcmp(options.options[1].name, "bframes") == 0);
|
||||
CHECK(strcmp(options.options[1].value, "8") == 0);
|
||||
CHECK(options.ignored_word_count == 0);
|
||||
obs_x264_free_options(options);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_obs_x264_parse_options();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -16,10 +16,13 @@
|
|||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <util/bmem.h>
|
||||
#include <util/dstr.h>
|
||||
#include <util/darray.h>
|
||||
#include <util/platform.h>
|
||||
#include <obs-module.h>
|
||||
#include "obs-x264-options.h"
|
||||
|
||||
#ifndef _STDINT_H_INCLUDED
|
||||
#define _STDINT_H_INCLUDED
|
||||
|
|
@ -255,72 +258,63 @@ static const char *validate(struct obs_x264 *obsx264, const char *val,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void override_base_param(struct obs_x264 *obsx264, const char *param,
|
||||
char **preset, char **profile, char **tune)
|
||||
static void override_base_param(struct obs_x264 *obsx264,
|
||||
struct obs_x264_option option, char **preset,
|
||||
char **profile, char **tune)
|
||||
{
|
||||
char *name;
|
||||
const char *val;
|
||||
|
||||
if (getparam(param, &name, &val)) {
|
||||
if (astrcmpi(name, "preset") == 0) {
|
||||
const char *valid_name = validate(
|
||||
obsx264, val, "preset", x264_preset_names);
|
||||
if (valid_name) {
|
||||
bfree(*preset);
|
||||
*preset = bstrdup(val);
|
||||
}
|
||||
|
||||
} else if (astrcmpi(name, "profile") == 0) {
|
||||
const char *valid_name = validate(
|
||||
obsx264, val, "profile", x264_profile_names);
|
||||
if (valid_name) {
|
||||
bfree(*profile);
|
||||
*profile = bstrdup(val);
|
||||
}
|
||||
|
||||
} else if (astrcmpi(name, "tune") == 0) {
|
||||
const char *valid_name =
|
||||
validate(obsx264, val, "tune", x264_tune_names);
|
||||
if (valid_name) {
|
||||
bfree(*tune);
|
||||
*tune = bstrdup(val);
|
||||
}
|
||||
const char *name = option.name;
|
||||
const char *val = option.value;
|
||||
if (astrcmpi(name, "preset") == 0) {
|
||||
const char *valid_name =
|
||||
validate(obsx264, val, "preset", x264_preset_names);
|
||||
if (valid_name) {
|
||||
bfree(*preset);
|
||||
*preset = bstrdup(val);
|
||||
}
|
||||
|
||||
bfree(name);
|
||||
} else if (astrcmpi(name, "profile") == 0) {
|
||||
const char *valid_name =
|
||||
validate(obsx264, val, "profile", x264_profile_names);
|
||||
if (valid_name) {
|
||||
bfree(*profile);
|
||||
*profile = bstrdup(val);
|
||||
}
|
||||
|
||||
} else if (astrcmpi(name, "tune") == 0) {
|
||||
const char *valid_name =
|
||||
validate(obsx264, val, "tune", x264_tune_names);
|
||||
if (valid_name) {
|
||||
bfree(*tune);
|
||||
*tune = bstrdup(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void override_base_params(struct obs_x264 *obsx264, char **params,
|
||||
static inline void override_base_params(struct obs_x264 *obsx264,
|
||||
const struct obs_x264_options *options,
|
||||
char **preset, char **profile,
|
||||
char **tune)
|
||||
{
|
||||
while (*params)
|
||||
override_base_param(obsx264, *(params++), preset, profile,
|
||||
tune);
|
||||
for (size_t i = 0; i < options->count; ++i)
|
||||
override_base_param(obsx264, options->options[i], preset,
|
||||
profile, tune);
|
||||
}
|
||||
|
||||
#define OPENCL_ALIAS "opencl_is_experimental_and_potentially_unstable"
|
||||
|
||||
static inline void set_param(struct obs_x264 *obsx264, const char *param)
|
||||
static inline void set_param(struct obs_x264 *obsx264,
|
||||
struct obs_x264_option option)
|
||||
{
|
||||
char *name;
|
||||
const char *val;
|
||||
|
||||
if (getparam(param, &name, &val)) {
|
||||
if (strcmp(name, "preset") != 0 &&
|
||||
strcmp(name, "profile") != 0 && strcmp(name, "tune") != 0 &&
|
||||
strcmp(name, "fps") != 0 &&
|
||||
strcmp(name, "force-cfr") != 0 &&
|
||||
strcmp(name, "width") != 0 && strcmp(name, "height") != 0 &&
|
||||
strcmp(name, "opencl") != 0) {
|
||||
if (strcmp(name, OPENCL_ALIAS) == 0)
|
||||
strcpy(name, "opencl");
|
||||
if (x264_param_parse(&obsx264->params, name, val) != 0)
|
||||
warn("x264 param: %s failed", param);
|
||||
}
|
||||
|
||||
bfree(name);
|
||||
const char *name = option.name;
|
||||
const char *val = option.value;
|
||||
if (strcmp(name, "preset") != 0 && strcmp(name, "profile") != 0 &&
|
||||
strcmp(name, "tune") != 0 && strcmp(name, "fps") != 0 &&
|
||||
strcmp(name, "force-cfr") != 0 && strcmp(name, "width") != 0 &&
|
||||
strcmp(name, "height") != 0 && strcmp(name, "opencl") != 0) {
|
||||
if (strcmp(option.name, OPENCL_ALIAS) == 0)
|
||||
name = "opencl";
|
||||
if (x264_param_parse(&obsx264->params, name, val) != 0)
|
||||
warn("x264 param: %s=%s failed", name, val);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -362,23 +356,9 @@ static void log_x264(void *param, int level, const char *format, va_list args)
|
|||
UNUSED_PARAMETER(level);
|
||||
}
|
||||
|
||||
static inline const char *get_x264_colorspace_name(enum video_colorspace cs)
|
||||
{
|
||||
switch (cs) {
|
||||
case VIDEO_CS_DEFAULT:
|
||||
case VIDEO_CS_601:
|
||||
case VIDEO_CS_SRGB:
|
||||
return "undef";
|
||||
case VIDEO_CS_709:;
|
||||
}
|
||||
|
||||
return "bt709";
|
||||
}
|
||||
|
||||
static inline int get_x264_cs_val(enum video_colorspace cs,
|
||||
static inline int get_x264_cs_val(const char *const name,
|
||||
const char *const names[])
|
||||
{
|
||||
const char *name = get_x264_colorspace_name(cs);
|
||||
int idx = 0;
|
||||
do {
|
||||
if (strcmp(names[idx], name) == 0)
|
||||
|
|
@ -398,7 +378,7 @@ enum rate_control {
|
|||
};
|
||||
|
||||
static void update_params(struct obs_x264 *obsx264, obs_data_t *settings,
|
||||
char **params, bool update)
|
||||
const struct obs_x264_options *options, bool update)
|
||||
{
|
||||
video_t *video = obs_encoder_video(obsx264->encoder);
|
||||
const struct video_output_info *voi = video_output_get_info(video);
|
||||
|
|
@ -481,13 +461,38 @@ static void update_params(struct obs_x264 *obsx264, obs_data_t *settings,
|
|||
if (obs_data_has_user_value(settings, "bf"))
|
||||
obsx264->params.i_bframe = bf;
|
||||
|
||||
obsx264->params.vui.i_transfer =
|
||||
get_x264_cs_val(info.colorspace, x264_transfer_names);
|
||||
obsx264->params.vui.i_colmatrix =
|
||||
get_x264_cs_val(info.colorspace, x264_colmatrix_names);
|
||||
obsx264->params.vui.i_colorprim =
|
||||
get_x264_cs_val(info.colorspace, x264_colorprim_names);
|
||||
static const char *const smpte170m = "smpte170m";
|
||||
static const char *const bt709 = "bt709";
|
||||
static const char *const iec61966_2_1 = "iec61966-2-1";
|
||||
const char *colorprim = NULL;
|
||||
const char *transfer = NULL;
|
||||
const char *colmatrix = NULL;
|
||||
switch (info.colorspace) {
|
||||
case VIDEO_CS_601:
|
||||
colorprim = smpte170m;
|
||||
transfer = smpte170m;
|
||||
colmatrix = smpte170m;
|
||||
break;
|
||||
case VIDEO_CS_DEFAULT:
|
||||
case VIDEO_CS_709:
|
||||
colorprim = bt709;
|
||||
transfer = bt709;
|
||||
colmatrix = bt709;
|
||||
break;
|
||||
case VIDEO_CS_SRGB:
|
||||
colorprim = bt709;
|
||||
transfer = iec61966_2_1;
|
||||
colmatrix = bt709;
|
||||
break;
|
||||
}
|
||||
|
||||
obsx264->params.vui.b_fullrange = info.range == VIDEO_RANGE_FULL;
|
||||
obsx264->params.vui.i_colorprim =
|
||||
get_x264_cs_val(colorprim, x264_colorprim_names);
|
||||
obsx264->params.vui.i_transfer =
|
||||
get_x264_cs_val(transfer, x264_transfer_names);
|
||||
obsx264->params.vui.i_colmatrix =
|
||||
get_x264_cs_val(colmatrix, x264_colmatrix_names);
|
||||
|
||||
/* use the new filler method for CBR to allow real-time adjusting of
|
||||
* the bitrate */
|
||||
|
|
@ -516,8 +521,11 @@ static void update_params(struct obs_x264 *obsx264, obs_data_t *settings,
|
|||
else
|
||||
obsx264->params.i_csp = X264_CSP_NV12;
|
||||
|
||||
while (*params)
|
||||
set_param(obsx264, *(params++));
|
||||
for (size_t i = 0; i < options->ignored_word_count; ++i)
|
||||
warn("ignoring invalid x264 option: %s",
|
||||
options->ignored_words[i]);
|
||||
for (size_t i = 0; i < options->count; ++i)
|
||||
set_param(obsx264, options->options[i]);
|
||||
|
||||
if (!update) {
|
||||
info("settings:\n"
|
||||
|
|
@ -537,24 +545,52 @@ static void update_params(struct obs_x264 *obsx264, obs_data_t *settings,
|
|||
}
|
||||
}
|
||||
|
||||
static void log_custom_options(struct obs_x264 *obsx264,
|
||||
const struct obs_x264_options *options)
|
||||
{
|
||||
if (options->count == 0) {
|
||||
return;
|
||||
}
|
||||
size_t settings_string_length = 0;
|
||||
for (size_t i = 0; i < options->count; ++i)
|
||||
settings_string_length += strlen(options->options[i].name) +
|
||||
strlen(options->options[i].value) + 5;
|
||||
size_t buffer_size = settings_string_length + 1;
|
||||
char *settings_string = bmalloc(settings_string_length + 1);
|
||||
char *p = settings_string;
|
||||
size_t remaining_buffer_size = buffer_size;
|
||||
for (size_t i = 0; i < options->count; ++i) {
|
||||
int chars_written = snprintf(p, remaining_buffer_size,
|
||||
"\n\t%s = %s",
|
||||
options->options[i].name,
|
||||
options->options[i].value);
|
||||
assert(chars_written >= 0);
|
||||
assert((size_t)chars_written <= remaining_buffer_size);
|
||||
p += chars_written;
|
||||
remaining_buffer_size -= chars_written;
|
||||
}
|
||||
assert(remaining_buffer_size == 1);
|
||||
assert(*p == '\0');
|
||||
info("custom settings: %s", settings_string);
|
||||
bfree(settings_string);
|
||||
}
|
||||
|
||||
static bool update_settings(struct obs_x264 *obsx264, obs_data_t *settings,
|
||||
bool update)
|
||||
{
|
||||
char *preset = bstrdup(obs_data_get_string(settings, "preset"));
|
||||
char *profile = bstrdup(obs_data_get_string(settings, "profile"));
|
||||
char *tune = bstrdup(obs_data_get_string(settings, "tune"));
|
||||
const char *opts = obs_data_get_string(settings, "x264opts");
|
||||
struct obs_x264_options options = obs_x264_parse_options(
|
||||
obs_data_get_string(settings, "x264opts"));
|
||||
|
||||
char **paramlist;
|
||||
bool success = true;
|
||||
|
||||
paramlist = strlist_split(opts, ' ', false);
|
||||
|
||||
if (!update)
|
||||
blog(LOG_INFO, "---------------------------------");
|
||||
|
||||
if (!obsx264->context) {
|
||||
override_base_params(obsx264, paramlist, &preset, &profile,
|
||||
override_base_params(obsx264, &options, &preset, &profile,
|
||||
&tune);
|
||||
|
||||
if (preset && *preset)
|
||||
|
|
@ -568,9 +604,10 @@ static bool update_settings(struct obs_x264 *obsx264, obs_data_t *settings,
|
|||
}
|
||||
|
||||
if (success) {
|
||||
update_params(obsx264, settings, paramlist, update);
|
||||
if (opts && *opts && !update)
|
||||
info("custom settings: %s", opts);
|
||||
update_params(obsx264, settings, &options, update);
|
||||
if (!update) {
|
||||
log_custom_options(obsx264, &options);
|
||||
}
|
||||
|
||||
if (!obsx264->context)
|
||||
apply_x264_profile(obsx264, profile);
|
||||
|
|
@ -578,7 +615,7 @@ static bool update_settings(struct obs_x264 *obsx264, obs_data_t *settings,
|
|||
|
||||
obsx264->params.b_repeat_headers = false;
|
||||
|
||||
strlist_free(paramlist);
|
||||
obs_x264_free_options(options);
|
||||
bfree(preset);
|
||||
bfree(profile);
|
||||
bfree(tune);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue