FFmpeg
dcadec.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 foo86
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/mem.h"
22 #include "libavutil/opt.h"
24 #include "libavutil/downmix_info.h"
25 #include "libavutil/thread.h"
26 
27 #include "codec_internal.h"
28 #include "dcadec.h"
29 #include "dcadata.h"
30 #include "dcahuff.h"
31 #include "dca_syncwords.h"
32 #include "profiles.h"
33 
34 #define MIN_PACKET_SIZE 16
35 #define MAX_PACKET_SIZE 0x104000
36 
37 
38 static const uint8_t dca2wav_norm[28] = {
39  2, 0, 1, 9, 10, 3, 8, 4, 5, 9, 10, 6, 7, 12,
40  13, 14, 3, 6, 7, 11, 12, 14, 16, 15, 17, 8, 4, 5,
41 };
42 
43 static const uint8_t dca2wav_wide[28] = {
44  2, 0, 1, 4, 5, 3, 8, 4, 5, 9, 10, 6, 7, 12,
45  13, 14, 3, 6, 7, 11, 12, 14, 16, 15, 17, 8, 4, 5,
46 };
47 
48 int ff_dca_set_channel_layout(AVCodecContext *avctx, int *ch_remap, int dca_mask)
49 {
50  DCAContext *s = avctx->priv_data;
51 
52  int dca_ch, wav_ch, nchannels = 0;
53  const uint8_t *dca2wav;
54 
55  if (dca_mask == DCA_SPEAKER_LAYOUT_7POINT0_WIDE ||
57  dca2wav = dca2wav_wide;
58  else
59  dca2wav = dca2wav_norm;
60 
62  if (s->output_channel_order == CHANNEL_ORDER_CODED) {
63  int ret;
64  for (dca_ch = 0; dca_ch < DCA_SPEAKER_COUNT; dca_ch++)
65  if (dca_mask & (1U << dca_ch))
66  ch_remap[nchannels++] = dca_ch;
67  ret = av_channel_layout_custom_init(&avctx->ch_layout, nchannels);
68  if (ret < 0)
69  return ret;
70 
71  nchannels = 0;
72  for (dca_ch = 0; dca_ch < DCA_SPEAKER_COUNT; dca_ch++)
73  if (dca_mask & (1U << dca_ch))
74  avctx->ch_layout.u.map[nchannels++].id = dca2wav[dca_ch];
75  } else {
76  int wav_mask = 0;
77  int wav_map[18];
78  for (dca_ch = 0; dca_ch < 28; dca_ch++) {
79  if (dca_mask & (1 << dca_ch)) {
80  wav_ch = dca2wav[dca_ch];
81  if (!(wav_mask & (1 << wav_ch))) {
82  wav_map[wav_ch] = dca_ch;
83  wav_mask |= 1 << wav_ch;
84  }
85  }
86  }
87  for (wav_ch = 0; wav_ch < 18; wav_ch++)
88  if (wav_mask & (1 << wav_ch))
89  ch_remap[nchannels++] = wav_map[wav_ch];
90 
91  av_channel_layout_from_mask(&avctx->ch_layout, wav_mask);
92  }
93 
94  return nchannels;
95 }
96 
98  int *coeff_l, int nsamples, int ch_mask)
99 {
100  int pos, spkr, max_spkr = av_log2(ch_mask);
101  int *coeff_r = coeff_l + av_popcount(ch_mask);
102 
103  av_assert0(DCA_HAS_STEREO(ch_mask));
104 
105  // Scale left and right channels
106  pos = (ch_mask & DCA_SPEAKER_MASK_C);
107  dcadsp->dmix_scale(samples[DCA_SPEAKER_L], coeff_l[pos ], nsamples);
108  dcadsp->dmix_scale(samples[DCA_SPEAKER_R], coeff_r[pos + 1], nsamples);
109 
110  // Downmix remaining channels
111  for (spkr = 0; spkr <= max_spkr; spkr++) {
112  if (!(ch_mask & (1U << spkr)))
113  continue;
114 
115  if (*coeff_l && spkr != DCA_SPEAKER_L)
116  dcadsp->dmix_add(samples[DCA_SPEAKER_L], samples[spkr],
117  *coeff_l, nsamples);
118 
119  if (*coeff_r && spkr != DCA_SPEAKER_R)
120  dcadsp->dmix_add(samples[DCA_SPEAKER_R], samples[spkr],
121  *coeff_r, nsamples);
122 
123  coeff_l++;
124  coeff_r++;
125  }
126 }
127 
129  int *coeff_l, int nsamples, int ch_mask)
130 {
131  int pos, spkr, max_spkr = av_log2(ch_mask);
132  int *coeff_r = coeff_l + av_popcount(ch_mask);
133  const float scale = 1.0f / (1 << 15);
134 
135  av_assert0(DCA_HAS_STEREO(ch_mask));
136 
137  // Scale left and right channels
138  pos = (ch_mask & DCA_SPEAKER_MASK_C);
140  coeff_l[pos ] * scale, nsamples);
142  coeff_r[pos + 1] * scale, nsamples);
143 
144  // Downmix remaining channels
145  for (spkr = 0; spkr <= max_spkr; spkr++) {
146  if (!(ch_mask & (1U << spkr)))
147  continue;
148 
149  if (*coeff_l && spkr != DCA_SPEAKER_L)
151  *coeff_l * scale, nsamples);
152 
153  if (*coeff_r && spkr != DCA_SPEAKER_R)
155  *coeff_r * scale, nsamples);
156 
157  coeff_l++;
158  coeff_r++;
159  }
160 }
161 
163  enum DCADownMixType downmix_type,
164  int output_mask, const int *coeff_l)
165 {
166  enum AVDownmixType dmix_type = (downmix_type == DCA_DMIX_TYPE_LoRo) ?
168  size_t size;
169  AVDownmixMatrix *dm = av_downmix_matrix_alloc(dmix_type, av_popcount(output_mask), &size);
170  const int *coeff_r = coeff_l + av_popcount(output_mask);
171  const double scale = 1.0 / (1 << 15);
172  AVDownmixCoeff *matrix_l, *matrix_r;
173  const uint8_t *dca2wav;
174 
175  if (!dm)
176  return AVERROR(ENOMEM);
177 
178  if (output_mask == DCA_SPEAKER_LAYOUT_7POINT0_WIDE ||
179  output_mask == DCA_SPEAKER_LAYOUT_7POINT1_WIDE)
180  dca2wav = dca2wav_wide;
181  else
182  dca2wav = dca2wav_norm;
183 
184  matrix_l = av_downmix_matrix_coeff(dm, 0, 0);
185  matrix_r = av_downmix_matrix_coeff(dm, 1, 0);
186 
187  for (int i = 0; i <= av_log2(output_mask); i++) {
188  if (!(output_mask & (1U << i)))
189  continue;
190 
191  int idx = av_channel_layout_index_from_channel(&avctx->ch_layout, dca2wav[i]);
192  av_assert0(idx >= 0);
193 
194  if (*coeff_l)
195  matrix_l[idx] = *coeff_l * scale;
196 
197  if (*coeff_r)
198  matrix_r[idx] = *coeff_r * scale;
199 
200  coeff_l++;
201  coeff_r++;
202  }
203 
204  AVBufferRef *buf = av_buffer_create((uint8_t *)dm, size, NULL, NULL, 0);
205  if (!buf) {
206  av_free(dm);
207  return AVERROR(ENOMEM);
208  }
209 
211  av_buffer_unref(&buf);
212  return AVERROR(ENOMEM);
213  }
214 
215  return 0;
216 }
217 
219  int *got_frame_ptr, AVPacket *avpkt)
220 {
221  DCAContext *s = avctx->priv_data;
222  const uint8_t *input = avpkt->data;
223  int input_size = avpkt->size;
224  int i, ret, prev_packet = s->packet;
225  uint32_t mrk;
226 
227  if (input_size < MIN_PACKET_SIZE || input_size > MAX_PACKET_SIZE) {
228  av_log(avctx, AV_LOG_ERROR, "Invalid packet size\n");
229  return AVERROR_INVALIDDATA;
230  }
231 
232  // Convert input to BE format
233  mrk = AV_RB32(input);
234  if (mrk != DCA_SYNCWORD_CORE_BE && mrk != DCA_SYNCWORD_SUBSTREAM) {
235  av_fast_padded_malloc(&s->buffer, &s->buffer_size, input_size);
236  if (!s->buffer)
237  return AVERROR(ENOMEM);
238 
239  for (i = 0, ret = AVERROR_INVALIDDATA; i < input_size - MIN_PACKET_SIZE + 1 && ret < 0; i++)
240  ret = avpriv_dca_convert_bitstream(input + i, input_size - i, s->buffer, s->buffer_size);
241 
242  if (ret < 0) {
243  av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n");
244  return ret;
245  }
246 
247  input = s->buffer;
248  input_size = ret;
249  }
250 
251  s->packet = 0;
252 
253  // Parse backward compatible core sub-stream
255  int frame_size;
256 
257  if ((ret = ff_dca_core_parse(&s->core, input, input_size)) < 0)
258  return ret;
259 
260  s->packet |= DCA_PACKET_CORE;
261 
262  // EXXS data must be aligned on 4-byte boundary
263  frame_size = FFALIGN(s->core.frame_size, 4);
264  if (input_size - 4 > frame_size) {
265  input += frame_size;
266  input_size -= frame_size;
267  }
268  }
269 
270  if (!s->core_only) {
271  DCAExssAsset *asset = NULL;
272 
273  // Parse extension sub-stream (EXSS)
275  if ((ret = ff_dca_exss_parse(&s->exss, input, input_size)) < 0) {
276  if (avctx->err_recognition & AV_EF_EXPLODE)
277  return ret;
278  } else {
279  s->packet |= DCA_PACKET_EXSS;
280  asset = &s->exss.assets[0];
281  }
282  }
283 
284  // Parse XLL component in EXSS
285  if (asset && (asset->extension_mask & DCA_EXSS_XLL)) {
286  if ((ret = ff_dca_xll_parse(&s->xll, input, asset)) < 0) {
287  // Conceal XLL synchronization error
288  if (ret == AVERROR(EAGAIN)) {
289  if ((prev_packet & DCA_PACKET_XLL) && (s->packet & DCA_PACKET_CORE))
290  s->packet |= DCA_PACKET_XLL | DCA_PACKET_RECOVERY;
291  } else if (ret == AVERROR(ENOMEM) || (avctx->err_recognition & AV_EF_EXPLODE))
292  return ret;
293  } else {
294  s->packet |= DCA_PACKET_XLL;
295  }
296  }
297 
298  // Parse LBR component in EXSS
299  if (asset && (asset->extension_mask & DCA_EXSS_LBR)) {
300  if ((ret = ff_dca_lbr_parse(&s->lbr, input, asset)) < 0) {
301  if (ret == AVERROR(ENOMEM) || (avctx->err_recognition & AV_EF_EXPLODE))
302  return ret;
303  } else {
304  s->packet |= DCA_PACKET_LBR;
305  }
306  }
307 
308  // Parse core extensions in EXSS or backward compatible core sub-stream
309  if ((s->packet & DCA_PACKET_CORE)
310  && (ret = ff_dca_core_parse_exss(&s->core, input, asset)) < 0)
311  return ret;
312  }
313 
314  // Filter the frame
315  if (s->packet & DCA_PACKET_LBR) {
316  if ((ret = ff_dca_lbr_filter_frame(&s->lbr, frame)) < 0)
317  return ret;
318  } else if (s->packet & DCA_PACKET_XLL) {
319  if (s->packet & DCA_PACKET_CORE) {
320  int x96_synth = -1;
321 
322  // Enable X96 synthesis if needed
323  if (s->xll.chset[0].freq == 96000 && s->core.sample_rate == 48000)
324  x96_synth = 1;
325 
326  if ((ret = ff_dca_core_filter_fixed(&s->core, x96_synth)) < 0)
327  return ret;
328 
329  // Force lossy downmixed output on the first core frame filtered.
330  // This prevents audible clicks when seeking and is consistent with
331  // what reference decoder does when there are multiple channel sets.
332  if (!(prev_packet & DCA_PACKET_RESIDUAL) && s->xll.nreschsets > 0
333  && s->xll.nchsets > 1) {
334  av_log(avctx, AV_LOG_VERBOSE, "Forcing XLL recovery mode\n");
335  s->packet |= DCA_PACKET_RECOVERY;
336  }
337 
338  // Set 'residual ok' flag for the next frame
339  s->packet |= DCA_PACKET_RESIDUAL;
340  }
341 
342  if ((ret = ff_dca_xll_filter_frame(&s->xll, frame)) < 0) {
343  // Fall back to core unless hard error
344  if (!(s->packet & DCA_PACKET_CORE))
345  return ret;
347  return ret;
348  if ((ret = ff_dca_core_filter_frame(&s->core, frame)) < 0)
349  return ret;
350  }
351  } else if (s->packet & DCA_PACKET_CORE) {
352  if ((ret = ff_dca_core_filter_frame(&s->core, frame)) < 0)
353  return ret;
354  if (s->core.filter_mode & DCA_FILTER_MODE_FIXED)
355  s->packet |= DCA_PACKET_RESIDUAL;
356  } else {
357  av_log(avctx, AV_LOG_ERROR, "No valid DCA sub-stream found\n");
358  if (s->core_only)
359  av_log(avctx, AV_LOG_WARNING, "Consider disabling 'core_only' option\n");
360  return AVERROR_INVALIDDATA;
361  }
362 
363  *got_frame_ptr = 1;
364 
365  return avpkt->size;
366 }
367 
369 {
370  DCAContext *s = avctx->priv_data;
371 
372  ff_dca_core_flush(&s->core);
373  ff_dca_xll_flush(&s->xll);
374  ff_dca_lbr_flush(&s->lbr);
375 
376  s->packet &= DCA_PACKET_MASK;
377 }
378 
380 {
381  DCAContext *s = avctx->priv_data;
382 
383  ff_dca_core_close(&s->core);
384  ff_dca_xll_close(&s->xll);
385  ff_dca_lbr_close(&s->lbr);
386 
387  av_freep(&s->buffer);
388  s->buffer_size = 0;
389 
390  return 0;
391 }
392 
393 static av_cold void dcadec_init_static(void)
394 {
397 }
398 
400 {
401  static AVOnce init_static_once = AV_ONCE_INIT;
402  DCAContext *s = avctx->priv_data;
403 
404  s->avctx = avctx;
405  s->core.avctx = avctx;
406  s->exss.avctx = avctx;
407  s->xll.avctx = avctx;
408  s->lbr.avctx = avctx;
409 
410  if (ff_dca_core_init(&s->core) < 0)
411  return AVERROR(ENOMEM);
412 
413  if (ff_dca_lbr_init(&s->lbr) < 0)
414  return AVERROR(ENOMEM);
415 
416  ff_dcadsp_init(&s->dcadsp);
417  s->core.dcadsp = &s->dcadsp;
418  s->xll.dcadsp = &s->dcadsp;
419  s->lbr.dcadsp = &s->dcadsp;
420 
422 
423  if (s->downmix_layout.nb_channels) {
426  s->request_channel_layout = DCA_SPEAKER_LAYOUT_STEREO;
429  } else if (!av_channel_layout_compare(&s->downmix_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0)) {
430  s->request_channel_layout = DCA_SPEAKER_LAYOUT_5POINT0;
433  } else if (!av_channel_layout_compare(&s->downmix_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1)) {
434  s->request_channel_layout = DCA_SPEAKER_LAYOUT_5POINT1;
437  }
438  else
439  av_log(avctx, AV_LOG_WARNING, "Invalid downmix layout\n");
440  }
441 
442  ff_thread_once(&init_static_once, dcadec_init_static);
443 
444  return 0;
445 }
446 
447 #define OFFSET(x) offsetof(DCAContext, x)
448 #define PARAM AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
449 
450 static const AVOption dcadec_options[] = {
451  { "core_only", "Decode core only without extensions", OFFSET(core_only), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, PARAM },
452 
453  { "channel_order", "Order in which the channels are to be exported",
454  OFFSET(output_channel_order), AV_OPT_TYPE_INT,
455  { .i64 = CHANNEL_ORDER_DEFAULT }, 0, 1, PARAM, .unit = "channel_order" },
456  { "default", "normal libavcodec channel order", 0, AV_OPT_TYPE_CONST,
457  { .i64 = CHANNEL_ORDER_DEFAULT }, .flags = PARAM, .unit = "channel_order" },
458  { "coded", "order in which the channels are coded in the bitstream",
459  0, AV_OPT_TYPE_CONST, { .i64 = CHANNEL_ORDER_CODED }, .flags = PARAM, .unit = "channel_order" },
460 
461  { "downmix", "Request a specific channel layout from the decoder", OFFSET(downmix_layout),
462  AV_OPT_TYPE_CHLAYOUT, {.str = NULL}, .flags = PARAM },
463 
464  { NULL }
465 };
466 
467 static const AVClass dcadec_class = {
468  .class_name = "DCA decoder",
469  .item_name = av_default_item_name,
470  .option = dcadec_options,
471  .version = LIBAVUTIL_VERSION_INT,
472  .category = AV_CLASS_CATEGORY_DECODER,
473 };
474 
476  .p.name = "dca",
477  CODEC_LONG_NAME("DCA (DTS Coherent Acoustics)"),
478  .p.type = AVMEDIA_TYPE_AUDIO,
479  .p.id = AV_CODEC_ID_DTS,
480  .priv_data_size = sizeof(DCAContext),
481  .init = dcadec_init,
483  .close = dcadec_close,
484  .flush = dcadec_flush,
485  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
486  .p.priv_class = &dcadec_class,
487  .p.profiles = NULL_IF_CONFIG_SMALL(ff_dca_profiles),
488  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
489 };
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:216
dcadec_close
static av_cold int dcadec_close(AVCodecContext *avctx)
Definition: dcadec.c:379
AV_CHANNEL_LAYOUT_STEREO_DOWNMIX
#define AV_CHANNEL_LAYOUT_STEREO_DOWNMIX
Definition: channel_layout.h:432
AV_EF_EXPLODE
#define AV_EF_EXPLODE
abort decoding on minor error detection
Definition: defs.h:51
ff_dca_xll_parse
int ff_dca_xll_parse(DCAXllDecoder *s, const uint8_t *data, DCAExssAsset *asset)
Definition: dca_xll.c:1191
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:43
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
AV_CLASS_CATEGORY_DECODER
@ AV_CLASS_CATEGORY_DECODER
Definition: log.h:35
AV_CHANNEL_LAYOUT_STEREO
#define AV_CHANNEL_LAYOUT_STEREO
Definition: channel_layout.h:395
DCA_SPEAKER_LAYOUT_5POINT0
#define DCA_SPEAKER_LAYOUT_5POINT0
Definition: dca.h:128
thread.h
ff_dca_core_close
av_cold void ff_dca_core_close(DCACoreDecoder *s)
Definition: dca_core.c:2448
AVCodecContext::err_recognition
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
Definition: avcodec.h:1416
av_cold
#define av_cold
Definition: attributes.h:119
AVChannelLayout::map
AVChannelCustom * map
This member must be used when the channel order is AV_CHANNEL_ORDER_CUSTOM.
Definition: channel_layout.h:370
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:472
DCA_PACKET_LBR
#define DCA_PACKET_LBR
Definition: dcadec.h:42
AVPacket::data
uint8_t * data
Definition: packet.h:603
AVOption
AVOption.
Definition: opt.h:428
DCA_SPEAKER_LAYOUT_STEREO
#define DCA_SPEAKER_LAYOUT_STEREO
Definition: dca.h:122
av_downmix_matrix_coeff
static av_always_inline AVDownmixCoeff * av_downmix_matrix_coeff(AVDownmixMatrix *dm, unsigned int out, unsigned int in)
Get a pointer to the coeff that represents the weight of input channel.
Definition: downmix_info.h:154
FFCodec
Definition: codec_internal.h:127
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:226
av_popcount
#define av_popcount
Definition: common.h:154
dca2wav_wide
static const uint8_t dca2wav_wide[28]
Definition: dcadec.c:43
DCA_PACKET_XLL
#define DCA_PACKET_XLL
Definition: dcadec.h:41
DCA_FILTER_MODE_FIXED
#define DCA_FILTER_MODE_FIXED
Definition: dca_core.h:55
ff_dca_lbr_parse
int ff_dca_lbr_parse(DCALbrDecoder *s, const uint8_t *data, DCAExssAsset *asset)
Definition: dca_lbr.c:1170
dcadec_init
static av_cold int dcadec_init(AVCodecContext *avctx)
Definition: dcadec.c:399
DCAExssAsset
Definition: dca_exss.h:29
DCA_PACKET_RECOVERY
#define DCA_PACKET_RECOVERY
Sync error recovery flag.
Definition: dcadec.h:45
ff_dca_core_filter_frame
int ff_dca_core_filter_frame(DCACoreDecoder *s, AVFrame *frame)
Definition: dca_core.c:2344
avpriv_dca_convert_bitstream
int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, int max_size)
Convert bitstream to one representation based on sync marker.
Definition: dca.c:49
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
DCA_EXSS_XLL
@ DCA_EXSS_XLL
Definition: dca.h:179
AVCodecContext::ch_layout
AVChannelLayout ch_layout
Audio channel layout.
Definition: avcodec.h:1055
ff_dca_profiles
const AVProfile ff_dca_profiles[]
Definition: profiles.c:40
AV_FRAME_DATA_DOWNMIX_MATRIX
@ AV_FRAME_DATA_DOWNMIX_MATRIX
Metadata relevant to a downmix procedure in the form of a remixig matrix.
Definition: frame.h:307
dcadec_flush
static av_cold void dcadec_flush(AVCodecContext *avctx)
Definition: dcadec.c:368
DCA_SPEAKER_MASK_C
@ DCA_SPEAKER_MASK_C
Definition: dca.h:91
DCA_SPEAKER_LAYOUT_7POINT1_WIDE
#define DCA_SPEAKER_LAYOUT_7POINT1_WIDE
Definition: dca.h:131
ff_dca_downmix_to_stereo_float
void ff_dca_downmix_to_stereo_float(AVFloatDSPContext *fdsp, float **samples, int *coeff_l, int nsamples, int ch_mask)
Definition: dcadec.c:128
dcadec_init_static
static av_cold void dcadec_init_static(void)
Definition: dcadec.c:393
dcadata.h
ff_thread_once
static int ff_thread_once(char *control, void(*routine)(void))
Definition: thread.h:205
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
dcadec_decode_frame
static int dcadec_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition: dcadec.c:218
DCA_DMIX_TYPE_LoRo
@ DCA_DMIX_TYPE_LoRo
Definition: dca.h:187
ff_dca_lbr_init_tables
av_cold void ff_dca_lbr_init_tables(void)
Definition: dca_lbr.c:135
ff_dca_downmix_to_stereo_fixed
void ff_dca_downmix_to_stereo_fixed(DCADSPContext *dcadsp, int32_t **samples, int *coeff_l, int nsamples, int ch_mask)
Definition: dcadec.c:97
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:364
dcadec_options
static const AVOption dcadec_options[]
Definition: dcadec.c:450
DCA_SPEAKER_LAYOUT_7POINT0_WIDE
#define DCA_SPEAKER_LAYOUT_7POINT0_WIDE
Definition: dca.h:130
DCA_SPEAKER_LAYOUT_5POINT1
#define DCA_SPEAKER_LAYOUT_5POINT1
Definition: dca.h:129
frame_size
int frame_size
Definition: mxfenc.c:2489
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:201
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:253
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:42
DCADSPContext::dmix_scale
void(* dmix_scale)(int32_t *dst, int scale, ptrdiff_t len)
Definition: dcadsp.h:82
dcadec.h
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:349
dca_syncwords.h
ff_dca_export_downmix_matrix
int ff_dca_export_downmix_matrix(AVCodecContext *avctx, AVFrame *frame, enum DCADownMixType downmix_type, int output_mask, const int *coeff_l)
Definition: dcadec.c:162
ff_dca_set_channel_layout
int ff_dca_set_channel_layout(AVCodecContext *avctx, int *ch_remap, int dca_mask)
Definition: dcadec.c:48
ff_dca_lbr_filter_frame
int ff_dca_lbr_filter_frame(DCALbrDecoder *s, AVFrame *frame)
Definition: dca_lbr.c:1737
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AV_ONCE_INIT
#define AV_ONCE_INIT
Definition: thread.h:203
dca2wav_norm
static const uint8_t dca2wav_norm[28]
Definition: dcadec.c:38
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
DCA_HAS_STEREO
#define DCA_HAS_STEREO(mask)
Definition: dca.h:133
NULL
#define NULL
Definition: coverity.c:32
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
AVFloatDSPContext::vector_fmul_scalar
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
Definition: float_dsp.h:85
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:242
profiles.h
ff_dca_init_vlcs
av_cold void ff_dca_init_vlcs(void)
Definition: dcahuff.c:789
ff_dca_decoder
const FFCodec ff_dca_decoder
Definition: dcadec.c:475
OFFSET
#define OFFSET(x)
Definition: dcadec.c:447
av_frame_new_side_data_from_buf
AVFrameSideData * av_frame_new_side_data_from_buf(AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef *buf)
Add a new side data to a frame from an existing AVBufferRef.
Definition: frame.c:638
AV_OPT_TYPE_CHLAYOUT
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
Definition: opt.h:330
DCA_PACKET_CORE
#define DCA_PACKET_CORE
Definition: dcadec.h:39
DCADSPContext
Definition: dcadsp.h:30
AVOnce
#define AVOnce
Definition: thread.h:202
av_buffer_create
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
Definition: buffer.c:55
AVDownmixCoeff
double AVDownmixCoeff
Data type for storing coefficients, which are allocated as a part of AVDownmixMatrix and should be re...
Definition: downmix_info.h:144
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:88
DCA_SYNCWORD_CORE_BE
#define DCA_SYNCWORD_CORE_BE
Definition: dca_syncwords.h:22
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:608
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:49
dcahuff.h
AVPacket::size
int size
Definition: packet.h:604
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:88
ff_dca_core_parse
int ff_dca_core_parse(DCACoreDecoder *s, const uint8_t *data, int size)
Definition: dca_core.c:1796
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:319
codec_internal.h
PARAM
#define PARAM
Definition: dcadec.c:448
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
AV_CODEC_ID_DTS
@ AV_CODEC_ID_DTS
Definition: codec_id.h:456
size
int size
Definition: twinvq_data.h:10344
AV_RB32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
Definition: bytestream.h:96
AVFloatDSPContext
Definition: float_dsp.h:24
DCA_PACKET_RESIDUAL
#define DCA_PACKET_RESIDUAL
Core valid for residual decoding.
Definition: dcadec.h:46
av_crc_get_table
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
Definition: crc.c:389
DCA_SPEAKER_R
@ DCA_SPEAKER_R
Definition: dca.h:78
AVDownmixType
AVDownmixType
Possible downmix types.
Definition: downmix_info.h:45
DCADownMixType
DCADownMixType
Definition: dca.h:185
input
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
Definition: filter_design.txt:172
av_channel_layout_compare
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
Definition: channel_layout.c:811
av_channel_layout_custom_init
int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels)
Initialize a custom channel layout with the specified number of channels.
Definition: channel_layout.c:233
ff_dca_core_init
av_cold int ff_dca_core_init(DCACoreDecoder *s)
Definition: dca_core.c:2422
DCADSPContext::dmix_add
void(* dmix_add)(int32_t *dst, const int32_t *src, int coeff, ptrdiff_t len)
Definition: dcadsp.h:80
ff_dca_exss_parse
int ff_dca_exss_parse(DCAExssParser *s, const uint8_t *data, int size)
Definition: dca_exss.c:378
CHANNEL_ORDER_CODED
@ CHANNEL_ORDER_CODED
Definition: aacdec.h:63
DCAContext
Definition: dcadec.h:53
ff_dcadsp_init
av_cold void ff_dcadsp_init(DCADSPContext *s)
Definition: dcadsp.c:461
AV_CRC_16_CCITT
@ AV_CRC_16_CCITT
Definition: crc.h:51
AVFloatDSPContext::vector_fmac_scalar
void(* vector_fmac_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float and add to destination vector.
Definition: float_dsp.h:54
downmix_info.h
AVChannelLayout::u
union AVChannelLayout::@528 u
Details about which channels are present in this layout.
s
uint8_t s
Definition: llvidencdsp.c:39
av_fast_padded_malloc
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
Definition: utils.c:53
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:176
AV_DOWNMIX_TYPE_LORO
@ AV_DOWNMIX_TYPE_LORO
Lo/Ro 2-channel downmix (Stereo).
Definition: downmix_info.h:47
ff_dca_lbr_init
av_cold int ff_dca_lbr_init(DCALbrDecoder *s)
Definition: dca_lbr.c:1823
DCA_SYNCWORD_SUBSTREAM
#define DCA_SYNCWORD_SUBSTREAM
Definition: dca_syncwords.h:32
ff_dca_core_filter_fixed
int ff_dca_core_filter_fixed(DCACoreDecoder *s, int x96_synth)
Definition: dca_core.c:1957
ff_dca_xll_filter_frame
int ff_dca_xll_filter_frame(DCAXllDecoder *s, AVFrame *frame)
Definition: dca_xll.c:1352
ff_dca_lbr_flush
av_cold void ff_dca_lbr_flush(DCALbrDecoder *s)
Definition: dca_lbr.c:1799
ret
ret
Definition: filter_design.txt:187
ff_dca_core_parse_exss
int ff_dca_core_parse_exss(DCACoreDecoder *s, const uint8_t *data, DCAExssAsset *asset)
Definition: dca_core.c:1829
DCA_PACKET_EXSS
#define DCA_PACKET_EXSS
Definition: dcadec.h:40
ff_dca_lbr_close
av_cold void ff_dca_lbr_close(DCALbrDecoder *s)
Definition: dca_lbr.c:1832
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:81
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:265
AVDownmixMatrix
This structure describes optional metadata relevant to a downmix procedure in the form of a remixing ...
Definition: downmix_info.h:116
pos
unsigned int pos
Definition: spdifenc.c:414
CHANNEL_ORDER_DEFAULT
@ CHANNEL_ORDER_DEFAULT
Definition: aacdec.h:62
dcadec_class
static const AVClass dcadec_class
Definition: dcadec.c:467
U
#define U(x)
Definition: vpx_arith.h:37
AVCodecContext
main external API structure.
Definition: avcodec.h:443
channel_layout.h
MAX_PACKET_SIZE
#define MAX_PACKET_SIZE
Definition: dcadec.c:35
av_channel_layout_index_from_channel
int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout, enum AVChannel channel)
Get the index of a given channel in a channel layout.
Definition: channel_layout.c:715
DCA_PACKET_MASK
#define DCA_PACKET_MASK
Definition: dcadec.h:43
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:258
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:443
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
av_downmix_matrix_alloc
AVDownmixMatrix * av_downmix_matrix_alloc(enum AVDownmixType type, int in_ch_count, size_t *out_size)
Allocates memory for AVDownmixMatrix of the given type, plus an array of.
Definition: downmix_info.c:53
mem.h
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:278
DCAExssAsset::extension_mask
int extension_mask
Coding components used in asset.
Definition: dca_exss.h:45
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
MIN_PACKET_SIZE
#define MIN_PACKET_SIZE
Definition: dcadec.c:34
AVPacket
This structure stores compressed data.
Definition: packet.h:580
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:470
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:326
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
ff_dca_xll_flush
av_cold void ff_dca_xll_flush(DCAXllDecoder *s)
Definition: dca_xll.c:1519
int32_t
int32_t
Definition: audioconvert.c:56
DCA_SPEAKER_COUNT
@ DCA_SPEAKER_COUNT
Definition: dca.h:87
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
DCA_SPEAKER_L
@ DCA_SPEAKER_L
Definition: dca.h:78
AV_CHANNEL_LAYOUT_5POINT0
#define AV_CHANNEL_LAYOUT_5POINT0
Definition: channel_layout.h:404
AV_CHANNEL_LAYOUT_5POINT1
#define AV_CHANNEL_LAYOUT_5POINT1
Definition: channel_layout.h:405
AV_DOWNMIX_TYPE_LTRT
@ AV_DOWNMIX_TYPE_LTRT
Lt/Rt 2-channel downmix, Dolby Surround compatible.
Definition: downmix_info.h:48
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:298
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
ff_dca_xll_close
av_cold void ff_dca_xll_close(DCAXllDecoder *s)
Definition: dca_xll.c:1524
AVChannelCustom::id
enum AVChannel id
Definition: channel_layout.h:284
DCA_EXSS_LBR
@ DCA_EXSS_LBR
Definition: dca.h:178
ff_dca_core_flush
av_cold void ff_dca_core_flush(DCACoreDecoder *s)
Definition: dca_core.c:2409