project: Modernize code to proper C++

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2020-04-08 23:38:42 +02:00 committed by Michael Fabian Dirks
parent e16b4f0004
commit 908d1f0a20
81 changed files with 556 additions and 554 deletions

View File

@ -24,7 +24,7 @@
using namespace encoder::codec;
enum class nal_unit_type : uint8_t { // 6 bits
enum class nal_unit_type : std::uint8_t { // 6 bits
TRAIL_N = 0,
TRAIL_R = 1,
TSA_N = 2,
@ -94,19 +94,19 @@ enum class nal_unit_type : uint8_t { // 6 bits
struct hevc_nal_unit_header {
bool zero_bit : 1;
nal_unit_type nut : 6;
uint8_t layer_id : 6;
uint8_t temporal_id_plus1 : 3;
std::uint8_t layer_id : 6;
std::uint8_t temporal_id_plus1 : 3;
};
struct hevc_nal {
hevc_nal_unit_header* header;
size_t size = 0;
uint8_t* data = nullptr;
std::size_t size = 0;
std::uint8_t* data = nullptr;
};
bool is_nal(uint8_t* data, uint8_t* end)
bool is_nal(std::uint8_t* data, std::uint8_t* end)
{
size_t s = static_cast<size_t>(end - data);
std::size_t s = static_cast<size_t>(end - data);
if (s < 4)
return false;
@ -122,7 +122,7 @@ bool is_nal(uint8_t* data, uint8_t* end)
return true;
}
bool seek_to_nal(uint8_t*& data, uint8_t* end)
bool seek_to_nal(std::uint8_t*& data, std::uint8_t* end)
{
if (data > end)
return false;
@ -136,18 +136,18 @@ bool seek_to_nal(uint8_t*& data, uint8_t* end)
return false;
}
size_t get_nal_size(uint8_t* data, uint8_t* end)
std::size_t get_nal_size(std::uint8_t* data, std::uint8_t* end)
{
uint8_t* ptr = data + 4;
std::uint8_t* ptr = data + 4;
if (!seek_to_nal(ptr, end)) {
return static_cast<size_t>(end - data);
}
return static_cast<size_t>(ptr - data);
}
bool is_discard_marker(uint8_t* data, uint8_t* end)
bool is_discard_marker(std::uint8_t* data, std::uint8_t* end)
{
size_t s = static_cast<size_t>(end - data);
std::size_t s = static_cast<size_t>(end - data);
if (s < 4)
return false;
@ -180,7 +180,7 @@ bool is_discard_marker(uint8_t* data, uint8_t* end)
}
}
bool should_discard_nal(uint8_t* data, uint8_t* end)
bool should_discard_nal(std::uint8_t* data, std::uint8_t* end)
{
if (data > end)
return true;
@ -193,16 +193,17 @@ bool should_discard_nal(uint8_t* data, uint8_t* end)
return false;
}
void progress_parse(uint8_t*& ptr, uint8_t* end, size_t& sz)
void progress_parse(std::uint8_t*& ptr, std::uint8_t* end, size_t& sz)
{
ptr += sz;
sz = get_nal_size(ptr, end);
}
void hevc::extract_header_sei(uint8_t* data, size_t sz_data, std::vector<uint8_t>& header, std::vector<uint8_t>& sei)
void hevc::extract_header_sei(std::uint8_t* data, std::size_t sz_data, std::vector<std::uint8_t>& header,
std::vector<std::uint8_t>& sei)
{
uint8_t* ptr = data;
uint8_t* end = data + sz_data;
std::uint8_t* ptr = data;
std::uint8_t* end = data + sz_data;
// Reserve enough memory to store the entire packet data if necessary.
header.reserve(sz_data);
@ -212,7 +213,7 @@ void hevc::extract_header_sei(uint8_t* data, size_t sz_data, std::vector<uint8_t
return;
}
for (size_t nal_sz = get_nal_size(ptr, end); nal_sz > 0; progress_parse(ptr, end, nal_sz)) {
for (std::size_t nal_sz = get_nal_size(ptr, end); nal_sz > 0; progress_parse(ptr, end, nal_sz)) {
if (should_discard_nal(ptr + 4, ptr + nal_sz)) {
continue;
}

View File

@ -59,5 +59,6 @@ namespace encoder::codec::hevc {
UNKNOWN = -1,
};
void extract_header_sei(uint8_t* data, size_t sz_data, std::vector<uint8_t>& header, std::vector<uint8_t>& sei);
void extract_header_sei(std::uint8_t* data, std::size_t sz_data, std::vector<std::uint8_t>& header,
std::vector<std::uint8_t>& sei);
} // namespace encoder::codec::hevc

View File

@ -253,7 +253,7 @@ try {
return false;
}
static bool _get_sei_data(void* ptr, uint8_t** sei_data, size_t* size) noexcept
static bool _get_sei_data(void* ptr, std::uint8_t** sei_data, size_t* size) noexcept
try {
return reinterpret_cast<ffmpeg_instance*>(ptr)->get_sei_data(sei_data, size);
} catch (const std::exception& ex) {
@ -264,7 +264,7 @@ try {
return false;
}
static bool _get_extra_data(void* ptr, uint8_t** extra_data, size_t* size) noexcept
static bool _get_extra_data(void* ptr, std::uint8_t** extra_data, size_t* size) noexcept
try {
return reinterpret_cast<ffmpeg_instance*>(ptr)->get_extra_data(extra_data, size);
} catch (const std::exception& ex) {
@ -296,8 +296,8 @@ try {
return false;
}
static bool _encode_texture(void* ptr, uint32_t handle, int64_t pts, uint64_t lock_key, uint64_t* next_key,
struct encoder_packet* packet, bool* received_packet) noexcept
static bool _encode_texture(void* ptr, std::uint32_t handle, std::int64_t pts, std::uint64_t lock_key,
std::uint64_t* next_key, struct encoder_packet* packet, bool* received_packet) noexcept
try {
return reinterpret_cast<ffmpeg_instance*>(ptr)->video_encode_texture(handle, pts, lock_key, next_key, packet,
received_packet);
@ -318,7 +318,7 @@ try {
LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__);
}
static size_t _get_frame_size(void* ptr) noexcept
static std::size_t _get_frame_size(void* ptr) noexcept
try {
return reinterpret_cast<ffmpeg_instance*>(ptr)->get_frame_size();
} catch (const std::exception& ex) {
@ -530,13 +530,13 @@ void ffmpeg_factory::get_properties(obs_properties_t* props, bool hw_encode)
}
{
auto p = obs_properties_add_float(grp, KEY_KEYFRAMES_INTERVAL_SECONDS, D_TRANSLATE(ST_KEYFRAMES_INTERVAL),
0.00, std::numeric_limits<int16_t>::max(), 0.01);
0.00, std::numeric_limits<std::int16_t>::max(), 0.01);
obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_KEYFRAMES_INTERVAL)));
obs_property_float_set_suffix(p, " seconds");
}
{
auto p = obs_properties_add_int(grp, KEY_KEYFRAMES_INTERVAL_FRAMES, D_TRANSLATE(ST_KEYFRAMES_INTERVAL), 0,
std::numeric_limits<int32_t>::max(), 1);
std::numeric_limits<std::int32_t>::max(), 1);
obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_KEYFRAMES_INTERVAL)));
obs_property_int_set_suffix(p, " frames");
}
@ -558,7 +558,7 @@ void ffmpeg_factory::get_properties(obs_properties_t* props, bool hw_encode)
if (!hw_encode) {
{
auto p = obs_properties_add_int(grp, KEY_FFMPEG_GPU, D_TRANSLATE(ST_FFMPEG_GPU), -1,
std::numeric_limits<uint8_t>::max(), 1);
std::numeric_limits<std::uint8_t>::max(), 1);
obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_FFMPEG_GPU)));
}
if (avcodec_ptr->pix_fmts) {
@ -653,11 +653,13 @@ void ffmpeg_instance::initialize_sw(obs_data_t* settings)
_context->framerate.num = _context->time_base.den = static_cast<int>(voi->fps_num);
_context->framerate.den = _context->time_base.num = static_cast<int>(voi->fps_den);
_swscale.set_source_size(static_cast<uint32_t>(_context->width), static_cast<uint32_t>(_context->height));
_swscale.set_source_size(static_cast<std::uint32_t>(_context->width),
static_cast<std::uint32_t>(_context->height));
_swscale.set_source_color(_context->color_range == AVCOL_RANGE_JPEG, _context->colorspace);
_swscale.set_source_format(_pixfmt_source);
_swscale.set_target_size(static_cast<uint32_t>(_context->width), static_cast<uint32_t>(_context->height));
_swscale.set_target_size(static_cast<std::uint32_t>(_context->width),
static_cast<std::uint32_t>(_context->height));
_swscale.set_target_color(_context->color_range == AVCOL_RANGE_JPEG, _context->colorspace);
_swscale.set_target_format(_pixfmt_target);
@ -924,7 +926,7 @@ bool ffmpeg_instance::update(obs_data_t* settings)
{ // FFmpeg Custom Options
const char* opts = obs_data_get_string(settings, KEY_FFMPEG_CUSTOMSETTINGS);
size_t opts_len = strnlen(opts, 65535);
std::size_t opts_len = strnlen(opts, 65535);
parse_ffmpeg_commandline(std::string{opts, opts + opts_len});
}
@ -980,7 +982,7 @@ bool ffmpeg_instance::update(obs_data_t* settings)
void ffmpeg_instance::get_audio_info(audio_convert_info*) {}
size_t ffmpeg_instance::get_frame_size()
std::size_t ffmpeg_instance::get_frame_size()
{
return size_t();
}
@ -997,7 +999,7 @@ void ffmpeg_instance::get_video_info(video_scale_info* vsi)
vsi->format = ::ffmpeg::tools::avpixelformat_to_obs_videoformat(_swscale.get_source_format());
}
bool ffmpeg_instance::get_sei_data(uint8_t** data, size_t* size)
bool ffmpeg_instance::get_sei_data(std::uint8_t** data, size_t* size)
{
if (_sei_data.size() == 0)
return false;
@ -1007,7 +1009,7 @@ bool ffmpeg_instance::get_sei_data(uint8_t** data, size_t* size)
return true;
}
bool ffmpeg_instance::get_extra_data(uint8_t** data, size_t* size)
bool ffmpeg_instance::get_extra_data(std::uint8_t** data, size_t* size)
{
if (_extra_data.size() == 0)
return false;
@ -1022,23 +1024,23 @@ static inline void copy_data(encoder_frame* frame, AVFrame* vframe)
int h_chroma_shift, v_chroma_shift;
av_pix_fmt_get_chroma_sub_sample(static_cast<AVPixelFormat>(vframe->format), &h_chroma_shift, &v_chroma_shift);
for (size_t idx = 0; idx < MAX_AV_PLANES; idx++) {
for (std::size_t idx = 0; idx < MAX_AV_PLANES; idx++) {
if (!frame->data[idx] || !vframe->data[idx])
continue;
size_t plane_height = static_cast<size_t>(vframe->height) >> (idx ? v_chroma_shift : 0);
std::size_t plane_height = static_cast<size_t>(vframe->height) >> (idx ? v_chroma_shift : 0);
if (static_cast<uint32_t>(vframe->linesize[idx]) == frame->linesize[idx]) {
if (static_cast<std::uint32_t>(vframe->linesize[idx]) == frame->linesize[idx]) {
std::memcpy(vframe->data[idx], frame->data[idx], frame->linesize[idx] * plane_height);
} else {
size_t ls_in = static_cast<size_t>(frame->linesize[idx]);
size_t ls_out = static_cast<size_t>(vframe->linesize[idx]);
size_t bytes = ls_in < ls_out ? ls_in : ls_out;
std::size_t ls_in = static_cast<size_t>(frame->linesize[idx]);
std::size_t ls_out = static_cast<size_t>(vframe->linesize[idx]);
std::size_t bytes = ls_in < ls_out ? ls_in : ls_out;
uint8_t* to = vframe->data[idx];
uint8_t* from = frame->data[idx];
std::uint8_t* to = vframe->data[idx];
std::uint8_t* from = frame->data[idx];
for (size_t y = 0; y < plane_height; y++) {
for (std::size_t y = 0; y < plane_height; y++) {
std::memcpy(to, from, bytes);
to += ls_out;
from += ls_in;
@ -1067,8 +1069,8 @@ bool ffmpeg_instance::video_encode(encoder_frame* frame, encoder_packet* packet,
copy_data(frame, vframe.get());
} else {
int res =
_swscale.convert(reinterpret_cast<uint8_t**>(frame->data), reinterpret_cast<int*>(frame->linesize), 0,
_context->height, vframe->data, vframe->linesize);
_swscale.convert(reinterpret_cast<std::uint8_t**>(frame->data), reinterpret_cast<int*>(frame->linesize),
0, _context->height, vframe->data, vframe->linesize);
if (res <= 0) {
LOG_ERROR("Failed to convert frame: %s (%ld).", ::ffmpeg::tools::get_error_description(res), res);
return false;
@ -1082,8 +1084,8 @@ bool ffmpeg_instance::video_encode(encoder_frame* frame, encoder_packet* packet,
return true;
}
bool ffmpeg_instance::video_encode_texture(uint32_t handle, int64_t pts, uint64_t lock_key, uint64_t* next_lock_key,
encoder_packet* packet, bool* received_packet)
bool ffmpeg_instance::video_encode_texture(std::uint32_t handle, std::int64_t pts, std::uint64_t lock_key,
std::uint64_t* next_lock_key, encoder_packet* packet, bool* received_packet)
{
if (handle == GS_INVALID_HANDLE) {
LOG_ERROR("Received invalid handle.");
@ -1124,10 +1126,10 @@ int ffmpeg_instance::receive_packet(bool* received_packet, struct encoder_packet
if (!_have_first_frame) {
if (_codec->id == AV_CODEC_ID_H264) {
uint8_t* tmp_packet;
uint8_t* tmp_header;
uint8_t* tmp_sei;
size_t sz_packet, sz_header, sz_sei;
std::uint8_t* tmp_packet;
std::uint8_t* tmp_header;
std::uint8_t* tmp_sei;
std::size_t sz_packet, sz_header, sz_sei;
obs_extract_avc_headers(_current_packet.data, static_cast<size_t>(_current_packet.size), &tmp_packet,
&sz_packet, &tmp_header, &sz_header, &tmp_sei, &sz_sei);
@ -1294,11 +1296,11 @@ void ffmpeg_instance::parse_ffmpeg_commandline(std::string text)
std::list<std::string> opts;
std::stringstream opt_stream{std::ios_base::in | std::ios_base::out | std::ios_base::binary};
std::stack<char> quote_stack;
for (size_t p = 0; p <= text.size(); p++) {
for (std::size_t p = 0; p <= text.size(); p++) {
char here = p < text.size() ? text.at(p) : 0;
if (here == '\\') {
size_t p2 = p + 1;
std::size_t p2 = p + 1;
if (p2 < text.size()) {
char here2 = text.at(p2);
if (isdigit(here2)) { // Octal

View File

@ -133,13 +133,13 @@ namespace encoder::ffmpeg {
::ffmpeg::swscale _swscale;
AVPacket _current_packet;
size_t _lag_in_frames;
size_t _count_send_frames;
std::size_t _lag_in_frames;
std::size_t _count_send_frames;
// Extra Data
bool _have_first_frame;
std::vector<uint8_t> _extra_data;
std::vector<uint8_t> _sei_data;
bool _have_first_frame;
std::vector<std::uint8_t> _extra_data;
std::vector<std::uint8_t> _sei_data;
// Frame Stack and Queue
std::stack<std::shared_ptr<AVFrame>> _free_frames;
@ -168,21 +168,21 @@ namespace encoder::ffmpeg {
// Audio only
void get_audio_info(struct audio_convert_info* info);
size_t get_frame_size();
std::size_t get_frame_size();
bool audio_encode(struct encoder_frame* frame, struct encoder_packet* packet, bool* received_packet);
// Video only
void get_video_info(struct video_scale_info* info);
bool get_sei_data(uint8_t** sei_data, size_t* size);
bool get_sei_data(std::uint8_t** sei_data, size_t* size);
bool get_extra_data(uint8_t** extra_data, size_t* size);
bool get_extra_data(std::uint8_t** extra_data, size_t* size);
bool video_encode(struct encoder_frame* frame, struct encoder_packet* packet, bool* received_packet);
bool video_encode_texture(uint32_t handle, int64_t pts, uint64_t lock_key, uint64_t* next_key,
struct encoder_packet* packet, bool* received_packet);
bool video_encode_texture(std::uint32_t handle, std::int64_t pts, std::uint64_t lock_key,
std::uint64_t* next_key, struct encoder_packet* packet, bool* received_packet);
int receive_packet(bool* received_packet, struct encoder_packet* packet);

View File

@ -335,7 +335,7 @@ void nvenc::get_properties_post(obs_properties_t* props, const AVCodec* codec)
{
auto p = obs_properties_add_int(grp, KEY_RATECONTROL_BUFFERSIZE, D_TRANSLATE(ST_RATECONTROL_BUFFERSIZE), 0,
std::numeric_limits<int32_t>::max(), 1);
std::numeric_limits<std::int32_t>::max(), 1);
obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_RATECONTROL_BUFFERSIZE)));
obs_property_int_set_suffix(p, " kbit");
}
@ -352,13 +352,13 @@ void nvenc::get_properties_post(obs_properties_t* props, const AVCodec* codec)
{
auto p =
obs_properties_add_int(grp, KEY_RATECONTROL_BITRATE_TARGET, D_TRANSLATE(ST_RATECONTROL_BITRATE_TARGET),
-1, std::numeric_limits<int32_t>::max(), 1);
-1, std::numeric_limits<std::int32_t>::max(), 1);
obs_property_int_set_suffix(p, " kbit/s");
}
{
auto p = obs_properties_add_int(grp, KEY_RATECONTROL_BITRATE_MAXIMUM,
D_TRANSLATE(ST_RATECONTROL_BITRATE_MAXIMUM), -1,
std::numeric_limits<int32_t>::max(), 1);
std::numeric_limits<std::int32_t>::max(), 1);
obs_property_int_set_suffix(p, " kbit/s");
}
}
@ -453,7 +453,7 @@ void nvenc::get_properties_post(obs_properties_t* props, const AVCodec* codec)
obs_properties_add_list(grp, KEY_OTHER_BFRAMEREFERENCEMODE, D_TRANSLATE(ST_OTHER_BFRAMEREFERENCEMODE),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
for (auto kv : b_ref_modes) {
obs_property_list_add_int(p, D_TRANSLATE(kv.second.c_str()), static_cast<int64_t>(kv.first));
obs_property_list_add_int(p, D_TRANSLATE(kv.second.c_str()), static_cast<std::int64_t>(kv.first));
}
}

View File

@ -49,24 +49,24 @@ avframe_queue::~avframe_queue()
clear();
}
void avframe_queue::set_resolution(uint32_t const width, uint32_t const height)
void avframe_queue::set_resolution(std::int32_t const width, std::int32_t const height)
{
this->_resolution.first = width;
this->_resolution.second = height;
}
void avframe_queue::get_resolution(uint32_t& width, uint32_t& height)
void avframe_queue::get_resolution(std::int32_t& width, std::int32_t& height)
{
width = this->_resolution.first;
height = this->_resolution.second;
}
uint32_t avframe_queue::get_width()
std::int32_t avframe_queue::get_width()
{
return this->_resolution.first;
}
uint32_t avframe_queue::get_height()
std::int32_t avframe_queue::get_height()
{
return this->_resolution.second;
}
@ -81,9 +81,9 @@ AVPixelFormat avframe_queue::get_pixel_format()
return this->_format;
}
void avframe_queue::precache(size_t count)
void avframe_queue::precache(std::size_t count)
{
for (size_t n = 0; n < count; n++) {
for (std::size_t n = 0; n < count; n++) {
push(create_frame());
}
}
@ -113,8 +113,8 @@ std::shared_ptr<AVFrame> avframe_queue::pop()
ret = create_frame();
} else {
_frames.pop_front();
if ((static_cast<uint32_t>(ret->width) != this->_resolution.first)
|| (static_cast<uint32_t>(ret->height) != this->_resolution.second)
if ((static_cast<std::int32_t>(ret->width) != this->_resolution.first)
|| (static_cast<std::int32_t>(ret->height) != this->_resolution.second)
|| (ret->format != this->_format)) {
ret = nullptr;
}
@ -143,7 +143,7 @@ bool avframe_queue::empty()
return _frames.empty();
}
size_t avframe_queue::size()
std::size_t avframe_queue::size()
{
return _frames.size();
}

View File

@ -40,8 +40,8 @@ namespace ffmpeg {
std::deque<std::shared_ptr<AVFrame>> _frames;
std::mutex _lock;
std::pair<uint32_t, uint32_t> _resolution;
AVPixelFormat _format = AV_PIX_FMT_NONE;
std::pair<std::int32_t, std::int32_t> _resolution;
AVPixelFormat _format = AV_PIX_FMT_NONE;
std::shared_ptr<AVFrame> create_frame();
@ -49,15 +49,15 @@ namespace ffmpeg {
avframe_queue();
~avframe_queue();
void set_resolution(uint32_t width, uint32_t height);
void get_resolution(uint32_t& width, uint32_t& height);
uint32_t get_width();
uint32_t get_height();
void set_resolution(std::int32_t width, std::int32_t height);
void get_resolution(std::int32_t& width, std::int32_t& height);
std::int32_t get_width();
std::int32_t get_height();
void set_pixel_format(AVPixelFormat format);
AVPixelFormat get_pixel_format();
void precache(size_t count);
void precache(std::size_t count);
void clear();
@ -69,6 +69,6 @@ namespace ffmpeg {
bool empty();
size_t size();
std::size_t size();
};
} // namespace ffmpeg

View File

@ -50,10 +50,10 @@ namespace ffmpeg::hwapi {
virtual std::shared_ptr<AVFrame> allocate_frame(AVBufferRef* frames) = 0;
virtual void copy_from_obs(AVBufferRef* frames, uint32_t handle, uint64_t lock_key, uint64_t* next_lock_key,
std::shared_ptr<AVFrame> frame) = 0;
virtual void copy_from_obs(AVBufferRef* frames, std::uint32_t handle, uint64_t lock_key,
uint64_t* next_lock_key, std::shared_ptr<AVFrame> frame) = 0;
virtual std::shared_ptr<AVFrame> avframe_from_obs(AVBufferRef* frames, uint32_t handle, uint64_t lock_key,
virtual std::shared_ptr<AVFrame> avframe_from_obs(AVBufferRef* frames, std::uint32_t handle, uint64_t lock_key,
uint64_t* next_lock_key) = 0;
};

View File

@ -88,8 +88,8 @@ std::list<device> d3d11::enumerate_adapters()
dxgi_adapter->GetDesc1(&desc);
std::vector<char> buf(1024);
size_t len = snprintf(buf.data(), buf.size(), "%ls (VEN_%04x/DEV_%04x/SUB_%04x/REV_%04x)", desc.Description,
desc.VendorId, desc.DeviceId, desc.SubSysId, desc.Revision);
std::size_t len = snprintf(buf.data(), buf.size(), "%ls (VEN_%04x/DEV_%04x/SUB_%04x/REV_%04x)",
desc.Description, desc.VendorId, desc.DeviceId, desc.SubSysId, desc.Revision);
device dev;
dev.name = std::string(buf.data(), buf.data() + len);
@ -203,7 +203,7 @@ std::shared_ptr<AVFrame> d3d11_instance::allocate_frame(AVBufferRef* frames)
return frame;
}
void d3d11_instance::copy_from_obs(AVBufferRef*, uint32_t handle, uint64_t lock_key, uint64_t* next_lock_key,
void d3d11_instance::copy_from_obs(AVBufferRef*, std::uint32_t handle, uint64_t lock_key, uint64_t* next_lock_key,
std::shared_ptr<AVFrame> frame)
{
auto gctx = gs::context();
@ -242,7 +242,7 @@ void d3d11_instance::copy_from_obs(AVBufferRef*, uint32_t handle, uint64_t lock_
mutex->ReleaseSync(*next_lock_key);
}
std::shared_ptr<AVFrame> d3d11_instance::avframe_from_obs(AVBufferRef* frames, uint32_t handle, uint64_t lock_key,
std::shared_ptr<AVFrame> d3d11_instance::avframe_from_obs(AVBufferRef* frames, std::uint32_t handle, uint64_t lock_key,
uint64_t* next_lock_key)
{
auto gctx = gs::context();

View File

@ -79,10 +79,10 @@ namespace ffmpeg::hwapi {
virtual std::shared_ptr<AVFrame> allocate_frame(AVBufferRef* frames) override;
virtual void copy_from_obs(AVBufferRef* frames, uint32_t handle, uint64_t lock_key, uint64_t* next_lock_key,
std::shared_ptr<AVFrame> frame) override;
virtual void copy_from_obs(AVBufferRef* frames, std::uint32_t handle, uint64_t lock_key,
uint64_t* next_lock_key, std::shared_ptr<AVFrame> frame) override;
virtual std::shared_ptr<AVFrame> avframe_from_obs(AVBufferRef* frames, uint32_t handle, uint64_t lock_key,
virtual std::shared_ptr<AVFrame> avframe_from_obs(AVBufferRef* frames, std::uint32_t handle, uint64_t lock_key,
uint64_t* next_lock_key) override;
};
} // namespace ffmpeg::hwapi

View File

@ -31,7 +31,7 @@ swscale::~swscale()
finalize();
}
void swscale::set_source_size(uint32_t width, uint32_t height)
void swscale::set_source_size(std::uint32_t width, std::uint32_t height)
{
source_size.first = width;
source_size.second = height;
@ -48,12 +48,12 @@ std::pair<uint32_t, uint32_t> swscale::get_source_size()
return this->source_size;
}
uint32_t swscale::get_source_width()
std::uint32_t swscale::get_source_width()
{
return this->source_size.first;
}
uint32_t swscale::get_source_height()
std::uint32_t swscale::get_source_height()
{
return this->source_size.second;
}
@ -94,7 +94,7 @@ bool swscale::is_source_full_range()
return this->source_full_range;
}
void swscale::set_target_size(uint32_t width, uint32_t height)
void swscale::set_target_size(std::uint32_t width, std::uint32_t height)
{
target_size.first = width;
target_size.second = height;
@ -111,12 +111,12 @@ std::pair<uint32_t, uint32_t> swscale::get_target_size()
return this->target_size;
}
uint32_t swscale::get_target_width()
std::uint32_t swscale::get_target_width()
{
return this->target_size.first;
}
uint32_t swscale::get_target_height()
std::uint32_t swscale::get_target_height()
{
return this->target_size.second;
}
@ -194,8 +194,8 @@ bool swscale::finalize()
return false;
}
int32_t swscale::convert(const uint8_t* const source_data[], const int source_stride[], int32_t source_row,
int32_t source_rows, uint8_t* const target_data[], const int target_stride[])
int32_t swscale::convert(const std::uint8_t* const source_data[], const int source_stride[], int32_t source_row,
int32_t source_rows, std::uint8_t* const target_data[], const int target_stride[])
{
if (!this->context) {
return 0;

View File

@ -53,11 +53,11 @@ namespace ffmpeg {
swscale();
~swscale();
void set_source_size(uint32_t width, uint32_t height);
void set_source_size(std::uint32_t width, std::uint32_t height);
void get_source_size(uint32_t& width, uint32_t& height);
std::pair<uint32_t, uint32_t> get_source_size();
uint32_t get_source_width();
uint32_t get_source_height();
std::uint32_t get_source_width();
std::uint32_t get_source_height();
void set_source_format(AVPixelFormat format);
AVPixelFormat get_source_format();
void set_source_color(bool full_range, AVColorSpace space);
@ -66,11 +66,11 @@ namespace ffmpeg {
void set_source_full_range(bool full_range);
bool is_source_full_range();
void set_target_size(uint32_t width, uint32_t height);
void set_target_size(std::uint32_t width, std::uint32_t height);
void get_target_size(uint32_t& width, uint32_t& height);
std::pair<uint32_t, uint32_t> get_target_size();
uint32_t get_target_width();
uint32_t get_target_height();
std::uint32_t get_target_width();
std::uint32_t get_target_height();
void set_target_format(AVPixelFormat format);
AVPixelFormat get_target_format();
void set_target_color(bool full_range, AVColorSpace space);
@ -82,7 +82,7 @@ namespace ffmpeg {
bool initialize(int flags);
bool finalize();
int32_t convert(const uint8_t* const source_data[], const int source_stride[], int32_t source_row,
int32_t source_rows, uint8_t* const target_data[], const int target_stride[]);
int32_t convert(const std::uint8_t* const source_data[], const int source_stride[], int32_t source_row,
int32_t source_rows, std::uint8_t* const target_data[], const int target_stride[]);
};
} // namespace ffmpeg

View File

@ -295,12 +295,12 @@ void blur::blur_instance::update(obs_data_t* settings)
break;
}
if ((_mask.type == mask_type::Image) || (_mask.type == mask_type::Source)) {
uint32_t color = static_cast<uint32_t>(obs_data_get_int(settings, ST_MASK_COLOR));
_mask.color.r = ((color >> 0) & 0xFF) / 255.0f;
_mask.color.g = ((color >> 8) & 0xFF) / 255.0f;
_mask.color.b = ((color >> 16) & 0xFF) / 255.0f;
_mask.color.a = static_cast<float_t>(obs_data_get_double(settings, ST_MASK_ALPHA));
_mask.multiplier = float_t(obs_data_get_double(settings, ST_MASK_MULTIPLIER));
std::uint32_t color = static_cast<uint32_t>(obs_data_get_int(settings, ST_MASK_COLOR));
_mask.color.r = ((color >> 0) & 0xFF) / 255.0f;
_mask.color.g = ((color >> 8) & 0xFF) / 255.0f;
_mask.color.b = ((color >> 16) & 0xFF) / 255.0f;
_mask.color.a = static_cast<float_t>(obs_data_get_double(settings, ST_MASK_ALPHA));
_mask.multiplier = float_t(obs_data_get_double(settings, ST_MASK_MULTIPLIER));
}
}
}
@ -360,9 +360,8 @@ void blur::blur_instance::video_render(gs_effect_t* effect)
obs_source_t* parent = obs_filter_get_parent(this->_self);
obs_source_t* target = obs_filter_get_target(this->_self);
gs_effect_t* defaultEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT);
uint32_t baseW = obs_source_get_base_width(target);
uint32_t baseH = obs_source_get_base_height(target);
vec4 black = {};
std::uint32_t baseW = obs_source_get_base_width(target);
std::uint32_t baseH = obs_source_get_base_height(target);
// Verify that we can actually run first.
if (!target || !parent || !this->_self || !this->_blur || (baseW == 0) || (baseH == 0)) {
@ -460,8 +459,8 @@ void blur::blur_instance::video_render(gs_effect_t* effect)
}
if (_mask.source.source_texture) {
uint32_t source_width = obs_source_get_width(this->_mask.source.source_texture->get_object());
uint32_t source_height = obs_source_get_height(this->_mask.source.source_texture->get_object());
std::uint32_t source_width = obs_source_get_width(this->_mask.source.source_texture->get_object());
std::uint32_t source_height = obs_source_get_height(this->_mask.source.source_texture->get_object());
if (source_width == 0) {
source_width = baseW;
@ -611,8 +610,8 @@ try {
obs_property_t* prop_subtype = obs_properties_get(props, ST_SUBTYPE);
/// Disable unsupported items.
size_t subvalue_idx = 0;
for (size_t idx = 0, edx = obs_property_list_item_count(prop_subtype); idx < edx; idx++) {
std::size_t subvalue_idx = 0;
for (std::size_t idx = 0, edx = obs_property_list_item_count(prop_subtype); idx < edx; idx++) {
const char* subtype = obs_property_list_item_string(prop_subtype, idx);
bool disabled = false;
@ -631,7 +630,7 @@ try {
/// Ensure that there is a valid item selected.
if (obs_property_list_item_disabled(prop_subtype, subvalue_idx)) {
for (size_t idx = 0, edx = obs_property_list_item_count(prop_subtype); idx < edx; idx++) {
for (std::size_t idx = 0, edx = obs_property_list_item_count(prop_subtype); idx < edx; idx++) {
if (!obs_property_list_item_disabled(prop_subtype, idx)) {
obs_data_set_string(settings, ST_SUBTYPE, obs_property_list_item_string(prop_subtype, idx));
@ -876,7 +875,7 @@ std::string blur::blur_factory::translate_string(const char* format, ...)
va_list vargs;
va_start(vargs, format);
std::vector<char> buffer(2048);
size_t len = static_cast<size_t>(vsnprintf(buffer.data(), buffer.size(), format, vargs));
std::size_t len = static_cast<size_t>(vsnprintf(buffer.data(), buffer.size(), format, vargs));
va_end(vargs);
return std::string(buffer.data(), buffer.data() + len);
}

View File

@ -103,7 +103,7 @@ namespace filter::blur {
virtual void migrate(obs_data_t* settings, std::uint64_t version) override;
virtual void update(obs_data_t* settings) override;
virtual void video_tick(float time) override;
virtual void video_tick(float_t time) override;
virtual void video_render(gs_effect_t* effect) override;
private:

View File

@ -177,8 +177,8 @@ void color_grade::color_grade_instance::video_render(gs_effect_t* effect)
// Grab initial values.
obs_source_t* parent = obs_filter_get_parent(_self);
obs_source_t* target = obs_filter_get_target(_self);
uint32_t width = obs_source_get_base_width(target);
uint32_t height = obs_source_get_base_height(target);
std::uint32_t width = obs_source_get_base_width(target);
std::uint32_t height = obs_source_get_base_height(target);
gs_effect_t* effect_default = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT);
// Skip filter if anything is wrong.

View File

@ -75,7 +75,7 @@ namespace filter::color_grade {
virtual void migrate(obs_data_t* data, std::uint64_t version) override;
virtual void update(obs_data_t* data) override;
virtual void video_tick(float time) override;
virtual void video_tick(float_t time) override;
virtual void video_render(gs_effect_t* effect) override;
};

View File

@ -33,8 +33,8 @@ namespace filter::displacement {
float_t _scale_type;
// Cache
uint32_t _width;
uint32_t _height;
std::uint32_t _width;
std::uint32_t _height;
public:
displacement_instance(obs_data_t*, obs_source_t*);

View File

@ -219,8 +219,8 @@ void dynamic_mask::dynamic_mask_instance::video_render(gs_effect_t* in_effect)
{
obs_source_t* parent = obs_filter_get_parent(_self);
obs_source_t* target = obs_filter_get_target(_self);
uint32_t width = obs_source_get_base_width(target);
uint32_t height = obs_source_get_base_height(target);
std::uint32_t width = obs_source_get_base_width(target);
std::uint32_t height = obs_source_get_base_height(target);
if (!_self || !parent || !target || !width || !height || !_input || !_input_capture || !_effect) {
obs_source_skip_video_filter(_self);
@ -455,7 +455,7 @@ std::string dynamic_mask::dynamic_mask_factory::translate_string(const char* for
va_list vargs;
va_start(vargs, format);
std::vector<char> buffer(2048);
size_t len = static_cast<size_t>(vsnprintf(buffer.data(), buffer.size(), format, vargs));
std::size_t len = static_cast<size_t>(vsnprintf(buffer.data(), buffer.size(), format, vargs));
va_end(vargs);
return std::string(buffer.data(), buffer.data() + len);
}

View File

@ -28,7 +28,7 @@
#include "obs/obs-source.hpp"
namespace filter::dynamic_mask {
enum class channel : int8_t { Invalid = -1, Red, Green, Blue, Alpha };
enum class channel : std::int8_t { Invalid = -1, Red, Green, Blue, Alpha };
class dynamic_mask_instance : public obs::source_instance {
std::map<std::tuple<channel, channel, std::string>, std::string> _translation_map;
@ -51,7 +51,7 @@ namespace filter::dynamic_mask {
struct channel_data {
float_t value = 0.0;
float_t scale = 1.0;
vec4 values = {0};
vec4 values = {0, 0, 0, 0};
};
std::map<channel, channel_data> _channels;
@ -75,7 +75,7 @@ namespace filter::dynamic_mask {
static bool modified(void* self, obs_properties_t* properties, obs_property_t* property,
obs_data_t* settings) noexcept;
void video_tick(float _time);
void video_tick(float_t _time);
void video_render(gs_effect_t* effect);
};

View File

@ -153,8 +153,8 @@ void filter::nvidia::face_tracking_instance::create_image_buffer(std::size_t wid
auto cctx = std::make_shared<::nvidia::cuda::context_stack>(_cuda, _cuda_ctx);
// Create CUDA and AR interop.
size_t pitch = width * 4;
_cuda_mem = std::make_shared<::nvidia::cuda::memory>(_cuda, pitch * height);
std::size_t pitch = width * 4;
_cuda_mem = std::make_shared<::nvidia::cuda::memory>(_cuda, pitch * height);
_ar->image_init(&_ar_image, static_cast<unsigned int>(width), static_cast<unsigned int>(height),
static_cast<int>(pitch), reinterpret_cast<void*>(_cuda_mem->get()), NVCV_RGBA, NVCV_U8,
NVCV_INTERLEAVED, NVCV_CUDA);
@ -208,14 +208,14 @@ void filter::nvidia::face_tracking_instance::update(obs_data_t* data)
roi_refresh();
}
void filter::nvidia::face_tracking_instance::video_tick(float seconds)
void filter::nvidia::face_tracking_instance::video_tick(float_t seconds)
{
if (!_ar_ready)
return;
// Update Buffers
uint32_t width = obs_source_get_base_width(obs_filter_get_target(_self));
uint32_t height = obs_source_get_base_height(obs_filter_get_target(_self));
std::uint32_t width = obs_source_get_base_width(obs_filter_get_target(_self));
std::uint32_t height = obs_source_get_base_height(obs_filter_get_target(_self));
if (((width != _width) || (height != _height)) && width && height)
try {
// Recreate things.
@ -550,7 +550,7 @@ obs_properties_t* filter::nvidia::face_tracking_factory::get_properties2(filter:
}
#ifdef _DEBUG
{
auto p = obs_properties_add_button2(
obs_properties_add_button2(
pr, "Profile", "Profile",
[](obs_properties_t* props, obs_property_t* property, void* data) {
return reinterpret_cast<filter::nvidia::face_tracking_instance*>(data)->button_profile(props, property);

View File

@ -105,7 +105,7 @@ namespace filter::nvidia {
virtual void update(obs_data_t* data) override;
virtual void video_tick(float seconds) override;
virtual void video_tick(float_t seconds) override;
virtual void video_render(gs_effect_t* effect) override;

View File

@ -81,7 +81,7 @@ sdf_effects::sdf_effects_instance::sdf_effects_instance(obs_data_t* settings, ob
{
{
auto gctx = gs::context();
vec4 transparent = {0};
vec4 transparent = {0, 0, 0, 0};
_source_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
_sdf_write = std::make_shared<gs::rendertarget>(GS_RGBA32F, GS_ZS_NONE);
@ -134,12 +134,12 @@ void sdf_effects::sdf_effects_instance::update(obs_data_t* data)
&& (obs_data_get_double(data, ST_SHADOW_OUTER_ALPHA) >= std::numeric_limits<double_t>::epsilon());
{
struct cs {
uint8_t r, g, b, a;
std::uint8_t r, g, b, a;
};
union {
uint32_t color;
uint8_t channel[4];
cs c;
std::uint32_t color;
std::uint8_t channel[4];
cs c;
};
color = uint32_t(obs_data_get_int(data, ST_SHADOW_OUTER_COLOR));
_outer_shadow_color.x = float_t(c.r / 255.0);
@ -159,12 +159,12 @@ void sdf_effects::sdf_effects_instance::update(obs_data_t* data)
&& (obs_data_get_double(data, ST_SHADOW_INNER_ALPHA) >= std::numeric_limits<double_t>::epsilon());
{
struct cs {
uint8_t r, g, b, a;
std::uint8_t r, g, b, a;
};
union {
uint32_t color;
uint8_t channel[4];
cs c;
std::uint32_t color;
std::uint8_t channel[4];
cs c;
};
color = uint32_t(obs_data_get_int(data, ST_SHADOW_INNER_COLOR));
_inner_shadow_color.x = float_t(c.r / 255.0);
@ -183,12 +183,12 @@ void sdf_effects::sdf_effects_instance::update(obs_data_t* data)
&& (obs_data_get_double(data, ST_GLOW_OUTER_ALPHA) >= std::numeric_limits<double_t>::epsilon());
{
struct cs {
uint8_t r, g, b, a;
std::uint8_t r, g, b, a;
};
union {
uint32_t color;
uint8_t channel[4];
cs c;
std::uint32_t color;
std::uint8_t channel[4];
cs c;
};
color = uint32_t(obs_data_get_int(data, ST_GLOW_OUTER_COLOR));
_outer_glow_color.x = float_t(c.r / 255.0);
@ -209,12 +209,12 @@ void sdf_effects::sdf_effects_instance::update(obs_data_t* data)
&& (obs_data_get_double(data, ST_GLOW_INNER_ALPHA) >= std::numeric_limits<double_t>::epsilon());
{
struct cs {
uint8_t r, g, b, a;
std::uint8_t r, g, b, a;
};
union {
uint32_t color;
uint8_t channel[4];
cs c;
std::uint32_t color;
std::uint8_t channel[4];
cs c;
};
color = uint32_t(obs_data_get_int(data, ST_GLOW_INNER_COLOR));
_inner_glow_color.x = float_t(c.r / 255.0);
@ -235,12 +235,12 @@ void sdf_effects::sdf_effects_instance::update(obs_data_t* data)
&& (obs_data_get_double(data, ST_OUTLINE_ALPHA) >= std::numeric_limits<double_t>::epsilon());
{
struct cs {
uint8_t r, g, b, a;
std::uint8_t r, g, b, a;
};
union {
uint32_t color;
uint8_t channel[4];
cs c;
std::uint32_t color;
std::uint8_t channel[4];
cs c;
};
color = uint32_t(obs_data_get_int(data, ST_OUTLINE_COLOR));
_outline_color.x = float_t(c.r / 255.0);
@ -263,31 +263,18 @@ void sdf_effects::sdf_effects_instance::update(obs_data_t* data)
void sdf_effects::sdf_effects_instance::video_tick(float)
{
uint32_t width = 1;
uint32_t height = 1;
// Figure out the actual source size.
do {
obs_source_t* target = obs_filter_get_target(_self);
if (target == nullptr) {
break;
}
// Grab width an height of the target source (child filter or source).
width = obs_source_get_width(target);
height = obs_source_get_height(target);
} while (false);
_source_rendered = false;
_output_rendered = false;
if (obs_source_t* target = obs_filter_get_target(_self); target != nullptr) {
_source_rendered = false;
_output_rendered = false;
}
}
void sdf_effects::sdf_effects_instance::video_render(gs_effect_t* effect)
{
obs_source_t* parent = obs_filter_get_parent(_self);
obs_source_t* target = obs_filter_get_target(_self);
uint32_t baseW = obs_source_get_base_width(target);
uint32_t baseH = obs_source_get_base_height(target);
std::uint32_t baseW = obs_source_get_base_width(target);
std::uint32_t baseH = obs_source_get_base_height(target);
gs_effect_t* final_effect = effect ? effect : obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT);
gs_effect_t* default_effect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT);
@ -297,8 +284,7 @@ void sdf_effects::sdf_effects_instance::video_render(gs_effect_t* effect)
}
auto gctx = gs::context();
vec4 color_transparent = {0};
vec4_zero(&color_transparent);
vec4 color_transparent = {0, 0, 0, 0};
try {
gs_blend_state_push();
@ -582,8 +568,10 @@ try {
return true;
} catch (const std::exception& ex) {
LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what());
return true;
} catch (...) {
LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__);
return true;
}
bool cb_modified_shadow_outside(void*, obs_properties_t* props, obs_property*, obs_data_t* settings) noexcept
@ -598,8 +586,10 @@ try {
return true;
} catch (const std::exception& ex) {
LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what());
return true;
} catch (...) {
LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__);
return true;
}
bool cb_modified_glow_inside(void*, obs_properties_t* props, obs_property*, obs_data_t* settings) noexcept
@ -612,8 +602,10 @@ try {
return true;
} catch (const std::exception& ex) {
LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what());
return true;
} catch (...) {
LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__);
return true;
}
bool cb_modified_glow_outside(void*, obs_properties_t* props, obs_property*, obs_data_t* settings) noexcept
@ -626,8 +618,10 @@ try {
return true;
} catch (const std::exception& ex) {
LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what());
return true;
} catch (...) {
LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__);
return true;
}
bool cb_modified_outline(void*, obs_properties_t* props, obs_property*, obs_data_t* settings) noexcept
@ -641,8 +635,10 @@ try {
return true;
} catch (const std::exception& ex) {
LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what());
return true;
} catch (...) {
LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__);
return true;
}
bool cb_modified_advanced(void*, obs_properties_t* props, obs_property*, obs_data_t* settings) noexcept
@ -653,8 +649,10 @@ try {
return true;
} catch (const std::exception& ex) {
LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what());
return true;
} catch (...) {
LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__);
return true;
}
obs_properties_t* sdf_effects::sdf_effects_factory::get_properties2(sdf_effects::sdf_effects_instance* data)

View File

@ -35,12 +35,12 @@ filter::shader::shader_instance::shader_instance(obs_data_t* data, obs_source_t*
filter::shader::shader_instance::~shader_instance() {}
uint32_t filter::shader::shader_instance::get_width()
std::uint32_t filter::shader::shader_instance::get_width()
{
return _fx->width();
}
uint32_t filter::shader::shader_instance::get_height()
std::uint32_t filter::shader::shader_instance::get_height()
{
return _fx->height();
}
@ -90,7 +90,7 @@ void filter::shader::shader_instance::video_render(gs_effect_t* effect)
gs_ortho(0, static_cast<float_t>(_fx->width()), 0, static_cast<float_t>(_fx->height()), -1, 1);
vec4 clear_color = {0};
vec4 clear_color = {0, 0, 0, 0};
gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &clear_color, 0, 0);
/// Render original source

View File

@ -32,8 +32,8 @@ namespace filter::shader {
shader_instance(obs_data_t* data, obs_source_t* self);
virtual ~shader_instance();
virtual uint32_t get_width() override;
virtual uint32_t get_height() override;
virtual std::uint32_t get_width() override;
virtual std::uint32_t get_height() override;
void properties(obs_properties_t* props);

View File

@ -66,8 +66,8 @@
using namespace filter;
static const float farZ = 2097152.0f; // 2 pow 21
static const float nearZ = 1.0f / farZ;
static const float_t farZ = 2097152.0f; // 2 pow 21
static const float_t nearZ = 1.0f / farZ;
enum class CameraMode : int64_t { Orthographic, Perspective };
@ -87,7 +87,7 @@ transform::transform_instance::transform_instance(obs_data_t* data, obs_source_t
{
_cache_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
_source_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
_vertex_buffer = std::make_shared<gs::vertex_buffer>(uint32_t(4u), uint8_t(1u));
_vertex_buffer = std::make_shared<gs::vertex_buffer>(uint32_t(4u), std::uint8_t(1u));
_position = std::make_unique<util::vec3a>();
_rotation = std::make_unique<util::vec3a>();
@ -158,8 +158,8 @@ void transform::transform_instance::update(obs_data_t* settings)
void transform::transform_instance::video_tick(float)
{
uint32_t width = 0;
uint32_t height = 0;
std::uint32_t width = 0;
std::uint32_t height = 0;
// Grab parent and target.
obs_source_t* target = obs_filter_get_target(_self);
@ -278,8 +278,8 @@ void transform::transform_instance::video_render(gs_effect_t* effect)
{
obs_source_t* parent = obs_filter_get_parent(_self);
obs_source_t* target = obs_filter_get_target(_self);
uint32_t base_width = obs_source_get_base_width(target);
uint32_t base_height = obs_source_get_base_height(target);
std::uint32_t base_width = obs_source_get_base_width(target);
std::uint32_t base_height = obs_source_get_base_height(target);
gs_effect_t* default_effect = obs_get_base_effect(OBS_EFFECT_DEFAULT);
if (!effect)
effect = default_effect;
@ -291,8 +291,8 @@ void transform::transform_instance::video_render(gs_effect_t* effect)
gs::debug_marker marker{gs::debug_color_source, "3D Transform: %s", obs_source_get_name(_self)};
uint32_t cache_width = base_width;
uint32_t cache_height = base_height;
std::uint32_t cache_width = base_width;
std::uint32_t cache_height = base_height;
if (_mipmap_enabled) {
double_t aspect = double_t(base_width) / double_t(base_height);
@ -318,7 +318,7 @@ void transform::transform_instance::video_render(gs_effect_t* effect)
gs_ortho(0, static_cast<float_t>(base_width), 0, static_cast<float_t>(base_height), -1, 1);
vec4 clear_color = {0};
vec4 clear_color = {0, 0, 0, 0};
gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &clear_color, 0, 0);
/// Render original source
@ -354,8 +354,8 @@ void transform::transform_instance::video_render(gs_effect_t* effect)
if (!_mipmap_texture || (_mipmap_texture->get_width() != cache_width)
|| (_mipmap_texture->get_height() != cache_height)) {
size_t mip_levels = std::max(util::math::get_power_of_two_exponent_ceil(cache_width),
util::math::get_power_of_two_exponent_ceil(cache_height));
std::size_t mip_levels = std::max(util::math::get_power_of_two_exponent_ceil(cache_width),
util::math::get_power_of_two_exponent_ceil(cache_height));
_mipmap_texture = std::make_shared<gs::texture>(cache_width, cache_height, GS_RGBA, mip_levels, nullptr,
gs::texture::flags::None);
@ -394,7 +394,7 @@ void transform::transform_instance::video_render(gs_effect_t* effect)
gs_matrix_translate3f(0., 0., -1.0);
}
vec4 clear_color = {0};
vec4 clear_color = {0, 0, 0, 0};
gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &clear_color, 0, 0);
gs_load_vertexbuffer(_vertex_buffer->update(false));
@ -483,8 +483,10 @@ try {
return true;
} catch (const std::exception& ex) {
LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what());
return true;
} catch (...) {
LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__);
return true;
}
obs_properties_t* transform::transform_factory::get_properties2(transform::transform_instance* data)

View File

@ -50,7 +50,7 @@ namespace filter::transform {
// Mesh
bool _update_mesh;
std::shared_ptr<gs::vertex_buffer> _vertex_buffer;
uint32_t _rotation_order;
std::uint32_t _rotation_order;
std::unique_ptr<util::vec3a> _position;
std::unique_ptr<util::vec3a> _rotation;
std::unique_ptr<util::vec3a> _scale;

View File

@ -185,7 +185,7 @@ gfx::blur::dual_filtering::dual_filtering()
{
auto gctx = gs::context();
_rendertargets.resize(MAX_LEVELS + 1);
for (size_t n = 0; n <= MAX_LEVELS; n++) {
for (std::size_t n = 0; n <= MAX_LEVELS; n++) {
_rendertargets[n] = std::make_shared<gs::rendertarget>(GS_RGBA32F, GS_ZS_NONE);
}
}
@ -228,7 +228,7 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render()
return _input_texture;
}
size_t actual_iterations = _size_iterations;
std::size_t actual_iterations = _size_iterations;
gs_blend_state_push();
gs_reset_blend_state();
@ -244,7 +244,7 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render()
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
// Downsample
for (size_t n = 1; n <= actual_iterations; n++) {
for (std::size_t n = 1; n <= actual_iterations; n++) {
// Idx 0 is a simply considered as a straight copy of the original and not rendered to.
// Select Texture
@ -256,8 +256,8 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render()
}
// Reduce Size
uint32_t width = tex_cur->get_width() / 2;
uint32_t height = tex_cur->get_height() / 2;
std::uint32_t width = tex_cur->get_width() / 2;
std::uint32_t height = tex_cur->get_height() / 2;
if ((width <= 0) || (height <= 0)) {
actual_iterations = n - 1;
break;
@ -279,13 +279,13 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render()
}
// Upsample
for (size_t n = actual_iterations; n > 0; n--) {
for (std::size_t n = actual_iterations; n > 0; n--) {
// Select Texture
std::shared_ptr<gs::texture> tex_cur = _rendertargets[n]->get_texture();
// Get Size
uint32_t width = tex_cur->get_width();
uint32_t height = tex_cur->get_height();
std::uint32_t width = tex_cur->get_width();
std::uint32_t height = tex_cur->get_height();
// Apply
effect.get_parameter("pImage").set_texture(tex_cur);

View File

@ -83,8 +83,8 @@ namespace gfx {
class dual_filtering : public ::gfx::blur::base {
std::shared_ptr<::gfx::blur::dual_filtering_data> _data;
double_t _size;
size_t _size_iterations;
double_t _size;
std::size_t _size_iterations;
std::shared_ptr<gs::texture> _input_texture;
@ -110,6 +110,5 @@ namespace gfx {
virtual std::shared_ptr<::gs::texture> get() override;
};
}; // namespace blur
}; // namespace gfx
} // namespace blur
} // namespace gfx

View File

@ -52,7 +52,7 @@ gfx::blur::gaussian_linear_data::gaussian_linear_data()
}
// Precalculate Kernels
for (size_t kernel_size = 1; kernel_size <= MAX_BLUR_SIZE; kernel_size++) {
for (std::size_t kernel_size = 1; kernel_size <= MAX_BLUR_SIZE; kernel_size++) {
std::vector<double_t> kernel_math(MAX_KERNEL_SIZE);
std::vector<float_t> kernel_data(MAX_KERNEL_SIZE);
double_t actual_width = 1.;
@ -67,14 +67,14 @@ gfx::blur::gaussian_linear_data::gaussian_linear_data()
// Calculate and normalize
double_t sum = 0;
for (size_t p = 0; p <= kernel_size; p++) {
for (std::size_t p = 0; p <= kernel_size; p++) {
kernel_math[p] = util::math::gaussian<double_t>(double_t(p), actual_width);
sum += kernel_math[p] * (p > 0 ? 2 : 1);
}
// Normalize to fill the entire 0..1 range over the width.
double_t inverse_sum = 1.0 / sum;
for (size_t p = 0; p <= kernel_size; p++) {
for (std::size_t p = 0; p <= kernel_size; p++) {
kernel_data.at(p) = float_t(kernel_math[p] * inverse_sum);
}
@ -92,7 +92,7 @@ gs::effect gfx::blur::gaussian_linear_data::get_effect()
return _effect;
}
std::vector<float_t> const& gfx::blur::gaussian_linear_data::get_kernel(size_t width)
std::vector<float_t> const& gfx::blur::gaussian_linear_data::get_kernel(std::size_t width)
{
if (width < 1)
width = 1;

View File

@ -36,7 +36,7 @@ namespace gfx {
gs::effect get_effect();
std::vector<float_t> const& get_kernel(size_t width);
std::vector<float_t> const& get_kernel(std::size_t width);
};
class gaussian_linear_factory : public ::gfx::blur::ifactory {

View File

@ -52,7 +52,7 @@ gfx::blur::gaussian_data::gaussian_data()
}
// Precalculate Kernels
for (size_t kernel_size = 1; kernel_size <= MAX_BLUR_SIZE; kernel_size++) {
for (std::size_t kernel_size = 1; kernel_size <= MAX_BLUR_SIZE; kernel_size++) {
std::vector<double_t> kernel_math(MAX_KERNEL_SIZE);
std::vector<float_t> kernel_data(MAX_KERNEL_SIZE);
double_t actual_width = 1.;
@ -67,14 +67,14 @@ gfx::blur::gaussian_data::gaussian_data()
// Calculate and normalize
double_t sum = 0;
for (size_t p = 0; p <= kernel_size; p++) {
for (std::size_t p = 0; p <= kernel_size; p++) {
kernel_math[p] = util::math::gaussian<double_t>(double_t(p), actual_width);
sum += kernel_math[p] * (p > 0 ? 2 : 1);
}
// Normalize to fill the entire 0..1 range over the width.
double_t inverse_sum = 1.0 / sum;
for (size_t p = 0; p <= kernel_size; p++) {
for (std::size_t p = 0; p <= kernel_size; p++) {
kernel_data.at(p) = float_t(kernel_math[p] * inverse_sum);
}
@ -93,7 +93,7 @@ gs::effect gfx::blur::gaussian_data::get_effect()
return _effect;
}
std::vector<float_t> const& gfx::blur::gaussian_data::get_kernel(size_t width)
std::vector<float_t> const& gfx::blur::gaussian_data::get_kernel(std::size_t width)
{
if (width < 1)
width = 1;

View File

@ -36,7 +36,7 @@ namespace gfx {
gs::effect get_effect();
std::vector<float_t> const& get_kernel(size_t width);
std::vector<float_t> const& get_kernel(std::size_t width);
};
class gaussian_factory : public ::gfx::blur::ifactory {

View File

@ -105,7 +105,7 @@ void gfx::source_texture::clear()
_child.reset();
}
std::shared_ptr<gs::texture> gfx::source_texture::render(size_t width, size_t height)
std::shared_ptr<gs::texture> gfx::source_texture::render(std::size_t width, std::size_t height)
{
if ((width == 0) || (width >= 16384)) {
throw std::runtime_error("Width too large or too small.");

View File

@ -49,7 +49,7 @@ namespace gfx {
source_texture& operator=(source_texture&& other) = delete;
public:
std::shared_ptr<gs::texture> render(size_t width, size_t height);
std::shared_ptr<gs::texture> render(std::size_t width, std::size_t height);
public: // Unsafe Methods
void clear();

View File

@ -95,7 +95,7 @@ gfx::shader::basic_parameter::basic_parameter(gs::effect_parameter param, std::s
_names[0] = get_name();
_keys[0] = get_key();
} else {
for (size_t idx = 0; idx < get_size(); idx++) {
for (std::size_t idx = 0; idx < get_size(); idx++) {
snprintf(string_buffer, sizeof(string_buffer), "[%d]", static_cast<int32_t>(idx));
_names[idx] = std::string(string_buffer, string_buffer + strnlen(string_buffer, sizeof(string_buffer)));
snprintf(string_buffer, sizeof(string_buffer), "%s[%d]", get_key().c_str(), static_cast<int32_t>(idx));
@ -119,7 +119,7 @@ gfx::shader::basic_parameter::basic_parameter(gs::effect_parameter param, std::s
if (auto anno = get_parameter().get_annotation(ANNO_ENUM_VALUES);
anno && (anno.get_type() == gs::effect_parameter::type::Integer)) {
_values.resize(static_cast<size_t>(std::max(anno.get_default_int(), 0)));
for (size_t idx = 0; idx < _values.size(); idx++) {
for (std::size_t idx = 0; idx < _values.size(); idx++) {
auto& entry = _values[idx];
snprintf(string_buffer, sizeof(string_buffer), "_%zu", idx);
std::string key =
@ -159,14 +159,14 @@ const std::string& gfx::shader::basic_parameter::get_suffix()
return _suffix;
}
const std::string& gfx::shader::basic_parameter::get_keys(size_t idx)
const std::string& gfx::shader::basic_parameter::get_keys(std::size_t idx)
{
if (idx >= get_size())
throw std::out_of_range("Index out of range.");
return _keys[idx];
}
const std::string& gfx::shader::basic_parameter::get_names(size_t idx)
const std::string& gfx::shader::basic_parameter::get_names(std::size_t idx)
{
if (idx >= get_size())
throw std::out_of_range("Index out of range.");
@ -223,7 +223,7 @@ void gfx::shader::bool_parameter::update(obs_data_t* settings)
void gfx::shader::bool_parameter::assign()
{
get_parameter().set_value(_data.data(), sizeof(uint8_t));
get_parameter().set_value(_data.data(), sizeof(std::uint8_t));
}
gfx::shader::float_parameter::float_parameter(gs::effect_parameter param, std::string prefix)
@ -232,7 +232,7 @@ gfx::shader::float_parameter::float_parameter(gs::effect_parameter param, std::s
_data.resize(get_size());
// Reset minimum, maximum, step and scale.
for (size_t idx = 0; idx < get_size(); idx++) {
for (std::size_t idx = 0; idx < get_size(); idx++) {
_min[idx].f32 = std::numeric_limits<float_t>::lowest();
_max[idx].f32 = std::numeric_limits<float_t>::max();
_step[idx].f32 = 0.01f;
@ -270,7 +270,7 @@ void gfx::shader::float_parameter::defaults(obs_data_t* settings)
defaults.resize(get_size());
get_parameter().get_default_value(defaults.data(), get_size());
for (size_t idx = 0; idx < get_size(); idx++) {
for (std::size_t idx = 0; idx < get_size(); idx++) {
obs_data_set_default_double(settings, get_keys(idx).c_str(), static_cast<double_t>(defaults[idx]));
}
}
@ -282,7 +282,7 @@ static inline obs_property_t* build_float_property(gfx::shader::basic_field_type
switch (ft) {
case gfx::shader::basic_field_type::Enum: {
auto p = obs_properties_add_list(props, key, name, OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_FLOAT);
for (size_t idx = 0; idx < edata.size(); idx++) {
for (std::size_t idx = 0; idx < edata.size(); idx++) {
auto& el = edata.at(idx);
obs_property_list_add_float(p, el.name.c_str(), el.data.f32);
}
@ -313,7 +313,7 @@ void gfx::shader::float_parameter::properties(obs_properties_t* props, obs_data_
if (has_description())
obs_property_set_long_description(p, get_description().c_str());
for (size_t idx = 0; idx < get_size(); idx++) {
for (std::size_t idx = 0; idx < get_size(); idx++) {
p = build_float_property(_field_type, grp, _keys[idx].c_str(), _names[idx].c_str(), _min[idx].f32,
_max[idx].f32, _step[idx].f32, _values);
if (has_description())
@ -324,7 +324,7 @@ void gfx::shader::float_parameter::properties(obs_properties_t* props, obs_data_
void gfx::shader::float_parameter::update(obs_data_t* settings)
{
for (size_t idx = 0; idx < get_size(); idx++) {
for (std::size_t idx = 0; idx < get_size(); idx++) {
_data[idx].f32 = static_cast<float_t>(obs_data_get_double(settings, _keys[idx].c_str())) * _scale[idx].f32;
}
}
@ -343,7 +343,7 @@ static inline obs_property_t* build_int_property(gfx::shader::basic_field_type f
switch (ft) {
case gfx::shader::basic_field_type::Enum: {
auto p = obs_properties_add_list(props, key, name, OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
for (size_t idx = 0; idx < edata.size(); idx++) {
for (std::size_t idx = 0; idx < edata.size(); idx++) {
auto& el = edata.at(idx);
obs_property_list_add_int(p, el.name.c_str(), el.data.i32);
}
@ -363,7 +363,7 @@ gfx::shader::int_parameter::int_parameter(gs::effect_parameter param, std::strin
_data.resize(get_size());
// Reset minimum, maximum, step and scale.
for (size_t idx = 0; idx < get_size(); idx++) {
for (std::size_t idx = 0; idx < get_size(); idx++) {
_min[idx].i32 = std::numeric_limits<int32_t>::lowest();
_max[idx].i32 = std::numeric_limits<int32_t>::max();
_step[idx].i32 = 1;
@ -400,7 +400,7 @@ void gfx::shader::int_parameter::defaults(obs_data_t* settings)
std::vector<int32_t> defaults;
defaults.resize(get_size());
get_parameter().get_default_value(defaults.data(), get_size());
for (size_t idx = 0; idx < get_size(); idx++) {
for (std::size_t idx = 0; idx < get_size(); idx++) {
obs_data_set_default_int(settings, get_keys(idx).c_str(), defaults[idx]);
}
}
@ -422,7 +422,7 @@ void gfx::shader::int_parameter::properties(obs_properties_t* props, obs_data_t*
if (has_description())
obs_property_set_long_description(p, get_description().c_str());
for (size_t idx = 0; idx < get_size(); idx++) {
for (std::size_t idx = 0; idx < get_size(); idx++) {
p = build_int_property(_field_type, grp, _keys[idx].c_str(), _names[idx].c_str(), _min[idx].i32,
_max[idx].i32, _step[idx].i32, _values);
if (has_description())
@ -433,7 +433,7 @@ void gfx::shader::int_parameter::properties(obs_properties_t* props, obs_data_t*
void gfx::shader::int_parameter::update(obs_data_t* settings)
{
for (size_t idx = 0; idx < get_size(); idx++) {
for (std::size_t idx = 0; idx < get_size(); idx++) {
_data[idx].i32 = static_cast<int32_t>(obs_data_get_int(settings, _keys[idx].c_str()) * _scale[idx].i32);
}
}

View File

@ -33,9 +33,9 @@ namespace gfx {
struct basic_data {
union {
int32_t i32;
uint32_t ui32;
float_t f32;
int32_t i32;
std::uint32_t ui32;
float_t f32;
};
};
@ -72,14 +72,14 @@ namespace gfx {
const std::string& get_suffix();
const std::string& get_keys(size_t idx);
const std::string& get_keys(std::size_t idx);
const std::string& get_names(size_t idx);
const std::string& get_names(std::size_t idx);
};
struct bool_parameter : public basic_parameter {
// std::vector<bool> doesn't allow .data()
std::vector<uint8_t> _data;
std::vector<std::uint8_t> _data;
public:
bool_parameter(gs::effect_parameter param, std::string prefix);

View File

@ -55,7 +55,7 @@ gfx::shader::parameter_type gfx::shader::get_type_from_effect_type(gs::effect_pa
}
}
size_t gfx::shader::get_length_from_effect_type(gs::effect_parameter::type type)
std::size_t gfx::shader::get_length_from_effect_type(gs::effect_parameter::type type)
{
switch (type) {
default:
@ -160,7 +160,7 @@ gfx::shader::parameter::parameter(gs::effect_parameter param, std::string key_pr
// Read Size override.
_size = get_length_from_effect_type(_param.get_type());
if (auto anno = _param.get_annotation(ANNO_SIZE); anno) {
size_t ov = static_cast<size_t>(anno.get_default_int());
std::size_t ov = static_cast<size_t>(anno.get_default_int());
if (ov > 0)
_size = ov;
}
@ -185,7 +185,7 @@ gfx::shader::parameter_type gfx::shader::parameter::get_type()
return _type;
}
size_t gfx::shader::parameter::get_size()
std::size_t gfx::shader::parameter::get_size()
{
return _size;
}

View File

@ -41,7 +41,7 @@ namespace gfx {
parameter_type get_type_from_effect_type(gs::effect_parameter::type type);
size_t get_length_from_effect_type(gs::effect_parameter::type type);
std::size_t get_length_from_effect_type(gs::effect_parameter::type type);
parameter_type get_type_from_string(std::string v);
@ -53,7 +53,7 @@ namespace gfx {
parameter_type _type;
// Real size of the parameter (libobs gets it wrong often).
size_t _size;
std::size_t _size;
// Order of the parameter in a list/map.
int32_t _order;
@ -85,7 +85,7 @@ namespace gfx {
parameter_type get_type();
size_t get_size();
std::size_t get_size();
int32_t get_order();

View File

@ -103,7 +103,7 @@ try {
std::shared_ptr<obs_data_t>(obs_source_get_settings(_self), [](obs_data_t* p) { obs_data_release(p); });
bool have_valid_tech = false;
for (size_t idx = 0; idx < _shader.count_techniques(); idx++) {
for (std::size_t idx = 0; idx < _shader.count_techniques(); idx++) {
if (_shader.get_technique(idx).name() == tech) {
have_valid_tech = true;
break;
@ -121,10 +121,10 @@ try {
// Clear the shader parameters map and rebuild.
_shader_params.clear();
auto etech = _shader.get_technique(_shader_tech);
for (size_t idx = 0; idx < etech.count_passes(); idx++) {
for (std::size_t idx = 0; idx < etech.count_passes(); idx++) {
auto pass = etech.get_pass(idx);
for (size_t vidx = 0; vidx < pass.count_vertex_parameters(); vidx++) {
for (std::size_t vidx = 0; vidx < pass.count_vertex_parameters(); vidx++) {
auto el = pass.get_vertex_parameter(vidx);
if (!el)
@ -143,7 +143,7 @@ try {
}
}
for (size_t vidx = 0; vidx < pass.count_pixel_parameters(); vidx++) {
for (std::size_t vidx = 0; vidx < pass.count_pixel_parameters(); vidx++) {
auto el = pass.get_pixel_parameter(vidx);
if (!el)
@ -185,7 +185,7 @@ void gfx::shader::shader::properties(obs_properties_t* pr)
_have_current_params = false;
{
auto p = obs_properties_add_button2(
obs_properties_add_button2(
pr, ST_REFRESH, D_TRANSLATE(ST_REFRESH),
[](obs_properties_t* props, obs_property_t* prop, void* priv) {
return reinterpret_cast<gfx::shader::shader*>(priv)->on_refresh_properties(props, prop);
@ -250,7 +250,7 @@ bool gfx::shader::shader::on_refresh_properties(obs_properties_t* props, obs_pro
if (_shader) { // Clear list of techniques and rebuild it.
obs_property_t* p_tech_list = obs_properties_get(props, ST_SHADER_TECHNIQUE);
obs_property_list_clear(p_tech_list);
for (size_t idx = 0; idx < _shader.count_techniques(); idx++) {
for (std::size_t idx = 0; idx < _shader.count_techniques(); idx++) {
auto tech = _shader.get_technique(idx);
obs_property_list_add_string(p_tech_list, tech.name().c_str(), tech.name().c_str());
}
@ -286,7 +286,7 @@ bool gfx::shader::shader::on_shader_or_technique_modified(obs_properties_t* prop
{ // Clear list of techniques and rebuild it.
obs_property_t* p_tech_list = obs_properties_get(props, ST_SHADER_TECHNIQUE);
obs_property_list_clear(p_tech_list);
for (size_t idx = 0; idx < _shader.count_techniques(); idx++) {
for (std::size_t idx = 0; idx < _shader.count_techniques(); idx++) {
auto tech = _shader.get_technique(idx);
obs_property_list_add_string(p_tech_list, tech.name().c_str(), tech.name().c_str());
}
@ -355,7 +355,7 @@ void gfx::shader::shader::update(obs_data_t* data)
}
}
uint32_t gfx::shader::shader::width()
std::uint32_t gfx::shader::shader::width()
{
switch (_mode) {
case shader_mode::Transition:
@ -379,7 +379,7 @@ uint32_t gfx::shader::shader::width()
}
}
uint32_t gfx::shader::shader::height()
std::uint32_t gfx::shader::shader::height()
{
switch (_mode) {
case shader_mode::Transition:
@ -465,7 +465,7 @@ void gfx::shader::shader::render()
}
}
void gfx::shader::shader::set_size(uint32_t w, uint32_t h)
void gfx::shader::shader::set_size(std::uint32_t w, std::uint32_t h)
{
_base_width = w;
_base_height = h;
@ -507,13 +507,13 @@ void gfx::shader::shader::set_transition_time(float_t t)
}
}
void gfx::shader::shader::set_transition_size(uint32_t w, uint32_t h)
void gfx::shader::shader::set_transition_size(std::uint32_t w, std::uint32_t h)
{
if (!_shader)
return;
if (gs::effect_parameter el = _shader.get_parameter("TransitionSize"); el != nullptr) {
if (el.get_type() == gs::effect_parameter::type::Integer2) {
el.set_int2(w, h);
el.set_int2(static_cast<int32_t>(w), static_cast<int32_t>(h));
}
}
}

View File

@ -43,9 +43,9 @@ namespace gfx {
obs_source_t* _self;
// Inputs
shader_mode _mode;
uint32_t _base_width;
uint32_t _base_height;
shader_mode _mode;
std::uint32_t _base_width;
std::uint32_t _base_height;
// Shader
gs::effect _shader;
@ -92,9 +92,9 @@ namespace gfx {
void update(obs_data_t* data);
uint32_t width();
std::uint32_t width();
uint32_t height();
std::uint32_t height();
bool tick(float_t time);
@ -103,7 +103,7 @@ namespace gfx {
void render();
public:
void set_size(uint32_t w, uint32_t h);
void set_size(std::uint32_t w, std::uint32_t h);
void set_input_a(std::shared_ptr<gs::texture> tex);
@ -111,7 +111,7 @@ namespace gfx {
void set_transition_time(float_t t);
void set_transition_size(uint32_t w, uint32_t h);
void set_transition_size(std::uint32_t w, std::uint32_t h);
};
} // namespace shader
} // namespace gfx

View File

@ -26,7 +26,7 @@ namespace nvidia::cuda {
class memory {
std::shared_ptr<::nvidia::cuda::cuda> _cuda;
cu_device_ptr_t _pointer;
size_t _size;
std::size_t _size;
public:
memory(std::shared_ptr<::nvidia::cuda::cuda> cuda, std::size_t size);

View File

@ -82,8 +82,8 @@ namespace nvidia::cuda {
typedef void* cu_stream_t;
struct cu_memcpy2d_t {
size_t src_x_in_bytes;
size_t src_y;
std::size_t src_x_in_bytes;
std::size_t src_y;
cu_memory_type src_memory_type;
const void* src_host;
@ -91,8 +91,8 @@ namespace nvidia::cuda {
cu_array_t src_array;
std::size_t src_pitch;
size_t dst_x_in_bytes;
size_t dst_y;
std::size_t dst_x_in_bytes;
std::size_t dst_y;
cu_memory_type dst_memory_type;
const void* dst_host;

View File

@ -115,7 +115,7 @@ try {
std::string gs::effect_parameter::get_name()
{
const char* name_c = get()->name;
size_t name_len = strnlen(name_c, 256);
std::size_t name_len = strnlen(name_c, 256);
return name_c ? std::string(name_c, name_c + name_len) : std::string();
}
@ -152,12 +152,12 @@ gs::effect_parameter::type gs::effect_parameter::get_type()
}
}
inline size_t gs::effect_parameter::count_annotations()
inline std::size_t gs::effect_parameter::count_annotations()
{
return gs_param_get_num_annotations(get());
}
gs::effect_parameter gs::effect_parameter::get_annotation(size_t idx)
gs::effect_parameter gs::effect_parameter::get_annotation(std::size_t idx)
{
if (idx >= get()->annotations.num) {
return nullptr;
@ -168,7 +168,7 @@ gs::effect_parameter gs::effect_parameter::get_annotation(size_t idx)
gs::effect_parameter gs::effect_parameter::get_annotation(std::string name)
{
for (size_t idx = 0; idx < get()->annotations.num; idx++) {
for (std::size_t idx = 0; idx < get()->annotations.num; idx++) {
auto ptr = get()->annotations.array + idx;
if (strcmp(ptr->name, name.c_str()) == 0) {
return gs::effect_parameter(ptr, this);
@ -227,7 +227,7 @@ void gs::effect_parameter::get_default_bool(bool& v)
}
}
void gs::effect_parameter::set_bool_array(bool v[], size_t sz)
void gs::effect_parameter::set_bool_array(bool v[], std::size_t sz)
{
if (get_type() != type::Boolean)
throw std::bad_cast();
@ -296,7 +296,7 @@ void gs::effect_parameter::get_float2(float_t& x, float_t& y)
{
if (get_type() != type::Float2)
throw std::bad_cast();
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_val(get()));
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_val(get()));
if (ptr) {
x = *reinterpret_cast<float_t*>(ptr);
y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t));
@ -310,7 +310,7 @@ void gs::effect_parameter::get_default_float2(float_t& x, float_t& y)
{
if (get_type() != type::Float2)
throw std::bad_cast();
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_default_val(get()));
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_default_val(get()));
if (ptr) {
x = *reinterpret_cast<float_t*>(ptr);
y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t));
@ -349,7 +349,7 @@ void gs::effect_parameter::get_float3(float_t& x, float_t& y, float_t& z)
{
if (get_type() != type::Float3)
throw std::bad_cast();
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_val(get()));
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_val(get()));
if (ptr) {
x = *reinterpret_cast<float_t*>(ptr);
y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t));
@ -364,7 +364,7 @@ void gs::effect_parameter::get_default_float3(float_t& x, float_t& y, float_t& z
{
if (get_type() != type::Float3)
throw std::bad_cast();
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_default_val(get()));
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_default_val(get()));
if (ptr) {
x = *reinterpret_cast<float_t*>(ptr);
y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t));
@ -404,7 +404,7 @@ void gs::effect_parameter::get_float4(float_t& x, float_t& y, float_t& z, float_
{
if (get_type() != type::Float4)
throw std::bad_cast();
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_val(get()));
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_val(get()));
if (ptr) {
x = *reinterpret_cast<float_t*>(ptr);
y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t));
@ -420,7 +420,7 @@ void gs::effect_parameter::get_default_float4(float_t& x, float_t& y, float_t& z
{
if (get_type() != type::Float4)
throw std::bad_cast();
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_default_val(get()));
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_default_val(get()));
if (ptr) {
x = *reinterpret_cast<float_t*>(ptr);
y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t));
@ -443,7 +443,7 @@ void gs::effect_parameter::get_int(int32_t& x)
{
if ((get_type() != type::Integer) && (get_type() != type::Unknown))
throw std::bad_cast();
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_val(get()));
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_val(get()));
if (ptr) {
x = *reinterpret_cast<int32_t*>(ptr);
bfree(ptr);
@ -456,7 +456,7 @@ void gs::effect_parameter::get_default_int(int32_t& x)
{
if ((get_type() != type::Integer) && (get_type() != type::Unknown))
throw std::bad_cast();
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_default_val(get()));
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_default_val(get()));
if (ptr) {
x = *reinterpret_cast<int32_t*>(ptr);
bfree(ptr);
@ -477,7 +477,7 @@ void gs::effect_parameter::get_int2(int32_t& x, int32_t& y)
{
if ((get_type() != type::Integer2) && (get_type() != type::Unknown))
throw std::bad_cast();
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_val(get()));
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_val(get()));
if (ptr) {
x = *reinterpret_cast<int32_t*>(ptr);
y = *reinterpret_cast<int32_t*>(ptr + sizeof(int32_t));
@ -491,7 +491,7 @@ void gs::effect_parameter::get_default_int2(int32_t& x, int32_t& y)
{
if ((get_type() != type::Integer2) && (get_type() != type::Unknown))
throw std::bad_cast();
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_default_val(get()));
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_default_val(get()));
if (ptr) {
x = *reinterpret_cast<int32_t*>(ptr);
y = *reinterpret_cast<int32_t*>(ptr + sizeof(int32_t));
@ -513,7 +513,7 @@ void gs::effect_parameter::get_int3(int32_t& x, int32_t& y, int32_t& z)
{
if ((get_type() != type::Integer3) && (get_type() != type::Unknown))
throw std::bad_cast();
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_val(get()));
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_val(get()));
if (ptr) {
x = *reinterpret_cast<int32_t*>(ptr);
y = *reinterpret_cast<int32_t*>(ptr + sizeof(int32_t));
@ -528,7 +528,7 @@ void gs::effect_parameter::get_default_int3(int32_t& x, int32_t& y, int32_t& z)
{
if ((get_type() != type::Integer3) && (get_type() != type::Unknown))
throw std::bad_cast();
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_default_val(get()));
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_default_val(get()));
if (ptr) {
x = *reinterpret_cast<int32_t*>(ptr);
y = *reinterpret_cast<int32_t*>(ptr + sizeof(int32_t));
@ -551,7 +551,7 @@ void gs::effect_parameter::get_int4(int32_t& x, int32_t& y, int32_t& z, int32_t&
{
if ((get_type() != type::Integer4) && (get_type() != type::Unknown))
throw std::bad_cast();
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_val(get()));
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_val(get()));
if (ptr) {
x = *reinterpret_cast<int32_t*>(ptr);
y = *reinterpret_cast<int32_t*>(ptr + sizeof(int32_t));
@ -567,7 +567,7 @@ void gs::effect_parameter::get_default_int4(int32_t& x, int32_t& y, int32_t& z,
{
if ((get_type() != type::Integer4) && (get_type() != type::Unknown))
throw std::bad_cast();
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_default_val(get()));
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_default_val(get()));
if (ptr) {
x = *reinterpret_cast<int32_t*>(ptr);
y = *reinterpret_cast<int32_t*>(ptr + sizeof(int32_t));
@ -590,7 +590,7 @@ void gs::effect_parameter::get_matrix(matrix4& v)
{
if (get_type() != type::Matrix)
throw std::bad_cast();
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_val(get()));
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_val(get()));
if (ptr) {
v.x.x = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 0);
v.x.y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 1);
@ -621,7 +621,7 @@ void gs::effect_parameter::get_default_matrix(matrix4& v)
{
if (get_type() != type::Matrix)
throw std::bad_cast();
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_default_val(get()));
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_default_val(get()));
if (ptr) {
v.x.x = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 0);
v.x.y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 1);
@ -687,10 +687,10 @@ void gs::effect_parameter::get_string(std::string& v)
{
if (get_type() != type::String)
throw std::bad_cast();
size_t ptr_len = gs_effect_get_val_size(get());
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_val(get()));
std::size_t ptr_len = gs_effect_get_val_size(get());
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_val(get()));
if (ptr) {
v = std::string(ptr, ptr + ptr_len - 1);
v = std::string(reinterpret_cast<std::int8_t*>(ptr), reinterpret_cast<std::int8_t*>(ptr) + ptr_len - 1);
bfree(ptr);
} else {
v = "";
@ -701,10 +701,10 @@ void gs::effect_parameter::get_default_string(std::string& v)
{
if (get_type() != type::String)
throw std::bad_cast();
size_t ptr_len = gs_effect_get_default_val_size(get());
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_default_val(get()));
std::size_t ptr_len = gs_effect_get_default_val_size(get());
std::uint8_t* ptr = static_cast<std::uint8_t*>(gs_effect_get_default_val(get()));
if (ptr) {
v = std::string(ptr, ptr + ptr_len - 1);
v = std::string(reinterpret_cast<std::int8_t*>(ptr), reinterpret_cast<std::int8_t*>(ptr) + ptr_len - 1);
bfree(ptr);
} else {
v = "";

View File

@ -65,33 +65,33 @@ namespace gs {
type get_type();
size_t count_annotations();
effect_parameter get_annotation(size_t idx);
std::size_t count_annotations();
effect_parameter get_annotation(std::size_t idx);
effect_parameter get_annotation(std::string name);
bool has_annotation(std::string name);
bool has_annotation(std::string name, effect_parameter::type type);
public /* Memory API */:
size_t get_default_value_size_in_bytes()
std::size_t get_default_value_size_in_bytes()
{
return gs_effect_get_default_val_size(get());
}
template<typename T>
size_t get_default_value_size()
std::size_t get_default_value_size()
{
return gs_effect_get_default_val_size(get()) / sizeof(T);
}
template<typename T>
bool get_default_value(T v[], size_t len)
bool get_default_value(T v[], std::size_t len)
{
if (len != get_default_value_size<T>()) {
return false;
}
if (T* ptr = reinterpret_cast<T*>(gs_effect_get_default_val(get())); ptr != nullptr) {
for (size_t idx = 0; idx < len; idx++) {
for (std::size_t idx = 0; idx < len; idx++) {
v[idx] = *(ptr + idx);
}
@ -101,26 +101,26 @@ namespace gs {
return false;
}
size_t get_value_size_in_bytes()
std::size_t get_value_size_in_bytes()
{
return gs_effect_get_val_size(get());
}
template<typename T>
size_t get_value_size()
std::size_t get_value_size()
{
return gs_effect_get_val_size(get()) / sizeof(T);
}
template<typename T>
bool get_value(T v[], size_t len)
bool get_value(T v[], std::size_t len)
{
if (len != get_value_size<T>()) {
return false;
}
if (T* ptr = reinterpret_cast<T*>(gs_effect_get_val(get())); ptr != nullptr) {
for (size_t idx = 0; idx < len; idx++) {
for (std::size_t idx = 0; idx < len; idx++) {
v[idx] = *(ptr + idx);
}
@ -131,7 +131,7 @@ namespace gs {
}
template<typename T>
bool set_value(T v[], size_t len)
bool set_value(T v[], std::size_t len)
{
gs_effect_set_val(get(), v, sizeof(T) * len);
return true;
@ -142,7 +142,7 @@ namespace gs {
void get_bool(bool& v);
void get_default_bool(bool& v);
void set_bool_array(bool v[], size_t sz);
void set_bool_array(bool v[], std::size_t sz);
void set_float(float_t x);
void get_float(float_t& x);

View File

@ -41,16 +41,16 @@ gs::effect_pass::~effect_pass() {}
std::string gs::effect_pass::name()
{
const char* name_c = get()->name;
size_t name_len = strnlen(name_c, 256);
std::size_t name_len = strnlen(name_c, 256);
return name_c ? std::string(name_c, name_c + name_len) : std::string();
}
size_t gs::effect_pass::count_vertex_parameters()
std::size_t gs::effect_pass::count_vertex_parameters()
{
return static_cast<size_t>(get()->vertshader_params.num);
}
gs::effect_parameter gs::effect_pass::get_vertex_parameter(size_t idx)
gs::effect_parameter gs::effect_pass::get_vertex_parameter(std::size_t idx)
{
if (idx >= count_vertex_parameters())
return nullptr;
@ -60,7 +60,7 @@ gs::effect_parameter gs::effect_pass::get_vertex_parameter(size_t idx)
gs::effect_parameter gs::effect_pass::get_vertex_parameter(std::string name)
{
for (size_t idx = 0; idx < count_vertex_parameters(); idx++) {
for (std::size_t idx = 0; idx < count_vertex_parameters(); idx++) {
auto ptr = get()->vertshader_params.array + idx;
if (strcmp(ptr->eparam->name, name.c_str()) == 0)
return gs::effect_parameter(ptr->eparam, this);
@ -81,12 +81,12 @@ bool gs::effect_pass::has_vertex_parameter(std::string name, gs::effect_paramete
return false;
}
size_t gs::effect_pass::count_pixel_parameters()
std::size_t gs::effect_pass::count_pixel_parameters()
{
return static_cast<size_t>(get()->pixelshader_params.num);
}
gs::effect_parameter gs::effect_pass::get_pixel_parameter(size_t idx)
gs::effect_parameter gs::effect_pass::get_pixel_parameter(std::size_t idx)
{
if (idx >= count_pixel_parameters())
return nullptr;
@ -96,7 +96,7 @@ gs::effect_parameter gs::effect_pass::get_pixel_parameter(size_t idx)
gs::effect_parameter gs::effect_pass::get_pixel_parameter(std::string name)
{
for (size_t idx = 0; idx < count_pixel_parameters(); idx++) {
for (std::size_t idx = 0; idx < count_pixel_parameters(); idx++) {
auto ptr = get()->pixelshader_params.array + idx;
if (strcmp(ptr->eparam->name, name.c_str()) == 0)
return gs::effect_parameter(ptr->eparam, this);

View File

@ -34,14 +34,14 @@ namespace gs {
//gs::shader get_pixel_shader();
//gs::shader get_vertex_shader();
size_t count_vertex_parameters();
gs::effect_parameter get_vertex_parameter(size_t idx);
std::size_t count_vertex_parameters();
gs::effect_parameter get_vertex_parameter(std::size_t idx);
gs::effect_parameter get_vertex_parameter(std::string name);
bool has_vertex_parameter(std::string name);
bool has_vertex_parameter(std::string name, gs::effect_parameter::type type);
size_t count_pixel_parameters();
gs::effect_parameter get_pixel_parameter(size_t idx);
std::size_t count_pixel_parameters();
gs::effect_parameter get_pixel_parameter(std::size_t idx);
gs::effect_parameter get_pixel_parameter(std::string name);
bool has_pixel_parameter(std::string name);
bool has_pixel_parameter(std::string name, gs::effect_parameter::type type);

View File

@ -43,16 +43,16 @@ gs::effect_technique::~effect_technique() {}
std::string gs::effect_technique::name()
{
const char* name_c = get()->name;
size_t name_len = strnlen(name_c, 256);
std::size_t name_len = strnlen(name_c, 256);
return name_c ? std::string(name_c, name_c + name_len) : std::string();
}
size_t gs::effect_technique::count_passes()
std::size_t gs::effect_technique::count_passes()
{
return static_cast<size_t>(get()->passes.num);
}
gs::effect_pass gs::effect_technique::get_pass(size_t idx)
gs::effect_pass gs::effect_technique::get_pass(std::size_t idx)
{
if (idx >= get()->passes.num) {
return nullptr;
@ -63,7 +63,7 @@ gs::effect_pass gs::effect_technique::get_pass(size_t idx)
gs::effect_pass gs::effect_technique::get_pass(std::string name)
{
for (size_t idx = 0; idx < get()->passes.num; idx++) {
for (std::size_t idx = 0; idx < get()->passes.num; idx++) {
auto ptr = get()->passes.array + idx;
if (strcmp(ptr->name, name.c_str()) == 0)
return gs::effect_pass(ptr, this);

View File

@ -31,8 +31,8 @@ namespace gs {
std::string name();
size_t count_passes();
gs::effect_pass get_pass(size_t idx);
std::size_t count_passes();
gs::effect_pass get_pass(std::size_t idx);
gs::effect_pass get_pass(std::string name);
bool has_pass(std::string name);
};

View File

@ -66,12 +66,12 @@ gs::effect::~effect()
reset();
}
size_t gs::effect::count_techniques()
std::size_t gs::effect::count_techniques()
{
return static_cast<size_t>(get()->techniques.num);
}
gs::effect_technique gs::effect::get_technique(size_t idx)
gs::effect_technique gs::effect::get_technique(std::size_t idx)
{
if (idx >= count_techniques()) {
return nullptr;
@ -82,7 +82,7 @@ gs::effect_technique gs::effect::get_technique(size_t idx)
gs::effect_technique gs::effect::get_technique(const std::string& name)
{
for (size_t idx = 0; idx < count_techniques(); idx++) {
for (std::size_t idx = 0; idx < count_techniques(); idx++) {
auto ptr = get()->techniques.array + idx;
if (strcmp(ptr->name, name.c_str()) == 0) {
return gs::effect_technique(ptr, this);
@ -99,12 +99,12 @@ bool gs::effect::has_technique(const std::string& name)
return false;
}
size_t gs::effect::count_parameters()
std::size_t gs::effect::count_parameters()
{
return get()->params.num;
}
gs::effect_parameter gs::effect::get_parameter(size_t idx)
gs::effect_parameter gs::effect::get_parameter(std::size_t idx)
{
if (idx >= count_parameters()) {
throw std::out_of_range("Index is out of range.");
@ -115,7 +115,7 @@ gs::effect_parameter gs::effect::get_parameter(size_t idx)
gs::effect_parameter gs::effect::get_parameter(const std::string& name)
{
for (size_t idx = 0; idx < count_parameters(); idx++) {
for (std::size_t idx = 0; idx < count_parameters(); idx++) {
auto ptr = get()->params.array + idx;
if (strcmp(ptr->name, name.c_str()) == 0) {
return gs::effect_parameter(ptr, this);

View File

@ -32,13 +32,13 @@ namespace gs {
effect(std::filesystem::path file);
~effect();
size_t count_techniques();
gs::effect_technique get_technique(size_t idx);
std::size_t count_techniques();
gs::effect_technique get_technique(std::size_t idx);
gs::effect_technique get_technique(const std::string& name);
bool has_technique(const std::string& name);
size_t count_parameters();
gs::effect_parameter get_parameter(size_t idx);
std::size_t count_parameters();
gs::effect_parameter get_parameter(std::size_t idx);
gs::effect_parameter get_parameter(const std::string& name);
bool has_parameter(const std::string& name);
bool has_parameter(const std::string& name, effect_parameter::type type);

View File

@ -34,9 +34,9 @@ gs::context::~context()
gs_debug_marker_begin(color, _name.c_str());
}*/
gs::debug_marker::debug_marker(const float color[4], const char* format, ...)
gs::debug_marker::debug_marker(const float_t color[4], const char* format, ...)
{
size_t size;
std::size_t size;
std::vector<char> buffer(128);
va_list vargs;

View File

@ -29,18 +29,18 @@ namespace gs {
~context();
};
static const float debug_color_source[4] = {0.f, .5f, 5.f, 1.f};
static const float debug_color_cache[4] = {1.f, .75f, 0.f, 1.f};
static const float debug_color_cache_render[4] = {.2f, .15f, 0.f, 1.f};
static const float debug_color_convert[4] = {.5f, .5f, 0.5f, 1.f};
static const float debug_color_render[4] = {0.f, 1.f, 0.0f, 1.f};
static const float_t debug_color_source[4] = {0.f, .5f, 5.f, 1.f};
static const float_t debug_color_cache[4] = {1.f, .75f, 0.f, 1.f};
static const float_t debug_color_cache_render[4] = {.2f, .15f, 0.f, 1.f};
static const float_t debug_color_convert[4] = {.5f, .5f, 0.5f, 1.f};
static const float_t debug_color_render[4] = {0.f, 1.f, 0.0f, 1.f};
class debug_marker {
std::string _name;
public:
//debug_marker(const float color[4], std::string name);
debug_marker(const float color[4], const char* format, ...);
debug_marker(const float_t color[4], const char* format, ...);
~debug_marker();
};
} // namespace gs

View File

@ -22,7 +22,7 @@
#include "gs-limits.hpp"
#include "obs/gs/gs-helper.hpp"
gs::index_buffer::index_buffer(uint32_t maximumVertices)
gs::index_buffer::index_buffer(std::uint32_t maximumVertices)
{
this->reserve(maximumVertices);
auto gctx = gs::context();

View File

@ -24,7 +24,7 @@
namespace gs {
class index_buffer : public std::vector<uint32_t> {
public:
index_buffer(uint32_t maximumVertices);
index_buffer(std::uint32_t maximumVertices);
index_buffer();
index_buffer(index_buffer& other);
index_buffer(std::vector<uint32_t>& other);

View File

@ -21,6 +21,6 @@
#include "common.hpp"
namespace gs {
static const uint32_t MAXIMUM_VERTICES = 0xFFFFFFu;
static const uint32_t MAXIMUM_UVW_LAYERS = 8u;
static const std::uint32_t MAXIMUM_VERTICES = 0xFFFFFFu;
static const std::uint32_t MAXIMUM_UVW_LAYERS = 8u;
} // namespace gs

View File

@ -73,7 +73,7 @@ gs::mipmapper::~mipmapper()
gs::mipmapper::mipmapper()
{
_vb = std::make_unique<gs::vertex_buffer>(uint32_t(6u), uint8_t(1u));
_vb = std::make_unique<gs::vertex_buffer>(uint32_t(6u), std::uint8_t(1u));
auto v0 = _vb->at(0);
v0.position->x = 0;
v0.position->y = 0;
@ -153,13 +153,11 @@ void gs::mipmapper::rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr
}
// Render
graphics_t* ctx = gs_get_context();
#if defined(WIN32) || defined(WIN64)
graphics_t* ctx = gs_get_context();
gs_d3d11_device* dev = reinterpret_cast<gs_d3d11_device*>(ctx->device);
#endif
int device_type = gs_get_device_type();
void* sobj = gs_texture_get_obj(source->get_object());
void* tobj = gs_texture_get_obj(target->get_object());
std::string technique = "Draw";
switch (generator) {
@ -187,11 +185,11 @@ void gs::mipmapper::rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr
gs_load_indexbuffer(nullptr);
if (source->get_type() == gs::texture::type::Normal) {
size_t texture_width = source->get_width();
size_t texture_height = source->get_height();
float_t texel_width = 1.0f / texture_width;
float_t texel_height = 1.0f / texture_height;
size_t mip_levels = 1;
std::size_t texture_width = source->get_width();
std::size_t texture_height = source->get_height();
float_t texel_width = 1.0f / texture_width;
float_t texel_height = 1.0f / texture_height;
std::size_t mip_levels = 1;
#if defined(WIN32) || defined(WIN64)
ID3D11Texture2D* target_t2 = nullptr;
@ -199,8 +197,8 @@ void gs::mipmapper::rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr
if (device_type == GS_DEVICE_DIRECT3D_11) {
// We definitely have a Direct3D11 resource.
D3D11_TEXTURE2D_DESC target_t2desc;
target_t2 = reinterpret_cast<ID3D11Texture2D*>(tobj);
source_t2 = reinterpret_cast<ID3D11Texture2D*>(sobj);
target_t2 = reinterpret_cast<ID3D11Texture2D*>(gs_texture_get_obj(target->get_object()));
source_t2 = reinterpret_cast<ID3D11Texture2D*>(gs_texture_get_obj(source->get_object()));
target_t2->GetDesc(&target_t2desc);
dev->context->CopySubresourceRegion(target_t2, 0, 0, 0, 0, source_t2, 0, nullptr);
mip_levels = target_t2desc.MipLevels;
@ -215,7 +213,7 @@ void gs::mipmapper::rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr
return;
}
for (size_t mip = 1; mip < mip_levels; mip++) {
for (std::size_t mip = 1; mip < mip_levels; mip++) {
texture_width /= 2;
texture_height /= 2;
if (texture_width == 0) {
@ -262,7 +260,7 @@ void gs::mipmapper::rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr
if (device_type == GS_DEVICE_DIRECT3D_11) {
// Copy
ID3D11Texture2D* rt = reinterpret_cast<ID3D11Texture2D*>(gs_texture_get_obj(_rt->get_object()));
uint32_t level = uint32_t(D3D11CalcSubresource(UINT(mip), 0, UINT(mip_levels)));
std::uint32_t level = uint32_t(D3D11CalcSubresource(UINT(mip), 0, UINT(mip_levels)));
dev->context->CopySubresourceRegion(target_t2, level, 0, 0, 0, rt, 0, NULL);
}
#endif

View File

@ -31,7 +31,7 @@ namespace gs {
gs::effect _effect;
public:
enum class generator : uint8_t {
enum class generator : std::uint8_t {
Point,
Linear,
Sharpen,

View File

@ -38,7 +38,7 @@ gs::rendertarget::rendertarget(gs_color_format colorFormat, gs_zstencil_format z
}
}
gs::rendertarget_op gs::rendertarget::render(uint32_t width, uint32_t height)
gs::rendertarget_op gs::rendertarget::render(std::uint32_t width, std::uint32_t height)
{
return {this, width, height};
}
@ -80,7 +80,7 @@ gs_zstencil_format gs::rendertarget::get_zstencil_format()
return _zstencil_format;
}
gs::rendertarget_op::rendertarget_op(gs::rendertarget* rt, uint32_t width, uint32_t height) : parent(rt)
gs::rendertarget_op::rendertarget_op(gs::rendertarget* rt, std::uint32_t width, std::uint32_t height) : parent(rt)
{
if (parent == nullptr)
throw std::invalid_argument("rt");

View File

@ -53,7 +53,7 @@ namespace gs {
gs_zstencil_format get_zstencil_format();
gs::rendertarget_op render(uint32_t width, uint32_t height);
gs::rendertarget_op render(std::uint32_t width, std::uint32_t height);
};
class rendertarget_op {
@ -62,7 +62,7 @@ namespace gs {
public:
~rendertarget_op();
rendertarget_op(gs::rendertarget* rt, uint32_t width, uint32_t height);
rendertarget_op(gs::rendertarget* rt, std::uint32_t width, std::uint32_t height);
// Move Constructor
rendertarget_op(gs::rendertarget_op&&);

View File

@ -78,36 +78,36 @@ gs_address_mode gs::sampler::get_address_mode_w()
return _sampler_info.address_w;
}
void gs::sampler::set_max_anisotropy(int v)
void gs::sampler::set_max_anisotropy(std::int32_t v)
{
_dirty = true;
_sampler_info.max_anisotropy = v;
}
int gs::sampler::get_max_anisotropy()
std::int32_t gs::sampler::get_max_anisotropy()
{
return _sampler_info.max_anisotropy;
}
void gs::sampler::set_border_color(uint32_t v)
void gs::sampler::set_border_color(std::uint32_t v)
{
_dirty = true;
_sampler_info.border_color = v;
}
void gs::sampler::set_border_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
void gs::sampler::set_border_color(std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a)
{
_dirty = true;
_sampler_info.border_color = (static_cast<uint32_t>(a) << 24) | (static_cast<uint32_t>(r) << 16)
| (static_cast<uint32_t>(g) << 8) | static_cast<uint32_t>(b);
_sampler_info.border_color = (static_cast<std::uint32_t>(a) << 24) | (static_cast<std::uint32_t>(r) << 16)
| (static_cast<std::uint32_t>(g) << 8) | static_cast<std::uint32_t>(b);
}
uint32_t gs::sampler::get_border_color()
std::uint32_t gs::sampler::get_border_color()
{
return _sampler_info.border_color;
}
uint8_t gs::sampler::get_border_color(bool r, bool g, bool b, bool a)
std::uint8_t gs::sampler::get_border_color(bool r, bool g, bool b, bool a)
{
if (a)
return (_sampler_info.border_color >> 24) & 0xFF;

View File

@ -38,13 +38,13 @@ namespace gs {
void set_address_mode_w(gs_address_mode v);
gs_address_mode get_address_mode_w();
void set_max_anisotropy(int v);
void set_max_anisotropy(std::int32_t v);
int get_max_anisotropy();
void set_border_color(uint32_t v);
void set_border_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
uint32_t get_border_color();
uint8_t get_border_color(bool r, bool g, bool b, bool a);
void set_border_color(std::uint32_t v);
void set_border_color(std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a);
std::uint32_t get_border_color();
std::uint8_t get_border_color(bool r, bool g, bool b, bool a);
gs_sampler_state* refresh();

View File

@ -24,9 +24,9 @@
#include "obs/gs/gs-helper.hpp"
#include "util-math.hpp"
static uint32_t decode_flags(gs::texture::flags texture_flags)
static std::uint32_t decode_flags(gs::texture::flags texture_flags)
{
uint32_t flags = 0;
std::uint32_t flags = 0;
if (exact(texture_flags, gs::texture::flags::Dynamic))
flags |= GS_DYNAMIC;
if (exact(texture_flags, gs::texture::flags::BuildMipMaps))
@ -34,8 +34,8 @@ static uint32_t decode_flags(gs::texture::flags texture_flags)
return flags;
}
gs::texture::texture(uint32_t width, uint32_t height, gs_color_format format, uint32_t mip_levels,
const uint8_t** mip_data, gs::texture::flags texture_flags)
gs::texture::texture(std::uint32_t width, std::uint32_t height, gs_color_format format, std::uint32_t mip_levels,
const std::uint8_t** mip_data, gs::texture::flags texture_flags)
{
if (width == 0)
throw std::logic_error("width must be at least 1");
@ -61,8 +61,8 @@ gs::texture::texture(uint32_t width, uint32_t height, gs_color_format format, ui
_type = type::Normal;
}
gs::texture::texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_format format, uint32_t mip_levels,
const uint8_t** mip_data, gs::texture::flags texture_flags)
gs::texture::texture(std::uint32_t width, std::uint32_t height, std::uint32_t depth, gs_color_format format,
std::uint32_t mip_levels, const std::uint8_t** mip_data, gs::texture::flags texture_flags)
{
if (width == 0)
throw std::logic_error("width must be at least 1");
@ -93,8 +93,8 @@ gs::texture::texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_f
_type = type::Volume;
}
gs::texture::texture(uint32_t size, gs_color_format format, uint32_t mip_levels, const uint8_t** mip_data,
gs::texture::flags texture_flags)
gs::texture::texture(std::uint32_t size, gs_color_format format, std::uint32_t mip_levels,
const std::uint8_t** mip_data, gs::texture::flags texture_flags)
{
if (size == 0)
throw std::logic_error("size must be at least 1");
@ -150,7 +150,7 @@ gs::texture::~texture()
_texture = nullptr;
}
void gs::texture::load(int unit)
void gs::texture::load(std::int32_t unit)
{
auto gctx = gs::context();
gs_load_texture(_texture, unit);
@ -161,7 +161,7 @@ gs_texture_t* gs::texture::get_object()
return _texture;
}
uint32_t gs::texture::get_width()
std::uint32_t gs::texture::get_width()
{
switch (_type) {
case type::Normal:
@ -174,7 +174,7 @@ uint32_t gs::texture::get_width()
return 0;
}
uint32_t gs::texture::get_height()
std::uint32_t gs::texture::get_height()
{
switch (_type) {
case type::Normal:
@ -187,7 +187,7 @@ uint32_t gs::texture::get_height()
return 0;
}
uint32_t gs::texture::get_depth()
std::uint32_t gs::texture::get_depth()
{
switch (_type) {
case type::Normal:

View File

@ -24,9 +24,9 @@
namespace gs {
class texture {
public:
enum class type : uint8_t { Normal, Volume, Cube };
enum class type : std::uint8_t { Normal, Volume, Cube };
enum class flags : uint8_t {
enum class flags : std::uint8_t {
None,
Dynamic,
BuildMipMaps,
@ -50,8 +50,8 @@ namespace gs {
* \param mip_data Texture data including mipmaps
* \param texture_flags Texture Flags
*/
texture(uint32_t width, uint32_t height, gs_color_format format, uint32_t mip_levels, const uint8_t** mip_data,
gs::texture::flags texture_flags);
texture(std::uint32_t width, std::uint32_t height, gs_color_format format, std::uint32_t mip_levels,
const std::uint8_t** mip_data, gs::texture::flags texture_flags);
/*!
* \brief Create a 3D Texture
@ -64,8 +64,8 @@ namespace gs {
* \param mip_data Texture data including mipmaps
* \param texture_flags Texture Flags
*/
texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_format format, uint32_t mip_levels,
const uint8_t** mip_data, gs::texture::flags texture_flags);
texture(std::uint32_t width, std::uint32_t height, std::uint32_t depth, gs_color_format format,
std::uint32_t mip_levels, const std::uint8_t** mip_data, gs::texture::flags texture_flags);
/*!
* \brief Create a Cube Texture
@ -76,7 +76,7 @@ namespace gs {
* \param mip_data Texture data including mipmaps
* \param texture_flags Texture Flags
*/
texture(uint32_t size, gs_color_format format, uint32_t mip_levels, const uint8_t** mip_data,
texture(std::uint32_t size, gs_color_format format, std::uint32_t mip_levels, const std::uint8_t** mip_data,
gs::texture::flags texture_flags);
/*!
@ -96,15 +96,15 @@ namespace gs {
*/
texture(gs_texture_t* tex, bool takeOwnership = false) : _texture(tex), _is_owner(takeOwnership) {}
void load(int unit);
void load(std::int32_t unit);
gs_texture_t* get_object();
uint32_t get_width();
std::uint32_t get_width();
uint32_t get_height();
std::uint32_t get_height();
uint32_t get_depth();
std::uint32_t get_depth();
gs::texture::type get_type();

View File

@ -26,7 +26,7 @@ gs::vertex::vertex()
{
_store = util::malloc_aligned(16, sizeof(vec3) * 3 + sizeof(uint32_t) + sizeof(vec4) * MAXIMUM_UVW_LAYERS);
size_t offset = 0;
std::size_t offset = 0;
position = reinterpret_cast<vec3*>(reinterpret_cast<char*>(_store) + offset);
offset += sizeof(vec3);
@ -40,7 +40,7 @@ gs::vertex::vertex()
color = reinterpret_cast<uint32_t*>(reinterpret_cast<char*>(_store) + offset);
offset += sizeof(uint32_t);
for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
for (std::size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
uv[n] = reinterpret_cast<vec4*>(reinterpret_cast<char*>(_store) + offset);
offset += sizeof(vec4);
}
@ -57,7 +57,7 @@ gs::vertex::vertex(vec3* p, vec3* n, vec3* t, uint32_t* col, vec4* uvs[MAXIMUM_U
: position(p), normal(n), tangent(t), color(col), _has_store(false)
{
if (uvs != nullptr) {
for (size_t idx = 0; idx < MAXIMUM_UVW_LAYERS; idx++) {
for (std::size_t idx = 0; idx < MAXIMUM_UVW_LAYERS; idx++) {
this->uv[idx] = uvs[idx];
}
}

View File

@ -22,7 +22,7 @@
#include "obs/gs/gs-helper.hpp"
#include "utility.hpp"
void gs::vertex_buffer::initialize(size_t capacity, size_t layers)
void gs::vertex_buffer::initialize(std::size_t capacity, std::size_t layers)
{
if (capacity > MAXIMUM_VERTICES) {
throw std::out_of_range("capacity too large");
@ -41,7 +41,7 @@ void gs::vertex_buffer::initialize(size_t capacity, size_t layers)
_data->colors = _colors = (uint32_t*)util::malloc_aligned(16, sizeof(uint32_t) * _capacity);
if (_layers > 0) {
_data->tvarray = _layer_data = (gs_tvertarray*)util::malloc_aligned(16, sizeof(gs_tvertarray) * _layers);
for (size_t n = 0; n < _layers; n++) {
for (std::size_t n = 0; n < _layers; n++) {
_layer_data[n].array = _uvs[n] = (vec4*)util::malloc_aligned(16, sizeof(vec4) * _capacity);
_layer_data[n].width = 4;
memset(_uvs[n], 0, sizeof(vec4) * _capacity);
@ -69,7 +69,7 @@ gs::vertex_buffer::~vertex_buffer()
util::free_aligned(_colors);
_colors = nullptr;
}
for (size_t n = 0; n < _layers; n++) {
for (std::size_t n = 0; n < _layers; n++) {
if (_uvs[n]) {
util::free_aligned(_uvs[n]);
_uvs[n] = nullptr;
@ -95,9 +95,9 @@ gs::vertex_buffer::~vertex_buffer()
gs::vertex_buffer::vertex_buffer() : vertex_buffer(MAXIMUM_VERTICES, MAXIMUM_UVW_LAYERS) {}
gs::vertex_buffer::vertex_buffer(uint32_t vertices) : vertex_buffer(vertices, MAXIMUM_UVW_LAYERS) {}
gs::vertex_buffer::vertex_buffer(std::uint32_t vertices) : vertex_buffer(vertices, MAXIMUM_UVW_LAYERS) {}
gs::vertex_buffer::vertex_buffer(uint32_t vertices, uint8_t uvlayers)
gs::vertex_buffer::vertex_buffer(std::uint32_t vertices, std::uint8_t uvlayers)
: _size(vertices), _capacity(vertices), _layers(uvlayers), _positions(nullptr), _normals(nullptr),
_tangents(nullptr), _colors(nullptr), _data(nullptr), _buffer(nullptr), _layer_data(nullptr)
{
@ -142,12 +142,12 @@ gs::vertex_buffer::vertex_buffer(gs_vertbuffer_t* vb)
if (_colors && vbd->colors)
memcpy(_colors, vbd->colors, vbd->num * sizeof(uint32_t));
if (vbd->tvarray != nullptr) {
for (size_t n = 0; n < vbd->num_tex; n++) {
for (std::size_t n = 0; n < vbd->num_tex; n++) {
if (vbd->tvarray[n].array != nullptr && vbd->tvarray[n].width <= 4 && vbd->tvarray[n].width > 0) {
if (vbd->tvarray[n].width == 4) {
memcpy(_uvs[n], vbd->tvarray[n].array, vbd->num * sizeof(vec4));
} else if (vbd->tvarray[n].width < 4) {
for (size_t idx = 0; idx < _capacity; idx++) {
for (std::size_t idx = 0; idx < _capacity; idx++) {
float* mem = reinterpret_cast<float*>(vbd->tvarray[n].array) + (idx * vbd->tvarray[n].width);
// cppcheck-suppress memsetClassFloat
memset(&_uvs[n][idx], 0, sizeof(vec4));
@ -167,7 +167,7 @@ gs::vertex_buffer::vertex_buffer(vertex_buffer const& other) : vertex_buffer(oth
memcpy(_normals, other._normals, _capacity * sizeof(vec3));
memcpy(_tangents, other._tangents, _capacity * sizeof(vec3));
memcpy(_colors, other._colors, _capacity * sizeof(vec3));
for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
for (std::size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
memcpy(_uvs[n], other._uvs[n], _capacity * sizeof(vec3));
}
}
@ -182,7 +182,7 @@ gs::vertex_buffer::vertex_buffer(vertex_buffer const&& other) noexcept : _uvs()
_normals = other._normals;
_tangents = other._tangents;
_colors = other._colors;
for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
for (std::size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
_uvs[n] = other._uvs[n];
}
_data = other._data;
@ -210,7 +210,7 @@ void gs::vertex_buffer::operator=(vertex_buffer const&& other) noexcept
util::free_aligned(_colors);
_colors = nullptr;
}
for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
for (std::size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
if (_uvs[n]) {
util::free_aligned(_uvs[n]);
_uvs[n] = nullptr;
@ -240,7 +240,7 @@ void gs::vertex_buffer::operator=(vertex_buffer const&& other) noexcept
_positions = other._positions;
_normals = other._normals;
_tangents = other._tangents;
for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
for (std::size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
_uvs[n] = other._uvs[n];
}
_data = other._data;
@ -248,7 +248,7 @@ void gs::vertex_buffer::operator=(vertex_buffer const&& other) noexcept
_layer_data = other._layer_data;
}
void gs::vertex_buffer::resize(uint32_t new_size)
void gs::vertex_buffer::resize(std::uint32_t new_size)
{
if (new_size > _capacity) {
throw std::out_of_range("new_size out of range");
@ -256,7 +256,7 @@ void gs::vertex_buffer::resize(uint32_t new_size)
_size = new_size;
}
uint32_t gs::vertex_buffer::size()
std::uint32_t gs::vertex_buffer::size()
{
return _size;
}
@ -266,30 +266,30 @@ bool gs::vertex_buffer::empty()
return _size == 0;
}
const gs::vertex gs::vertex_buffer::at(uint32_t idx)
const gs::vertex gs::vertex_buffer::at(std::uint32_t idx)
{
if (idx >= _size) {
throw std::out_of_range("idx out of range");
}
gs::vertex vtx(&_positions[idx], &_normals[idx], &_tangents[idx], &_colors[idx], nullptr);
for (size_t n = 0; n < _layers; n++) {
for (std::size_t n = 0; n < _layers; n++) {
vtx.uv[n] = &_uvs[n][idx];
}
return vtx;
}
const gs::vertex gs::vertex_buffer::operator[](uint32_t const pos)
const gs::vertex gs::vertex_buffer::operator[](std::uint32_t const pos)
{
return at(pos);
}
void gs::vertex_buffer::set_uv_layers(uint32_t layers)
void gs::vertex_buffer::set_uv_layers(std::uint32_t layers)
{
_layers = layers;
}
uint32_t gs::vertex_buffer::get_uv_layers()
std::uint32_t gs::vertex_buffer::get_uv_layers()
{
return _layers;
}
@ -314,7 +314,7 @@ uint32_t* gs::vertex_buffer::get_colors()
return _colors;
}
vec4* gs::vertex_buffer::get_uv_layer(size_t idx)
vec4* gs::vertex_buffer::get_uv_layer(std::size_t idx)
{
if (idx >= _layers) {
throw std::out_of_range("idx out of range");
@ -341,7 +341,7 @@ gs_vertbuffer_t* gs::vertex_buffer::update(bool refreshGPU)
_data->colors = _colors;
_data->num_tex = _layers;
_data->tvarray = _layer_data;
for (size_t n = 0; n < _layers; n++) {
for (std::size_t n = 0; n < _layers; n++) {
_layer_data[n].array = _uvs[n];
_layer_data[n].width = 4;
}
@ -353,7 +353,7 @@ gs_vertbuffer_t* gs::vertex_buffer::update(bool refreshGPU)
memset(_data, 0, sizeof(gs_vb_data));
_data->num = _capacity;
_data->num_tex = _layers;
for (uint32_t n = 0; n < _layers; n++) {
for (std::uint32_t n = 0; n < _layers; n++) {
_layer_data[n].width = 4;
}

View File

@ -25,9 +25,9 @@
namespace gs {
class vertex_buffer {
uint32_t _size;
uint32_t _capacity;
uint32_t _layers;
std::uint32_t _size;
std::uint32_t _capacity;
std::uint32_t _layers;
// Memory Storage
vec3* _positions;
@ -41,7 +41,7 @@ namespace gs {
gs_vertbuffer_t* _buffer;
gs_tvertarray* _layer_data;
void initialize(size_t capacity, size_t layers);
void initialize(std::size_t capacity, std::size_t layers);
public:
virtual ~vertex_buffer();
@ -56,7 +56,7 @@ namespace gs {
*
* \param vertices Number of vertices to store.
*/
vertex_buffer(uint32_t vertices);
vertex_buffer(std::uint32_t vertices);
/*!
* \brief Create a Vertex Buffer with a specific number of Vertices and uv layers.
@ -64,7 +64,7 @@ namespace gs {
* \param vertices Number of vertices to store.
* \param layers Number of uv layers to store.
*/
vertex_buffer(uint32_t vertices, uint8_t layers);
vertex_buffer(std::uint32_t vertices, std::uint8_t layers);
/*!
* \brief Create a copy of a Vertex Buffer
@ -110,19 +110,19 @@ namespace gs {
*/
void operator=(vertex_buffer const&& other) noexcept;
void resize(uint32_t new_size);
void resize(std::uint32_t new_size);
uint32_t size();
std::uint32_t size();
bool empty();
const gs::vertex at(uint32_t idx);
const gs::vertex at(std::uint32_t idx);
const gs::vertex operator[](uint32_t const pos);
const gs::vertex operator[](std::uint32_t const pos);
void set_uv_layers(uint32_t layers);
void set_uv_layers(std::uint32_t layers);
uint32_t get_uv_layers();
std::uint32_t get_uv_layers();
/*!
* \brief Directly access the positions buffer
@ -162,7 +162,7 @@ namespace gs {
*
* \return A <vec4*> that points at the first vertex's uv.
*/
vec4* get_uv_layer(size_t idx);
vec4* get_uv_layer(std::size_t idx);
gs_vertbuffer_t* update();

View File

@ -225,7 +225,7 @@ namespace obs {
LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__);
}
static uint32_t _get_width(void* data) noexcept
static std::uint32_t _get_width(void* data) noexcept
try {
if (data)
return reinterpret_cast<_instance*>(data)->get_width();
@ -238,7 +238,7 @@ namespace obs {
return 0;
}
static uint32_t _get_height(void* data) noexcept
static std::uint32_t _get_height(void* data) noexcept
try {
if (data)
return reinterpret_cast<_instance*>(data)->get_height();
@ -387,7 +387,7 @@ namespace obs {
}
static void _mouse_click(void* data, const struct obs_mouse_event* event, int32_t type, bool mouse_up,
uint32_t click_count) noexcept
std::uint32_t click_count) noexcept
try {
if (data)
reinterpret_cast<_instance*>(data)->mouse_click(event, type, mouse_up, click_count);
@ -448,7 +448,7 @@ namespace obs {
}
static bool _audio_render(void* data, uint64_t* ts_out, struct obs_source_audio_mix* audio_output,
uint32_t mixers, size_t channels, size_t sample_rate) noexcept
std::uint32_t mixers, std::size_t channels, std::size_t sample_rate) noexcept
try {
if (data)
return reinterpret_cast<_instance*>(data)->audio_render(ts_out, audio_output, mixers, channels,
@ -492,8 +492,8 @@ namespace obs {
LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__);
}
static bool _audio_mix(void* data, uint64_t* ts_out, struct audio_output_data* audio_output, size_t channels,
size_t sample_rate) noexcept
static bool _audio_mix(void* data, uint64_t* ts_out, struct audio_output_data* audio_output,
std::size_t channels, std::size_t sample_rate) noexcept
try {
if (data)
return reinterpret_cast<_instance*>(data)->audio_mix(ts_out, audio_output, channels, sample_rate);
@ -533,12 +533,12 @@ namespace obs {
source_instance(obs_data_t* settings, obs_source_t* source) : _self(source) {}
virtual ~source_instance(){};
virtual uint32_t get_width()
virtual std::uint32_t get_width()
{
return 0;
}
virtual uint32_t get_height()
virtual std::uint32_t get_height()
{
return 0;
}
@ -551,7 +551,7 @@ namespace obs {
virtual void hide() {}
virtual void video_tick(float seconds) {}
virtual void video_tick(float_t seconds) {}
virtual void video_render(gs_effect_t* effect) {}
@ -575,12 +575,13 @@ namespace obs {
virtual void save(obs_data_t* settings) {}
virtual void mouse_click(const struct obs_mouse_event* event, int32_t type, bool mouse_up, uint32_t click_count)
virtual void mouse_click(const struct obs_mouse_event* event, std::int32_t type, bool mouse_up,
std::uint32_t click_count)
{}
virtual void mouse_move(const struct obs_mouse_event* event, bool mouse_leave) {}
virtual void mouse_wheel(const struct obs_mouse_event* event, int x_delta, int y_delta) {}
virtual void mouse_wheel(const struct obs_mouse_event* event, std::int32_t x_delta, std::int32_t y_delta) {}
virtual void focus(bool focus) {}
@ -588,8 +589,8 @@ namespace obs {
virtual void filter_remove(obs_source_t* source) {}
virtual bool audio_render(uint64_t* ts_out, struct obs_source_audio_mix* audio_output, uint32_t mixers,
size_t channels, size_t sample_rate)
virtual bool audio_render(std::uint64_t* ts_out, struct obs_source_audio_mix* audio_output,
std::uint32_t mixers, std::size_t channels, std::size_t sample_rate)
{
return false;
}
@ -600,8 +601,8 @@ namespace obs {
virtual void transition_stop() {}
virtual bool audio_mix(uint64_t* ts_out, struct audio_output_data* audio_output, size_t channels,
size_t sample_rate)
virtual bool audio_mix(std::uint64_t* ts_out, struct audio_output_data* audio_output, std::size_t channels,
std::size_t sample_rate)
{
return false;
}

View File

@ -185,13 +185,13 @@ bool obs::source_tracker::filter_sources(std::string, obs_source_t* source)
bool obs::source_tracker::filter_audio_sources(std::string, obs_source_t* source)
{
uint32_t flags = obs_source_get_output_flags(source);
std::uint32_t flags = obs_source_get_output_flags(source);
return !(flags & OBS_SOURCE_AUDIO) || (obs_source_get_type(source) != OBS_SOURCE_TYPE_INPUT);
}
bool obs::source_tracker::filter_video_sources(std::string, obs_source_t* source)
{
uint32_t flags = obs_source_get_output_flags(source);
std::uint32_t flags = obs_source_get_output_flags(source);
return !(flags & OBS_SOURCE_VIDEO) || (obs_source_get_type(source) != OBS_SOURCE_TYPE_INPUT);
}

View File

@ -371,11 +371,11 @@ try {
void obs::deprecated_source::handle_audio_data(void* p, obs_source_t*, const audio_data* audio, bool muted) noexcept
try {
obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p);
if (!self->events.audio_data) {
if (!self->events.audio) {
return;
}
self->events.audio_data(self, audio, muted);
self->events.audio(self, audio, muted);
} catch (const std::exception& ex) {
LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what());
} catch (...) {
@ -498,7 +498,7 @@ obs::deprecated_source::~deprecated_source()
auto_signal_d(update_flags);
auto_signal_d(audio_sync);
auto_signal_d(audio_mixers);
auto_signal_d(audio_data);
auto_signal_d(audio);
auto_signal_d(filter_add);
auto_signal_d(filter_remove);
auto_signal_d(reorder_filters);
@ -550,12 +550,12 @@ obs::deprecated_source::deprecated_source()
// libOBS unfortunately does not use the event system for audio data callbacks, which is kind of odd as most other
// things do. So instead we'll have to manually deal with it for now.
{
this->events.audio_data.set_listen_callback([this]() noexcept {
this->events.audio.set_listen_callback([this]() noexcept {
if (!this->_self)
return;
obs_source_add_audio_capture_callback(this->_self, obs::deprecated_source::handle_audio_data, this);
});
this->events.audio_data.set_silence_callback([this]() noexcept {
this->events.audio.set_silence_callback([this]() noexcept {
if (!this->_self)
return;
obs_source_remove_audio_capture_callback(this->_self, obs::deprecated_source::handle_audio_data, this);
@ -624,7 +624,7 @@ obs::deprecated_source::deprecated_source(deprecated_source const& other)
auto_signal_c(update_flags);
auto_signal_c(audio_sync);
auto_signal_c(audio_mixers);
auto_signal_c(audio_data);
auto_signal_c(audio);
auto_signal_c(filter_add);
auto_signal_c(filter_remove);
auto_signal_c(reorder_filters);
@ -676,7 +676,7 @@ obs::deprecated_source& obs::deprecated_source::operator=(deprecated_source cons
auto_signal_c(update_flags);
auto_signal_c(audio_sync);
auto_signal_c(audio_mixers);
auto_signal_c(audio_data);
auto_signal_c(audio);
auto_signal_c(filter_add);
auto_signal_c(filter_remove);
auto_signal_c(reorder_filters);
@ -720,7 +720,7 @@ obs::deprecated_source::deprecated_source(deprecated_source&& other)
auto_signal_c(update_flags);
auto_signal_c(audio_sync);
auto_signal_c(audio_mixers);
auto_signal_c(audio_data);
auto_signal_c(audio);
auto_signal_c(filter_add);
auto_signal_c(filter_remove);
auto_signal_c(reorder_filters);
@ -770,7 +770,7 @@ obs::deprecated_source& obs::deprecated_source::operator=(deprecated_source&& ot
auto_signal_c(update_flags);
auto_signal_c(audio_sync);
auto_signal_c(audio_mixers);
auto_signal_c(audio_data);
auto_signal_c(audio);
auto_signal_c(filter_add);
auto_signal_c(filter_remove);
auto_signal_c(reorder_filters);
@ -798,7 +798,7 @@ void* obs::deprecated_source::type_data()
return obs_source_get_type_data(_self);
}
uint32_t obs::deprecated_source::width()
std::uint32_t obs::deprecated_source::width()
{
if (!_self) {
return 0;
@ -806,7 +806,7 @@ uint32_t obs::deprecated_source::width()
return obs_source_get_width(_self);
}
uint32_t obs::deprecated_source::height()
std::uint32_t obs::deprecated_source::height()
{
if (!_self) {
return 0;

View File

@ -76,8 +76,8 @@ namespace obs {
void* type_data();
uint32_t width();
uint32_t height();
std::uint32_t width();
std::uint32_t height();
bool destroyed();
@ -121,7 +121,7 @@ namespace obs {
util::event<obs::deprecated_source*, double&> volume;
util::event<obs::deprecated_source*, long long&> audio_sync;
util::event<obs::deprecated_source*, long long&> audio_mixers;
util::event<obs::deprecated_source*, const audio_data*, bool> audio_data;
util::event<obs::deprecated_source*, const audio_data*, bool> audio;
// Filters
util::event<obs::deprecated_source*, obs_source_t*> filter_add;

View File

@ -105,7 +105,7 @@ struct _hack_obs_property {
struct _hack_obs_properties {
void* param;
void (*destroy)(void* param);
uint32_t flags;
std::uint32_t flags;
struct _hack_obs_property* first_property;
struct _hack_obs_property** last;

View File

@ -38,22 +38,22 @@ namespace obs {
};
} // namespace tools
static void obs_source_deleter(obs_source_t* v)
inline void obs_source_deleter(obs_source_t* v)
{
obs_source_release(v);
}
static void obs_scene_deleter(obs_scene_t* v)
inline void obs_scene_deleter(obs_scene_t* v)
{
obs_scene_release(v);
}
static void obs_sceneitem_releaser(obs_scene_item* v)
inline void obs_sceneitem_releaser(obs_scene_item* v)
{
obs_sceneitem_release(v);
}
static void obs_sceneitem_remover(obs_scene_item* v)
inline void obs_sceneitem_remover(obs_scene_item* v)
{
obs_sceneitem_remove(v);
}

View File

@ -59,7 +59,7 @@ source::mirror::mirror_audio_data::mirror_audio_data(const audio_data* audio, sp
osa.format = aoi->format;
osa.samples_per_sec = aoi->samples_per_sec;
data.resize(MAX_AV_PLANES);
for (size_t idx = 0; idx < MAX_AV_PLANES; idx++) {
for (std::size_t idx = 0; idx < MAX_AV_PLANES; idx++) {
if (!audio->data[idx]) {
osa.data[idx] = nullptr;
continue;
@ -81,12 +81,12 @@ mirror::mirror_instance::~mirror_instance()
release();
}
uint32_t mirror::mirror_instance::get_width()
std::uint32_t mirror::mirror_instance::get_width()
{
return _source_size.first;
}
uint32_t mirror::mirror_instance::get_height()
std::uint32_t mirror::mirror_instance::get_height()
{
return _source_size.second;
}
@ -126,7 +126,7 @@ void mirror::mirror_instance::save(obs_data_t* data)
}
}
void mirror::mirror_instance::video_tick(float time)
void mirror::mirror_instance::video_tick(float_t time)
{
if (_source) {
_source_size.first = obs_source_get_width(_source.get());
@ -215,7 +215,7 @@ void source::mirror::mirror_instance::on_audio(std::shared_ptr<obs_source_t>, co
detected_layout = _audio_layout;
} else {
std::bitset<MAX_AV_PLANES> layout_detection;
for (size_t idx = 0; idx < MAX_AV_PLANES; idx++) {
for (std::size_t idx = 0; idx < MAX_AV_PLANES; idx++) {
layout_detection.set(idx, audio->data[idx] != nullptr);
}
switch (layout_detection.to_ulong()) {

View File

@ -36,8 +36,8 @@ namespace source::mirror {
struct mirror_audio_data {
mirror_audio_data(const audio_data*, speaker_layout);
obs_source_audio osa;
std::vector<std::vector<uint8_t>> data;
obs_source_audio osa;
std::vector<std::vector<std::uint8_t>> data;
};
class mirror_instance : public obs::source_instance {
@ -58,8 +58,8 @@ namespace source::mirror {
mirror_instance(obs_data_t* settings, obs_source_t* self);
virtual ~mirror_instance();
virtual uint32_t get_width() override;
virtual uint32_t get_height() override;
virtual std::uint32_t get_width() override;
virtual std::uint32_t get_height() override;
virtual void load(obs_data_t*) override;
virtual void migrate(obs_data_t*, std::uint64_t) override;

View File

@ -35,12 +35,12 @@ shader::shader_instance::shader_instance(obs_data_t* data, obs_source_t* self) :
shader::shader_instance::~shader_instance() {}
uint32_t shader::shader_instance::get_width()
std::uint32_t shader::shader_instance::get_width()
{
return _fx->width();
}
uint32_t shader::shader_instance::get_height()
std::uint32_t shader::shader_instance::get_height()
{
return _fx->height();
}

View File

@ -32,8 +32,8 @@ namespace source::shader {
shader_instance(obs_data_t* data, obs_source_t* self);
virtual ~shader_instance();
virtual uint32_t get_width() override;
virtual uint32_t get_height() override;
virtual std::uint32_t get_width() override;
virtual std::uint32_t get_height() override;
void properties(obs_properties_t* props);

View File

@ -34,12 +34,12 @@ transition::shader::shader_instance::shader_instance(obs_data_t* data, obs_sourc
transition::shader::shader_instance::~shader_instance() {}
uint32_t transition::shader::shader_instance::get_width()
std::uint32_t transition::shader::shader_instance::get_width()
{
return _fx->width();
}
uint32_t transition::shader::shader_instance::get_height()
std::uint32_t transition::shader::shader_instance::get_height()
{
return _fx->height();
}
@ -80,14 +80,14 @@ void transition::shader::shader_instance::video_render(gs_effect_t* effect)
}
_fx->prepare_render();
obs_transition_video_render(_self,
[](void* data, gs_texture_t* a, gs_texture_t* b, float t, uint32_t cx, uint32_t cy) {
reinterpret_cast<shader_instance*>(data)->transition_render(a, b, t, cx, cy);
});
obs_transition_video_render(
_self, [](void* data, gs_texture_t* a, gs_texture_t* b, float t, std::uint32_t cx, std::uint32_t cy) {
reinterpret_cast<shader_instance*>(data)->transition_render(a, b, t, cx, cy);
});
}
void transition::shader::shader_instance::transition_render(gs_texture_t* a, gs_texture_t* b, float t, uint32_t cx,
uint32_t cy)
void transition::shader::shader_instance::transition_render(gs_texture_t* a, gs_texture_t* b, float_t t,
std::uint32_t cx, std::uint32_t cy)
{
_fx->set_input_a(std::make_shared<::gs::texture>(a, false));
_fx->set_input_b(std::make_shared<::gs::texture>(b, false));
@ -97,7 +97,8 @@ void transition::shader::shader_instance::transition_render(gs_texture_t* a, gs_
}
bool transition::shader::shader_instance::audio_render(uint64_t* ts_out, obs_source_audio_mix* audio_output,
uint32_t mixers, size_t channels, size_t sample_rate)
std::uint32_t mixers, std::size_t channels,
std::size_t sample_rate)
{
return obs_transition_audio_render(
_self, ts_out, audio_output, mixers, channels, sample_rate, [](void*, float_t t) { return 1.0f - t; },

View File

@ -34,8 +34,8 @@ namespace transition::shader {
shader_instance(obs_data_t* data, obs_source_t* self);
virtual ~shader_instance();
virtual uint32_t get_width() override;
virtual uint32_t get_height() override;
virtual std::uint32_t get_width() override;
virtual std::uint32_t get_height() override;
void properties(obs_properties_t* props);
@ -45,10 +45,10 @@ namespace transition::shader {
virtual void video_tick(float_t sec_since_last) override;
virtual void video_render(gs_effect_t* effect) override;
void transition_render(gs_texture_t* a, gs_texture_t* b, float t, uint32_t cx, uint32_t cy);
void transition_render(gs_texture_t* a, gs_texture_t* b, float_t t, std::uint32_t cx, std::uint32_t cy);
virtual bool audio_render(uint64_t* ts_out, struct obs_source_audio_mix* audio_output, uint32_t mixers,
size_t channels, size_t sample_rate) override;
virtual bool audio_render(uint64_t* ts_out, struct obs_source_audio_mix* audio_output, std::uint32_t mixers,
std::size_t channels, std::size_t sample_rate) override;
virtual void transition_start() override;
virtual void transition_stop() override;

View File

@ -25,8 +25,8 @@
util::threadpool::threadpool() : _workers(), _worker_stop(false), _tasks(), _tasks_lock(), _tasks_cv()
{
size_t concurrency = static_cast<size_t>(std::thread::hardware_concurrency()) * CONCURRENCY_MULTIPLIER;
for (size_t n = 0; n < concurrency; n++) {
std::size_t concurrency = static_cast<size_t>(std::thread::hardware_concurrency()) * CONCURRENCY_MULTIPLIER;
for (std::size_t n = 0; n < concurrency; n++) {
_workers.emplace_back(std::bind(&util::threadpool::work, this));
}
}

View File

@ -34,7 +34,7 @@
#pragma warning(pop)
#endif
const char* obs_module_recursive_text(const char* to_translate, size_t depth)
const char* obs_module_recursive_text(const char* to_translate, std::size_t depth)
{
static std::unordered_map<std::string, std::string> translate_map;
@ -51,10 +51,10 @@ const char* obs_module_recursive_text(const char* to_translate, size_t depth)
std::stringstream out;
{
size_t seq_start = 0, seq_end = 0;
bool seq_got = false;
std::size_t seq_start = 0, seq_end = 0;
bool seq_got = false;
for (size_t pos = 0; pos <= orig.length(); pos++) {
for (std::size_t pos = 0; pos <= orig.length(); pos++) {
std::string chr = orig.substr(pos, 2);
if (chr == "\\@") {
if (seq_got) {
@ -93,12 +93,12 @@ obs_property_t* util::obs_properties_add_tristate(obs_properties_t* props, const
return p;
}
void* util::vec2a::operator new(size_t count)
void* util::vec2a::operator new(std::size_t count)
{
return util::malloc_aligned(16, count);
}
void* util::vec2a::operator new[](size_t count)
void* util::vec2a::operator new[](std::size_t count)
{
return util::malloc_aligned(16, count);
}
@ -113,12 +113,12 @@ void util::vec2a::operator delete[](void* p)
util::free_aligned(p);
}
void* util::vec3a::operator new(size_t count)
void* util::vec3a::operator new(std::size_t count)
{
return util::malloc_aligned(16, count);
}
void* util::vec3a::operator new[](size_t count)
void* util::vec3a::operator new[](std::size_t count)
{
return util::malloc_aligned(16, count);
}
@ -133,12 +133,12 @@ void util::vec3a::operator delete[](void* p)
util::free_aligned(p);
}
void* util::vec4a::operator new(size_t count)
void* util::vec4a::operator new(std::size_t count)
{
return util::malloc_aligned(16, count);
}
void* util::vec4a::operator new[](size_t count)
void* util::vec4a::operator new[](std::size_t count)
{
return util::malloc_aligned(16, count);
}
@ -193,7 +193,7 @@ std::pair<int64_t, int64_t> util::size_from_string(std::string text, bool allowS
return {width, height};
}
void* util::malloc_aligned(size_t align, size_t size)
void* util::malloc_aligned(std::size_t align, std::size_t size)
{
#ifdef USE_MSC_ALLOC
return _aligned_malloc(size, align);
@ -201,7 +201,7 @@ void* util::malloc_aligned(size_t align, size_t size)
return aligned_alloc(size, align);
#else
// Ensure that we have space for the pointer and the data.
size_t asize = aligned_offset(align, size + (sizeof(void*) * 2));
std::size_t asize = aligned_offset(align, size + (sizeof(void*) * 2));
// Allocate memory and store integer representation of pointer.
void* ptr = malloc(asize);

View File

@ -46,7 +46,7 @@ extern "C" {
#define D_DEG_TO_RAD(x) (x * S_DEG)
#define D_RAD_TO_DEG(x) (x * S_RAD)
const char* obs_module_recursive_text(const char* to_translate, size_t depth = std::numeric_limits<size_t>::max());
const char* obs_module_recursive_text(const char* to_translate, std::size_t depth = std::numeric_limits<size_t>::max());
template<typename Enum>
struct enable_bitmask_operators {
@ -98,25 +98,25 @@ namespace util {
obs_property_t* obs_properties_add_tristate(obs_properties_t* props, const char* name, const char* desc);
inline bool is_tristate_enabled(int64_t tristate)
inline bool is_tristate_enabled(std::int64_t tristate)
{
return tristate == 1;
}
inline bool is_tristate_disabled(int64_t tristate)
inline bool is_tristate_disabled(std::int64_t tristate)
{
return tristate == 0;
}
inline bool is_tristate_default(int64_t tristate)
inline bool is_tristate_default(std::int64_t tristate)
{
return tristate == -1;
}
struct vec2a : public vec2 {
// 16-byte Aligned version of vec2
static void* operator new(size_t count);
static void* operator new[](size_t count);
static void* operator new(std::size_t count);
static void* operator new[](std::size_t count);
static void operator delete(void* p);
static void operator delete[](void* p);
};
@ -126,8 +126,8 @@ namespace util {
#endif
struct vec3a : public vec3 {
// 16-byte Aligned version of vec3
static void* operator new(size_t count);
static void* operator new[](size_t count);
static void* operator new(std::size_t count);
static void* operator new[](std::size_t count);
static void operator delete(void* p);
static void operator delete[](void* p);
};
@ -137,8 +137,8 @@ namespace util {
#endif
struct vec4a : public vec4 {
// 16-byte Aligned version of vec4
static void* operator new(size_t count);
static void* operator new[](size_t count);
static void* operator new(std::size_t count);
static void* operator new[](std::size_t count);
static void operator delete(void* p);
static void operator delete[](void* p);
};
@ -154,13 +154,13 @@ namespace util {
inline bool is_power_of_two(T v)
{
return T(1ull << uint64_t(floor(log10(T(v)) / log10(2.0)))) == v;
};
}
template<typename T>
inline bool is_power_of_two_loop(T v)
{
bool have_bit = false;
for (size_t index = 0; index < (sizeof(T) * 8); index++) {
for (std::size_t index = 0; index < (sizeof(T) * 8); index++) {
bool cur = (v & (static_cast<T>(1ull) << index)) != 0;
if (cur) {
if (have_bit)
@ -178,27 +178,27 @@ namespace util {
{ \
return is_power_of_two_loop(v); \
}
P_IS_POWER_OF_TWO_AS_LOOP(int8_t)
P_IS_POWER_OF_TWO_AS_LOOP(uint8_t)
P_IS_POWER_OF_TWO_AS_LOOP(int16_t)
P_IS_POWER_OF_TWO_AS_LOOP(uint16_t)
P_IS_POWER_OF_TWO_AS_LOOP(int32_t)
P_IS_POWER_OF_TWO_AS_LOOP(uint32_t)
P_IS_POWER_OF_TWO_AS_LOOP(int64_t)
P_IS_POWER_OF_TWO_AS_LOOP(uint64_t)
P_IS_POWER_OF_TWO_AS_LOOP(std::int8_t)
P_IS_POWER_OF_TWO_AS_LOOP(std::uint8_t)
P_IS_POWER_OF_TWO_AS_LOOP(std::int16_t)
P_IS_POWER_OF_TWO_AS_LOOP(std::uint16_t)
P_IS_POWER_OF_TWO_AS_LOOP(std::int32_t)
P_IS_POWER_OF_TWO_AS_LOOP(std::uint32_t)
P_IS_POWER_OF_TWO_AS_LOOP(std::int64_t)
P_IS_POWER_OF_TWO_AS_LOOP(std::uint64_t)
#undef P_IS_POWER_OF_TWO_AS_LOOP
#pragma pop_macro("P_IS_POWER_OF_TWO_AS_LOOP")
template<typename T>
inline uint64_t get_power_of_two_exponent_floor(T v)
inline std::uint64_t get_power_of_two_exponent_floor(T v)
{
return uint64_t(floor(log10(T(v)) / log10(2.0)));
return std::uint64_t(floor(log10(T(v)) / log10(2.0)));
}
template<typename T>
inline uint64_t get_power_of_two_exponent_ceil(T v)
inline std::uint64_t get_power_of_two_exponent_ceil(T v)
{
return uint64_t(ceil(log10(T(v)) / log10(2.0)));
return std::uint64_t(ceil(log10(T(v)) / log10(2.0)));
}
template<typename T, typename C>
@ -212,8 +212,8 @@ namespace util {
inline T gaussian(T x, T o /*, T u = 0*/)
{
// u/µ can be simulated by subtracting that value from x.
static const double_t pi = 3.1415926535897932384626433832795;
static const double_t two_pi = pi * 2.;
//static const double_t pi = 3.1415926535897932384626433832795;
//static const double_t two_pi = pi * 2.;
static const double_t two_pi_sqroot = 2.506628274631000502415765284811; //sqrt(two_pi);
if (is_equal<double_t>(0, o)) {
@ -271,10 +271,10 @@ namespace util {
};
} // namespace math
inline size_t aligned_offset(size_t align, size_t pos)
inline std::size_t aligned_offset(std::size_t align, std::size_t pos)
{
return ((pos / align) + 1) * align;
}
void* malloc_aligned(size_t align, size_t size);
void* malloc_aligned(std::size_t align, std::size_t size);
void free_aligned(void* mem);
} // namespace util