// B54: the only C surface Reelhouse's Swift code sees. FFmpeg's own structs never cross it.
// LGPL-2.1-or-later, like the FFmpeg code it is linked with inside Libav.framework.
#ifndef LIBAV_SHIM_H
#define LIBAV_SHIM_H
#include <stdint.h>

typedef struct ls_decoder ls_decoder;
enum { LS_CODEC_TRUEHD = 1, LS_CODEC_DTS = 2 };
enum { LS_OK = 0, LS_ERR_ALLOC = -1, LS_ERR_OPEN = -2, LS_ERR_DECODE = -3,
       LS_ERR_CAPACITY = -4, LS_ERR_FORMAT = -5,
       LS_ERR_ARG = -6 };

ls_decoder *ls_open(int codec, int sample_rate, int channels);
// `out` must hold out_capacity_frames * 8 int32 samples: frames wider than 8 channels are
// rejected with LS_ERR_FORMAT before anything is written.
int ls_decode(ls_decoder *d, const uint8_t *data, int size,
              int32_t *out, int out_capacity_frames,
              int *out_frames, int *out_channels, uint64_t *out_layout_mask, int *out_bits);
void ls_reset(ls_decoder *d);
void ls_close(ls_decoder *d);
const char *ls_version(void);
#endif
