summaryrefslogtreecommitdiff
path: root/src/codec
diff options
context:
space:
mode:
Diffstat (limited to 'src/codec')
-rw-r--r--src/codec/codec.h4
-rw-r--r--src/codec/ffmpeg/common.c2
-rw-r--r--src/codec/ffmpeg/encoder.c4
-rw-r--r--src/codec/ffmpeg/packet_ext.c248
-rw-r--r--src/codec/ffmpeg/packet_ext.h20
-rw-r--r--src/codec/spng/demuxer.h2
-rw-r--r--src/codec/spng/impl.c14
-rw-r--r--src/codec/stb_image/demuxer.h2
-rw-r--r--src/codec/stb_image/impl.c14
-rw-r--r--src/codec/wuffs/demuxer.h2
-rw-r--r--src/codec/wuffs/impl.c14
11 files changed, 162 insertions, 164 deletions
diff --git a/src/codec/codec.h b/src/codec/codec.h
index a9b188a..697f456 100644
--- a/src/codec/codec.h
+++ b/src/codec/codec.h
@@ -1,7 +1,7 @@
#pragma once
#include <al/array.h>
-#include <aki/common.h>
+#include <nnwt/common.h>
#ifdef CAMU_HAVE_FFMPEG
#include <libavutil/pixdesc.h>
#include <libavformat/avformat.h>
@@ -141,7 +141,7 @@ struct camu_codec_stream {
struct camu_codec_packet {
u8 mode;
- struct aki_buffer *buffer;
+ struct nn_buffer *buffer;
#ifdef CAMU_HAVE_FFMPEG
struct { AVPacket *pkt; } av;
#endif
diff --git a/src/codec/ffmpeg/common.c b/src/codec/ffmpeg/common.c
index c147d81..16bbeab 100644
--- a/src/codec/ffmpeg/common.c
+++ b/src/codec/ffmpeg/common.c
@@ -22,7 +22,7 @@ static void av_log_callback(void *userdata, int level, const char *fmt, va_list
if (level < AV_LOG_DEBUG) {
pos += al_vsnprintf(&buf[pos], CHUNK_SIZE, fmt, args);
if (buf[pos - 1] == '\n' || pos >= CHUNK_SIZE) {
- al_log_info("ff_log", buf);
+ al_log_info("ff", buf);
pos = 0;
}
}
diff --git a/src/codec/ffmpeg/encoder.c b/src/codec/ffmpeg/encoder.c
index 6e914c8..7c7b010 100644
--- a/src/codec/ffmpeg/encoder.c
+++ b/src/codec/ffmpeg/encoder.c
@@ -99,7 +99,7 @@ void camu_ff_encoder_push(struct camu_ff_encoder *enc, u8 **data, s32 sample_cou
return;
}
AVPacket pkt = { 0 };
- do {
+ for (;;) {
ret = avcodec_receive_packet(enc->codec_context, &pkt);
if (ret < 0) {
if (!(ret = AVERROR_EOF || ret == AVERROR(EAGAIN))) {
@@ -109,7 +109,7 @@ void camu_ff_encoder_push(struct camu_ff_encoder *enc, u8 **data, s32 sample_cou
}
enc->callback(enc->userdata, &pkt);
enc->frame->pts += SAMPLES_PER_FRAME;
- } while (1);
+ }
}
void camu_ff_encoder_reset(struct camu_ff_encoder *enc)
diff --git a/src/codec/ffmpeg/packet_ext.c b/src/codec/ffmpeg/packet_ext.c
index 16f5748..759719b 100644
--- a/src/codec/ffmpeg/packet_ext.c
+++ b/src/codec/ffmpeg/packet_ext.c
@@ -1,201 +1,201 @@
#include "packet_ext.h"
-void aki_packet_write_av_codec_parameters(struct aki_packet *packet, AVCodecParameters *codecpar)
+void nn_packet_write_av_codec_parameters(struct nn_packet *packet, AVCodecParameters *codecpar)
{
- AKI_PACKET_WRITE_TYPE(packet, enum AVMediaType, codecpar->codec_type);
- AKI_PACKET_WRITE_TYPE(packet, enum AVCodecID, codecpar->codec_id);
- AKI_PACKET_WRITE_TYPE(packet, u32, codecpar->codec_tag);
- AKI_PACKET_WRITE_TYPE(packet, s32, codecpar->extradata_size);
- AKI_PACKET_WRITE_DATA(packet, codecpar->extradata, codecpar->extradata_size);
- AKI_PACKET_WRITE_TYPE(packet, s32, codecpar->format);
- AKI_PACKET_WRITE_TYPE(packet, s64, codecpar->bit_rate);
- AKI_PACKET_WRITE_TYPE(packet, s32, codecpar->bits_per_coded_sample);
- AKI_PACKET_WRITE_TYPE(packet, s32, codecpar->bits_per_raw_sample);
- AKI_PACKET_WRITE_TYPE(packet, s32, codecpar->profile);
- AKI_PACKET_WRITE_TYPE(packet, s32, codecpar->level);
- AKI_PACKET_WRITE_TYPE(packet, s32, codecpar->width);
- AKI_PACKET_WRITE_TYPE(packet, s32, codecpar->height);
- AKI_PACKET_WRITE_TYPE(packet, AVRational, codecpar->sample_aspect_ratio);
- AKI_PACKET_WRITE_TYPE(packet, AVRational, codecpar->framerate);
- AKI_PACKET_WRITE_TYPE(packet, enum AVFieldOrder, codecpar->field_order);
- AKI_PACKET_WRITE_TYPE(packet, enum AVColorRange, codecpar->color_range);
- AKI_PACKET_WRITE_TYPE(packet, enum AVColorPrimaries, codecpar->color_primaries);
- AKI_PACKET_WRITE_TYPE(packet, enum AVColorTransferCharacteristic, codecpar->color_trc);
- AKI_PACKET_WRITE_TYPE(packet, enum AVColorSpace, codecpar->color_space);
- AKI_PACKET_WRITE_TYPE(packet, enum AVChromaLocation, codecpar->chroma_location);
- AKI_PACKET_WRITE_TYPE(packet, s32, codecpar->video_delay);
- AKI_PACKET_WRITE_TYPE(packet, AVChannelLayout, codecpar->ch_layout);
- AKI_PACKET_WRITE_TYPE(packet, s32, codecpar->sample_rate);
- AKI_PACKET_WRITE_TYPE(packet, s32, codecpar->block_align);
- AKI_PACKET_WRITE_TYPE(packet, s32, codecpar->frame_size);
- AKI_PACKET_WRITE_TYPE(packet, s32, codecpar->initial_padding);
- AKI_PACKET_WRITE_TYPE(packet, s32, codecpar->trailing_padding);
- AKI_PACKET_WRITE_TYPE(packet, s32, codecpar->seek_preroll);
+ NNWT_PACKET_WRITE_TYPE(packet, enum AVMediaType, codecpar->codec_type);
+ NNWT_PACKET_WRITE_TYPE(packet, enum AVCodecID, codecpar->codec_id);
+ NNWT_PACKET_WRITE_TYPE(packet, u32, codecpar->codec_tag);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, codecpar->extradata_size);
+ NNWT_PACKET_WRITE_DATA(packet, codecpar->extradata, codecpar->extradata_size);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, codecpar->format);
+ NNWT_PACKET_WRITE_TYPE(packet, s64, codecpar->bit_rate);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, codecpar->bits_per_coded_sample);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, codecpar->bits_per_raw_sample);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, codecpar->profile);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, codecpar->level);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, codecpar->width);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, codecpar->height);
+ NNWT_PACKET_WRITE_TYPE(packet, AVRational, codecpar->sample_aspect_ratio);
+ NNWT_PACKET_WRITE_TYPE(packet, AVRational, codecpar->framerate);
+ NNWT_PACKET_WRITE_TYPE(packet, enum AVFieldOrder, codecpar->field_order);
+ NNWT_PACKET_WRITE_TYPE(packet, enum AVColorRange, codecpar->color_range);
+ NNWT_PACKET_WRITE_TYPE(packet, enum AVColorPrimaries, codecpar->color_primaries);
+ NNWT_PACKET_WRITE_TYPE(packet, enum AVColorTransferCharacteristic, codecpar->color_trc);
+ NNWT_PACKET_WRITE_TYPE(packet, enum AVColorSpace, codecpar->color_space);
+ NNWT_PACKET_WRITE_TYPE(packet, enum AVChromaLocation, codecpar->chroma_location);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, codecpar->video_delay);
+ NNWT_PACKET_WRITE_TYPE(packet, AVChannelLayout, codecpar->ch_layout);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, codecpar->sample_rate);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, codecpar->block_align);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, codecpar->frame_size);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, codecpar->initial_padding);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, codecpar->trailing_padding);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, codecpar->seek_preroll);
}
-void aki_packet_write_av_codec_id(struct aki_packet *packet, enum AVCodecID codec_id)
+void nn_packet_write_av_codec_id(struct nn_packet *packet, enum AVCodecID codec_id)
{
- AKI_PACKET_WRITE_TYPE(packet, enum AVCodecID, codec_id);
+ NNWT_PACKET_WRITE_TYPE(packet, enum AVCodecID, codec_id);
}
-void aki_packet_write_av_dictionary(struct aki_packet *packet, AVDictionary *dict)
+void nn_packet_write_av_dictionary(struct nn_packet *packet, AVDictionary *dict)
{
s32 count = av_dict_count(dict);
- AKI_PACKET_WRITE_TYPE(packet, s32, count);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, count);
const AVDictionaryEntry *entry = NULL;
while ((entry = av_dict_iterate(dict, entry))) {
size_t len = al_strlen(entry->key);
al_assert(len <= UINT32_MAX);
- AKI_PACKET_WRITE_TYPE(packet, u32, len);
- AKI_PACKET_WRITE_DATA(packet, entry->key, len);
+ NNWT_PACKET_WRITE_TYPE(packet, u32, len);
+ NNWT_PACKET_WRITE_DATA(packet, entry->key, len);
len = al_strlen(entry->value);
al_assert(len <= UINT32_MAX);
- AKI_PACKET_WRITE_TYPE(packet, u32, len);
- AKI_PACKET_WRITE_DATA(packet, entry->value, len);
+ NNWT_PACKET_WRITE_TYPE(packet, u32, len);
+ NNWT_PACKET_WRITE_DATA(packet, entry->value, len);
}
}
-void aki_packet_write_av_stream(struct aki_packet *packet, AVStream *stream)
+void nn_packet_write_av_stream(struct nn_packet *packet, AVStream *stream)
{
- AKI_PACKET_WRITE_TYPE(packet, s32, stream->index);
- aki_packet_write_av_codec_parameters(packet, stream->codecpar);
- AKI_PACKET_WRITE_TYPE(packet, AVRational, stream->time_base);
- AKI_PACKET_WRITE_TYPE(packet, s64, stream->duration);
- AKI_PACKET_WRITE_TYPE(packet, s64, stream->start_time);
- AKI_PACKET_WRITE_TYPE(packet, s64, stream->nb_frames);
- aki_packet_write_av_dictionary(packet, stream->metadata);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, stream->index);
+ nn_packet_write_av_codec_parameters(packet, stream->codecpar);
+ NNWT_PACKET_WRITE_TYPE(packet, AVRational, stream->time_base);
+ NNWT_PACKET_WRITE_TYPE(packet, s64, stream->duration);
+ NNWT_PACKET_WRITE_TYPE(packet, s64, stream->start_time);
+ NNWT_PACKET_WRITE_TYPE(packet, s64, stream->nb_frames);
+ nn_packet_write_av_dictionary(packet, stream->metadata);
if (stream->avg_frame_rate.den == 0) {
- // r_frame_rate.den == 0 handled on the client.
- AKI_PACKET_WRITE_TYPE(packet, AVRational, stream->r_frame_rate);
+ // r_frame_rate.den = 0 handled on the client.
+ NNWT_PACKET_WRITE_TYPE(packet, AVRational, stream->r_frame_rate);
} else {
- AKI_PACKET_WRITE_TYPE(packet, AVRational, stream->avg_frame_rate);
+ NNWT_PACKET_WRITE_TYPE(packet, AVRational, stream->avg_frame_rate);
}
}
-void aki_packet_write_av_packet(struct aki_packet *packet, AVPacket *pkt)
+void nn_packet_write_av_packet(struct nn_packet *packet, AVPacket *pkt)
{
- AKI_PACKET_WRITE_TYPE(packet, s64, pkt->pts);
- AKI_PACKET_WRITE_TYPE(packet, s64, pkt->dts);
- AKI_PACKET_WRITE_TYPE(packet, s32, pkt->size);
- AKI_PACKET_WRITE_DATA(packet, pkt->data, pkt->size);
- AKI_PACKET_WRITE_TYPE(packet, s32, pkt->stream_index);
- AKI_PACKET_WRITE_TYPE(packet, s32, pkt->flags);
- AKI_PACKET_WRITE_TYPE(packet, s32, pkt->side_data_elems);
+ NNWT_PACKET_WRITE_TYPE(packet, s64, pkt->pts);
+ NNWT_PACKET_WRITE_TYPE(packet, s64, pkt->dts);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, pkt->size);
+ NNWT_PACKET_WRITE_DATA(packet, pkt->data, pkt->size);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, pkt->stream_index);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, pkt->flags);
+ NNWT_PACKET_WRITE_TYPE(packet, s32, pkt->side_data_elems);
for (s32 i = 0; i < pkt->side_data_elems; i++) {
// Possibly upcast size_t.
s64 size = (s64)pkt->side_data[i].size;
- AKI_PACKET_WRITE_TYPE(packet, s64, size);
- AKI_PACKET_WRITE_DATA(packet, pkt->side_data[i].data, pkt->side_data[i].size);
- AKI_PACKET_WRITE_TYPE(packet, enum AVPacketSideDataType, pkt->side_data[i].type);
+ NNWT_PACKET_WRITE_TYPE(packet, s64, size);
+ NNWT_PACKET_WRITE_DATA(packet, pkt->side_data[i].data, pkt->side_data[i].size);
+ NNWT_PACKET_WRITE_TYPE(packet, enum AVPacketSideDataType, pkt->side_data[i].type);
}
- AKI_PACKET_WRITE_TYPE(packet, s64, pkt->duration);
- AKI_PACKET_WRITE_TYPE(packet, s64, pkt->pos);
- AKI_PACKET_WRITE_TYPE(packet, AVRational, pkt->time_base);
+ NNWT_PACKET_WRITE_TYPE(packet, s64, pkt->duration);
+ NNWT_PACKET_WRITE_TYPE(packet, s64, pkt->pos);
+ NNWT_PACKET_WRITE_TYPE(packet, AVRational, pkt->time_base);
}
-void aki_packet_read_av_codec_parameters(struct aki_packet *packet, AVCodecParameters *codecpar)
+void nn_packet_read_av_codec_parameters(struct nn_packet *packet, AVCodecParameters *codecpar)
{
- AKI_PACKET_READ_TYPE(packet, enum AVMediaType, codecpar->codec_type);
- AKI_PACKET_READ_TYPE(packet, enum AVCodecID, codecpar->codec_id);
- AKI_PACKET_READ_TYPE(packet, u32, codecpar->codec_tag);
- AKI_PACKET_READ_TYPE(packet, s32, codecpar->extradata_size);
+ NNWT_PACKET_READ_TYPE(packet, enum AVMediaType, codecpar->codec_type);
+ NNWT_PACKET_READ_TYPE(packet, enum AVCodecID, codecpar->codec_id);
+ NNWT_PACKET_READ_TYPE(packet, u32, codecpar->codec_tag);
+ NNWT_PACKET_READ_TYPE(packet, s32, codecpar->extradata_size);
codecpar->extradata = av_malloc(codecpar->extradata_size);
u8 *extradata;
- AKI_PACKET_READ_DATA(packet, codecpar->extradata_size, extradata);
+ NNWT_PACKET_READ_DATA(packet, codecpar->extradata_size, extradata);
al_memcpy(codecpar->extradata, extradata, codecpar->extradata_size);
- AKI_PACKET_READ_TYPE(packet, s32, codecpar->format);
- AKI_PACKET_READ_TYPE(packet, s64, codecpar->bit_rate);
- AKI_PACKET_READ_TYPE(packet, s32, codecpar->bits_per_coded_sample);
- AKI_PACKET_READ_TYPE(packet, s32, codecpar->bits_per_raw_sample);
- AKI_PACKET_READ_TYPE(packet, s32, codecpar->profile);
- AKI_PACKET_READ_TYPE(packet, s32, codecpar->level);
- AKI_PACKET_READ_TYPE(packet, s32, codecpar->width);
- AKI_PACKET_READ_TYPE(packet, s32, codecpar->height);
- AKI_PACKET_READ_TYPE(packet, AVRational, codecpar->sample_aspect_ratio);
- AKI_PACKET_READ_TYPE(packet, AVRational, codecpar->framerate);
- AKI_PACKET_READ_TYPE(packet, enum AVFieldOrder, codecpar->field_order);
- AKI_PACKET_READ_TYPE(packet, enum AVColorRange, codecpar->color_range);
- AKI_PACKET_READ_TYPE(packet, enum AVColorPrimaries, codecpar->color_primaries);
- AKI_PACKET_READ_TYPE(packet, enum AVColorTransferCharacteristic, codecpar->color_trc);
- AKI_PACKET_READ_TYPE(packet, enum AVColorSpace, codecpar->color_space);
- AKI_PACKET_READ_TYPE(packet, enum AVChromaLocation, codecpar->chroma_location);
- AKI_PACKET_READ_TYPE(packet, s32, codecpar->video_delay);
- AKI_PACKET_READ_TYPE(packet, AVChannelLayout, codecpar->ch_layout);
- AKI_PACKET_READ_TYPE(packet, s32, codecpar->sample_rate);
- AKI_PACKET_READ_TYPE(packet, s32, codecpar->block_align);
- AKI_PACKET_READ_TYPE(packet, s32, codecpar->frame_size);
- AKI_PACKET_READ_TYPE(packet, s32, codecpar->initial_padding);
- AKI_PACKET_READ_TYPE(packet, s32, codecpar->trailing_padding);
- AKI_PACKET_READ_TYPE(packet, s32, codecpar->seek_preroll);
+ NNWT_PACKET_READ_TYPE(packet, s32, codecpar->format);
+ NNWT_PACKET_READ_TYPE(packet, s64, codecpar->bit_rate);
+ NNWT_PACKET_READ_TYPE(packet, s32, codecpar->bits_per_coded_sample);
+ NNWT_PACKET_READ_TYPE(packet, s32, codecpar->bits_per_raw_sample);
+ NNWT_PACKET_READ_TYPE(packet, s32, codecpar->profile);
+ NNWT_PACKET_READ_TYPE(packet, s32, codecpar->level);
+ NNWT_PACKET_READ_TYPE(packet, s32, codecpar->width);
+ NNWT_PACKET_READ_TYPE(packet, s32, codecpar->height);
+ NNWT_PACKET_READ_TYPE(packet, AVRational, codecpar->sample_aspect_ratio);
+ NNWT_PACKET_READ_TYPE(packet, AVRational, codecpar->framerate);
+ NNWT_PACKET_READ_TYPE(packet, enum AVFieldOrder, codecpar->field_order);
+ NNWT_PACKET_READ_TYPE(packet, enum AVColorRange, codecpar->color_range);
+ NNWT_PACKET_READ_TYPE(packet, enum AVColorPrimaries, codecpar->color_primaries);
+ NNWT_PACKET_READ_TYPE(packet, enum AVColorTransferCharacteristic, codecpar->color_trc);
+ NNWT_PACKET_READ_TYPE(packet, enum AVColorSpace, codecpar->color_space);
+ NNWT_PACKET_READ_TYPE(packet, enum AVChromaLocation, codecpar->chroma_location);
+ NNWT_PACKET_READ_TYPE(packet, s32, codecpar->video_delay);
+ NNWT_PACKET_READ_TYPE(packet, AVChannelLayout, codecpar->ch_layout);
+ NNWT_PACKET_READ_TYPE(packet, s32, codecpar->sample_rate);
+ NNWT_PACKET_READ_TYPE(packet, s32, codecpar->block_align);
+ NNWT_PACKET_READ_TYPE(packet, s32, codecpar->frame_size);
+ NNWT_PACKET_READ_TYPE(packet, s32, codecpar->initial_padding);
+ NNWT_PACKET_READ_TYPE(packet, s32, codecpar->trailing_padding);
+ NNWT_PACKET_READ_TYPE(packet, s32, codecpar->seek_preroll);
}
-enum AVCodecID aki_packet_read_av_codec_id(struct aki_packet *packet)
+enum AVCodecID nn_packet_read_av_codec_id(struct nn_packet *packet)
{
enum AVCodecID id;
- AKI_PACKET_READ_TYPE(packet, enum AVCodecID, id);
+ NNWT_PACKET_READ_TYPE(packet, enum AVCodecID, id);
return id;
}
-void aki_packet_read_av_dictionary(struct aki_packet *packet, AVDictionary **dict)
+void nn_packet_read_av_dictionary(struct nn_packet *packet, AVDictionary **dict)
{
s32 count;
- AKI_PACKET_READ_TYPE(packet, s32, count);
+ NNWT_PACKET_READ_TYPE(packet, s32, count);
for (s32 i = 0; i < count; i++) {
char *key, *value;
u32 len;
- AKI_PACKET_READ_TYPE(packet, u32, len);
- AKI_PACKET_READ_DATA(packet, len, key);
+ NNWT_PACKET_READ_TYPE(packet, u32, len);
+ NNWT_PACKET_READ_DATA(packet, len, key);
// Key and value MUST be allocated with av_malloc functions
// just like all FFmpeg structures.
key = av_strndup(key, len);
- AKI_PACKET_READ_TYPE(packet, u32, len);
- AKI_PACKET_READ_DATA(packet, len, value);
+ NNWT_PACKET_READ_TYPE(packet, u32, len);
+ NNWT_PACKET_READ_DATA(packet, len, value);
value = av_strndup(value, len);
av_dict_set(dict, key, value, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
}
}
-AVStream *aki_packet_read_av_stream(AVFormatContext *format_context, const AVCodec *codec, struct aki_packet *packet)
+AVStream *nn_packet_read_av_stream(AVFormatContext *format_context, const AVCodec *codec, struct nn_packet *packet)
{
AVStream *stream = avformat_new_stream(format_context, codec);
- AKI_PACKET_READ_TYPE(packet, s32, stream->index);
- aki_packet_read_av_codec_parameters(packet, stream->codecpar);
- AKI_PACKET_READ_TYPE(packet, AVRational, stream->time_base);
- AKI_PACKET_READ_TYPE(packet, s64, stream->duration);
- AKI_PACKET_READ_TYPE(packet, s64, stream->start_time);
- AKI_PACKET_READ_TYPE(packet, s64, stream->nb_frames);
+ NNWT_PACKET_READ_TYPE(packet, s32, stream->index);
+ nn_packet_read_av_codec_parameters(packet, stream->codecpar);
+ NNWT_PACKET_READ_TYPE(packet, AVRational, stream->time_base);
+ NNWT_PACKET_READ_TYPE(packet, s64, stream->duration);
+ NNWT_PACKET_READ_TYPE(packet, s64, stream->start_time);
+ NNWT_PACKET_READ_TYPE(packet, s64, stream->nb_frames);
stream->metadata = NULL;
- aki_packet_read_av_dictionary(packet, &stream->metadata);
- AKI_PACKET_READ_TYPE(packet, AVRational, stream->avg_frame_rate);
+ nn_packet_read_av_dictionary(packet, &stream->metadata);
+ NNWT_PACKET_READ_TYPE(packet, AVRational, stream->avg_frame_rate);
return stream;
}
-AVPacket *aki_packet_read_av_packet(struct aki_packet *packet)
+AVPacket *nn_packet_read_av_packet(struct nn_packet *packet)
{
AVPacket *pkt = av_packet_alloc();
- AKI_PACKET_READ_TYPE(packet, s64, pkt->pts);
- AKI_PACKET_READ_TYPE(packet, s64, pkt->dts);
- AKI_PACKET_READ_TYPE(packet, s32, pkt->size);
- AKI_PACKET_READ_DATA(packet, pkt->size, pkt->data);
- AKI_PACKET_READ_TYPE(packet, s32, pkt->stream_index);
- AKI_PACKET_READ_TYPE(packet, s32, pkt->flags);
+ NNWT_PACKET_READ_TYPE(packet, s64, pkt->pts);
+ NNWT_PACKET_READ_TYPE(packet, s64, pkt->dts);
+ NNWT_PACKET_READ_TYPE(packet, s32, pkt->size);
+ NNWT_PACKET_READ_DATA(packet, pkt->size, pkt->data);
+ NNWT_PACKET_READ_TYPE(packet, s32, pkt->stream_index);
+ NNWT_PACKET_READ_TYPE(packet, s32, pkt->flags);
s32 side_data_elems;
- AKI_PACKET_READ_TYPE(packet, s32, side_data_elems);
+ NNWT_PACKET_READ_TYPE(packet, s32, side_data_elems);
pkt->side_data_elems = 0;
for (s32 i = 0; i < side_data_elems; i++) {
u8 *data;
enum AVPacketSideDataType type;
s64 storage_for_size;
- AKI_PACKET_READ_TYPE(packet, s64, storage_for_size);
+ NNWT_PACKET_READ_TYPE(packet, s64, storage_for_size);
al_assert((sizeof(size_t) > 4 || storage_for_size <= INT32_MAX));
size_t size = (size_t)storage_for_size;
- AKI_PACKET_READ_DATA(packet, size, data);
- AKI_PACKET_READ_TYPE(packet, enum AVPacketSideDataType, type);
+ NNWT_PACKET_READ_DATA(packet, size, data);
+ NNWT_PACKET_READ_TYPE(packet, enum AVPacketSideDataType, type);
u8 *side_data = av_packet_new_side_data(pkt, type, size);
al_memcpy(side_data, data, size);
}
- AKI_PACKET_READ_TYPE(packet, s64, pkt->duration);
- AKI_PACKET_READ_TYPE(packet, s64, pkt->pos);
- AKI_PACKET_READ_TYPE(packet, AVRational, pkt->time_base);
+ NNWT_PACKET_READ_TYPE(packet, s64, pkt->duration);
+ NNWT_PACKET_READ_TYPE(packet, s64, pkt->pos);
+ NNWT_PACKET_READ_TYPE(packet, AVRational, pkt->time_base);
return pkt;
}
diff --git a/src/codec/ffmpeg/packet_ext.h b/src/codec/ffmpeg/packet_ext.h
index 26a1392..91254c2 100644
--- a/src/codec/ffmpeg/packet_ext.h
+++ b/src/codec/ffmpeg/packet_ext.h
@@ -1,19 +1,17 @@
#pragma once
-#include <aki/common.h>
-#include <aki/event_loop.h>
-
+#include <nnwt/packet.h>
#include <libavcodec/packet.h>
#include <libavcodec/codec_par.h>
#include <libavformat/avformat.h>
#include <libavutil/dict.h>
-void aki_packet_write_av_codec_parameters(struct aki_packet *packet, AVCodecParameters *codecpar);
-void aki_packet_write_av_codec_id(struct aki_packet *packet, enum AVCodecID codec_id);
-void aki_packet_write_av_stream(struct aki_packet *packet, AVStream *stream);
-void aki_packet_write_av_packet(struct aki_packet *packet, AVPacket *pkt);
+void nn_packet_write_av_codec_parameters(struct nn_packet *packet, AVCodecParameters *codecpar);
+void nn_packet_write_av_codec_id(struct nn_packet *packet, enum AVCodecID codec_id);
+void nn_packet_write_av_stream(struct nn_packet *packet, AVStream *stream);
+void nn_packet_write_av_packet(struct nn_packet *packet, AVPacket *pkt);
-void aki_packet_read_av_codec_parameters(struct aki_packet *packet, AVCodecParameters *codecpar);
-enum AVCodecID aki_packet_read_av_codec_id(struct aki_packet *packet);
-AVStream *aki_packet_read_av_stream(AVFormatContext *format_context, const AVCodec *codec, struct aki_packet *packet);
-AVPacket *aki_packet_read_av_packet(struct aki_packet *packet);
+void nn_packet_read_av_codec_parameters(struct nn_packet *packet, AVCodecParameters *codecpar);
+enum AVCodecID nn_packet_read_av_codec_id(struct nn_packet *packet);
+AVStream *nn_packet_read_av_stream(AVFormatContext *format_context, const AVCodec *codec, struct nn_packet *packet);
+AVPacket *nn_packet_read_av_packet(struct nn_packet *packet);
diff --git a/src/codec/spng/demuxer.h b/src/codec/spng/demuxer.h
index 1947bb7..bd89ef1 100644
--- a/src/codec/spng/demuxer.h
+++ b/src/codec/spng/demuxer.h
@@ -5,7 +5,7 @@
struct camu_spng_demuxer {
struct camu_demuxer demux;
struct cch_handle *handle;
- struct aki_buffer buffer;
+ struct nn_buffer buffer;
bool eof;
};
diff --git a/src/codec/spng/impl.c b/src/codec/spng/impl.c
index 198d514..58b68f6 100644
--- a/src/codec/spng/impl.c
+++ b/src/codec/spng/impl.c
@@ -1,5 +1,5 @@
#include <al/lib.h>
-#include <aki/common.h>
+#include <nnwt/common.h>
#include <spng.h>
#include "../../cache/entry.h"
@@ -14,17 +14,17 @@ static bool spng_demuxer_init(struct camu_demuxer *demux, struct cch_handle *han
struct camu_spng_demuxer *spng = (struct camu_spng_demuxer *)demux;
spng->handle = handle;
- aki_buffer_init(&spng->buffer);
+ nn_buffer_init(&spng->buffer);
spng->eof = false;
cch_handle_seek(spng->handle, 0, SEEK_SET);
off_t size = cch_entry_get_size(spng->handle->entry);
- aki_buffer_ensure_space(&spng->buffer, size);
- cch_handle_read(spng->handle, aki_buffer_get_ptr(&spng->buffer, 0), size);
+ nn_buffer_ensure_space(&spng->buffer, size);
+ cch_handle_read(spng->handle, nn_buffer_get_ptr(&spng->buffer, 0), size);
spng->buffer.size = size;
spng_ctx *ctx = spng_ctx_new(SPNG_CTX_IGNORE_ADLER32);
- spng_set_png_buffer(ctx, aki_buffer_get_ptr(&spng->buffer, 0), spng->buffer.size);
+ spng_set_png_buffer(ctx, nn_buffer_get_ptr(&spng->buffer, 0), spng->buffer.size);
spng_set_option(ctx, SPNG_CHUNK_COUNT_LIMIT, 6250);
spng_set_crc_action(ctx, SPNG_CRC_DISCARD, SPNG_CRC_DISCARD);
@@ -73,7 +73,7 @@ static bool spng_demuxer_seek(struct camu_demuxer *demux, u64 pos)
static void spng_demuxer_free(struct camu_demuxer **demux)
{
struct camu_spng_demuxer *spng = (struct camu_spng_demuxer *)*demux;
- aki_buffer_free(&spng->buffer);
+ nn_buffer_free(&spng->buffer);
al_array_free(spng->demux.streams);
al_free(spng);
*demux = NULL;
@@ -96,7 +96,7 @@ static s32 spng_decoder_push(struct camu_decoder *dec, struct camu_codec_packet
if (!packet) return CAMU_OK;
spng_ctx *ctx = spng_ctx_new(SPNG_CTX_IGNORE_ADLER32);
- spng_set_png_buffer(ctx, aki_buffer_get_ptr(packet->buffer, 0), packet->buffer->size);
+ spng_set_png_buffer(ctx, nn_buffer_get_ptr(packet->buffer, 0), packet->buffer->size);
spng_set_option(ctx, SPNG_CHUNK_COUNT_LIMIT, 6250);
spng_set_crc_action(ctx, SPNG_CRC_DISCARD, SPNG_CRC_DISCARD);
diff --git a/src/codec/stb_image/demuxer.h b/src/codec/stb_image/demuxer.h
index 52f9256..d64e311 100644
--- a/src/codec/stb_image/demuxer.h
+++ b/src/codec/stb_image/demuxer.h
@@ -5,7 +5,7 @@
struct camu_stbi_demuxer {
struct camu_demuxer demux;
struct cch_handle *handle;
- struct aki_buffer buffer;
+ struct nn_buffer buffer;
bool eof;
};
diff --git a/src/codec/stb_image/impl.c b/src/codec/stb_image/impl.c
index ac1cbc5..bb38844 100644
--- a/src/codec/stb_image/impl.c
+++ b/src/codec/stb_image/impl.c
@@ -1,5 +1,5 @@
#include <al/lib.h>
-#include <aki/common.h>
+#include <nnwt/common.h>
#include "../common.h"
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_STATIC
@@ -22,17 +22,17 @@ static bool stbi_demuxer_init(struct camu_demuxer *demux, struct cch_handle *han
struct camu_stbi_demuxer *stb = (struct camu_stbi_demuxer *)demux;
stb->handle = handle;
- aki_buffer_init(&stb->buffer);
+ nn_buffer_init(&stb->buffer);
stb->eof = false;
cch_handle_seek(stb->handle, 0, SEEK_SET);
off_t size = cch_entry_get_size(stb->handle->entry);
- aki_buffer_ensure_space(&stb->buffer, size);
- cch_handle_read(stb->handle, aki_buffer_get_ptr(&stb->buffer, 0), size);
+ nn_buffer_ensure_space(&stb->buffer, size);
+ cch_handle_read(stb->handle, nn_buffer_get_ptr(&stb->buffer, 0), size);
stb->buffer.size = size;
s32 w, h, channels;
- u8 *data = aki_buffer_get_ptr(&stb->buffer, 0);
+ u8 *data = nn_buffer_get_ptr(&stb->buffer, 0);
if (!stbi_info_from_memory(data, stb->buffer.size, &w, &h, &channels)) {
goto err;
}
@@ -80,7 +80,7 @@ static bool stbi_demuxer_seek(struct camu_demuxer *demux, u64 pos)
static void stbi_demuxer_free(struct camu_demuxer **demux)
{
struct camu_stbi_demuxer *stb = (struct camu_stbi_demuxer *)*demux;
- aki_buffer_free(&stb->buffer);
+ nn_buffer_free(&stb->buffer);
al_array_free(stb->demux.streams);
al_free(stb);
*demux = NULL;
@@ -104,7 +104,7 @@ static s32 stbi_decoder_push(struct camu_decoder *dec, struct camu_codec_packet
if (!packet) return CAMU_OK;
s32 w, h, channels;
- u8 *data = aki_buffer_get_ptr(packet->buffer, 0);
+ u8 *data = nn_buffer_get_ptr(packet->buffer, 0);
u8 *pixels = stbi_load_from_memory(data, packet->buffer->size, &w, &h, &channels, 0);
if (!pixels) return CAMU_ERR_ERROR;
struct camu_video_format *fmt = &stb->stream->video.fmt;
diff --git a/src/codec/wuffs/demuxer.h b/src/codec/wuffs/demuxer.h
index 6e9e391..c2cb8a5 100644
--- a/src/codec/wuffs/demuxer.h
+++ b/src/codec/wuffs/demuxer.h
@@ -5,7 +5,7 @@
struct camu_wuffs_demuxer {
struct camu_demuxer demux;
struct cch_handle *handle;
- struct aki_buffer buffer;
+ struct nn_buffer buffer;
bool eof;
};
diff --git a/src/codec/wuffs/impl.c b/src/codec/wuffs/impl.c
index 4d9ea7e..378ac00 100644
--- a/src/codec/wuffs/impl.c
+++ b/src/codec/wuffs/impl.c
@@ -1,4 +1,4 @@
-#include <aki/common.h>
+#include <nnwt/common.h>
#define WUFFS_IMPLEMENTATION
#define WUFFS_CONFIG__STATIC_FUNCTIONS
#define WUFFS_CONFIG__MODULES
@@ -22,13 +22,13 @@ static bool wuffs_demuxer_init(struct camu_demuxer *demux, struct cch_handle *ha
struct camu_wuffs_demuxer *wfs = (struct camu_wuffs_demuxer *)demux;
wfs->handle = handle;
- aki_buffer_init(&wfs->buffer);
+ nn_buffer_init(&wfs->buffer);
wfs->eof = false;
cch_handle_seek(wfs->handle, 0, SEEK_SET);
off_t size = cch_entry_get_size(wfs->handle->entry);
- aki_buffer_ensure_space(&wfs->buffer, size);
- cch_handle_read(wfs->handle, aki_buffer_get_ptr(&wfs->buffer, 0), size);
+ nn_buffer_ensure_space(&wfs->buffer, size);
+ cch_handle_read(wfs->handle, nn_buffer_get_ptr(&wfs->buffer, 0), size);
wfs->buffer.size = size;
wuffs_png__decoder wf_dec = { 0 };
@@ -38,7 +38,7 @@ static bool wuffs_demuxer_init(struct camu_demuxer *demux, struct cch_handle *ha
wuffs_png__decoder__set_quirk(&wf_dec, WUFFS_BASE__QUIRK_IGNORE_CHECKSUM, true);
wuffs_base__io_buffer src = { 0 };
- src.data.ptr = aki_buffer_get_ptr(&wfs->buffer, 0);
+ src.data.ptr = nn_buffer_get_ptr(&wfs->buffer, 0);
src.data.len = wfs->buffer.size;
src.meta.wi = wfs->buffer.size;
src.meta.closed = true;
@@ -90,7 +90,7 @@ static bool wuffs_demuxer_seek(struct camu_demuxer *demux, u64 pos)
static void wuffs_demuxer_free(struct camu_demuxer **demux)
{
struct camu_wuffs_demuxer *wfs = (struct camu_wuffs_demuxer *)*demux;
- aki_buffer_free(&wfs->buffer);
+ nn_buffer_free(&wfs->buffer);
al_array_free(wfs->demux.streams);
al_free(wfs);
*demux = NULL;
@@ -127,7 +127,7 @@ static s32 wuffs_decoder_push(struct camu_decoder *dec, struct camu_codec_packet
wuffs_png__decoder__set_quirk(&wf_dec, WUFFS_BASE__QUIRK_IGNORE_CHECKSUM, true);
wuffs_base__io_buffer src = { 0 };
- src.data.ptr = aki_buffer_get_ptr(packet->buffer, 0);
+ src.data.ptr = nn_buffer_get_ptr(packet->buffer, 0);
src.data.len = packet->buffer->size;
src.meta.wi = packet->buffer->size;
src.meta.closed = true;