diff --git a/UI/qt-display.hpp b/UI/qt-display.hpp index 4c975cee2..11231f99e 100644 --- a/UI/qt-display.hpp +++ b/UI/qt-display.hpp @@ -5,8 +5,8 @@ class OBSQTDisplay : public QWidget { Q_OBJECT - Q_PROPERTY(QColor displayBackgroundColor WRITE SetDisplayBackgroundColor - NOTIFY SetDisplayBackgroundColor) + Q_PROPERTY(QColor displayBackgroundColor MEMBER backgroundColor + WRITE SetDisplayBackgroundColor) OBSDisplay display; @@ -20,7 +20,8 @@ signals: void DisplayResized(); public: - OBSQTDisplay(QWidget *parent = 0, Qt::WindowFlags flags = 0); + OBSQTDisplay(QWidget *parent = nullptr, + Qt::WindowFlags flags = nullptr); virtual QPaintEngine *paintEngine() const override; diff --git a/libobs-opengl/gl-subsystem.h b/libobs-opengl/gl-subsystem.h index ba6cf98d6..d5b89c9eb 100644 --- a/libobs-opengl/gl-subsystem.h +++ b/libobs-opengl/gl-subsystem.h @@ -36,7 +36,7 @@ enum copy_type { COPY_TYPE_FBO_BLIT }; -static inline GLint convert_gs_format(enum gs_color_format format) +static inline GLenum convert_gs_format(enum gs_color_format format) { switch (format) { case GS_A8: return GL_RED; @@ -51,6 +51,7 @@ static inline GLint convert_gs_format(enum gs_color_format format) case GS_RGBA32F: return GL_RGBA; case GS_RG16F: return GL_RG; case GS_RG32F: return GL_RG; + case GS_R8G8: return GL_RG; case GS_R16F: return GL_RED; case GS_R32F: return GL_RED; case GS_DXT1: return GL_RGB; @@ -62,7 +63,7 @@ static inline GLint convert_gs_format(enum gs_color_format format) return 0; } -static inline GLint convert_gs_internal_format(enum gs_color_format format) +static inline GLenum convert_gs_internal_format(enum gs_color_format format) { switch (format) { case GS_A8: return GL_R8; /* NOTE: use GL_TEXTURE_SWIZZLE_x */ @@ -77,6 +78,7 @@ static inline GLint convert_gs_internal_format(enum gs_color_format format) case GS_RGBA32F: return GL_RGBA32F; case GS_RG16F: return GL_RG16F; case GS_RG32F: return GL_RG32F; + case GS_R8G8: return GL_R16; case GS_R16F: return GL_R16F; case GS_R32F: return GL_R32F; case GS_DXT1: return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; @@ -103,6 +105,7 @@ static inline GLenum get_gl_format_type(enum gs_color_format format) case GS_RGBA32F: return GL_FLOAT; case GS_RG16F: return GL_UNSIGNED_SHORT; case GS_RG32F: return GL_FLOAT; + case GS_R8G8: return GL_UNSIGNED_SHORT; case GS_R16F: return GL_UNSIGNED_SHORT; case GS_R32F: return GL_FLOAT; case GS_DXT1: return GL_UNSIGNED_BYTE; @@ -399,7 +402,7 @@ struct gs_texture { enum gs_color_format format; GLenum gl_format; GLenum gl_target; - GLint gl_internal_format; + GLenum gl_internal_format; GLenum gl_type; GLuint texture; uint32_t levels; diff --git a/libobs/graphics/image-file.c b/libobs/graphics/image-file.c index 588a0b2d8..402014f69 100644 --- a/libobs/graphics/image-file.c +++ b/libobs/graphics/image-file.c @@ -62,6 +62,8 @@ static inline int get_full_decoded_gif_size(gs_image_file_t *image) static inline void *alloc_mem(gs_image_file_t *image, uint64_t *mem_usage, size_t size) { + UNUSED_PARAMETER(image); + if (mem_usage) *mem_usage += size; return bzalloc(size); diff --git a/libobs/obs-video-gpu-encode.c b/libobs/obs-video-gpu-encode.c index 05f01e4d9..aca8dfd9b 100644 --- a/libobs/obs-video-gpu-encode.c +++ b/libobs/obs-video-gpu-encode.c @@ -34,7 +34,7 @@ static void *gpu_encode_thread(void *unused) uint64_t timestamp; uint64_t lock_key; uint64_t next_key; - int lock_count = 0; + size_t lock_count = 0; if (os_atomic_load_bool(&video->gpu_encode_stop)) break; diff --git a/libobs/obs-video.c b/libobs/obs-video.c index f57d97704..6d1f216b8 100644 --- a/libobs/obs-video.c +++ b/libobs/obs-video.c @@ -343,6 +343,8 @@ static void render_nv12(struct obs_core_video *video, gs_texture_t *target, } gs_technique_end(tech); gs_enable_blending(true); + + UNUSED_PARAMETER(cur_texture); } static const char *render_convert_nv12_name = "render_convert_texture_nv12"; @@ -628,11 +630,9 @@ static void set_gpu_converted_data(struct obs_core_video *video, video_frame_copy(output, &frame, info->format, info->height); } else if (video->using_nv12_tex) { - int width = (int)info->width; - int height = (int)info->height; - int width_d2 = width / 2; - int height_d2 = height / 2; - int height_d4 = height_d2 / 2; + size_t width = info->width; + size_t height = info->height; + size_t height_d2 = height / 2; uint8_t *out_y = output->data[0]; uint8_t *out_uv = output->data[1]; uint8_t *in = input->data[0]; @@ -767,8 +767,7 @@ static inline void output_frame(bool raw_active, const bool gpu_active) int cur_texture = video->cur_texture; int prev_texture = cur_texture == 0 ? NUM_TEXTURES-1 : cur_texture-1; struct video_data frame; - bool active = raw_active || gpu_active; - bool frame_ready; + bool frame_ready = 0; memset(&frame, 0, sizeof(struct video_data)); @@ -847,7 +846,9 @@ void *obs_graphics_thread(void *param) uint64_t frame_time_total_ns = 0; uint64_t fps_total_ns = 0; uint32_t fps_total_frames = 0; +#ifdef _WIN32 bool gpu_was_active = false; +#endif bool raw_was_active = false; bool was_active = false; @@ -867,11 +868,12 @@ void *obs_graphics_thread(void *param) uint64_t frame_time_ns; bool raw_active = obs->video.raw_active > 0; #ifdef _WIN32 - bool gpu_active = obs->video.gpu_encoder_active > 0; + const bool gpu_active = obs->video.gpu_encoder_active > 0; + const bool active = raw_active || gpu_active; #else const bool gpu_active = 0; + const bool active = raw_active; #endif - bool active = raw_active || gpu_active; if (!was_active && active) clear_base_frame_data(); @@ -880,9 +882,10 @@ void *obs_graphics_thread(void *param) #ifdef _WIN32 if (!gpu_was_active && gpu_active) clear_gpu_frame_data(); + + gpu_was_active = gpu_active; #endif raw_was_active = raw_active; - gpu_was_active = gpu_active; was_active = active; profile_start(video_thread_name); diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-vaapi.c b/plugins/obs-ffmpeg/obs-ffmpeg-vaapi.c index 6f6e9b699..6b17ffe3d 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-vaapi.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-vaapi.c @@ -464,7 +464,7 @@ static obs_properties_t *vaapi_properties(void *unused) list = obs_properties_add_list(props, "vaapi_device", "VAAPI Device", OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); - char path[128] = "/dev/dri/renderD1"; + char path[32] = "/dev/dri/renderD1"; for (int i = 28;; i++) { sprintf(path, "/dev/dri/renderD1%d", i); if (access(path, F_OK) == 0) { diff --git a/plugins/obs-ffmpeg/obs-ffmpeg.c b/plugins/obs-ffmpeg/obs-ffmpeg.c index b94544cdb..808e5a0e5 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg.c @@ -297,7 +297,9 @@ static bool nvenc_supported(void) cleanup: if (lib) os_dlclose(lib); +#if defined(_WIN32) finish: +#endif profile_end(nvenc_check_name); return success; } diff --git a/plugins/obs-filters/expander-filter.c b/plugins/obs-filters/expander-filter.c index f834097f9..dc4e8217f 100644 --- a/plugins/obs-filters/expander-filter.c +++ b/plugins/obs-filters/expander-filter.c @@ -47,12 +47,12 @@ #define TEXT_PRESETS_EXP MT_("expander.Presets.Expander") #define TEXT_PRESETS_GATE MT_("expander.Presets.Gate") -#define MIN_RATIO 1.0 -#define MAX_RATIO 20.0 -#define MIN_THRESHOLD_DB -60.0 +#define MIN_RATIO 1.0f +#define MAX_RATIO 20.0f +#define MIN_THRESHOLD_DB -60.0f #define MAX_THRESHOLD_DB 0.0f -#define MIN_OUTPUT_GAIN_DB -32.0 -#define MAX_OUTPUT_GAIN_DB 32.0 +#define MIN_OUTPUT_GAIN_DB -32.0f +#define MAX_OUTPUT_GAIN_DB 32.0f #define MIN_ATK_RLS_MS 1 #define MAX_RLS_MS 1000 #define MAX_ATK_MS 100 @@ -101,36 +101,36 @@ enum { static void resize_env_buffer(struct expander_data *cd, size_t len) { cd->envelope_buf_len = len; - for (int i = 0; i < MAX_AUDIO_CHANNELS; i++) { - cd->envelope_buf[i] = brealloc(cd->envelope_buf[i], len * sizeof(float)); - } + for (int i = 0; i < MAX_AUDIO_CHANNELS; i++) + cd->envelope_buf[i] = brealloc(cd->envelope_buf[i], + cd->envelope_buf_len * sizeof(float)); } static void resize_runaverage_buffer(struct expander_data *cd, size_t len) { cd->runaverage_len = len; - for (int i = 0; i < MAX_AUDIO_CHANNELS; i++) { - cd->runaverage[i] = brealloc(cd->runaverage[i], len * sizeof(float)); - } + for (int i = 0; i < MAX_AUDIO_CHANNELS; i++) + cd->runaverage[i] = brealloc(cd->runaverage[i], + cd->runaverage_len * sizeof(float)); } static void resize_env_in_buffer(struct expander_data *cd, size_t len) { cd->env_in_len = len; - cd->env_in = brealloc(cd->env_in, len * sizeof(float)); + cd->env_in = brealloc(cd->env_in, cd->env_in_len * sizeof(float)); } static void resize_gaindB_buffer(struct expander_data *cd, size_t len) { cd->gaindB_len = len; - for (int i = 0; i < MAX_AUDIO_CHANNELS; i++) { - cd->gaindB[i] = brealloc(cd->gaindB[i], len * sizeof(float)); - } + for (int i = 0; i < MAX_AUDIO_CHANNELS; i++) + cd->gaindB[i] = brealloc(cd->gaindB[i], + cd->gaindB_len * sizeof(float)); } static inline float gain_coefficient(uint32_t sample_rate, float time) { - return (float)exp(-1.0f / (sample_rate * time)); + return expf(-1.0f / (sample_rate * time)); } static const char *expander_name(void *unused) @@ -249,22 +249,21 @@ static void expander_destroy(void *data) static void analyze_envelope(struct expander_data *cd, float **samples, const uint32_t num_samples) { - if (cd->envelope_buf_len < num_samples) { + if (cd->envelope_buf_len < num_samples) resize_env_buffer(cd, num_samples); - } - if (cd->runaverage_len < num_samples) { + if (cd->runaverage_len < num_samples) resize_runaverage_buffer(cd, num_samples); - } - if (cd->env_in_len < num_samples) { + if (cd->env_in_len < num_samples) resize_env_in_buffer(cd, num_samples); - } // 10 ms RMS window - const float rmscoef = exp2f((float)-100.0 / (float)cd->sample_rate); + const float rmscoef = exp2f(-100.0f / cd->sample_rate); for (int i = 0; i < MAX_AUDIO_CHANNELS; i++) { - memset(cd->envelope_buf[i], 0, num_samples * sizeof(cd->envelope_buf[i][0])); - memset(cd->runaverage[i], 0, num_samples * sizeof(cd->runaverage[i][0])); + memset(cd->envelope_buf[i], 0, + num_samples * sizeof(cd->envelope_buf[i][0])); + memset(cd->runaverage[i], 0, + num_samples * sizeof(cd->runaverage[i][0])); } memset(cd->env_in, 0, num_samples * sizeof(cd->env_in[0])); @@ -275,16 +274,15 @@ static void analyze_envelope(struct expander_data *cd, float *envelope_buf = cd->envelope_buf[chan]; float *runave = cd->runaverage[chan]; float *env_in = cd->env_in; - float RMSdet = 0; if (cd->detector == RMS_DETECT) { runave[0] = rmscoef * cd->runave[chan] + - (1 - rmscoef) * powf(samples[chan][0], 2.0); + (1 - rmscoef) * powf(samples[chan][0], 2.0f); env_in[0] = sqrtf(fmaxf(runave[0], 0)); for (uint32_t i = 1; i < num_samples; ++i) { runave[i] = rmscoef * runave[i - 1] + (1 - rmscoef) * - powf(samples[chan][i], 2.0); + powf(samples[chan][i], 2.0f); env_in[i] = sqrtf(runave[i]); } } else if (cd->detector == PEAK_DETECT) { @@ -305,7 +303,6 @@ static void analyze_envelope(struct expander_data *cd, static inline void process_expansion(struct expander_data *cd, float **samples, uint32_t num_samples) { - const float attack_gain = cd->attack_gain; const float release_gain = cd->release_gain; @@ -318,24 +315,29 @@ static inline void process_expansion(struct expander_data *cd, for (size_t i = 0; i < num_samples; ++i) { // gain stage of expansion float env_db = mul_to_db(cd->envelope_buf[chan][i]); - float gain = cd->threshold - env_db > 0 ? - fmaxf(cd->slope * (cd->threshold - env_db), - -60.0) : 0; + float gain = cd->threshold - env_db > 0.0f ? + fmaxf(cd->slope * + (cd->threshold - env_db), -60.0f) : + 0.0f; // ballistics (attack/release) if (i > 0) { if (gain > cd->gaindB[chan][i - 1]) - cd->gaindB[chan][i] = attack_gain * cd->gaindB[chan][i - 1] - + (1 - attack_gain) * gain; + cd->gaindB[chan][i] = attack_gain * + cd->gaindB[chan][i - 1] + + (1.0f - attack_gain) * gain; else - cd->gaindB[chan][i] = release_gain * cd->gaindB[chan][i - 1] - + (1 - release_gain) * gain; + cd->gaindB[chan][i] = release_gain * + cd->gaindB[chan][i - 1] + + (1.0f - release_gain) * gain; } else { if (gain > cd->gaindB_buf[chan]) - cd->gaindB[chan][i] = attack_gain * cd->gaindB_buf[chan] - + (1 - attack_gain) * gain; + cd->gaindB[chan][i] = attack_gain * + cd->gaindB_buf[chan] + + (1.0f - attack_gain) * gain; else - cd->gaindB[chan][i] = release_gain * cd->gaindB_buf[chan] - + (1 - release_gain) * gain; + cd->gaindB[chan][i] = release_gain * + cd->gaindB_buf[chan] + + (1.0f - release_gain) * gain; } gain = db_to_mul(fminf(0, cd->gaindB[chan][i])); @@ -373,12 +375,7 @@ static bool presets_changed(obs_properties_t *props, obs_property_t *prop, static obs_properties_t *expander_properties(void *data) { - struct expander_data *cd = data; obs_properties_t *props = obs_properties_create(); - obs_source_t *parent = NULL; - - if (cd) - parent = obs_filter_get_parent(cd->context); obs_property_t *presets = obs_properties_add_list(props, S_PRESETS, TEXT_PRESETS, OBS_COMBO_TYPE_LIST, diff --git a/plugins/obs-filters/limiter-filter.c b/plugins/obs-filters/limiter-filter.c index 158111673..c6bc1393b 100644 --- a/plugins/obs-filters/limiter-filter.c +++ b/plugins/obs-filters/limiter-filter.c @@ -192,7 +192,6 @@ static void limiter_defaults(obs_data_t *s) static obs_properties_t *limiter_properties(void *data) { - struct limiter_data *cd = data; obs_properties_t *props = obs_properties_create(); obs_properties_add_float_slider(props, S_THRESHOLD, TEXT_THRESHOLD, MIN_THRESHOLD_DB, MAX_THRESHOLD_DB, 0.1);