summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cache/meson.build32
-rw-r--r--src/codec/ffmpeg/decoder.c11
-rw-r--r--src/codec/ffmpeg/demuxer.c2
-rw-r--r--src/fruits/cmv/cmv.c2
-rw-r--r--src/liana/process.c4
-rw-r--r--src/libsink/sink.c2
-rw-r--r--src/render/meson.build95
-rw-r--r--src/render/queue_libplacebo.c33
-rw-r--r--src/render/queue_libplacebo.h6
-rw-r--r--src/render/renderer_libplacebo.c11
-rw-r--r--src/render/renderer_libplacebo.h4
-rw-r--r--src/util/meson.build19
12 files changed, 136 insertions, 85 deletions
diff --git a/src/cache/meson.build b/src/cache/meson.build
index 9c9af7b..1a198eb 100644
--- a/src/cache/meson.build
+++ b/src/cache/meson.build
@@ -19,23 +19,27 @@ if naunet_has_curl
endif
cache_have_cdio = false
-libcdio_paranoia = dependency('libcdio_paranoia', required: false, allow_fallback: true)
-libcdio_cdda = dependency('libcdio_cdda', required: false, allow_fallback: true)
-if libcdio_paranoia.found() and libcdio_cdda.found()
- cache_src += ['handlers/cdio.c']
- cache_deps += [libcdio_paranoia, libcdio_cdda]
- cache_args += ['-DCACHE_HAVE_CDIO']
- cache_have_cdio = true
+if is_linux
+ libcdio_paranoia = dependency('libcdio_paranoia', required: false, allow_fallback: true)
+ libcdio_cdda = dependency('libcdio_cdda', required: false, allow_fallback: true)
+ if libcdio_paranoia.found() and libcdio_cdda.found()
+ cache_src += ['handlers/cdio.c']
+ cache_deps += [libcdio_paranoia, libcdio_cdda]
+ cache_args += ['-DCACHE_HAVE_CDIO']
+ cache_have_cdio = true
+ endif
endif
cache_have_libdvd = false
-libdvdcss = dependency('libdvdcss', required: false, allow_fallback: true)
-libdvdread = dependency('dvdread', required: false, allow_fallback: true)
-libdvdnav = dependency('dvdnav', required: false, allow_fallback: true)
-if libdvdcss.found() and libdvdread.found() and libdvdnav.found()
- cache_deps += [libdvdcss, libdvdread, libdvdnav]
- cache_args += ['-DCACHE_HAVE_LIBDVD']
- cache_have_libdvd = true
+if is_linux
+ libdvdcss = dependency('libdvdcss', required: false, allow_fallback: true)
+ libdvdread = dependency('dvdread', required: false, allow_fallback: true)
+ libdvdnav = dependency('dvdnav', required: false, allow_fallback: true)
+ if libdvdcss.found() and libdvdread.found() and libdvdnav.found()
+ cache_deps += [libdvdcss, libdvdread, libdvdnav]
+ cache_args += ['-DCACHE_HAVE_LIBDVD']
+ cache_have_libdvd = true
+ endif
endif
cache = declare_dependency(sources: cache_src, dependencies: cache_deps, compile_args: cache_args)
diff --git a/src/codec/ffmpeg/decoder.c b/src/codec/ffmpeg/decoder.c
index 7401698..c22d1c1 100644
--- a/src/codec/ffmpeg/decoder.c
+++ b/src/codec/ffmpeg/decoder.c
@@ -256,14 +256,15 @@ static bool ff_decoder_init(struct camu_decoder *dec, struct camu_renderer *rend
s32 cpus = 0;
if (av->codec_context->codec_type == AVMEDIA_TYPE_VIDEO) {
cpus = av_cpu_count();
- cpus = MIN(4, MAX(1, cpus / 2));
+ cpus = MIN(6, MAX(1, cpus / 2));
}
if (cpus > 0) {
av->codec_context->thread_count = cpus;
- // FF_THREAD_FRAME, FF_THREAD_SLICE or both.
- // Slice seems to work better based on videos that get completely choked
- // in frame-only or both (4k60 HEVC, FFmpeg 7.1.1, AMD 3900x).
- av->codec_context->thread_type = FF_THREAD_SLICE;
+ // FF_THREAD_FRAME or FF_THREAD_SLICE.
+ // Both modes can get choked on certain videos, sometimes SLICE can squeeze
+ // out a little more performance but a higher thread_count with FRAME seems
+ // like the safest default.
+ av->codec_context->thread_type = FF_THREAD_FRAME;
log_info("Using %i threads for decoder.", cpus);
}
}
diff --git a/src/codec/ffmpeg/demuxer.c b/src/codec/ffmpeg/demuxer.c
index 4cf52dd..b539577 100644
--- a/src/codec/ffmpeg/demuxer.c
+++ b/src/codec/ffmpeg/demuxer.c
@@ -57,7 +57,7 @@ static bool ff_demuxer_init(struct camu_demuxer *demux, struct cch_handle *handl
// FFmpeg says the avio protocol configures "buffers and access patterns".
// I think we already do enough buffering but, better access patterns for
// network streams sounds like something we want.
- s32 ret = avformat_open_input(&av->format_context, "file:", NULL, &opts);
+ s32 ret = avformat_open_input(&av->format_context, "cache:", NULL, &opts);
if (ret < 0) {
log_error("Failed to open input (%s).", av_err2str(ret));
av_dict_free(&opts);
diff --git a/src/fruits/cmv/cmv.c b/src/fruits/cmv/cmv.c
index 1b9c8c1..c5bb22a 100644
--- a/src/fruits/cmv/cmv.c
+++ b/src/fruits/cmv/cmv.c
@@ -129,7 +129,7 @@ s32 window_system_main(u32 argc, str *argv, void *extra)
bool local = argc > 1;
#else
if (argc > 1) {
- warn("Got arguments in a sink-only configuration.");
+ log_warn("Got arguments in a sink-only configuration.");
}
#endif
diff --git a/src/liana/process.c b/src/liana/process.c
index 0a9f030..c2e4ce4 100644
--- a/src/liana/process.c
+++ b/src/liana/process.c
@@ -49,14 +49,14 @@ bool lia_prepare_visual_data(struct cch_handle *handle, struct lia_visual_data *
goto out;
}
- struct camu_codec_stream *stream;
+ struct camu_codec_stream *stream = NULL;
al_array_foreach_ptr(demux->streams, i, stream) {
if (stream->type == CAMU_STREAM_AUDIO) {
demux->subscribed = 1 << stream->index;
break;
}
}
- if (demux->subscribed == 0) goto out;
+ if (!stream || demux->subscribed == 0) goto out;
struct camu_resampler_format fmt;
AVCodecParameters *codecpar = stream->av.stream->codecpar;
diff --git a/src/libsink/sink.c b/src/libsink/sink.c
index 392f6b9..07bb604 100644
--- a/src/libsink/sink.c
+++ b/src/libsink/sink.c
@@ -1003,7 +1003,7 @@ static void client_callback(void *userdata, u8 op, struct camu_codec_stream *str
break;
case CAMU_STREAM_SUBTITLE:
if (!camu_video_buffer_configure_subtitles(&entry->video.buf, stream)) {
- log_warn("Video buffer failed to configure subtitles.");
+ log_warn("Video buffer couldn't configure subtitles.");
}
break;
case CAMU_STREAM_ATTACHMENT: {
diff --git a/src/render/meson.build b/src/render/meson.build
index 1dd2dce..98b86ec 100644
--- a/src/render/meson.build
+++ b/src/render/meson.build
@@ -21,7 +21,7 @@ elif get_option('renderer') == 'libplacebo'
'libdovi=disabled'
]
- if get_option('sink-use-vulkan') or get_option('sink-use-dx11')
+ if get_option('renderer-api') == 'vulkan' or get_option('renderer-api') == 'dx11'
shaderc = dependency('shaderc', required: false, allow_fallback: false)
if shaderc.found()
render_deps += [shaderc]
@@ -74,9 +74,9 @@ elif get_option('renderer') == 'libplacebo'
#endif
endif
- if get_option('sink-use-vulkan')
+ if get_option('renderer-api') == 'vulkan'
libplacebo_opts += ['shaderc=enabled', 'vulkan=enabled', 'd3d11=disabled', 'opengl=disabled']
- elif get_option('sink-use-dx11')
+ elif get_option('renderer-api') == 'dx11'
spirv_cross_opts = cmake.subproject_options()
reltype = is_minsize ? 'MinSizeRel' : 'Release'
spirv_cross_opts.add_cmake_defines({ 'CMAKE_BUILD_TYPE': is_debug ? 'Debug' : reltype })
@@ -106,53 +106,56 @@ elif get_option('renderer') == 'libplacebo'
render_args += ['-DCAMU_RENDERER_LIBPLACEBO']
endif
-libass = dependency('libass', required: false, allow_fallback: false)
-if not libass.found()
- libass_opts = []
- if not is_windows
- libass_opts += ['fontconfig=enabled']
- # libass(e46aede):meson.build:126
- fontconfig = dependency('fontconfig',
- version: '>=2.10.92',
+if get_option('subtitles').enabled()
+ libass = dependency('libass', required: false, allow_fallback: false)
+ if not libass.found()
+ libass_opts = []
+ if not is_windows
+ libass_opts += ['fontconfig=enabled']
+ # libass(e46aede):meson.build:126
+ fontconfig = dependency('fontconfig',
+ version: '>=2.10.92',
+ default_options: [
+ 'doc=disabled',
+ 'nls=disabled',
+ 'tests=disabled',
+ 'tools=disabled',
+ 'cache-build=disabled'
+ ])
+ endif
+ # libass(e46aede):meson.build:84
+ # fontconfig(72b9a48):meson.build:28
+ freetype = dependency('freetype2',
+ version: '>=9.17.3',
+ default_options: [
+ 'harfbuzz=disabled'
+ ])
+ # libass(e46aede):meson.build:90
+ fribidi = dependency('fribidi',
+ version: '>=0.19.1',
+ default_options: [
+ 'docs=false',
+ 'tests=false',
+ 'bin=false'
+ ])
+ # freetype2(42608f7):meson.build:346
+ harfbuz = dependency('harfbuzz',
+ version: '>=2.0.0',
default_options: [
- 'doc=disabled',
- 'nls=disabled',
+ 'freetype=disabled',
'tests=disabled',
- 'tools=disabled',
- 'cache-build=disabled'
+ 'introspection=disabled',
+ 'docs=disabled',
+ 'utilities=disabled',
+ 'glib=disabled',
+ 'gobject=disabled',
+ 'cairo=disabled',
+ 'chafa=disabled'
])
+ libass = dependency('libass', default_options: libass_opts)
endif
- # libass(e46aede):meson.build:84
- # fontconfig(72b9a48):meson.build:28
- freetype = dependency('freetype2',
- version: '>=9.17.3',
- default_options: [
- 'harfbuzz=disabled'
- ])
- # libass(e46aede):meson.build:90
- fribidi = dependency('fribidi',
- version: '>=0.19.1',
- default_options: [
- 'docs=false',
- 'tests=false',
- 'bin=false'
- ])
- # freetype2(42608f7):meson.build:346
- harfbuz = dependency('harfbuzz',
- version: '>=2.0.0',
- default_options: [
- 'freetype=disabled',
- 'tests=disabled',
- 'introspection=disabled',
- 'docs=disabled',
- 'utilities=disabled',
- 'glib=disabled',
- 'gobject=disabled',
- 'cairo=disabled',
- 'chafa=disabled'
- ])
- libass = dependency('libass', default_options: libass_opts)
+ render_deps += [libass]
+ render_args += ['-DCAMU_HAVE_SUBTITLES']
endif
-render_deps += [libass]
render = declare_dependency(sources: render_src, dependencies: render_deps, compile_args: render_args)
diff --git a/src/render/queue_libplacebo.c b/src/render/queue_libplacebo.c
index dd62975..8e17eb7 100644
--- a/src/render/queue_libplacebo.c
+++ b/src/render/queue_libplacebo.c
@@ -11,10 +11,11 @@
#include "queue_libplacebo.h"
-static bool queue_lp_configure_subtitiles(struct camu_frame_queue *queue, u32 width, u32 height,
+static bool queue_lp_configure_subtitles(struct camu_frame_queue *queue, u32 width, u32 height,
struct camu_codec_stream *stream)
{
struct camu_frame_queue_lp *lq = (struct camu_frame_queue_lp *)queue;
+#ifdef CAMU_HAVE_SUBTITLES
if (!lq->ass) return false;
lq->ass_renderer = ass_renderer_init(lq->ass);
if (!lq->ass_renderer) {
@@ -33,8 +34,15 @@ static bool queue_lp_configure_subtitiles(struct camu_frame_queue *queue, u32 wi
ass_process_codec_private(lq->ass_track, (const char *)codecpar->extradata,
codecpar->extradata_size);
nn_mutex_init(&lq->subtitle_lock);
- lq->have_subtitles = true;
+ lq->has_subtitles = true;
return true;
+#else
+ (void)lq;
+ (void)width;
+ (void)height;
+ (void)stream;
+ return false;
+#endif
}
static bool map_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *src,
@@ -129,6 +137,7 @@ static void queue_lp_push(struct camu_frame_queue *queue, struct camu_codec_fram
}
#ifdef CAMU_HAVE_FFMPEG
+#ifdef CAMU_HAVE_SUBTITLES
static struct camu_overlay_lp *create_subtitle_overlay(pl_gpu gpu, ASS_Image *ass_frame)
{
struct camu_overlay_lp *overlay = al_alloc_object(struct camu_overlay_lp);
@@ -202,6 +211,7 @@ static struct camu_overlay_lp *create_subtitle_overlay(pl_gpu gpu, ASS_Image *as
return overlay;
}
+#endif
static bool map_av_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *src,
struct pl_frame *out_frame)
@@ -247,7 +257,8 @@ static bool map_av_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *
((struct pl_source_frame *)src)->frame_data = NULL;
- if (ok && lq->have_subtitles) {
+#ifdef CAMU_HAVE_SUBTITLES
+ if (ok && lq->has_subtitles) {
s64 now = av_rescale_q(frame->best_effort_timestamp, stream->time_base, (AVRational){ 1, 1000 });
nn_mutex_lock(&lq->subtitle_lock);
s32 change; // 1 = different position, 2 = different content.
@@ -267,6 +278,7 @@ static bool map_av_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *
}
nn_mutex_unlock(&lq->subtitle_lock);
}
+#endif
av_frame_free(&frame);
@@ -329,10 +341,15 @@ static void queue_lp_push_subtitle(struct camu_frame_queue *queue, struct camu_c
{
struct camu_frame_queue_lp *lq = (struct camu_frame_queue_lp *)queue;
AVPacket *pkt = packet->av.pkt;
+#ifdef CAMU_HAVE_SUBTITLES
nn_mutex_lock(&lq->subtitle_lock);
al_assert(lq->ass_track && lq->ass_renderer);
ass_process_chunk(lq->ass_track, (const char *)pkt->data, pkt->size, pkt->pts, pkt->duration);
nn_mutex_unlock(&lq->subtitle_lock);
+#else
+ (void)lq;
+ (void)pkt;
+#endif
}
static void queue_lp_flush(struct camu_frame_queue *queue)
@@ -376,11 +393,13 @@ static void queue_lp_reset(struct camu_frame_queue *queue)
static void queue_lp_free(struct camu_frame_queue **queue)
{
struct camu_frame_queue_lp *lq = (struct camu_frame_queue_lp *)*queue;
- if (lq->have_subtitles) {
+#ifdef CAMU_HAVE_SUBTITLES
+ if (lq->has_subtitles) {
ass_free_track(lq->ass_track);
ass_renderer_done(lq->ass_renderer);
nn_mutex_destroy(&lq->subtitle_lock);
}
+#endif
if (lq->copy_frame_fallback) {
av_frame_free(&lq->swframe);
}
@@ -393,8 +412,10 @@ struct camu_frame_queue *camu_frame_queue_lp_create(void)
{
struct camu_frame_queue_lp *lq = al_alloc_object(struct camu_frame_queue_lp);
al_array_init(lq->overlays);
- lq->have_subtitles = false;
- lq->q.configure_subtitles = queue_lp_configure_subtitiles;
+#ifdef CAMU_HAVE_SUBTITLES
+ lq->has_subtitles = false;
+#endif
+ lq->q.configure_subtitles = queue_lp_configure_subtitles;
lq->q.push = queue_lp_push;
#ifdef CAMU_HAVE_FFMPEG
lq->q.push_av_frame = queue_lp_push_av_frame;
diff --git a/src/render/queue_libplacebo.h b/src/render/queue_libplacebo.h
index 67d2479..eeb562f 100644
--- a/src/render/queue_libplacebo.h
+++ b/src/render/queue_libplacebo.h
@@ -2,7 +2,9 @@
#include <libplacebo/utils/frame_queue.h>
#include <libplacebo/utils/upload.h>
+#ifdef CAMU_HAVE_SUBTITLES
#include <ass/ass.h>
+#endif
#include "../buffer/frame_queue.h"
@@ -21,11 +23,13 @@ struct camu_frame_queue_lp {
bool copy_frame_fallback;
AVFrame *swframe;
array(struct camu_overlay_lp *) overlays;
+#ifdef CAMU_HAVE_SUBTITLES
ASS_Library *ass;
ASS_Renderer *ass_renderer;
ASS_Track *ass_track;
struct nn_mutex subtitle_lock;
- bool have_subtitles;
+ bool has_subtitles;
+#endif
};
struct camu_frame_queue *camu_frame_queue_lp_create(void);
diff --git a/src/render/renderer_libplacebo.c b/src/render/renderer_libplacebo.c
index 71b156a..8f816b4 100644
--- a/src/render/renderer_libplacebo.c
+++ b/src/render/renderer_libplacebo.c
@@ -232,7 +232,9 @@ static bool renderer_lp_create_renderer(struct camu_renderer *renderer, u32 *wid
lr->r.opaque = &lr->gpu;
#endif
+#ifdef CAMU_HAVE_SUBTITLES
lr->ass = ass_library_init();
+#endif
lr->last_render_tick = nn_get_tick();
@@ -253,17 +255,24 @@ static struct camu_frame_queue *renderer_lp_create_queue(struct camu_renderer *r
lq->params.radius = pl_frame_mix_radius(&lr->params);
lq->params.timeout = 0;
lq->copy_frame_fallback = false;
+#ifdef CAMU_HAVE_SUBTITLES
lq->ass = lr->ass;
+#endif
return queue;
}
static void renderer_lp_add_font(struct camu_renderer *renderer, struct camu_codec_stream *attachment)
{
struct camu_renderer_lp *lr = (struct camu_renderer_lp *)renderer;
+#ifdef CAMU_HAVE_SUBTITLES
AVStream *stream = attachment->av.stream;
AVDictionaryEntry *entry = av_dict_get(stream->metadata, "filename", NULL, 0);
AVCodecParameters *codecpar = stream->codecpar;
ass_add_font(lr->ass, entry->value, (const char *)codecpar->extradata, codecpar->extradata_size);
+#else
+ (void)lr;
+ (void)attachment;
+#endif
}
static u32 renderer_lp_get_latency(struct camu_renderer *renderer)
@@ -389,7 +398,9 @@ void renderer_lp_free(struct camu_renderer **renderer)
if (lr->gl) pl_opengl_destroy(&lr->gl);
#endif
if (lr->logger) pl_log_destroy(&lr->logger);
+#ifdef CAMU_HAVE_SUBTITLES
if (lr->ass) ass_library_done(lr->ass);
+#endif
al_free(lr);
*renderer = NULL;
}
diff --git a/src/render/renderer_libplacebo.h b/src/render/renderer_libplacebo.h
index 8a284d5..7b1cfa2 100644
--- a/src/render/renderer_libplacebo.h
+++ b/src/render/renderer_libplacebo.h
@@ -4,7 +4,9 @@
#include <libplacebo/renderer.h>
#include <libplacebo/shaders/lut.h>
#include <libplacebo/colorspace.h>
+#ifdef CAMU_HAVE_SUBTITLES
#include <ass/ass.h>
+#endif
#include "renderer.h"
@@ -35,7 +37,9 @@ struct camu_renderer_lp {
pl_renderer renderer;
f64 last_render_tick;
struct pl_render_params params;
+#ifdef CAMU_HAVE_SUBTITLES
ASS_Library *ass;
+#endif
};
struct camu_renderer *camu_renderer_lp_create(void);
diff --git a/src/util/meson.build b/src/util/meson.build
index a83a66a..c2c3c3d 100644
--- a/src/util/meson.build
+++ b/src/util/meson.build
@@ -1,11 +1,14 @@
util_src = ['color_palette.c']
-blake3 = dependency('libblake3', required: false, allow_fallback: false)
-if not blake3.found()
- blake3_opts = cmake.subproject_options()
- reltype = is_minsize ? 'MinSizeRel' : 'Release'
- blake3_opts.add_cmake_defines({ 'CMAKE_BUILD_TYPE': is_debug ? 'Debug' : reltype })
- blake3_opts.add_cmake_defines({ 'CMAKE_POSITION_INDEPENDENT_CODE': true })
- blake3 = cmake.subproject('BLAKE3', options: blake3_opts).dependency('blake3')
+util_deps = []
+if get_option('portal').enabled()
+ blake3 = dependency('libblake3', required: false, allow_fallback: false)
+ if not blake3.found()
+ blake3_opts = cmake.subproject_options()
+ reltype = is_minsize ? 'MinSizeRel' : 'Release'
+ blake3_opts.add_cmake_defines({ 'CMAKE_BUILD_TYPE': is_debug ? 'Debug' : reltype })
+ blake3_opts.add_cmake_defines({ 'CMAKE_POSITION_INDEPENDENT_CODE': true })
+ blake3 = cmake.subproject('BLAKE3', options: blake3_opts).dependency('blake3')
+ endif
+ util_deps += [blake3]
endif
-util_deps = [blake3]
util = declare_dependency(sources: util_src, dependencies: util_deps)