FFmpeg
tta.c
Go to the documentation of this file.
1 /*
2  * TTA (The Lossless True Audio) decoder
3  * Copyright (c) 2006 Alex Beregszaszi
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * TTA (The Lossless True Audio) decoder
25  * @see http://www.true-audio.com/
26  * @see http://tta.corecodec.org/
27  * @author Alex Beregszaszi
28  */
29 
30 #include <limits.h>
31 
33 #include "libavutil/crc.h"
34 #include "libavutil/intreadwrite.h"
35 #include "libavutil/opt.h"
36 
37 #define BITSTREAM_READER_LE
38 #include "ttadata.h"
39 #include "ttadsp.h"
40 #include "avcodec.h"
41 #include "codec_internal.h"
42 #include "get_bits.h"
43 #include "thread.h"
44 #include "unary.h"
45 
46 #define FORMAT_SIMPLE 1
47 #define FORMAT_ENCRYPTED 2
48 
49 typedef struct TTAContext {
50  AVClass *class;
52  const AVCRC *crc_table;
53 
55  unsigned data_length;
57 
59 
60  uint8_t crc_pass[8];
61  uint8_t *pass;
64 } TTAContext;
65 
66 static const int64_t tta_channel_layouts[7] = {
70  0,
74 };
75 
76 static int tta_check_crc(TTAContext *s, const uint8_t *buf, int buf_size)
77 {
78  uint32_t crc, CRC;
79 
80  CRC = AV_RL32(buf + buf_size);
81  crc = av_crc(s->crc_table, 0xFFFFFFFFU, buf, buf_size);
82  if (CRC != (crc ^ 0xFFFFFFFFU)) {
83  av_log(s->avctx, AV_LOG_ERROR, "CRC error\n");
84  return AVERROR_INVALIDDATA;
85  }
86 
87  return 0;
88 }
89 
90 static uint64_t tta_check_crc64(uint8_t *pass)
91 {
92  uint64_t crc = UINT64_MAX, poly = 0x42F0E1EBA9EA3693U;
93  uint8_t *end = pass + strlen(pass);
94  int i;
95 
96  while (pass < end) {
97  crc ^= (uint64_t)*pass++ << 56;
98  for (i = 0; i < 8; i++)
99  crc = (crc << 1) ^ (poly & (((int64_t) crc) >> 63));
100  }
101 
102  return crc ^ UINT64_MAX;
103 }
104 
106 {
107  TTAContext *s = avctx->priv_data;
108 
109  if (s->bps < 3) {
110  s->decode_buffer = av_calloc(s->frame_length,
111  sizeof(*s->decode_buffer) * s->channels);
112  if (!s->decode_buffer)
113  return AVERROR(ENOMEM);
114  } else
115  s->decode_buffer = NULL;
116  s->ch_ctx = av_malloc_array(avctx->ch_layout.nb_channels, sizeof(*s->ch_ctx));
117  if (!s->ch_ctx)
118  return AVERROR(ENOMEM);
119 
120  return 0;
121 }
122 
124 {
125  TTAContext *s = avctx->priv_data;
126  GetBitContext gb;
127  int total_frames;
128  int ret;
129 
130  s->avctx = avctx;
131 
132  // 22 bytes for a TTA1 header
133  if (avctx->extradata_size < 22)
134  return AVERROR_INVALIDDATA;
135 
136  s->crc_table = av_crc_get_table(AV_CRC_32_IEEE_LE);
137  ret = init_get_bits8(&gb, avctx->extradata, avctx->extradata_size);
138  if (ret < 0)
139  return ret;
140 
141  if (show_bits_long(&gb, 32) == AV_RL32("TTA1")) {
142  /* signature */
143  skip_bits_long(&gb, 32);
144 
145  s->format = get_bits(&gb, 16);
146  if (s->format > 2) {
147  av_log(avctx, AV_LOG_ERROR, "Invalid format\n");
148  return AVERROR_INVALIDDATA;
149  }
150  if (s->format == FORMAT_ENCRYPTED) {
151  if (!s->pass) {
152  av_log(avctx, AV_LOG_ERROR, "Missing password for encrypted stream. Please use the -password option\n");
153  return AVERROR(EINVAL);
154  }
155  AV_WL64(s->crc_pass, tta_check_crc64(s->pass));
156  }
157 
158  s->channels = get_bits(&gb, 16);
159 
161  if (s->channels > 1 && s->channels < 9) {
163  }
164  if (avctx->ch_layout.nb_channels == 0) {
166  avctx->ch_layout.nb_channels = s->channels;
167  }
168 
169  avctx->bits_per_raw_sample = get_bits(&gb, 16);
170  s->bps = (avctx->bits_per_raw_sample + 7) / 8;
171  avctx->sample_rate = get_bits_long(&gb, 32);
172  s->data_length = get_bits_long(&gb, 32);
173  skip_bits_long(&gb, 32); // CRC32 of header
174 
175  if (s->channels == 0 || s->channels > 16) {
176  av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
177  return AVERROR_INVALIDDATA;
178  } else if (avctx->sample_rate == 0) {
179  av_log(avctx, AV_LOG_ERROR, "Invalid samplerate\n");
180  return AVERROR_INVALIDDATA;
181  }
182 
183  switch(s->bps) {
184  case 1: avctx->sample_fmt = AV_SAMPLE_FMT_U8; break;
185  case 2:
186  avctx->sample_fmt = AV_SAMPLE_FMT_S16;
187  break;
188  case 3:
189  avctx->sample_fmt = AV_SAMPLE_FMT_S32;
190  break;
191  //case 4: avctx->sample_fmt = AV_SAMPLE_FMT_S32; break;
192  default:
193  av_log(avctx, AV_LOG_ERROR, "Invalid/unsupported sample format.\n");
194  return AVERROR_INVALIDDATA;
195  }
196 
197  // prevent overflow
198  if (avctx->sample_rate > 0x7FFFFFu) {
199  av_log(avctx, AV_LOG_ERROR, "sample_rate too large\n");
200  return AVERROR(EINVAL);
201  }
202  s->frame_length = 256 * avctx->sample_rate / 245;
203 
204  s->last_frame_length = s->data_length % s->frame_length;
205  total_frames = s->data_length / s->frame_length +
206  (s->last_frame_length ? 1 : 0);
207 
208  av_log(avctx, AV_LOG_DEBUG, "format: %d chans: %d bps: %d rate: %d block: %d\n",
209  s->format, avctx->ch_layout.nb_channels, avctx->bits_per_coded_sample, avctx->sample_rate,
210  avctx->block_align);
211  av_log(avctx, AV_LOG_DEBUG, "data_length: %d frame_length: %d last: %d total: %d\n",
212  s->data_length, s->frame_length, s->last_frame_length, total_frames);
213 
214  if (s->frame_length >= UINT_MAX / (s->channels * sizeof(int32_t))) {
215  av_log(avctx, AV_LOG_ERROR, "frame_length too large\n");
216  return AVERROR_INVALIDDATA;
217  }
218  } else {
219  av_log(avctx, AV_LOG_ERROR, "Wrong extradata present\n");
220  return AVERROR_INVALIDDATA;
221  }
222 
223  ff_ttadsp_init(&s->dsp);
224 
225  return allocate_buffers(avctx);
226 }
227 
229  int *got_frame_ptr, AVPacket *avpkt)
230 {
231  const uint8_t *buf = avpkt->data;
232  int buf_size = avpkt->size;
233  TTAContext *s = avctx->priv_data;
234  GetBitContext gb;
235  int i, ret;
236  int cur_chan = 0, framelen = s->frame_length;
237  uint32_t *p;
238 
239  if (avctx->err_recognition & AV_EF_CRCCHECK) {
240  if (buf_size < 4 ||
241  (tta_check_crc(s, buf, buf_size - 4) && avctx->err_recognition & AV_EF_EXPLODE))
242  return AVERROR_INVALIDDATA;
243  }
244 
245  if ((ret = init_get_bits8(&gb, avpkt->data, avpkt->size)) < 0)
246  return ret;
247 
248  /* get output buffer */
249  frame->nb_samples = framelen;
250  if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0)
251  return ret;
252 
253  // decode directly to output buffer for 24-bit sample format
254  if (s->bps == 3)
255  s->decode_buffer = (int32_t *)frame->data[0];
256 
257  // init per channel states
258  for (i = 0; i < s->channels; i++) {
259  TTAFilter *filter = &s->ch_ctx[i].filter;
260  s->ch_ctx[i].predictor = 0;
262  if (s->format == FORMAT_ENCRYPTED) {
263  int i;
264  for (i = 0; i < 8; i++)
265  filter->qm[i] = sign_extend(s->crc_pass[i], 8);
266  }
267  ff_tta_rice_init(&s->ch_ctx[i].rice, 10, 10);
268  }
269 
270  i = 0;
271  for (p = s->decode_buffer; (int32_t*)p < s->decode_buffer + (framelen * s->channels); p++) {
272  int32_t *predictor = &s->ch_ctx[cur_chan].predictor;
273  TTAFilter *filter = &s->ch_ctx[cur_chan].filter;
274  TTARice *rice = &s->ch_ctx[cur_chan].rice;
275  uint32_t unary, depth, k;
276  int32_t value;
277 
278  unary = get_unary(&gb, 0, get_bits_left(&gb));
279 
280  if (unary == 0) {
281  depth = 0;
282  k = rice->k0;
283  } else {
284  depth = 1;
285  k = rice->k1;
286  unary--;
287  }
288 
289  if (get_bits_left(&gb) < k) {
291  goto error;
292  }
293 
294  if (k) {
295  if (k > MIN_CACHE_BITS || unary > INT32_MAX >> k) {
297  goto error;
298  }
299  value = (unary << k) + get_bits(&gb, k);
300  } else
301  value = unary;
302 
303  // FIXME: copy paste from original
304  switch (depth) {
305  case 1:
306  rice->sum1 += value - (rice->sum1 >> 4);
307  if (rice->k1 > 0 && rice->sum1 < ff_tta_shift_16[rice->k1])
308  rice->k1--;
309  else if (rice->sum1 > ff_tta_shift_16[rice->k1 + 1])
310  rice->k1++;
311  value += ff_tta_shift_1[rice->k0];
312  default:
313  rice->sum0 += value - (rice->sum0 >> 4);
314  if (rice->k0 > 0 && rice->sum0 < ff_tta_shift_16[rice->k0])
315  rice->k0--;
316  else if (rice->sum0 > ff_tta_shift_16[rice->k0 + 1])
317  rice->k0++;
318  }
319 
320  // extract coded value
321  *p = 1 + ((value >> 1) ^ ((value & 1) - 1));
322 
323  // run hybrid filter
324  s->dsp.filter_process(filter->qm, filter->dx, filter->dl, &filter->error, p,
325  filter->shift, filter->round);
326 
327  // fixed order prediction
328 #define PRED(x, k) (int32_t)((((uint64_t)(x) << (k)) - (x)) >> (k))
329  switch (s->bps) {
330  case 1: *p += PRED(*predictor, 4); break;
331  case 2:
332  case 3: *p += PRED(*predictor, 5); break;
333  case 4: *p += *predictor; break;
334  }
335  *predictor = *p;
336 
337  // flip channels
338  if (cur_chan < (s->channels-1))
339  cur_chan++;
340  else {
341  // decorrelate in case of multiple channels
342  if (s->channels > 1) {
343  int32_t *r = p - 1;
344  for (*p += *r / 2; r > (int32_t*)p - s->channels; r--)
345  *r = *(r + 1) - (unsigned)*r;
346  }
347  cur_chan = 0;
348  i++;
349  // check for last frame
350  if (i == s->last_frame_length && get_bits_left(&gb) / 8 == 4) {
351  frame->nb_samples = framelen = s->last_frame_length;
352  break;
353  }
354  }
355  }
356 
357  align_get_bits(&gb);
358  if (get_bits_left(&gb) < 32) {
360  goto error;
361  }
362  skip_bits_long(&gb, 32); // frame crc
363 
364  // convert to output buffer
365  switch (s->bps) {
366  case 1: {
367  uint8_t *samples = (uint8_t *)frame->data[0];
368  p = s->decode_buffer;
369  for (i = 0; i < framelen * s->channels; i++)
370  samples[i] = p[i] + 0x80;
371  break;
372  }
373  case 2: {
374  int16_t *samples = (int16_t *)frame->data[0];
375  p = s->decode_buffer;
376  for (i = 0; i < framelen * s->channels; i++)
377  samples[i] = p[i];
378  break;
379  }
380  case 3: {
381  // shift samples for 24-bit sample format
382  int32_t *samples = (int32_t *)frame->data[0];
383 
384  for (i = 0; i < framelen * s->channels; i++)
385  samples[i] = samples[i] * 256U;
386  // reset decode buffer
387  s->decode_buffer = NULL;
388  break;
389  }
390  }
391 
392  *got_frame_ptr = 1;
393 
394  return buf_size;
395 error:
396  // reset decode buffer
397  if (s->bps == 3)
398  s->decode_buffer = NULL;
399  return ret;
400 }
401 
403 {
404  TTAContext *s = avctx->priv_data;
405 
406  if (s->bps < 3)
407  av_freep(&s->decode_buffer);
408  s->decode_buffer = NULL;
409  av_freep(&s->ch_ctx);
410 
411  return 0;
412 }
413 
414 #define OFFSET(x) offsetof(TTAContext, x)
415 #define DEC (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM)
416 static const AVOption options[] = {
417  { "password", "Set decoding password", OFFSET(pass), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, DEC },
418  { NULL },
419 };
420 
421 static const AVClass tta_decoder_class = {
422  .class_name = "TTA Decoder",
423  .item_name = av_default_item_name,
424  .option = options,
425  .version = LIBAVUTIL_VERSION_INT,
426 };
427 
429  .p.name = "tta",
430  CODEC_LONG_NAME("TTA (True Audio)"),
431  .p.type = AVMEDIA_TYPE_AUDIO,
432  .p.id = AV_CODEC_ID_TTA,
433  .priv_data_size = sizeof(TTAContext),
435  .close = tta_decode_close,
438  .p.priv_class = &tta_decoder_class,
439  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
440 };
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:31
tta_check_crc
static int tta_check_crc(TTAContext *s, const uint8_t *buf, int buf_size)
Definition: tta.c:76
skip_bits_long
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
Definition: get_bits.h:278
AV_EF_EXPLODE
#define AV_EF_EXPLODE
abort decoding on minor error detection
Definition: defs.h:51
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
show_bits_long
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
Definition: get_bits.h:495
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:695
PRED
#define PRED(x, k)
r
const char * r
Definition: vf_curves.c:126
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
AVCodecContext::sample_rate
int sample_rate
samples per second
Definition: avcodec.h:1050
AVCRC
uint32_t AVCRC
Definition: crc.h:46
tta_check_crc64
static uint64_t tta_check_crc64(uint8_t *pass)
Definition: tta.c:90
AVCodecContext::err_recognition
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
Definition: avcodec.h:1420
get_bits_long
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:421
int64_t
long long int64_t
Definition: coverity.c:34
ff_tta_filter_init
void ff_tta_filter_init(TTAFilter *c, int32_t shift)
Definition: ttadata.c:50
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
AVPacket::data
uint8_t * data
Definition: packet.h:522
AVOption
AVOption.
Definition: opt.h:346
TTAContext
Definition: tta.c:49
FFCodec
Definition: codec_internal.h:127
filter
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
Definition: filter_design.txt:228
AVChannelLayout::order
enum AVChannelOrder order
Channel order used in this layout.
Definition: channel_layout.h:308
ff_tta_rice_init
void ff_tta_rice_init(TTARice *c, uint32_t k0, uint32_t k1)
Definition: ttadata.c:42
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:313
thread.h
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:365
ff_thread_get_buffer
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have so the codec calls ff_thread_report set FF_CODEC_CAP_ALLOCATE_PROGRESS in FFCodec caps_internal and use ff_thread_get_buffer() to allocate frames. Otherwise decode directly into the user-supplied frames. Call ff_thread_report_progress() after some part of the current picture has decoded. A good place to put this is where draw_horiz_band() is called - add this if it isn 't called anywhere
TTARice::k1
uint32_t k1
Definition: ttadata.h:35
crc.h
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:335
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
AVCodecContext::ch_layout
AVChannelLayout ch_layout
Audio channel layout.
Definition: avcodec.h:1065
tta_decoder_class
static const AVClass tta_decoder_class
Definition: tta.c:421
GetBitContext
Definition: get_bits.h:108
FORMAT_ENCRYPTED
#define FORMAT_ENCRYPTED
Definition: tta.c:47
TTARice::sum1
uint32_t sum1
Definition: ttadata.h:35
AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_STEREO
Definition: channel_layout.h:205
TTAContext::channels
int channels
Definition: tta.c:54
ff_ttadsp_init
av_cold void ff_ttadsp_init(TTADSPContext *c)
Definition: ttadsp.c:56
AV_CH_LAYOUT_QUAD
#define AV_CH_LAYOUT_QUAD
Definition: channel_layout.h:213
TTAContext::dsp
TTADSPContext dsp
Definition: tta.c:63
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
init_get_bits8
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:545
AV_CODEC_ID_TTA
@ AV_CODEC_ID_TTA
Definition: codec_id.h:462
AV_CH_LOW_FREQUENCY
#define AV_CH_LOW_FREQUENCY
Definition: channel_layout.h:171
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:524
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:287
tta_decode_init
static av_cold int tta_decode_init(AVCodecContext *avctx)
Definition: tta.c:123
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
tta_channel_layouts
static const int64_t tta_channel_layouts[7]
Definition: tta.c:66
AV_CHANNEL_ORDER_UNSPEC
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
Definition: channel_layout.h:112
av_channel_layout_from_mask
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.
Definition: channel_layout.c:242
allocate_buffers
static int allocate_buffers(AVCodecContext *avctx)
Definition: tta.c:105
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1574
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
get_bits.h
limits.h
TTAContext::crc_pass
uint8_t crc_pass[8]
Definition: tta.c:60
TTAContext::crc_table
const AVCRC * crc_table
Definition: tta.c:52
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
frame
static AVFrame * frame
Definition: demux_decode.c:54
TTARice::sum0
uint32_t sum0
Definition: ttadata.h:35
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:110
TTAContext::bps
int bps
Definition: tta.c:54
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
TTAFilter
Definition: ttadata.h:27
TTADSPContext
Definition: ttadsp.h:24
ff_tta_decoder
const FFCodec ff_tta_decoder
Definition: tta.c:428
DEC
#define DEC
Definition: tta.c:415
AV_EF_CRCCHECK
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data,...
Definition: defs.h:48
get_unary
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
Definition: unary.h:46
TTAContext::decode_buffer
int32_t * decode_buffer
Definition: tta.c:58
TTAContext::avctx
AVCodecContext * avctx
Definition: tta.c:51
AV_CODEC_CAP_CHANNEL_CONF
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: codec.h:106
TTAContext::last_frame_length
int last_frame_length
Definition: tta.c:56
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:365
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AVPacket::size
int size
Definition: packet.h:523
codec_internal.h
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AVCodecContext::sample_fmt
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:1057
TTAContext::data_length
unsigned data_length
Definition: tta.c:55
TTAContext::format
int format
Definition: tta.c:54
AV_WL64
#define AV_WL64(p, v)
Definition: intreadwrite.h:438
av_crc_get_table
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
Definition: crc.c:374
AV_CH_LAYOUT_5POINT1_BACK
#define AV_CH_LAYOUT_5POINT1_BACK
Definition: channel_layout.h:217
TTAContext::pass
uint8_t * pass
Definition: tta.c:61
predictor
static void predictor(uint8_t *src, ptrdiff_t size)
Definition: exrenc.c:170
unary.h
ff_tta_shift_1
const uint32_t ff_tta_shift_1[]
Definition: ttadata.c:24
tta_decode_frame
static int tta_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition: tta.c:228
AVCodecContext::bits_per_coded_sample
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:1567
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:424
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:523
AV_SAMPLE_FMT_U8
@ AV_SAMPLE_FMT_U8
unsigned 8 bits
Definition: samplefmt.h:57
ff_tta_shift_16
const uint32_t *const ff_tta_shift_16
Definition: ttadata.c:38
ff_tta_filter_configs
const uint8_t ff_tta_filter_configs[]
Definition: ttadata.c:40
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:31
MIN_CACHE_BITS
#define MIN_CACHE_BITS
Definition: get_bits.h:169
ttadata.h
AV_CH_BACK_CENTER
#define AV_CH_BACK_CENTER
Definition: channel_layout.h:176
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
AV_CH_LAYOUT_7POINT1_WIDE
#define AV_CH_LAYOUT_7POINT1_WIDE
Definition: channel_layout.h:228
AV_SAMPLE_FMT_S16
@ AV_SAMPLE_FMT_S16
signed 16 bits
Definition: samplefmt.h:58
TTAChannel
Definition: ttadata.h:38
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
avcodec.h
TTARice::k0
uint32_t k0
Definition: ttadata.h:35
ret
ret
Definition: filter_design.txt:187
AVCodecContext::block_align
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
Definition: avcodec.h:1083
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
align_get_bits
static const uint8_t * align_get_bits(GetBitContext *s)
Definition: get_bits.h:561
TTARice
Definition: ttadata.h:34
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
U
#define U(x)
Definition: vpx_arith.h:37
tta_decode_close
static av_cold int tta_decode_close(AVCodecContext *avctx)
Definition: tta.c:402
TTAContext::frame_length
int frame_length
Definition: tta.c:56
OFFSET
#define OFFSET(x)
Definition: tta.c:414
AVCodecContext
main external API structure.
Definition: avcodec.h:445
channel_layout.h
av_crc
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
Definition: crc.c:392
av_channel_layout_uninit
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
Definition: channel_layout.c:432
sign_extend
static av_const int sign_extend(int val, unsigned bits)
Definition: mathops.h:133
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
AV_CRC_32_IEEE_LE
@ AV_CRC_32_IEEE_LE
Definition: crc.h:53
TTAContext::ch_ctx
TTAChannel * ch_ctx
Definition: tta.c:62
ttadsp.h
AVPacket
This structure stores compressed data.
Definition: packet.h:499
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:472
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
int32_t
int32_t
Definition: audioconvert.c:56
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:239
options
static const AVOption options[]
Definition: tta.c:416
AV_SAMPLE_FMT_S32
@ AV_SAMPLE_FMT_S32
signed 32 bits
Definition: samplefmt.h:59