diff options
| author | 2026-04-13 17:01:47 -0400 | |
|---|---|---|
| committer | 2026-04-13 17:01:47 -0400 | |
| commit | 77b54c35bf9587450cd636e0d7df37e190e28bfb (patch) | |
| tree | a290efdd8b09066847199f3f52a32be70d24ef51 /src/codec | |
| parent | 20617b9c80cf8d8051ecdb53a2c22f68c012f21b (diff) | |
| download | camu-77b54c35bf9587450cd636e0d7df37e190e28bfb.tar.gz camu-77b54c35bf9587450cd636e0d7df37e190e28bfb.tar.bz2 camu-77b54c35bf9587450cd636e0d7df37e190e28bfb.zip | |
Smaller stuff that went uncommitted
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/codec')
| -rw-r--r-- | src/codec/codec.h | 2 | ||||
| -rw-r--r-- | src/codec/common.h | 5 | ||||
| -rw-r--r-- | src/codec/meson.build | 20 | ||||
| -rw-r--r-- | src/codec/stb_image.c | 18 | ||||
| -rw-r--r-- | src/codec/wuffs.c | 4 |
5 files changed, 36 insertions, 13 deletions
diff --git a/src/codec/codec.h b/src/codec/codec.h index 6a9b654..730e8cb 100644 --- a/src/codec/codec.h +++ b/src/codec/codec.h @@ -2,7 +2,7 @@ #include <al/array.h> #include <al/str.h> -#include <nnwt/common.h> +#include <nnwt/buffer.h> #ifdef CAMU_HAVE_FFMPEG #include <libavutil/pixdesc.h> #include <libavformat/avformat.h> diff --git a/src/codec/common.h b/src/codec/common.h index 98665d7..1b468cb 100644 --- a/src/codec/common.h +++ b/src/codec/common.h @@ -6,7 +6,10 @@ static inline void *camu_page_alloc(size_t size) { #ifdef AL_HAVE_POSIX_MEMALIGN void *ptr = NULL; - al_posix_memalign(&ptr, al_page_size, size); + if (al_posix_memalign(&ptr, al_page_size, size) != 0) { + // For possible EINVAL rather than ENOMEM. + return NULL; + } return ptr; #else return al_malloc(size); diff --git a/src/codec/meson.build b/src/codec/meson.build index 81144d4..a92a23d 100644 --- a/src/codec/meson.build +++ b/src/codec/meson.build @@ -3,29 +3,37 @@ codec_src = ['packet_ext.c', 'codecs.c'] codec_server_deps = [] codec_client_deps = [] -if get_option('codecs').contains('ffmpeg') +if 'ffmpeg' in get_option('codecs') subdir('ffmpeg') endif -if get_option('codecs').contains('stb_image') - stb = subproject('stb').get_variable('stb') +if 'stb_image' in get_option('codecs') + stb = [] stb_args = ['-DCAMU_HAVE_STB_IMAGE'] + if not compiler.check_header('stb/stb_image.h') + stb = [subproject('stb').get_variable('stb')] + stb_args += ['-DCAMU_LOCAL_STB'] + endif stb_codec = declare_dependency(sources: ['stb_image.c'], dependencies: stb, compile_args: stb_args) codec_server_deps += [stb_codec] codec_client_deps += [stb_codec] endif -if get_option('codecs').contains('wuffs') - wuffs = subproject('wuffs').get_variable('wuffs') +if 'wuffs' in get_option('codecs') + wuffs = [] wuffs_args = ['-DCAMU_HAVE_WUFFS'] + if not compiler.check_header('wuffs/wuffs-v0.4.c') + wuffs = [subproject('wuffs').get_variable('wuffs')] + wuffs_args += ['-DCAMU_LOCAL_WUFFS'] + endif wuffs_codec = declare_dependency(sources: ['wuffs.c'], dependencies: wuffs, compile_args: wuffs_args) codec_server_deps += [wuffs_codec] codec_client_deps += [wuffs_codec] endif -if get_option('codecs').contains('spng') +if 'spng' in get_option('codecs') spng = dependency('spng') spng_args = ['-DCAMU_HAVE_SPNG'] spng_codec = declare_dependency(sources: ['spng.c'], diff --git a/src/codec/stb_image.c b/src/codec/stb_image.c index 0cc61c8..b37d6da 100644 --- a/src/codec/stb_image.c +++ b/src/codec/stb_image.c @@ -8,10 +8,16 @@ #define STBI_NO_STDIO #define STBI_NO_FAILURE_STRINGS #define STB_IMAGE_IMPLEMENTATION +#ifdef CAMU_LOCAL_STB #include <stb_image.h> +#else +#include <stb/stb_image.h> +#endif #include "stb_image.h" +#define FORCE_RGBA + #ifdef LIANA_SERVER #include "../cache/entry.h" @@ -43,7 +49,11 @@ static bool stbi_demuxer_init(struct camu_demuxer *demux, struct cch_handle *han struct camu_video_format *fmt = &stream.video.fmt; fmt->width = (u32)w; fmt->height = (u32)h; +#ifdef FORCE_RGBA + fmt->format = camu_pixel_format_from_channels(4); +#else fmt->format = camu_pixel_format_from_channels(channels); +#endif al_array_push(stb->demux.streams, stream); @@ -118,10 +128,8 @@ static s32 stbi_decoder_push(struct camu_decoder *dec, struct camu_codec_packet s32 w, h, channels; u8 *data = nn_buffer_get_ptr(packet->buffer, 0); -#ifdef NAUNET_ON_WINDOWS -#define STB_FORCE_RGBA -#endif -#ifdef STB_FORCE_RGBA + +#ifdef FORCE_RGBA u8 *pixels = stbi_load_from_memory(data, packet->buffer->size, &w, &h, &channels, 4); #else u8 *pixels = stbi_load_from_memory(data, packet->buffer->size, &w, &h, &channels, 0); @@ -140,7 +148,7 @@ static s32 stbi_decoder_push(struct camu_decoder *dec, struct camu_codec_packet frame->data = pixels; frame->video.width = (u32)w; frame->video.height = (u32)h; -#ifdef STB_FORCE_RGBA +#ifdef FORCE_RGBA frame->format = camu_pixel_format_from_channels(4); #else frame->format = camu_pixel_format_from_channels(channels); diff --git a/src/codec/wuffs.c b/src/codec/wuffs.c index 6ae81d9..7050fb4 100644 --- a/src/codec/wuffs.c +++ b/src/codec/wuffs.c @@ -8,7 +8,11 @@ #define WUFFS_CONFIG__MODULE__JPEG #define WUFFS_CONFIG__MODULE__IMAGE #define WUFFS_IMPLEMENTATION +#ifdef CAMU_LOCAL_WUFFS #include <wuffs-unsupported-snapshot.c> +#else +#include <wuffs/wuffs-v0.4.c> +#endif #include "wuffs.h" #include "common.h" |