38 #define DST_MAX_CHANNELS 6
39 #define DST_MAX_ELEMENTS (2 * DST_MAX_CHANNELS)
41 #define DSD_FS44(sample_rate) (sample_rate * 8LL / 44100)
43 #define DST_SAMPLES_PER_FRAME(sample_rate) (588 * DSD_FS44(sample_rate))
102 memset(
s->dsdctx[
i].buf, 0x69,
sizeof(
s->dsdctx[
i].buf));
141 int coeff_bits,
int is_signed,
int offset)
151 int length_bits,
int coeff_bits,
int is_signed,
int offset)
153 unsigned int i, j, k;
159 int method =
get_bits(gb, 2), lsb_size;
166 for (j = method + 1; j < t->
length[
i]; j++) {
168 for (k = 0; k < method + 1; k++)
169 x += code_pred_coeff[method][k] * (
unsigned)t->
coeff[
i][j - k - 1];
176 if (c < offset || c >=
offset + (1<<coeff_bits))
194 unsigned int k = (ac->
a >> 8) | ((ac->
a >> 7) & 1);
195 unsigned int q = k * p;
196 unsigned int a_q = ac->
a - q;
225 for (j = 0; j < 16; j++) {
226 int total =
av_clip(length - j * 8, 0, 8);
228 for (k = 0; k < 256; k++) {
231 for (l = 0; l < total; l++)
232 v += (((k >> l) & 1) * 2 - 1) * fsets->
coeff[
i][j * 8 + l];
240 int *got_frame_ptr,
AVPacket *avpkt)
245 unsigned i, ch, same_map, dst_x_bit;
256 if (avpkt->
size <= 1)
301 s->probs.elements =
s->fsets.elements;
302 memcpy(map_ch_to_pelem, map_ch_to_felem,
sizeof(map_ch_to_felem));
334 memset(
s->status, 0xAA,
sizeof(
s->status));
339 for (
i = 0;
i < samples_per_frame;
i++) {
341 const unsigned felem = map_ch_to_felem[ch];
342 int16_t (*
filter)[256] =
s->filter[felem];
344 int prob, residual, v;
346 #define F(x) filter[(x)][status[(x)]]
347 const int16_t
predict =
F( 0) +
F( 1) +
F( 2) +
F( 3) +
348 F( 4) +
F( 5) +
F( 6) +
F( 7) +
349 F( 8) +
F( 9) +
F(10) +
F(11) +
350 F(12) +
F(13) +
F(14) +
F(15);
353 if (!half_prob[ch] ||
i >=
s->fsets.length[felem]) {
354 unsigned pelem = map_ch_to_pelem[ch];
362 v = ((
predict >> 15) ^ residual) & 1;
363 dsd[((
i >> 3) *
channels + ch) << 2] |= v << (7 - (
i & 0x7 ));
static enum AVSampleFormat sample_fmts[]
simple assert() macros that are a bit more flexible than ISO C assert().
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
#define prob(name, subs,...)
static av_always_inline void filter(int16_t *output, ptrdiff_t out_stride, const int16_t *low, ptrdiff_t low_stride, const int16_t *high, ptrdiff_t high_stride, int len, int clip)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
av_cold void ff_init_dsd_data(void)
void ff_dsd2pcm_translate(DSDContext *s, size_t samples, int lsbf, const uint8_t *src, ptrdiff_t src_stride, float *dst, ptrdiff_t dst_stride)
static void ac_init(ArithCoder *ac, GetBitContext *gb)
static av_always_inline void ac_get(ArithCoder *ac, GetBitContext *gb, int p, int *e)
static uint8_t prob_dst_x_bit(int c)
static void build_filter(int16_t table[DST_MAX_ELEMENTS][16][256], const Table *fsets)
static const int8_t fsets_code_pred_coeff[3][3]
static av_cold int decode_init(AVCodecContext *avctx)
static void read_uncoded_coeff(GetBitContext *gb, int *dst, unsigned int elements, int coeff_bits, int is_signed, int offset)
static av_always_inline int get_sr_golomb_dst(GetBitContext *gb, unsigned int k)
static int read_table(GetBitContext *gb, Table *t, const int8_t code_pred_coeff[3][3], int length_bits, int coeff_bits, int is_signed, int offset)
static const int8_t probs_code_pred_coeff[3][3]
#define DST_SAMPLES_PER_FRAME(sample_rate)
static int read_map(GetBitContext *gb, Table *t, unsigned int map[DST_MAX_CHANNELS], int channels)
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
bitstream reader API header.
static int get_sbits(GetBitContext *s, int n)
static int get_bits_left(GetBitContext *gb)
static unsigned int get_bits1(GetBitContext *s)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static void skip_bits1(GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int esc_len)
read unsigned golomb rice code (jpegls).
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
AVSampleFormat
Audio sample formats.
const VDPAUPixFmtMap * map
static av_always_inline void predict(PredictorState *ps, float *coef, int output_enable)
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
const uint8_t ff_reverse[256]
static const uint16_t table[]
static const ElemCat * elements[ELEMENT_COUNT]
Describe the class of an AVClass context structure.
main external API structure.
enum AVSampleFormat sample_fmt
audio sample format
int sample_rate
samples per second
int channels
number of audio channels
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
This structure stores compressed data.
uint8_t status[DST_MAX_CHANNELS][16]
int16_t filter[DST_MAX_ELEMENTS][16][256]
DSDContext dsdctx[DST_MAX_CHANNELS]
int coeff[DST_MAX_ELEMENTS][128]
unsigned int length[DST_MAX_ELEMENTS]
#define avpriv_request_sample(...)
static const uint8_t offset[127][2]