summaryrefslogtreecommitdiff
path: root/src/fmt/nut.h
blob: fd6b96d2c29e878e16fb57a16413d5ebfc4a57f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef ANIMTOOL_NUT_H_
#define ANIMTOOL_NUT_H_

#include <stdio.h>
#include "util/str.h"
#include "util/container.h"

enum nut_output_type : uint8_t {
    NUT_OUT_FILE,
    NUT_OUT_STATIC,
    NUT_OUT_HEAP,
};

struct nut_output
{
    enum nut_output_type type;
    size_t len;
    union {
        FILE *file;
        struct {
            size_t cap;
            char *ptr;
        };
    };
};

struct nut_syncp_off
{
    size_t off;
    size_t num;
};

struct nut_writer
{
    struct nut_output out;
    size_t frame_size;
    size_t last_syncpoint;
    size_t n_frame;
    arraybuf(struct nut_syncp_off) syncp_offs;
};

void nut_write_start(struct nut_writer *wr, FILE *f, unsigned int fps, unsigned int size[2]);
void nut_write_frame(struct nut_writer *wr, void *data);
void nut_write_end(struct nut_writer *wr);

#endif