30 #define BITSTREAM_READER_LE
38 #include "libavutil/crc.h"
39 #include "libavutil/intreadwrite.h"
40 #include "libavutil/opt.h"
42 #define FORMAT_SIMPLE 1
43 #define FORMAT_ENCRYPTED 2
66 qm[0] -= dx[0]; qm[1] -= dx[1]; qm[2] -= dx[2]; qm[3] -= dx[3];
67 qm[4] -= dx[4]; qm[5] -= dx[5]; qm[6] -= dx[6]; qm[7] -= dx[7];
68 }
else if (c->
error > 0) {
69 qm[0] += dx[0]; qm[1] += dx[1]; qm[2] += dx[2]; qm[3] += dx[3];
70 qm[4] += dx[4]; qm[5] += dx[5]; qm[6] += dx[6]; qm[7] += dx[7];
73 sum += dl[0] * qm[0] + dl[1] * qm[1] + dl[2] * qm[2] + dl[3] * qm[3] +
74 dl[4] * qm[4] + dl[5] * qm[5] + dl[6] * qm[6] + dl[7] * qm[7];
76 dx[0] = dx[1]; dx[1] = dx[2]; dx[2] = dx[3]; dx[3] = dx[4];
77 dl[0] = dl[1]; dl[1] = dl[2]; dl[2] = dl[3]; dl[3] = dl[4];
79 dx[4] = ((dl[4] >> 30) | 1);
80 dx[5] = ((dl[5] >> 30) | 2) & ~1;
81 dx[6] = ((dl[6] >> 30) | 2) & ~1;
82 dx[7] = ((dl[7] >> 30) | 4) & ~3;
85 *in += (sum >> c->
shift);
87 dl[4] = -dl[5]; dl[5] = -dl[6];
88 dl[6] = *in - dl[7]; dl[7] = *
in;
89 dl[5] += dl[6]; dl[4] += dl[5];
108 if (CRC != (crc ^ 0xFFFFFFFFU)) {
118 uint64_t crc = UINT64_MAX,
poly = 0x42F0E1EBA9EA3693
U;
123 crc ^= (uint64_t)*pass++ << 56;
124 for (i = 0; i < 8; i++)
125 crc = (crc << 1) ^ (poly & (((int64_t) crc) >> 63));
128 return crc ^ UINT64_MAX;
175 av_log(avctx,
AV_LOG_ERROR,
"Missing password for encrypted stream. Please use the -password option\n");
241 int *got_frame_ptr,
AVPacket *avpkt)
246 int buf_size = avpkt->
size;
277 for (i = 0; i < 8; i++)
288 uint32_t unary,
depth, k;
312 value = (unary << k) +
get_bits(&gb, k);
319 rice->
sum1 += value - (rice->
sum1 >> 4);
326 rice->
sum0 += value - (rice->
sum0 >> 4);
334 *p = 1 + ((value >> 1) ^ ((value & 1) - 1));
340 #define PRED(x, k) (int32_t)((((uint64_t)x << k) - x) >> k)
342 case 1: *p +=
PRED(*predictor, 4);
break;
344 case 3: *p +=
PRED(*predictor, 5);
break;
356 for (*p += *r / 2; r > p - s->
channels; r--)
381 *samples++ = *p + 0x80;
385 int16_t *samples = (int16_t *)frame->
data[0];
429 #define OFFSET(x) offsetof(TTAContext, x)
430 #define DEC (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM)
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
static int tta_check_crc(TTAContext *s, const uint8_t *buf, int buf_size)
This structure describes decoded (raw) audio or video data.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int init_thread_copy(AVCodecContext *avctx)
#define LIBAVUTIL_VERSION_INT
static void skip_bits_long(GetBitContext *s, int n)
static av_cold int init(AVCodecContext *avctx)
static av_cold int tta_decode_init(AVCodecContext *avctx)
static int tta_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
void ff_tta_rice_init(TTARice *c, uint32_t k0, uint32_t k1)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
#define AV_CH_LAYOUT_STEREO
static const int64_t tta_channel_layouts[7]
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static av_cold int tta_decode_close(AVCodecContext *avctx)
const char * av_default_item_name(void *ctx)
Return the context name.
enum AVSampleFormat sample_fmt
audio sample format
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static av_cold int end(AVCodecContext *avctx)
Multithreading support functions.
static uint64_t tta_check_crc64(uint8_t *pass)
const char * name
Name of the codec implementation.
#define AV_CH_LOW_FREQUENCY
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
bitstream reader API header.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
const OptionDef options[]
static void predictor(uint8_t *src, int size)
static int get_bits_left(GetBitContext *gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);ff_audio_convert_init_arm(ac);ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
static int allocate_buffers(AVCodecContext *avctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_CH_LAYOUT_QUAD
Libavcodec external API header.
uint64_t channel_layout
Audio channel layout.
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
const uint32_t ff_tta_shift_1[]
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
const uint32_t *const ff_tta_shift_16
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length) av_pure
Calculate the CRC of a block.
static void ttafilter_process(TTAFilter *c, int32_t *in)
#define AV_CH_LAYOUT_5POINT1_BACK
static const AVClass tta_decoder_class
int sample_rate
samples per second
const uint8_t ff_tta_filter_configs[]
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
main external API structure.
static void close(AVCodecParserContext *s)
Describe the class of an AVClass context structure.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static av_const int sign_extend(int val, unsigned bits)
#define AV_CH_BACK_CENTER
#define AV_CH_LAYOUT_7POINT1_WIDE
common internal api header.
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
#define AVERROR_INVALIDDATA
int channels
number of audio channels
static const uint8_t * align_get_bits(GetBitContext *s)
#define AV_EF_CRCCHECK
verify embedded CRCs
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
void ff_tta_filter_init(TTAFilter *c, int32_t shift)
This structure stores compressed 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.
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...