28#define BITSTREAM_READER_LE
40#if CONFIG_SWRESAMPLE && FF_API_DSD_PCM
49#define DSD_BYTE_READY(low,high) (!(((low) ^ (high)) & 0xff000000))
52#define PTABLE_BINS (1<<PTABLE_BITS)
53#define PTABLE_MASK (PTABLE_BINS-1)
56#define DOWN 0x00010000
60#define VALUE_ONE (1 << PRECISION)
61#define PRECISION_USE 12
65#define MAX_HISTORY_BITS 5
66#define MAX_HISTORY_BINS (1 << MAX_HISTORY_BITS)
67#define MAX_BIN_BYTES 1280
118#if CONFIG_SWRESAMPLE && FF_API_DSD_PCM
119 struct WvDSDSwr *dsd_swr;
120 uint8_t *dsd_scratch;
121 unsigned dsd_scratch_size;
128#if CONFIG_SWRESAMPLE && FF_API_DSD_PCM
129typedef struct WvDSDSwr {
132#define WV_DSD_SWR(wc) ((wc)->dsd_swr)
134#define WV_DSD_SWR(wc) (NULL)
137#define LEVEL_DECAY(a) (((a) + 0x80) >> 8)
146 e = (1LL << (p + 1)) - k - 1;
157 for (
i = 0;
i <=
ctx->stereo_in;
i++) {
158 if (
ctx->ch[
i].bitrate_acc > UINT_MAX -
ctx->ch[
i].bitrate_delta)
160 ctx->ch[
i].bitrate_acc +=
ctx->ch[
i].bitrate_delta;
161 br[
i] =
ctx->ch[
i].bitrate_acc >> 16;
164 if (
ctx->stereo_in &&
ctx->hybrid_bitrate) {
165 int balance = (sl[1] - sl[0] + br[1] + 1) >> 1;
166 if (balance > br[0]) {
169 }
else if (-balance > br[0]) {
173 br[1] = br[0] + balance;
174 br[0] = br[0] - balance;
177 for (
i = 0;
i <=
ctx->stereo_in;
i++) {
178 if (
ctx->hybrid_bitrate) {
179 if (sl[
i] - br[
i] > -0x100)
182 ctx->ch[
i].error_limit = 0;
195 int sign,
base, add, ret;
200 if ((
ctx->ch[0].median[0] < 2U) && (
ctx->ch[1].median[0] < 2U) &&
201 !
ctx->zero && !
ctx->one) {
220 memset(
ctx->ch[0].median, 0,
sizeof(
ctx->ch[0].median));
221 memset(
ctx->ch[1].median, 0,
sizeof(
ctx->ch[1].median));
285 if (!
c->error_limit) {
290 int mid = (
base * 2U + add + 1) >> 1;
291 while (add >
c->error_limit) {
295 add -= (mid - (unsigned)
base);
298 add = mid - (unsigned)
base - 1;
299 mid = (
base * 2U + add + 1) >> 1;
304 if (
ctx->hybrid_bitrate)
306 return sign ? ~ret : ret;
323 S *= 1 <<
s->extra_bits;
325 if (
s->got_extra_bits &&
328 *crc = *crc * 9 + (
S & 0xffff) * 3 + ((
unsigned)
S >> 16);
332 bit = (
S &
s->and) |
s->or;
338 return bit <<
s->post_shift;
349 int exp =
s->float_max_exp;
351 if (
s->got_extra_bits) {
352 const int max_bits = 1 + 23 + 8 + 1;
360 S *= 1U <<
s->float_shift;
364 if (
S >= 0x1000000U) {
365 if (
s->got_extra_bits &&
get_bits1(&
s->gb_extra_bits))
372 exp =
s->float_max_exp;
380 (
s->got_extra_bits &&
384 }
else if (
s->got_extra_bits &&
390 exp =
s->float_max_exp;
399 if (
s->float_max_exp >= 25)
409 *crc = *crc * 27 +
S * 9 +
exp * 3 + sign;
411 value.u = (sign << 31) | (
exp << 23) |
S;
416 uint32_t crc_extra_bits)
422 if (
s->got_extra_bits && crc_extra_bits !=
s->crc_extra_bits) {
432 int value = 0x808000, rate = rate_i << 8;
434 for (
int c = (rate + 128) >> 8;
c--;)
441 if (
value > 0x010000) {
442 rate += (rate * rate_s + 128) >> 8;
444 for (
int c = (rate + 64) >> 7;
c--;)
457 for (
int i = 0;
i < samples;
i++)
464 uint32_t checksum = 0xFFFFFFFF;
465 uint8_t *dst_l = dst_left, *dst_r = dst_right;
466 int total_samples =
s->samples, stereo = dst_r ? 1 : 0;
474 rate_i = bytestream2_get_byte(&
s->gbyte);
475 rate_s = bytestream2_get_byte(&
s->gbyte);
491 sp->
factor = bytestream2_get_byte(&
s->gbyte) & 0xff;
492 sp->
factor |= (bytestream2_get_byte(&
s->gbyte) << 8) & 0xff00;
496 value = bytestream2_get_be32(&
s->gbyte);
500 while (total_samples--) {
510 uint32_t
split = low + ((
high - low) >> 8) * (*pp >> 16);
525 value = (
value << 8) | bytestream2_get_byte(&
s->gbyte);
531 sp[0].
byte = (sp[0].
byte << 1) | (sp[0].fltr0 & 1);
533 ((sp[0].
value ^ (sp[0].
value - (sp[0].fltr6 * 16))) >> 31);
547 split = low + ((
high - low) >> 8) * (*pp >> 16);
562 value = (
value << 8) | bytestream2_get_byte(&
s->gbyte);
568 sp[1].
byte = (sp[1].
byte << 1) | (sp[1].fltr0 & 1);
570 ((sp[1].
value ^ (sp[1].
value - (sp[1].fltr6 * 16))) >> 31);
581 checksum += (checksum << 1) + (*dst_l = sp[0].
byte & 0xff);
586 checksum += (checksum << 1) + (*dst_r =
filters[1].
byte & 0xff);
608 uint8_t *dst_l = dst_left, *dst_r = dst_right;
609 uint8_t history_bits, max_probability;
610 int total_summed_probabilities = 0;
611 int total_samples =
s->samples;
612 uint8_t *vlb =
s->value_lookup_buffer;
613 int history_bins, p0, p1, chan;
614 uint32_t checksum = 0xFFFFFFFF;
620 history_bits = bytestream2_get_byte(&
s->gbyte);
625 history_bins = 1 << history_bits;
626 max_probability = bytestream2_get_byte(&
s->gbyte);
628 if (max_probability < 0xff) {
629 uint8_t *outptr = (uint8_t *)
s->probabilities;
630 uint8_t *outend = outptr +
sizeof(*
s->probabilities) * history_bins;
633 int code = bytestream2_get_byte(&
s->gbyte);
635 if (
code > max_probability) {
636 int zcount =
code - max_probability;
638 while (outptr < outend && zcount--)
648 if (outptr < outend ||
653 sizeof(*
s->probabilities) * history_bins);
658 for (p0 = 0; p0 < history_bins; p0++) {
661 for (
int i = 0;
i < 256;
i++)
662 s->summed_probabilities[p0][
i] = sum_values +=
s->probabilities[p0][
i];
665 total_summed_probabilities += sum_values;
667 if (total_summed_probabilities > history_bins *
MAX_BIN_BYTES)
670 s->value_lookup[p0] = vlb;
672 for (
int i = 0;
i < 256;
i++) {
673 int c =
s->probabilities[p0][
i];
685 low = 0;
high = 0xffffffff;
686 value = bytestream2_get_be32(&
s->gbyte);
691 while (total_samples--) {
694 if (!
s->summed_probabilities[p0][255])
697 mult = (
high - low) /
s->summed_probabilities[p0][255];
701 value = bytestream2_get_be32(&
s->gbyte);
705 mult =
high /
s->summed_probabilities[p0][255];
713 if (
index >=
s->summed_probabilities[p0][255])
717 if ((*dst_l =
code =
s->value_lookup[p0][
index]))
718 low +=
s->summed_probabilities[p0][
code-1] *
mult;
723 low +=
s->summed_probabilities[p0][
code-1] *
mult;
738 checksum += (checksum << 1) +
code;
741 p0 =
code & (history_bins-1);
744 p1 =
code & (history_bins-1);
748 value = (
value << 8) | bytestream2_get_byte(&
s->gbyte);
770 uint8_t *dst_l = dst_left, *dst_r = dst_right;
771 int total_samples =
s->samples;
772 uint32_t checksum = 0xFFFFFFFF;
777 while (total_samples--) {
778 checksum += (checksum << 1) + (*dst_l = bytestream2_get_byte(&
s->gbyte));
782 checksum += (checksum << 1) + (*dst_r = bytestream2_get_byte(&
s->gbyte));
801 void *dst_l,
void *dst_r,
const int type)
807 uint32_t crc = 0xFFFFFFFF;
808 uint32_t crc_extra_bits = 0xFFFFFFFF;
809 int16_t *dst16_l = dst_l;
810 int16_t *dst16_r = dst_r;
813 float *dstfl_l = dst_l;
814 float *dstfl_r = dst_r;
816 s->one =
s->zero =
s->zeroes = 0;
824 for (
i = 0;
i <
s->terms;
i++) {
849 L2 =
L + (unsigned)((
int)(decorr->
weightA * (
unsigned)
A + 512) >> 10);
850 R2 =
R + (unsigned)((
int)(decorr->
weightB * (
unsigned)
B + 512) >> 10);
858 }
else if (t == -1) {
862 L2 =
L + (unsigned)((
int)(decorr->
weightA * (
unsigned)decorr->
samplesA[0] + 512) >> 10);
868 R2 =
R + (unsigned)((
int)(decorr->
weightB * (
unsigned)L2 + 512) >> 10);
876 R2 =
R + (unsigned)((
int)(decorr->
weightB * (
unsigned)decorr->
samplesB[0] + 512) >> 10);
888 L2 =
L + (unsigned)((
int)(decorr->
weightA * (
unsigned)
R2 + 512) >> 10);
904 L += (unsigned)(
R -= (
unsigned)(
L >> 1));
905 crc = (crc * 3 +
L) * 3 +
R;
918 }
while (!last && count < s->samples);
920 if (last && count < s->samples) {
922 memset((uint8_t*)dst_l + count*
size, 0, (
s->samples-count)*
size);
923 memset((uint8_t*)dst_r + count*
size, 0, (
s->samples-count)*
size);
940 uint32_t crc = 0xFFFFFFFF;
941 uint32_t crc_extra_bits = 0xFFFFFFFF;
942 int16_t *dst16 =
dst;
946 s->one =
s->zero =
s->zeroes = 0;
952 for (
i = 0;
i <
s->terms;
i++) {
970 S =
T + (unsigned)((
int)(decorr->
weightA * (
unsigned)
A + 512) >> 10);
986 }
while (!last && count < s->samples);
988 if (last && count < s->samples) {
990 memset((uint8_t*)
dst + count*
size, 0, (
s->samples-count)*
size);
1011 if (!
c->fdec[
c->fdec_num])
1014 c->fdec[
c->fdec_num - 1]->avctx =
c->avctx;
1019#if CONFIG_SWRESAMPLE && FF_API_DSD_PCM
1032 s->dsd_channels = 0;
1033#if CONFIG_SWRESAMPLE && FF_API_DSD_PCM
1042#if CONFIG_SWRESAMPLE && FF_API_DSD_PCM
1069#if CONFIG_SWRESAMPLE && FF_API_DSD_PCM
1105#if CONFIG_SWRESAMPLE && FF_API_DSD_PCM
1113 progress_pool_init_cb,
1114 progress_pool_reset_cb,
1115 progress_pool_free_entry_cb,
NULL);
1116 if (!
s->progress_pool)
1128 for (
int i = 0;
i <
s->fdec_num;
i++)
1135#if CONFIG_SWRESAMPLE && FF_API_DSD_PCM
1143 const uint8_t *buf,
int buf_size,
int *new_progress)
1149 void *samples_l =
NULL, *samples_r =
NULL;
1152 int got_terms = 0, got_weights = 0, got_samples = 0,
1153 got_entropy = 0, got_pcm = 0, got_float = 0, got_hybrid = 0;
1156 int bpp, chan = 0, orig_bpp, sample_rate = 0, rate_x = 1, dsd_mode = 0;
1158 uint64_t chmask = 0;
1165 s = wc->
fdec[block_no];
1168 memset(
s->ch, 0,
sizeof(
s->ch));
1170 s->and =
s->or =
s->shift = 0;
1171 s->got_extra_bits = 0;
1175 s->samples = bytestream2_get_le32(&gb);
1178 "a sequence: %d and %d\n", wc->
samples,
s->samples);
1181 s->frame_flags = bytestream2_get_le32(&gb);
1187 else if ((
s->frame_flags & 0x03) <= 1)
1196 orig_bpp = ((
s->frame_flags & 0x03) + 1) << 3;
1199 s->stereo = !(
s->frame_flags &
WV_MONO);
1204 s->post_shift = bpp * 8 - orig_bpp + ((
s->frame_flags >> 13) & 0x1f);
1205 if (
s->post_shift < 0 ||
s->post_shift > 31) {
1208 s->hybrid_maxclip = ((1LL << (orig_bpp - 1)) - 1);
1209 s->hybrid_minclip = ((-1UL << (orig_bpp - 1)));
1210 s->CRC = bytestream2_get_le32(&gb);
1214 id = bytestream2_get_byte(&gb);
1215 size = bytestream2_get_byte(&gb);
1217 size |= (bytestream2_get_le16u(&gb)) << 8;
1224 "Got incorrect block %02X with size %i\n",
id,
size);
1229 "Block size %i is out of bounds\n",
size);
1241 for (
i = 0;
i <
s->terms;
i++) {
1242 uint8_t
val = bytestream2_get_byte(&gb);
1243 s->decorr[
s->terms -
i - 1].value = (
val & 0x1F) - 5;
1244 s->decorr[
s->terms -
i - 1].delta =
val >> 5;
1260 t = (int8_t)bytestream2_get_byte(&gb);
1261 s->decorr[
s->terms -
i - 1].weightA = t * (1 << 3);
1262 if (
s->decorr[
s->terms -
i - 1].weightA > 0)
1263 s->decorr[
s->terms -
i - 1].weightA +=
1264 (
s->decorr[
s->terms -
i - 1].weightA + 64) >> 7;
1266 t = (int8_t)bytestream2_get_byte(&gb);
1267 s->decorr[
s->terms -
i - 1].weightB = t * (1 << 3);
1268 if (
s->decorr[
s->terms -
i - 1].weightB > 0)
1269 s->decorr[
s->terms -
i - 1].weightB +=
1270 (
s->decorr[
s->terms -
i - 1].weightB + 64) >> 7;
1281 for (
i =
s->terms - 1; (
i >= 0) && (t <
size);
i--) {
1284 if (decorr->
value > 8) {
1286 wp_exp2(bytestream2_get_le16(&gb));
1288 wp_exp2(bytestream2_get_le16(&gb));
1292 wp_exp2(bytestream2_get_le16(&gb));
1294 wp_exp2(bytestream2_get_le16(&gb));
1298 }
else if (decorr->
value < 0) {
1300 wp_exp2(bytestream2_get_le16(&gb));
1302 wp_exp2(bytestream2_get_le16(&gb));
1305 for (j = 0; j < decorr->
value; j++) {
1307 wp_exp2(bytestream2_get_le16(&gb));
1310 wp_exp2(bytestream2_get_le16(&gb));
1313 t += decorr->
value * 2 * (
s->stereo_in + 1);
1319 if (
size != 6 * (
s->stereo_in + 1)) {
1321 "Entropy vars size should be %i, got %i.\n",
1322 6 * (
s->stereo_in + 1),
size);
1326 for (j = 0; j <=
s->stereo_in; j++)
1327 for (
i = 0;
i < 3;
i++) {
1328 s->ch[j].median[
i] =
wp_exp2(bytestream2_get_le16(&gb));
1333 if (
s->hybrid_bitrate) {
1334 for (
i = 0;
i <=
s->stereo_in;
i++) {
1335 s->ch[
i].slow_level =
wp_exp2(bytestream2_get_le16(&gb));
1339 for (
i = 0;
i < (
s->stereo_in + 1);
i++) {
1340 s->ch[
i].bitrate_acc = bytestream2_get_le16(&gb) << 16;
1344 for (
i = 0;
i < (
s->stereo_in + 1);
i++) {
1345 s->ch[
i].bitrate_delta =
1346 wp_exp2((int16_t)bytestream2_get_le16(&gb));
1349 for (
i = 0;
i < (
s->stereo_in + 1);
i++)
1350 s->ch[
i].bitrate_delta = 0;
1358 "Invalid INT32INFO, size = %i\n",
1366 "Invalid INT32INFO, extra_bits = %d (> 30)\n",
val[0]);
1369 s->extra_bits =
val[0];
1381 if (
s->shift > 31) {
1383 "Invalid INT32INFO, shift = %d (> 31)\n",
s->shift);
1384 s->and =
s->or =
s->shift = 0;
1389 if (
s->hybrid && bpp == 4 &&
s->post_shift < 8 &&
s->shift > 8) {
1392 s->hybrid_maxclip >>= 8;
1393 s->hybrid_minclip >>= 8;
1400 "Invalid FLOATINFO, size = %i\n",
size);
1404 s->float_flag = bytestream2_get_byte(&gb);
1405 s->float_shift = bytestream2_get_byte(&gb);
1406 s->float_max_exp = bytestream2_get_byte(&gb);
1407 if (
s->float_shift > 31) {
1409 "Invalid FLOATINFO, shift = %d (> 31)\n",
s->float_shift);
1429 rate_x = bytestream2_get_byte(&gb);
1432 rate_x = 1 << rate_x;
1433 dsd_mode = bytestream2_get_byte(&gb);
1434 if (dsd_mode && dsd_mode != 1 && dsd_mode != 3) {
1454 s->got_extra_bits = 1;
1459 "Insufficient channel information\n");
1462 chan = bytestream2_get_byte(&gb);
1465 chmask = bytestream2_get_byte(&gb);
1468 chmask = bytestream2_get_le16(&gb);
1471 chmask = bytestream2_get_le24(&gb);
1474 chmask = bytestream2_get_le32(&gb);
1477 bytestream2_get_byte(&gb);
1478 chan |= (bytestream2_get_byte(&gb) & 0xF) << 8;
1480 chmask = bytestream2_get_le24(&gb);
1483 bytestream2_get_byte(&gb);
1484 chan |= (bytestream2_get_byte(&gb) & 0xF) << 8;
1486 chmask = bytestream2_get_le32(&gb);
1499 sample_rate = bytestream2_get_le24(&gb);
1525 if (
s->hybrid && !got_hybrid) {
1535 const int wanted =
s->samples *
s->extra_bits <<
s->stereo_in;
1536 if (
size < wanted) {
1538 s->got_extra_bits = 0;
1543 if (!got_pcm && !got_dsd) {
1557 int sr = (
s->frame_flags >> 23) & 0xf;
1563 new_samplerate = sample_rate;
1567 if (new_samplerate * (uint64_t)rate_x > INT_MAX)
1569 new_samplerate *= rate_x;
1586#if CONFIG_SWRESAMPLE && FF_API_DSD_PCM
1588 int reset_dsd = !wc->
dsd_raw &&
1589 ((wc->dsd_swr && !got_dsd) ||
1599#if CONFIG_SWRESAMPLE && FF_API_DSD_PCM
1610 frame->nb_samples =
s->samples;
1638#if CONFIG_SWRESAMPLE && FF_API_DSD_PCM
1642 if (!wc->dsd_scratch)
1644 samples_l = wc->dsd_scratch + wc->
ch_offset;
1649 samples_r = (uint8_t *)samples_l + 1;
1660 if (dsd_mode == 3) {
1662 }
else if (dsd_mode == 1) {
1674 if (dsd_mode == 3) {
1676 }
else if (dsd_mode == 1) {
1689 for (
int i = 0;
i <
s->samples;
i++)
1690 ((uint8_t *)samples_r)[
i *
stride] =
1691 ((
const uint8_t *)samples_l)[
i *
stride];
1693 memcpy(samples_r, samples_l, bpp *
s->samples);
1706 int *got_frame_ptr,
AVPacket *avpkt)
1709 const uint8_t *buf = avpkt->
data;
1710 int buf_size = avpkt->
size;
1712 int block = 0, new_progress = 0;
1723 frame_flags =
AV_RL32(buf + 24);
1738 "Block %d has invalid size (size %d vs. %d bytes left)\n",
1758#if CONFIG_SWRESAMPLE && FF_API_DSD_PCM
1760 if (
s->prev_progress)
1763 (
const uint8_t *
const []){ s->dsd_scratch },
1765 if (
s->curr_progress)
1767 if (ret !=
s->samples)
1778 if (
s->prev_progress)
1787 .p.name =
"wavpack",
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static double val(void *priv, double ch)
static char * split(char *message, char delim)
#define filters(fmt, type, inverse, clp, inverset, clip, one, clip_fn, packed)
const FFCodec ff_wavpack_decoder
static AVFormatContext * ctx
static av_cold void close(AVCodecParserContext *s)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Libavcodec external API header.
#define FF_THREAD_FRAME
Decode more than one frame at once.
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
static av_always_inline int bytestream2_get_bytes_left(const GetByteContext *g)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define i(width, name, range_min, range_max)
#define bit(string, value)
Public libavutil channel layout APIs header.
#define UPDATE_THREAD_CONTEXT(func)
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
enum ThreadingStatus ff_thread_sync_ref(AVCodecContext *avctx, size_t offset)
Allows to synchronize objects whose lifetime is the whole decoding process among all frame threads.
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data,...
#define AV_EF_EXPLODE
abort decoding on minor error detection
int ff_dsd_to_pcm_init(struct AVCodecContext *avctx, struct SwrContext **swrp)
(Re)create a libswresample context converting AV_SAMPLE_FMT_DSD to avctx->sample_fmt at the same samp...
int(* init)(AVBSFContext *ctx)
channel
Use these values when setting the channel map with ebur128_set_channel().
static const uint8_t frame_size[4]
bitstream reader API header.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
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 unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_FLTP
float, planar
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
@ AV_SAMPLE_FMT_DSD
DSD (Direct Stream Digital) bitstream, interleaved.
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
av_cold void swr_free(SwrContext **ss)
Free the given SwrContext and set the pointer to NULL.
int attribute_align_arg swr_convert(struct SwrContext *s, uint8_t *const *out_arg, int out_count, const uint8_t *const *in_arg, int in_count)
Convert audio.
static const int weights[]
static int shift(int a, int b)
#define u(width, name, range_min, range_max)
static int16_t mult(Float11 *f1, Float11 *f2)
Multithreading API for decoders.
@ FF_THREAD_IS_FIRST_THREAD
#define FFSWAP(type, a, b)
Memory handling functions.
static const uint16_t table[]
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
void av_refstruct_replace(void *dstp, const void *src)
Ensure *dstp refers to the same object as src.
void * av_refstruct_pool_get(AVRefStructPool *pool)
Get an object from the pool, reusing an old one from the pool when available.
#define AV_REFSTRUCT_POOL_FLAG_FREE_ON_INIT_ERROR
If this flag is set and both init_cb and free_entry_cb callbacks are provided, then free_cb will be c...
static void av_refstruct_pool_uninit(AVRefStructPool **poolp)
Mark the pool as being available for freeing.
static void * av_refstruct_alloc_ext(size_t size, unsigned flags, void *opaque, void(*free_cb)(AVRefStructOpaque opaque, void *obj))
A wrapper around av_refstruct_alloc_ext_c() for the common case of a non-const qualified opaque.
static AVRefStructPool * av_refstruct_pool_alloc_ext(size_t size, unsigned flags, void *opaque, int(*init_cb)(AVRefStructOpaque opaque, void *obj), void(*reset_cb)(AVRefStructOpaque opaque, void *obj), void(*free_entry_cb)(AVRefStructOpaque opaque, void *obj), void(*free_cb)(AVRefStructOpaque opaque))
A wrapper around av_refstruct_pool_alloc_ext_c() for the common case of a non-const qualified opaque.
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
int active_thread_type
Which multithreading methods are in use by the codec.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
enum AVSampleFormat request_sample_fmt
desired sample format
int sample_rate
samples per second
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
AVRefStructPool is an API for a thread-safe pool of objects managed via the RefStruct API.
The libswresample context.
ThreadProgress is an API to easily notify other threads about progress of any kind as long as it can ...
ThreadProgress * prev_progress
RefStruct references.
WavpackFrameContext ** fdec
AVRefStructPool * progress_pool
RefStruct reference.
int dsd_raw
output the raw DSD bitstream instead of PCM
ThreadProgress * curr_progress
uint16_t summed_probabilities[MAX_HISTORY_BINS][256]
uint8_t value_lookup_buffer[MAX_HISTORY_BINS *MAX_BIN_BYTES]
GetBitContext gb_extra_bits
uint8_t probabilities[MAX_HISTORY_BINS][256]
uint8_t * value_lookup[MAX_HISTORY_BINS]
libswresample public header
static void error(const char *err)
av_cold void ff_thread_progress_destroy(ThreadProgress *pro)
Destroy a ThreadProgress.
av_cold int ff_thread_progress_init(ThreadProgress *pro, int init_mode)
Initialize a ThreadProgress.
void ff_thread_progress_report(ThreadProgress *pro, int n)
This function is a no-op in no-op mode; otherwise it notifies other threads that a certain level of p...
void ff_thread_progress_await(const ThreadProgress *pro_c, int n)
This function is a no-op in no-op mode; otherwise it waits until other threads have reached a certain...
static void ff_thread_progress_reset(ThreadProgress *pro)
Reset the ThreadProgress.progress counter; must only be called if the ThreadProgress is not in use in...
static int get_unary_0_33(GetBitContext *gb)
Get unary code terminated by a 0 with a maximum length of 33.
RefStruct is an API for creating reference-counted objects with minimal overhead.
static int wv_dsd_reset(AVCodecContext *avctx, int channels)
static float wv_get_value_float(WavpackFrameContext *s, uint32_t *crc, int S)
static av_cold int wavpack_decode_end(AVCodecContext *avctx)
static int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, void *dst, const int type)
static av_always_inline unsigned get_tail(GetBitContext *gb, unsigned k)
static int update_error_limit(WavpackFrameContext *ctx)
static int wavpack_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
static int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, void *dst_l, void *dst_r, const int type)
static int wv_get_value(WavpackFrameContext *ctx, GetBitContext *gb, int channel, int *last)
static int wv_get_value_integer(WavpackFrameContext *s, uint32_t *crc, unsigned S)
static int wv_unpack_dsd_fast(WavpackFrameContext *s, uint8_t *dst_left, uint8_t *dst_right, ptrdiff_t stride)
#define DSD_BYTE_READY(low, high)
static av_cold int wv_alloc_frame_context(WavpackContext *c)
static void wv_dsd_silence(uint8_t *dst, int samples, ptrdiff_t stride)
static void init_ptable(int *table, int rate_i, int rate_s)
static int wavpack_decode_block(AVCodecContext *avctx, AVFrame *frame, int block_no, const uint8_t *buf, int buf_size, int *new_progress)
static int wv_unpack_dsd_copy(WavpackFrameContext *s, uint8_t *dst_left, uint8_t *dst_right, ptrdiff_t stride)
static int wv_unpack_dsd_high(WavpackFrameContext *s, uint8_t *dst_left, uint8_t *dst_right, ptrdiff_t stride)
static av_cold void wavpack_decode_flush(AVCodecContext *avctx)
static av_cold int wavpack_decode_init(AVCodecContext *avctx)
static int wv_check_crc(WavpackFrameContext *s, uint32_t crc, uint32_t crc_extra_bits)
#define WV_FLT_SHIFT_SENT
static av_always_inline int wp_exp2(int16_t val)
#define WV_FLT_SHIFT_SAME
#define WV_HYBRID_BITRATE
#define WV_FLT_SHIFT_ONES
static const int wv_rates[16]
static av_always_inline int wp_log2(uint32_t val)
#define UPDATE_WEIGHT_CLIP(weight, delta, samples, in)