Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
27abbef
test(graphics): pin legacy image-file session ordering RED (Refs #5145)
zackees Nov 18, 2026
8771c45
graphics: swap legacy image-file orchestration to Rust (Refs #5145)
zackees Nov 18, 2026
5f2a8f0
graphics: retain real conversion dependencies in static consumers (Re…
zackees Nov 18, 2026
b0358c1
test(graphics): complete static fixture dependencies and registration…
zackees Nov 18, 2026
3f1d59a
test(graphics): link real logging bridge into image fixture (Refs #5145)
zackees Nov 18, 2026
48d32b6
style(graphics): format image-file native registration (Refs #5145)
zackees Nov 18, 2026
b720e90
test(graphics): refresh image-file registration after rebase (Refs #5…
zackees Nov 18, 2026
e1394f6
style(graphics): keep image-file graph registration in name order (Re…
zackees Nov 18, 2026
311c66f
test(graphics): require standalone image maximum-size callback suppor…
zackees Nov 19, 2026
ce55a25
fix(graphics): complete standalone image adapter link support (Refs #…
zackees Nov 19, 2026
f63ca94
test(graphics): require Windows timer imports for static consumers RE…
zackees Nov 19, 2026
b8beaf9
fix(graphics): propagate Windows timer library to static consumers (R…
zackees Nov 19, 2026
fcc98e6
test(graphics): cover Windows RPC and private logger linkage RED (Ref…
zackees Nov 19, 2026
f226cc1
fix(graphics): complete Windows UUID and private logger linkage (Refs…
zackees Nov 19, 2026
70b92bd
test(graphics): reproduce shared-library fixture binding RED (Refs #5…
zackees Nov 19, 2026
f47e0dd
fix(graphics): keep native fixture calls and cleanup local (Refs #5145)
zackees Nov 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions libobs/build/libobs.media+.h.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#include "libobs/build/libobs-media.pch.h"

#include "libobs/graphics/graphics-ffmpeg-init-adapter.c.h"
#include "libobs/graphics/graphics-ffmpeg-orientation-adapter.c.h"
#include "libobs/graphics/graphics-ffmpeg-orientation-fields.c.h"
#include "libobs/graphics/graphics-ffmpeg.c.h"
#include "libobs/graphics/graphics-texture-file-data.c.h"
#include "libobs/media-io/media-remux-ffmpeg.c.h"
#include "libobs/media-io/video-scaler-ffmpeg.c.h"
6 changes: 6 additions & 0 deletions libobs/build/libobs.media-texture-file-data-adapter+.h.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* C-owned image conversion and private opaque sessions. */
#include "libobs/build/libobs-media.pch.h"

#include "libobs/graphics/graphics-ffmpeg-orientation-adapter.c.h"
#include "libobs/graphics/graphics-texture-file-data-adapter.c.h"
#include "libobs/graphics/graphics-texture-file-data-convert.c.h"
4 changes: 4 additions & 0 deletions libobs/build/libobs.ported-texture-file-data+.h.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Original legacy image-file orchestration, C reference only. */
#include "libobs/build/libobs-media.pch.h"

#include "libobs/graphics/graphics-texture-file-data.c.h"
3 changes: 2 additions & 1 deletion libobs/build/modules.d/media.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"description": "libobs/media-io.",
"groups": [
"media",
"media-resampler-kernel"
"media-resampler-kernel",
"media-texture-file-data-adapter"
],
"depends": []
}
5 changes: 5 additions & 0 deletions libobs/build/ported-source-sets/texture-file-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"LIBOBS_PORTED_SOURCES": [
"build/libobs.ported-texture-file-data+.h.c"
]
}
1 change: 1 addition & 0 deletions libobs/build/source-sets.d/LIBOBS_SOURCES.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
"build/libobs.graphics-texture-creators-fields+.h.c",
"build/libobs.image-decode-adapter+.h.c",
"build/libobs.media+.h.c",
"build/libobs.media-texture-file-data-adapter+.h.c",
"build/libobs.media-resampler-kernel+.h.c",
"build/libobs.source-private-settings+.h.c"
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gs_create_texture_file_data
179 changes: 0 additions & 179 deletions libobs/graphics/graphics-ffmpeg.c.h
Original file line number Diff line number Diff line change
@@ -1,184 +1,5 @@
#include "build/libobs-media.pch.h"

static void *ffmpeg_image_copy_data_straight(struct ffmpeg_image *info, AVFrame *frame)
{
const size_t linesize = (size_t)info->cx * 4;
const size_t totalsize = (size_t)info->cy * linesize;
void *data = bmalloc(totalsize);

gs_ffmpeg_image_copy_rows(data, frame->data[0], (size_t)info->cx, (size_t)info->cy, (size_t)frame->linesize[0]);

return data;
}

static void *ffmpeg_image_orient(struct ffmpeg_image *info, void *in_data, int orient)
{
const size_t sx = (size_t)info->cx;
const size_t sy = (size_t)info->cy;
uint8_t *data = NULL;

if (!gs_ffmpeg_image_orient_needed(orient))
return in_data;

data = bmalloc(sx * 4 * sy);

if (gs_ffmpeg_image_orient_swaps(orient)) {
info->cx = (int)sy;
info->cy = (int)sx;
}

gs_ffmpeg_image_orient_copy(data, in_data, sx, sy, orient);

bfree(in_data);
return data;
}

/* graphics-ffmpeg-route.c gives the pixel formats, the texture formats and
* the alpha modes as their values. */
_Static_assert(GS_FFMPEG_IMAGE_PIX_FMT_YUV420P == AV_PIX_FMT_YUV420P, "AV_PIX_FMT_YUV420P");
_Static_assert(GS_FFMPEG_IMAGE_PIX_FMT_YUV422P == AV_PIX_FMT_YUV422P, "AV_PIX_FMT_YUV422P");
_Static_assert(GS_FFMPEG_IMAGE_PIX_FMT_YUV444P == AV_PIX_FMT_YUV444P, "AV_PIX_FMT_YUV444P");
_Static_assert(GS_FFMPEG_IMAGE_PIX_FMT_YUV411P == AV_PIX_FMT_YUV411P, "AV_PIX_FMT_YUV411P");
_Static_assert(GS_FFMPEG_IMAGE_PIX_FMT_YUVJ420P == AV_PIX_FMT_YUVJ420P, "AV_PIX_FMT_YUVJ420P");
_Static_assert(GS_FFMPEG_IMAGE_PIX_FMT_YUVJ422P == AV_PIX_FMT_YUVJ422P, "AV_PIX_FMT_YUVJ422P");
_Static_assert(GS_FFMPEG_IMAGE_PIX_FMT_YUVJ444P == AV_PIX_FMT_YUVJ444P, "AV_PIX_FMT_YUVJ444P");
_Static_assert(GS_FFMPEG_IMAGE_PIX_FMT_RGBA == AV_PIX_FMT_RGBA, "AV_PIX_FMT_RGBA");
_Static_assert(GS_FFMPEG_IMAGE_PIX_FMT_BGRA == AV_PIX_FMT_BGRA, "AV_PIX_FMT_BGRA");
_Static_assert(GS_FFMPEG_IMAGE_PIX_FMT_YUV440P == AV_PIX_FMT_YUV440P, "AV_PIX_FMT_YUV440P");
_Static_assert(GS_FFMPEG_IMAGE_PIX_FMT_YUVJ440P == AV_PIX_FMT_YUVJ440P, "AV_PIX_FMT_YUVJ440P");
_Static_assert(GS_FFMPEG_IMAGE_PIX_FMT_RGBA64BE == AV_PIX_FMT_RGBA64BE, "AV_PIX_FMT_RGBA64BE");
_Static_assert(GS_FFMPEG_IMAGE_PIX_FMT_BGR0 == AV_PIX_FMT_BGR0, "AV_PIX_FMT_BGR0");
_Static_assert(GS_FFMPEG_IMAGE_PIX_FMT_YUVJ411P == AV_PIX_FMT_YUVJ411P, "AV_PIX_FMT_YUVJ411P");
_Static_assert(GS_FFMPEG_IMAGE_GS_RGBA == GS_RGBA, "GS_RGBA");
_Static_assert(GS_FFMPEG_IMAGE_GS_BGRX == GS_BGRX, "GS_BGRX");
_Static_assert(GS_FFMPEG_IMAGE_GS_BGRA == GS_BGRA, "GS_BGRA");
_Static_assert(GS_FFMPEG_IMAGE_GS_RGBA16 == GS_RGBA16, "GS_RGBA16");
_Static_assert(GS_FFMPEG_IMAGE_ALPHA_STRAIGHT == GS_IMAGE_ALPHA_STRAIGHT, "GS_IMAGE_ALPHA_STRAIGHT");
_Static_assert(GS_FFMPEG_IMAGE_ALPHA_PREMULTIPLY_SRGB == GS_IMAGE_ALPHA_PREMULTIPLY_SRGB,
"GS_IMAGE_ALPHA_PREMULTIPLY_SRGB");
_Static_assert(GS_FFMPEG_IMAGE_ALPHA_PREMULTIPLY == GS_IMAGE_ALPHA_PREMULTIPLY, "GS_IMAGE_ALPHA_PREMULTIPLY");

/* graphics-ffmpeg-rgba64.c gives the alpha modes as their values. */
_Static_assert(GS_FFMPEG_RGBA64_ALPHA_STRAIGHT == GS_IMAGE_ALPHA_STRAIGHT, "GS_IMAGE_ALPHA_STRAIGHT");
_Static_assert(GS_FFMPEG_RGBA64_ALPHA_PREMULTIPLY_SRGB == GS_IMAGE_ALPHA_PREMULTIPLY_SRGB,
"GS_IMAGE_ALPHA_PREMULTIPLY_SRGB");
_Static_assert(GS_FFMPEG_RGBA64_ALPHA_PREMULTIPLY == GS_IMAGE_ALPHA_PREMULTIPLY, "GS_IMAGE_ALPHA_PREMULTIPLY");

void *ffmpeg_image_reformat_frame(struct ffmpeg_image *info, AVFrame *frame, enum gs_image_alpha_mode alpha_mode)
{
struct SwsContext *sws_ctx = NULL;
void *data = NULL;
int ret = 0;

const int orient = ffmpeg_image_get_orientation(frame);
const struct gs_ffmpeg_image_plan plan = gs_ffmpeg_image_plan(info->format, (int)alpha_mode);

switch (plan.route) {
case GS_FFMPEG_IMAGE_ROUTE_COPY:
data = ffmpeg_image_copy_data_straight(info, frame);
break;
case GS_FFMPEG_IMAGE_ROUTE_PREMULTIPLY_ROWS: {
const size_t linesize = (size_t)info->cx * 4;
const size_t totalsize = (size_t)info->cy * linesize;
data = bmalloc(totalsize);
const size_t src_linesize = (size_t)frame->linesize[0];
const size_t min_line = linesize < src_linesize ? linesize : src_linesize;
uint8_t *dst = data;
const uint8_t *src = frame->data[0];
const size_t row_elements = min_line >> 2;
if (plan.premultiply == GS_FFMPEG_IMAGE_PREMULTIPLY_SRGB) {
for (int y = 0; y < info->cy; y++) {
gs_premultiply_xyza_srgb_loop_restrict(dst, src, row_elements);
dst += linesize;
src += src_linesize;
}
} else if (plan.premultiply == GS_FFMPEG_IMAGE_PREMULTIPLY_LINEAR) {
for (int y = 0; y < info->cy; y++) {
gs_premultiply_xyza_loop_restrict(dst, src, row_elements);
dst += linesize;
src += src_linesize;
}
}
break;
}
case GS_FFMPEG_IMAGE_ROUTE_RGBA64: {
const size_t dst_linesize = (size_t)info->cx * 4;
data = bmalloc((size_t)info->cy * dst_linesize);
gs_ffmpeg_image_rgba64be_rows(data, frame->data[0], info->cx, info->cy, (size_t)frame->linesize[0],
(int)alpha_mode);

info->format = (enum AVPixelFormat)plan.out_format;
break;
}
default: {
/* GS_FFMPEG_IMAGE_ROUTE_SWS */
static const enum AVPixelFormat format = AV_PIX_FMT_BGRA;

sws_ctx = sws_getContext(info->cx, info->cy, (enum AVPixelFormat)plan.sws_format, info->cx, info->cy,
format, SWS_POINT, NULL, NULL, NULL);
if (!sws_ctx) {
blog(LOG_WARNING,
"Failed to create scale context "
"for '%s'",
info->file);
goto fail;
}

if (plan.full_range) {
/* What swscale sets up for a YUVJ format itself:
* full range in, its default (BT.601) matrix. */
const int *coeff = sws_getCoefficients(SWS_CS_DEFAULT);
sws_setColorspaceDetails(sws_ctx, coeff, 1, coeff, 0, 0, 1 << 16, 1 << 16);
}

uint8_t *pointers[4];
int linesizes[4];
ret = av_image_alloc(pointers, linesizes, info->cx, info->cy, format, 32);
if (ret < 0) {
blog(LOG_WARNING, "av_image_alloc failed for '%s': %s", info->file, av_err2str(ret));
sws_freeContext(sws_ctx);
goto fail;
}

ret = sws_scale(sws_ctx, (const uint8_t *const *)frame->data, frame->linesize, 0, info->cy, pointers,
linesizes);
sws_freeContext(sws_ctx);

if (ret < 0) {
blog(LOG_WARNING, "sws_scale failed for '%s': %s", info->file, av_err2str(ret));
av_freep(pointers);
goto fail;
}

const size_t linesize = (size_t)info->cx * 4;
data = bmalloc((size_t)info->cy * linesize);
const uint8_t *src = pointers[0];
uint8_t *dst = data;
for (size_t y = 0; y < (size_t)info->cy; y++) {
memcpy(dst, src, linesize);
dst += linesize;
src += linesizes[0];
}

av_freep(pointers);

if (plan.premultiply == GS_FFMPEG_IMAGE_PREMULTIPLY_SRGB) {
gs_premultiply_xyza_srgb_loop(data, (size_t)info->cx * (size_t)info->cy);
} else if (plan.premultiply == GS_FFMPEG_IMAGE_PREMULTIPLY_LINEAR) {
gs_premultiply_xyza_loop(data, (size_t)info->cx * (size_t)info->cy);
}

info->format = (enum AVPixelFormat)plan.out_format;
break;
}
}

data = ffmpeg_image_orient(info, data, orient);

fail:
return data;
}

void gs_init_image_deps(void);
void gs_free_image_deps(void);

Expand Down
49 changes: 49 additions & 0 deletions libobs/graphics/graphics-texture-file-data-adapter.c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "libobs/build/libobs-media.pch.h"

/* Private C/Rust session ABI, deliberately opaque outside this file. */
void *obs_texture_file_data_open(const char *file);
void *obs_texture_file_data_decode(void *session);
int obs_texture_file_data_format(void *session);
uint32_t obs_texture_file_data_width(void *session);
uint32_t obs_texture_file_data_height(void *session);
void obs_texture_file_data_close(void *session);

/* Private opaque session: FFmpeg's layout never crosses the Rust boundary.
* Initialization already releases FFmpeg resources on failure. */
void *obs_texture_file_data_open(const char *file)
{
struct ffmpeg_image *image = bzalloc(sizeof(*image));
if (!ffmpeg_image_init(image, file, gs_image_max_texture_size)) {
bfree(image);
return NULL;
}
return image;
}

void *obs_texture_file_data_decode(void *session)
{
struct gs_image_decode_context decode = {session, ffmpeg_image_too_large, ffmpeg_image_reformat_frame};
return gs_ffmpeg_image_decode(&decode, (int)GS_IMAGE_ALPHA_STRAIGHT);
}

int obs_texture_file_data_format(void *session)
{
const struct ffmpeg_image *image = session;
return gs_ffmpeg_image_color_format(image->format);
}

uint32_t obs_texture_file_data_width(void *session)
{
return (uint32_t)((struct ffmpeg_image *)session)->cx;
}

uint32_t obs_texture_file_data_height(void *session)
{
return (uint32_t)((struct ffmpeg_image *)session)->cy;
}

void obs_texture_file_data_close(void *session)
{
ffmpeg_image_free(session);
bfree(session);
}
Loading
Loading