New upstream version 26.1.0+dfsg1

This commit is contained in:
Sebastian Ramacher 2020-12-22 18:32:50 +01:00
parent 040dcc3fc2
commit 013818c4af
594 changed files with 19576 additions and 4478 deletions

52
libobs/util/bitstream.c Normal file
View file

@ -0,0 +1,52 @@
#include "bitstream.h"
#include <stdlib.h>
#include <string.h>
void bitstream_reader_init(struct bitstream_reader *r, uint8_t *data,
size_t len)
{
memset(r, 0, sizeof(struct bitstream_reader));
r->buf = data;
r->subPos = 0x80;
r->len = len;
}
uint8_t bitstream_reader_read_bit(struct bitstream_reader *r)
{
if (r->pos >= r->len)
return 0;
uint8_t bit = (*(r->buf + r->pos) & r->subPos) == r->subPos ? 1 : 0;
r->subPos >>= 0x1;
if (r->subPos == 0) {
r->subPos = 0x80;
r->pos++;
}
return bit;
}
uint8_t bitstream_reader_read_bits(struct bitstream_reader *r, int bits)
{
uint8_t res = 0;
for (int i = 1; i <= bits; i++) {
res <<= 1;
res |= bitstream_reader_read_bit(r);
}
return res;
}
uint8_t bitstream_reader_r8(struct bitstream_reader *r)
{
return bitstream_reader_read_bits(r, 8);
}
uint16_t bitstream_reader_r16(struct bitstream_reader *r)
{
uint8_t b = bitstream_reader_read_bits(r, 8);
return ((uint16_t)b << 8) | bitstream_reader_read_bits(r, 8);
}

29
libobs/util/bitstream.h Normal file
View file

@ -0,0 +1,29 @@
#pragma once
#include "c99defs.h"
/*
* General programmable serialization functions. (A shared interface to
* various reading/writing to/from different inputs/outputs)
*/
#ifdef __cplusplus
extern "C" {
#endif
struct bitstream_reader {
uint8_t pos;
uint8_t subPos;
uint8_t *buf;
size_t len;
};
EXPORT void bitstream_reader_init(struct bitstream_reader *r, uint8_t *data,
size_t len);
EXPORT uint8_t bitstream_reader_read_bits(struct bitstream_reader *r, int bits);
EXPORT uint8_t bitstream_reader_r8(struct bitstream_reader *r);
EXPORT uint16_t bitstream_reader_r16(struct bitstream_reader *r);
#ifdef __cplusplus
}
#endif

View file

@ -57,11 +57,15 @@ static inline bool create_process(const char *cmd_line, HANDLE stdin_handle,
si.hStdOutput = stdout_handle;
si.hStdError = stderr_handle;
DWORD flags = 0;
#ifndef SHOW_SUBPROCESSES
flags = CREATE_NO_WINDOW;
#endif
os_utf8_to_wcs_ptr(cmd_line, 0, &cmd_line_w);
if (cmd_line_w) {
success = !!CreateProcessW(NULL, cmd_line_w, NULL, NULL, true,
CREATE_NO_WINDOW, NULL, NULL, &si,
&pi);
flags, NULL, NULL, &si, &pi);
if (success) {
*process = pi.hProcess;

View file

@ -34,14 +34,16 @@
#include <sys/times.h>
#include <sys/wait.h>
#include <libgen.h>
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(__OpenBSD__)
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/user.h>
#include <unistd.h>
#if defined(__FreeBSD__)
#include <libprocstat.h>
#endif
#else
#include <sys/resource.h>
#endif
@ -272,6 +274,62 @@ char *os_get_program_data_path_ptr(const char *name)
return str;
}
#if defined(__OpenBSD__)
// a bit modified version of https://stackoverflow.com/a/31495527
ssize_t os_openbsd_get_executable_path(char *epath)
{
int mib[4];
char **argv;
size_t len;
const char *comm;
int ok = 0;
mib[0] = CTL_KERN;
mib[1] = KERN_PROC_ARGS;
mib[2] = getpid();
mib[3] = KERN_PROC_ARGV;
if (sysctl(mib, 4, NULL, &len, NULL, 0) < 0)
abort();
if (!(argv = malloc(len)))
abort();
if (sysctl(mib, 4, argv, &len, NULL, 0) < 0)
abort();
comm = argv[0];
if (*comm == '/' || *comm == '.') {
if (realpath(comm, epath))
ok = 1;
} else {
char *sp;
char *xpath = strdup(getenv("PATH"));
char *path = strtok_r(xpath, ":", &sp);
struct stat st;
if (!xpath)
abort();
while (path) {
snprintf(epath, PATH_MAX, "%s/%s", path, comm);
if (!stat(epath, &st) && (st.st_mode & S_IXUSR)) {
ok = 1;
break;
}
path = strtok_r(NULL, ":", &sp);
}
free(xpath);
}
free(argv);
return ok ? (ssize_t)strlen(epath) : -1;
}
#endif
char *os_get_executable_path_ptr(const char *name)
{
char exe[PATH_MAX];
@ -286,6 +344,8 @@ char *os_get_executable_path_ptr(const char *name)
return NULL;
}
count = pathlen;
#elif defined(__OpenBSD__)
ssize_t count = os_openbsd_get_executable_path(exe);
#else
ssize_t count = readlink("/proc/self/exe", exe, PATH_MAX - 1);
if (count >= 0) {

View file

@ -1058,7 +1058,11 @@ bool profiler_snapshot_dump_csv_gz(const profiler_snapshot_t *snap,
profiler_snapshot_dump(snap, dump_csv_gzwrite, gz);
#ifdef _WIN32
gzclose_w(gz);
#else
gzclose(gz);
#endif
return true;
}