New upstream version 21.0.2+dfsg1
This commit is contained in:
parent
1f1bbb3518
commit
baafb6325b
706 changed files with 49633 additions and 5044 deletions
|
|
@ -368,6 +368,13 @@ void gs_effect_set_vec4(gs_eparam_t *param, const struct vec4 *val)
|
|||
effect_setval_inline(param, val, sizeof(struct vec4));
|
||||
}
|
||||
|
||||
void gs_effect_set_color(gs_eparam_t *param, uint32_t argb)
|
||||
{
|
||||
struct vec4 v_color;
|
||||
vec4_from_bgra(&v_color, argb);
|
||||
effect_setval_inline(param, &v_color, sizeof(struct vec4));
|
||||
}
|
||||
|
||||
void gs_effect_set_texture(gs_eparam_t *param, gs_texture_t *val)
|
||||
{
|
||||
effect_setval_inline(param, &val, sizeof(gs_texture_t*));
|
||||
|
|
|
|||
|
|
@ -164,8 +164,19 @@ static bool ffmpeg_image_decode(struct ffmpeg_image *info, uint8_t *out,
|
|||
}
|
||||
|
||||
while (!got_frame) {
|
||||
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 40, 101)
|
||||
ret = avcodec_send_packet(info->decoder_ctx, &packet);
|
||||
if (ret == 0)
|
||||
ret = avcodec_receive_frame(info->decoder_ctx, frame);
|
||||
|
||||
got_frame = (ret == 0);
|
||||
|
||||
if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
|
||||
ret = 0;
|
||||
#else
|
||||
ret = avcodec_decode_video2(info->decoder_ctx, frame,
|
||||
&got_frame, &packet);
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
blog(LOG_WARNING, "Failed to decode frame for '%s': %s",
|
||||
info->file, av_err2str(ret));
|
||||
|
|
@ -176,7 +187,7 @@ static bool ffmpeg_image_decode(struct ffmpeg_image *info, uint8_t *out,
|
|||
success = ffmpeg_image_reformat_frame(info, frame, out, linesize);
|
||||
|
||||
fail:
|
||||
av_free_packet(&packet);
|
||||
av_packet_unref(&packet);
|
||||
av_frame_free(&frame);
|
||||
return success;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,10 +141,12 @@ bool load_graphics_imports(struct gs_exports *exports, void *module,
|
|||
|
||||
GRAPHICS_IMPORT(gs_vertexbuffer_destroy);
|
||||
GRAPHICS_IMPORT(gs_vertexbuffer_flush);
|
||||
GRAPHICS_IMPORT(gs_vertexbuffer_flush_direct);
|
||||
GRAPHICS_IMPORT(gs_vertexbuffer_get_data);
|
||||
|
||||
GRAPHICS_IMPORT(gs_indexbuffer_destroy);
|
||||
GRAPHICS_IMPORT(gs_indexbuffer_flush);
|
||||
GRAPHICS_IMPORT(gs_indexbuffer_flush_direct);
|
||||
GRAPHICS_IMPORT(gs_indexbuffer_get_data);
|
||||
GRAPHICS_IMPORT(gs_indexbuffer_get_num_indices);
|
||||
GRAPHICS_IMPORT(gs_indexbuffer_get_type);
|
||||
|
|
|
|||
|
|
@ -189,11 +189,15 @@ struct gs_exports {
|
|||
|
||||
void (*gs_vertexbuffer_destroy)(gs_vertbuffer_t *vertbuffer);
|
||||
void (*gs_vertexbuffer_flush)(gs_vertbuffer_t *vertbuffer);
|
||||
void (*gs_vertexbuffer_flush_direct)(gs_vertbuffer_t *vertbuffer,
|
||||
const struct gs_vb_data *data);
|
||||
struct gs_vb_data *(*gs_vertexbuffer_get_data)(
|
||||
const gs_vertbuffer_t *vertbuffer);
|
||||
|
||||
void (*gs_indexbuffer_destroy)(gs_indexbuffer_t *indexbuffer);
|
||||
void (*gs_indexbuffer_flush)(gs_indexbuffer_t *indexbuffer);
|
||||
void (*gs_indexbuffer_flush_direct)(gs_indexbuffer_t *indexbuffer,
|
||||
const void *data);
|
||||
void *(*gs_indexbuffer_get_data)(const gs_indexbuffer_t *indexbuffer);
|
||||
size_t (*gs_indexbuffer_get_num_indices)(
|
||||
const gs_indexbuffer_t *indexbuffer);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,14 @@
|
|||
#include "graphics.h"
|
||||
#include "obsconfig.h"
|
||||
|
||||
#define MAGICKCORE_QUANTUM_DEPTH 16
|
||||
#define MAGICKCORE_HDRI_ENABLE 0
|
||||
|
||||
#if LIBOBS_IMAGEMAGICK_DIR_STYLE == LIBOBS_IMAGEMAGICK_DIR_STYLE_6L
|
||||
#include <magick/MagickCore.h>
|
||||
#elif LIBOBS_IMAGEMAGICK_DIR_STYLE == LIBOBS_IMAGEMAGICK_DIR_STYLE_7GE
|
||||
#include <MagickCore/MagickCore.h>
|
||||
#endif
|
||||
|
||||
void gs_init_image_deps()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,11 +28,7 @@
|
|||
#include "effect-parser.h"
|
||||
#include "effect.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
static __declspec(thread) graphics_t *thread_graphics = NULL;
|
||||
#else /* assume GCC or that other compiler we dare not mention */
|
||||
static __thread graphics_t *thread_graphics = NULL;
|
||||
#endif
|
||||
static THREAD_LOCAL graphics_t *thread_graphics = NULL;
|
||||
|
||||
static inline bool gs_obj_valid(const void *obj, const char *f,
|
||||
const char *name)
|
||||
|
|
@ -1468,6 +1464,46 @@ gs_vertbuffer_t *gs_vertexbuffer_create(struct gs_vb_data *data,
|
|||
if (!gs_valid("gs_vertexbuffer_create"))
|
||||
return NULL;
|
||||
|
||||
if (data && data->num && (flags & GS_DUP_BUFFER) != 0) {
|
||||
struct gs_vb_data *new_data = gs_vbdata_create();
|
||||
|
||||
new_data->num = data->num;
|
||||
|
||||
#define DUP_VAL(val) \
|
||||
do { \
|
||||
if (data->val) \
|
||||
new_data->val = bmemdup(data->val, \
|
||||
sizeof(*data->val) * \
|
||||
data->num); \
|
||||
} while (false)
|
||||
|
||||
DUP_VAL(points);
|
||||
DUP_VAL(normals);
|
||||
DUP_VAL(tangents);
|
||||
DUP_VAL(colors);
|
||||
#undef DUP_VAL
|
||||
|
||||
if (data->tvarray && data->num_tex) {
|
||||
new_data->num_tex = data->num_tex;
|
||||
new_data->tvarray = bzalloc(
|
||||
sizeof(struct gs_tvertarray) *
|
||||
data->num_tex);
|
||||
|
||||
for (size_t i = 0; i < data->num_tex; i++) {
|
||||
struct gs_tvertarray *tv = &data->tvarray[i];
|
||||
struct gs_tvertarray *new_tv =
|
||||
&new_data->tvarray[i];
|
||||
size_t size = tv->width * sizeof(float);
|
||||
|
||||
new_tv->width = tv->width;
|
||||
new_tv->array = bmemdup(tv->array,
|
||||
size * data->num);
|
||||
}
|
||||
}
|
||||
|
||||
data = new_data;
|
||||
}
|
||||
|
||||
return graphics->exports.device_vertexbuffer_create(graphics->device,
|
||||
data, flags);
|
||||
}
|
||||
|
|
@ -1480,6 +1516,13 @@ gs_indexbuffer_t *gs_indexbuffer_create(enum gs_index_type type,
|
|||
if (!gs_valid("gs_indexbuffer_create"))
|
||||
return NULL;
|
||||
|
||||
if (indices && num && (flags & GS_DUP_BUFFER) != 0) {
|
||||
size_t size = type == GS_UNSIGNED_SHORT
|
||||
? sizeof(unsigned short)
|
||||
: sizeof(unsigned long);
|
||||
indices = bmemdup(indices, size * num);
|
||||
}
|
||||
|
||||
return graphics->exports.device_indexbuffer_create(graphics->device,
|
||||
type, indices, num, flags);
|
||||
}
|
||||
|
|
@ -2430,6 +2473,16 @@ void gs_vertexbuffer_flush(gs_vertbuffer_t *vertbuffer)
|
|||
thread_graphics->exports.gs_vertexbuffer_flush(vertbuffer);
|
||||
}
|
||||
|
||||
void gs_vertexbuffer_flush_direct(gs_vertbuffer_t *vertbuffer,
|
||||
const struct gs_vb_data *data)
|
||||
{
|
||||
if (!gs_valid_p2("gs_vertexbuffer_flush_direct", vertbuffer, data))
|
||||
return;
|
||||
|
||||
thread_graphics->exports.gs_vertexbuffer_flush_direct(vertbuffer,
|
||||
data);
|
||||
}
|
||||
|
||||
struct gs_vb_data *gs_vertexbuffer_get_data(const gs_vertbuffer_t *vertbuffer)
|
||||
{
|
||||
if (!gs_valid_p("gs_vertexbuffer_get_data", vertbuffer))
|
||||
|
|
@ -2458,6 +2511,15 @@ void gs_indexbuffer_flush(gs_indexbuffer_t *indexbuffer)
|
|||
thread_graphics->exports.gs_indexbuffer_flush(indexbuffer);
|
||||
}
|
||||
|
||||
void gs_indexbuffer_flush_direct(gs_indexbuffer_t *indexbuffer,
|
||||
const void *data)
|
||||
{
|
||||
if (!gs_valid_p2("gs_indexbuffer_flush_direct", indexbuffer, data))
|
||||
return;
|
||||
|
||||
thread_graphics->exports.gs_indexbuffer_flush_direct(indexbuffer, data);
|
||||
}
|
||||
|
||||
void *gs_indexbuffer_get_data(const gs_indexbuffer_t *indexbuffer)
|
||||
{
|
||||
if (!gs_valid_p("gs_indexbuffer_get_data", indexbuffer))
|
||||
|
|
|
|||
|
|
@ -291,6 +291,7 @@ enum gs_shader_param_type {
|
|||
GS_SHADER_PARAM_TEXTURE,
|
||||
};
|
||||
|
||||
#ifndef SWIG
|
||||
struct gs_shader_param_info {
|
||||
enum gs_shader_param_type type;
|
||||
const char *name;
|
||||
|
|
@ -327,6 +328,7 @@ EXPORT void gs_shader_set_val(gs_sparam_t *param, const void *val, size_t size);
|
|||
EXPORT void gs_shader_set_default(gs_sparam_t *param);
|
||||
EXPORT void gs_shader_set_next_sampler(gs_sparam_t *param,
|
||||
gs_samplerstate_t *sampler);
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------
|
||||
* effect functions
|
||||
|
|
@ -340,6 +342,7 @@ EXPORT void gs_shader_set_next_sampler(gs_sparam_t *param,
|
|||
GS_EFFECT_TEXTURE
|
||||
};*/
|
||||
|
||||
#ifndef SWIG
|
||||
struct gs_effect_param_info {
|
||||
const char *name;
|
||||
enum gs_shader_param_type type;
|
||||
|
|
@ -349,6 +352,7 @@ struct gs_effect_param_info {
|
|||
|
||||
float min, max, inc, mul; */
|
||||
};
|
||||
#endif
|
||||
|
||||
EXPORT void gs_effect_destroy(gs_effect_t *effect);
|
||||
|
||||
|
|
@ -382,8 +386,11 @@ EXPORT void gs_effect_update_params(gs_effect_t *effect);
|
|||
EXPORT gs_eparam_t *gs_effect_get_viewproj_matrix(const gs_effect_t *effect);
|
||||
EXPORT gs_eparam_t *gs_effect_get_world_matrix(const gs_effect_t *effect);
|
||||
|
||||
#ifndef SWIG
|
||||
EXPORT void gs_effect_get_param_info(const gs_eparam_t *param,
|
||||
struct gs_effect_param_info *info);
|
||||
#endif
|
||||
|
||||
EXPORT void gs_effect_set_bool(gs_eparam_t *param, bool val);
|
||||
EXPORT void gs_effect_set_float(gs_eparam_t *param, float val);
|
||||
EXPORT void gs_effect_set_int(gs_eparam_t *param, int val);
|
||||
|
|
@ -398,6 +405,8 @@ EXPORT void gs_effect_set_default(gs_eparam_t *param);
|
|||
EXPORT void gs_effect_set_next_sampler(gs_eparam_t *param,
|
||||
gs_samplerstate_t *sampler);
|
||||
|
||||
EXPORT void gs_effect_set_color(gs_eparam_t *param, uint32_t argb);
|
||||
|
||||
/* ---------------------------------------------------
|
||||
* texture render helper functions
|
||||
* --------------------------------------------------- */
|
||||
|
|
@ -419,6 +428,8 @@ EXPORT gs_texture_t *gs_texrender_get_texture(const gs_texrender_t *texrender);
|
|||
#define GS_DYNAMIC (1<<1)
|
||||
#define GS_RENDER_TARGET (1<<2)
|
||||
#define GS_GL_DUMMYTEX (1<<3) /**<< texture with no allocated texture data */
|
||||
#define GS_DUP_BUFFER (1<<4) /**<< do not pass buffer ownership when
|
||||
* creating a vertex/index buffer */
|
||||
|
||||
/* ---------------- */
|
||||
/* global functions */
|
||||
|
|
@ -716,11 +727,15 @@ EXPORT void gs_samplerstate_destroy(gs_samplerstate_t *samplerstate);
|
|||
|
||||
EXPORT void gs_vertexbuffer_destroy(gs_vertbuffer_t *vertbuffer);
|
||||
EXPORT void gs_vertexbuffer_flush(gs_vertbuffer_t *vertbuffer);
|
||||
EXPORT void gs_vertexbuffer_flush_direct(gs_vertbuffer_t *vertbuffer,
|
||||
const struct gs_vb_data *data);
|
||||
EXPORT struct gs_vb_data *gs_vertexbuffer_get_data(
|
||||
const gs_vertbuffer_t *vertbuffer);
|
||||
|
||||
EXPORT void gs_indexbuffer_destroy(gs_indexbuffer_t *indexbuffer);
|
||||
EXPORT void gs_indexbuffer_flush(gs_indexbuffer_t *indexbuffer);
|
||||
EXPORT void gs_indexbuffer_flush_direct(gs_indexbuffer_t *indexbuffer,
|
||||
const void *data);
|
||||
EXPORT void *gs_indexbuffer_get_data(const gs_indexbuffer_t *indexbuffer);
|
||||
EXPORT size_t gs_indexbuffer_get_num_indices(
|
||||
const gs_indexbuffer_t *indexbuffer);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ static bool init_animated_gif(gs_image_file_t *image, const char *path)
|
|||
bool is_animated_gif = true;
|
||||
gif_result result;
|
||||
uint64_t max_size;
|
||||
size_t size;
|
||||
size_t size, size_read;
|
||||
FILE *file;
|
||||
|
||||
image->bitmap_callbacks.bitmap_create = bi_def_bitmap_create;
|
||||
|
|
@ -87,7 +87,11 @@ static bool init_animated_gif(gs_image_file_t *image, const char *path)
|
|||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
image->gif_data = bmalloc(size);
|
||||
fread(image->gif_data, 1, size, file);
|
||||
size_read = fread(image->gif_data, 1, size, file);
|
||||
if (size_read != size) {
|
||||
blog(LOG_WARNING, "Failed to fully read gif file '%s'.", path);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
do {
|
||||
result = gif_initialise(&image->gif, size, image->gif_data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue