38#define BITSTREAM_READER_LE
47#define FORMAT_SIMPLE 1
48#define FORMAT_ENCRYPTED 2
82 crc =
av_crc(
s->crc_table, 0xFFFFFFFFU, buf, buf_size);
83 if (CRC != (crc ^ 0xFFFFFFFFU)) {
93 uint64_t crc = UINT64_MAX, poly = 0x42F0E1EBA9EA3693U;
94 uint8_t *end = pass + strlen(pass);
98 crc ^= (uint64_t)*pass++ << 56;
99 for (
i = 0;
i < 8;
i++)
100 crc = (crc << 1) ^ (poly & (((
int64_t) crc) >> 63));
103 return crc ^ UINT64_MAX;
112 sizeof(*
s->decode_buffer) *
s->channels);
113 if (!
s->decode_buffer)
116 s->decode_buffer =
NULL;
153 av_log(avctx,
AV_LOG_ERROR,
"Missing password for encrypted stream. Please use the -password option\n");
162 if (
s->channels > 1 &&
s->channels < 9) {
176 if (
s->channels == 0 ||
s->channels > 16) {
205 s->last_frame_length =
s->data_length %
s->frame_length;
206 total_frames =
s->data_length /
s->frame_length +
207 (
s->last_frame_length ? 1 : 0);
213 s->data_length,
s->frame_length,
s->last_frame_length, total_frames);
215 if (
s->frame_length >= UINT_MAX / (
s->channels *
sizeof(
int32_t))) {
230 int *got_frame_ptr,
AVPacket *avpkt)
232 const uint8_t *buf = avpkt->
data;
233 int buf_size = avpkt->
size;
237 int cur_chan = 0, framelen =
s->frame_length;
250 frame->nb_samples = framelen;
259 for (
i = 0;
i <
s->channels;
i++) {
261 s->ch_ctx[
i].predictor = 0;
264 for (
int j = 0; j < 8; j++)
271 for (p =
s->decode_buffer; (
int32_t*)p < s->decode_buffer + (framelen *
s->channels); p++) {
274 TTARice *rice = &
s->ch_ctx[cur_chan].rice;
275 uint32_t unary, depth, k;
330#define PRED(x, k) (int32_t)((((uint64_t)(x) << (k)) - (x)) >> (k))
340 if (cur_chan < (
s->channels-1))
344 if (
s->channels > 1) {
346 for (*p += *
r / 2;
r > (
int32_t*)p -
s->channels;
r--)
347 *
r = *(
r + 1) - (
unsigned)*
r;
353 frame->nb_samples = framelen =
s->last_frame_length;
369 uint8_t *samples = (uint8_t *)
frame->data[0];
370 p =
s->decode_buffer;
371 for (
i = 0;
i < framelen *
s->channels;
i++)
372 samples[
i] = p[
i] + 0x80;
376 int16_t *samples = (int16_t *)
frame->data[0];
377 p =
s->decode_buffer;
378 for (
i = 0;
i < framelen *
s->channels;
i++)
386 for (
i = 0;
i < framelen *
s->channels;
i++)
387 samples[
i] = samples[
i] * 256U;
389 s->decode_buffer =
NULL;
400 s->decode_buffer =
NULL;
410 s->decode_buffer =
NULL;
416#define OFFSET(x) offsetof(TTAContext, x)
417#define DEC (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM)
424 .class_name =
"TTA Decoder",
const FFCodec ff_tta_decoder
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
#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...
Public header for CRC hash function implementation.
#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(* init)(AVBSFContext *ctx)
static void predictor(uint8_t *src, ptrdiff_t size)
bitstream reader API header.
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int get_bits_left(GetBitContext *gb)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static const uint8_t * align_get_bits(GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define AV_CH_LAYOUT_QUAD
#define AV_CH_LAYOUT_7POINT1_WIDE
#define AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_5POINT1_BACK
#define AV_CH_BACK_CENTER
#define AV_CH_LOW_FREQUENCY
#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.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
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.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
@ AV_SAMPLE_FMT_S32
signed 32 bits
@ AV_SAMPLE_FMT_U8
unsigned 8 bits
@ AV_SAMPLE_FMT_S16
signed 16 bits
#define LIBAVUTIL_VERSION_INT
Multithreading API for decoders.
static const AVClass tta_decoder_class
static uint64_t tta_check_crc64(uint8_t *pass)
static av_cold int tta_decode_close(AVCodecContext *avctx)
static int allocate_buffers(AVCodecContext *avctx)
static const int64_t tta_channel_layouts[7]
static int tta_check_crc(TTAContext *s, const uint8_t *buf, int buf_size)
static av_cold int tta_decode_init(AVCodecContext *avctx)
static int tta_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
av_cold void ff_ttadsp_init(TTADSPContext *c)
static av_const int sign_extend(int val, unsigned bits)
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
enum AVChannelOrder order
Channel order used in this layout.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
int sample_rate
samples per second
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
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.
#define av_malloc_array(a, b)
static void error(const char *err)
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
const uint32_t *const ff_tta_shift_16
const uint32_t ff_tta_shift_1[]
void ff_tta_rice_init(TTARice *c, uint32_t k0, uint32_t k1)
void ff_tta_filter_init(TTAFilter *c, int32_t shift)
const uint8_t ff_tta_filter_configs[]
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.