FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mlp_parser.c
Go to the documentation of this file.
1 /*
2  * MLP parser
3  * Copyright (c) 2007 Ian Caulfield
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  * MLP parser
25  */
26 
27 #include <stdint.h>
28 
30 #include "libavutil/crc.h"
31 #include "libavutil/internal.h"
32 #include "get_bits.h"
33 #include "parser.h"
34 #include "mlp_parser.h"
35 #include "mlp.h"
36 
37 static const uint8_t mlp_quants[16] = {
38  16, 20, 24, 0, 0, 0, 0, 0,
39  0, 0, 0, 0, 0, 0, 0, 0,
40 };
41 
42 static const uint8_t mlp_channels[32] = {
43  1, 2, 3, 4, 3, 4, 5, 3, 4, 5, 4, 5, 6, 4, 5, 4,
44  5, 6, 5, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
45 };
46 
47 const uint64_t ff_mlp_layout[32] = {
52  AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY,
53  AV_CH_LAYOUT_2_1|AV_CH_LOW_FREQUENCY,
54  AV_CH_LAYOUT_QUAD|AV_CH_LOW_FREQUENCY,
58  AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY,
59  AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY,
63  AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY,
64  AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY,
66  AV_CH_LAYOUT_QUAD|AV_CH_LOW_FREQUENCY,
69  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
70 };
71 
72 static const uint8_t thd_chancount[13] = {
73 // LR C LFE LRs LRvh LRc LRrs Cs Ts LRsd LRw Cvh LFE2
74  2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1
75 };
76 
77 static const uint64_t thd_layout[13] = {
79  AV_CH_FRONT_CENTER, // C
80  AV_CH_LOW_FREQUENCY, // LFE
85  AV_CH_BACK_CENTER, // Cs
86  AV_CH_TOP_CENTER, // Ts
90  AV_CH_LOW_FREQUENCY_2, // LFE2
91 };
92 
93 static int mlp_samplerate(int in)
94 {
95  if (in == 0xF)
96  return 0;
97 
98  return (in & 8 ? 44100 : 48000) << (in & 7) ;
99 }
100 
101 static int truehd_channels(int chanmap)
102 {
103  int channels = 0, i;
104 
105  for (i = 0; i < 13; i++)
106  channels += thd_chancount[i] * ((chanmap >> i) & 1);
107 
108  return channels;
109 }
110 
111 uint64_t ff_truehd_layout(int chanmap)
112 {
113  int i;
114  uint64_t layout = 0;
115 
116  for (i = 0; i < 13; i++)
117  layout |= thd_layout[i] * ((chanmap >> i) & 1);
118 
119  return layout;
120 }
121 
122 static int ff_mlp_get_major_sync_size(const uint8_t * buf, int bufsize)
123 {
124  int has_extension, extensions = 0;
125  int size = 28;
126  if (bufsize < 28)
127  return -1;
128 
129  if (AV_RB32(buf) == 0xf8726fba) {
130  has_extension = buf[25] & 1;
131  if (has_extension) {
132  extensions = buf[26] >> 4;
133  size += 2 + extensions * 2;
134  }
135  }
136  return size;
137 }
138 
139 /** Read a major sync info header - contains high level information about
140  * the stream - sample rate, channel arrangement etc. Most of this
141  * information is not actually necessary for decoding, only for playback.
142  * gb must be a freshly initialized GetBitContext with no bits read.
143  */
144 
146 {
147  int ratebits, channel_arrangement, header_size;
148  uint16_t checksum;
149 
150  av_assert1(get_bits_count(gb) == 0);
151 
152  header_size = ff_mlp_get_major_sync_size(gb->buffer, gb->size_in_bits >> 3);
153  if (header_size < 0 || gb->size_in_bits < header_size << 3) {
154  av_log(log, AV_LOG_ERROR, "packet too short, unable to read major sync\n");
155  return -1;
156  }
157 
158  checksum = ff_mlp_checksum16(gb->buffer, header_size - 2);
159  if (checksum != AV_RL16(gb->buffer+header_size-2)) {
160  av_log(log, AV_LOG_ERROR, "major sync info header checksum error\n");
161  return AVERROR_INVALIDDATA;
162  }
163 
164  if (get_bits_long(gb, 24) != 0xf8726f) /* Sync words */
165  return AVERROR_INVALIDDATA;
166 
167  mh->stream_type = get_bits(gb, 8);
168  mh->header_size = header_size;
169 
170  if (mh->stream_type == 0xbb) {
171  mh->group1_bits = mlp_quants[get_bits(gb, 4)];
172  mh->group2_bits = mlp_quants[get_bits(gb, 4)];
173 
174  ratebits = get_bits(gb, 4);
175  mh->group1_samplerate = mlp_samplerate(ratebits);
177 
178  skip_bits(gb, 11);
179 
181  channel_arrangement = get_bits(gb, 5);
182  mh->channels_mlp = mlp_channels[channel_arrangement];
183  mh->channel_layout_mlp = ff_mlp_layout[channel_arrangement];
184  } else if (mh->stream_type == 0xba) {
185  mh->group1_bits = 24; // TODO: Is this information actually conveyed anywhere?
186  mh->group2_bits = 0;
187 
188  ratebits = get_bits(gb, 4);
189  mh->group1_samplerate = mlp_samplerate(ratebits);
190  mh->group2_samplerate = 0;
191 
192  skip_bits(gb, 4);
193 
196 
198  channel_arrangement = get_bits(gb, 5);
199  mh->channels_thd_stream1 = truehd_channels(channel_arrangement);
200  mh->channel_layout_thd_stream1 = ff_truehd_layout(channel_arrangement);
201 
203 
204  channel_arrangement = get_bits(gb, 13);
205  mh->channels_thd_stream2 = truehd_channels(channel_arrangement);
206  mh->channel_layout_thd_stream2 = ff_truehd_layout(channel_arrangement);
207  } else
208  return AVERROR_INVALIDDATA;
209 
210  mh->access_unit_size = 40 << (ratebits & 7);
211  mh->access_unit_size_pow2 = 64 << (ratebits & 7);
212 
213  skip_bits_long(gb, 48);
214 
215  mh->is_vbr = get_bits1(gb);
216 
217  mh->peak_bitrate = (get_bits(gb, 15) * mh->group1_samplerate + 8) >> 4;
218 
219  mh->num_substreams = get_bits(gb, 4);
220 
221  skip_bits_long(gb, 4 + (header_size - 17) * 8);
222 
223  return 0;
224 }
225 
226 typedef struct MLPParseContext
227 {
229 
231 
232  int in_sync;
233 
236 
238 {
239  ff_mlp_init_crc();
240  return 0;
241 }
242 
244  AVCodecContext *avctx,
245  const uint8_t **poutbuf, int *poutbuf_size,
246  const uint8_t *buf, int buf_size)
247 {
248  MLPParseContext *mp = s->priv_data;
249  int sync_present;
250  uint8_t parity_bits;
251  int next;
252  int ret;
253  int i, p = 0;
254 
255  *poutbuf_size = 0;
256  if (buf_size == 0)
257  return 0;
258 
259  if (!mp->in_sync) {
260  // Not in sync - find a major sync header
261 
262  for (i = 0; i < buf_size; i++) {
263  mp->pc.state = (mp->pc.state << 8) | buf[i];
264  if ((mp->pc.state & 0xfffffffe) == 0xf8726fba &&
265  // ignore if we do not have the data for the start of header
266  mp->pc.index + i >= 7) {
267  mp->in_sync = 1;
268  mp->bytes_left = 0;
269  break;
270  }
271  }
272 
273  if (!mp->in_sync) {
274  if (ff_combine_frame(&mp->pc, END_NOT_FOUND, &buf, &buf_size) != -1)
275  av_log(avctx, AV_LOG_WARNING, "ff_combine_frame failed\n");
276  return buf_size;
277  }
278 
279  if ((ret = ff_combine_frame(&mp->pc, i - 7, &buf, &buf_size)) < 0) {
280  av_log(avctx, AV_LOG_WARNING, "ff_combine_frame failed\n");
281  return ret;
282  }
283 
284  return i - 7;
285  }
286 
287  if (mp->bytes_left == 0) {
288  // Find length of this packet
289 
290  /* Copy overread bytes from last frame into buffer. */
291  for(; mp->pc.overread>0; mp->pc.overread--) {
292  mp->pc.buffer[mp->pc.index++]= mp->pc.buffer[mp->pc.overread_index++];
293  }
294 
295  if (mp->pc.index + buf_size < 2) {
296  if (ff_combine_frame(&mp->pc, END_NOT_FOUND, &buf, &buf_size) != -1)
297  av_log(avctx, AV_LOG_WARNING, "ff_combine_frame failed\n");
298  return buf_size;
299  }
300 
301  mp->bytes_left = ((mp->pc.index > 0 ? mp->pc.buffer[0] : buf[0]) << 8)
302  | (mp->pc.index > 1 ? mp->pc.buffer[1] : buf[1-mp->pc.index]);
303  mp->bytes_left = (mp->bytes_left & 0xfff) * 2;
304  if (mp->bytes_left <= 0) { // prevent infinite loop
305  goto lost_sync;
306  }
307  mp->bytes_left -= mp->pc.index;
308  }
309 
310  next = (mp->bytes_left > buf_size) ? END_NOT_FOUND : mp->bytes_left;
311 
312  if (ff_combine_frame(&mp->pc, next, &buf, &buf_size) < 0) {
313  mp->bytes_left -= buf_size;
314  return buf_size;
315  }
316 
317  mp->bytes_left = 0;
318 
319  sync_present = (AV_RB32(buf + 4) & 0xfffffffe) == 0xf8726fba;
320 
321  if (!sync_present) {
322  /* The first nibble of a frame is a parity check of the 4-byte
323  * access unit header and all the 2- or 4-byte substream headers. */
324  // Only check when this isn't a sync frame - syncs have a checksum.
325 
326  parity_bits = 0;
327  for (i = -1; i < mp->num_substreams; i++) {
328  parity_bits ^= buf[p++];
329  parity_bits ^= buf[p++];
330 
331  if (i < 0 || buf[p-2] & 0x80) {
332  parity_bits ^= buf[p++];
333  parity_bits ^= buf[p++];
334  }
335  }
336 
337  if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) {
338  av_log(avctx, AV_LOG_INFO, "mlpparse: Parity check failed.\n");
339  goto lost_sync;
340  }
341  } else {
342  GetBitContext gb;
344 
345  init_get_bits(&gb, buf + 4, (buf_size - 4) << 3);
346  if (ff_mlp_read_major_sync(avctx, &mh, &gb) < 0)
347  goto lost_sync;
348 
349  avctx->bits_per_raw_sample = mh.group1_bits;
350  if (avctx->bits_per_raw_sample > 16)
351  avctx->sample_fmt = AV_SAMPLE_FMT_S32;
352  else
353  avctx->sample_fmt = AV_SAMPLE_FMT_S16;
354  avctx->sample_rate = mh.group1_samplerate;
355  s->duration = mh.access_unit_size;
356 
357  if(!avctx->channels || !avctx->channel_layout) {
358  if (mh.stream_type == 0xbb) {
359  /* MLP stream */
360  if (avctx->request_channel_layout &&
362  avctx->request_channel_layout &&
363  mh.num_substreams > 1) {
364  avctx->channels = 2;
366  } else {
367  avctx->channels = mh.channels_mlp;
369  }
370  } else { /* mh.stream_type == 0xba */
371  /* TrueHD stream */
372  if (avctx->request_channel_layout &&
374  avctx->request_channel_layout &&
375  mh.num_substreams > 1) {
376  avctx->channels = 2;
378  } else if (!mh.channels_thd_stream2 ||
379  (avctx->request_channel_layout &&
381  avctx->request_channel_layout)) {
382  avctx->channels = mh.channels_thd_stream1;
384  } else {
385  avctx->channels = mh.channels_thd_stream2;
387  }
388  }
389  }
390 
391  if (!mh.is_vbr) /* Stream is CBR */
392  avctx->bit_rate = mh.peak_bitrate;
393 
395  }
396 
397  *poutbuf = buf;
398  *poutbuf_size = buf_size;
399 
400  return next;
401 
402 lost_sync:
403  mp->in_sync = 0;
404  return 1;
405 }
406 
409  .priv_data_size = sizeof(MLPParseContext),
410  .parser_init = mlp_init,
411  .parser_parse = mlp_parse,
412  .parser_close = ff_parse_close,
413 };
int channels_thd_stream1
Channel count for substream 1 of TrueHD streams ("6-channel presentation")
Definition: mlp_parser.h:50
const char * s
Definition: avisynth_c.h:768
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
#define AV_CH_TOP_FRONT_RIGHT
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:247
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
int64_t bit_rate
the average bitrate
Definition: avcodec.h:1724
#define AV_CH_LAYOUT_SURROUND
uint16_t ff_mlp_checksum16(const uint8_t *buf, unsigned int buf_size)
Definition: mlp.c:64
static void skip_bits_long(GetBitContext *s, int n)
Definition: get_bits.h:204
#define AV_CH_TOP_FRONT_LEFT
int num_substreams
Number of substreams within stream.
Definition: mlp_parser.h:62
#define AV_CH_TOP_FRONT_CENTER
int codec_ids[5]
Definition: avcodec.h:5122
#define AV_CH_LOW_FREQUENCY_2
const uint8_t * buffer
Definition: get_bits.h:56
#define AV_CH_LAYOUT_4POINT0
uint64_t channel_layout_mlp
Channel layout for MLP streams.
Definition: mlp_parser.h:52
int duration
Duration of the current frame.
Definition: avcodec.h:5076
#define AV_CH_SURROUND_DIRECT_RIGHT
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:3060
#define AV_CH_LAYOUT_STEREO
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
Definition: bytestream.h:87
int access_unit_size
Number of samples per coded frame.
Definition: mlp_parser.h:56
int peak_bitrate
Peak bitrate for VBR, actual bitrate (==peak) for CBR.
Definition: mlp_parser.h:60
#define AV_CH_WIDE_LEFT
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:2429
uint8_t
#define av_cold
Definition: attributes.h:82
int channel_modifier_thd_stream0
Channel modifier for substream 0 of TrueHD streams ("2-channel presentation")
Definition: mlp_parser.h:45
static const uint64_t thd_layout[13]
Definition: mlp_parser.c:77
#define AV_CH_WIDE_RIGHT
ParseContext pc
Definition: mlp_parser.c:228
#define AV_CH_LOW_FREQUENCY
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:87
Public header for CRC hash function implementation.
static int mlp_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
Definition: mlp_parser.c:243
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:199
uint64_t ff_truehd_layout(int chanmap)
Definition: mlp_parser.c:111
bitstream reader API header.
#define AV_CH_BACK_LEFT
static const uint8_t mlp_channels[32]
Definition: mlp_parser.c:42
int channel_arrangement
Definition: mlp_parser.h:43
ptrdiff_t size
Definition: opengl_enc.c:101
signed 32 bits
Definition: samplefmt.h:62
#define av_log(a,...)
AVCodecParser ff_mlp_parser
Definition: mlp_parser.c:407
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
int channel_modifier_thd_stream2
Channel modifier for substream 2 of TrueHD streams ("8-channel presentation")
Definition: mlp_parser.h:47
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
Definition: parser.c:245
static int truehd_channels(int chanmap)
Definition: mlp_parser.c:101
int channels_mlp
Channel count for MLP streams.
Definition: mlp_parser.h:49
#define AV_CH_LAYOUT_QUAD
int overread_index
the index into ParseContext.buffer of the overread bytes
Definition: parser.h:36
uint64_t channel_layout
Audio channel layout.
Definition: avcodec.h:2472
#define AV_CH_LAYOUT_2_1
void ff_parse_close(AVCodecParserContext *s)
Definition: parser.c:321
common internal API header
#define AV_CH_TOP_CENTER
audio channel layout utility functions
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
int overread
the number of bytes which where irreversibly read from the next frame
Definition: parser.h:35
int size_in_bits
Definition: get_bits.h:58
MLP parser prototypes.
int is_vbr
Stream is VBR instead of CBR.
Definition: mlp_parser.h:59
#define AV_CH_FRONT_LEFT_OF_CENTER
#define AV_CH_FRONT_CENTER
static volatile int checksum
Definition: adler32.c:28
#define AV_CH_LAYOUT_5POINT1_BACK
#define AV_CH_FRONT_RIGHT_OF_CENTER
int stream_type
0xBB for MLP, 0xBA for TrueHD
Definition: mlp_parser.h:34
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
static const uint8_t mlp_quants[16]
Definition: mlp_parser.c:37
int access_unit_size_pow2
Next power of two above number of samples per frame.
Definition: mlp_parser.h:57
uint8_t * buffer
Definition: parser.h:29
int sample_rate
samples per second
Definition: avcodec.h:2421
static int mlp_samplerate(int in)
Definition: mlp_parser.c:93
int channel_modifier_thd_stream1
Channel modifier for substream 1 of TrueHD streams ("6-channel presentation")
Definition: mlp_parser.h:46
main external API structure.
Definition: avcodec.h:1659
#define AV_CH_FRONT_LEFT
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){if(!*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));if(!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=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);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);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) 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_log(ac->avr, AV_LOG_TRACE,"%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
void * buf
Definition: avisynth_c.h:690
uint32_t state
contains the last few bytes in MSB order
Definition: parser.h:33
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:299
const uint64_t ff_mlp_layout[32]
Definition: mlp_parser.c:47
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:292
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition: get_bits.h:406
#define AV_CH_LAYOUT_5POINT0_BACK
static int ff_mlp_get_major_sync_size(const uint8_t *buf, int bufsize)
Definition: mlp_parser.c:122
#define END_NOT_FOUND
Definition: parser.h:40
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:332
int group2_bits
Bit depth of the second substream (MLP only)
Definition: mlp_parser.h:38
#define AV_CH_BACK_CENTER
#define AV_CH_SIDE_RIGHT
int channels_thd_stream2
Channel count for substream 2 of TrueHD streams ("8-channel presentation")
Definition: mlp_parser.h:51
if(ret< 0)
Definition: vf_mcdeint.c:282
signed 16 bits
Definition: samplefmt.h:61
uint64_t channel_layout_thd_stream1
Channel layout for substream 1 of TrueHD streams ("6-channel presentation")
Definition: mlp_parser.h:53
uint64_t channel_layout_thd_stream2
Channel layout for substream 2 of TrueHD streams ("8-channel presentation")
Definition: mlp_parser.h:54
int index
Definition: parser.h:30
int header_size
Size of the major sync header, in bytes.
Definition: mlp_parser.h:35
int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb)
Read a major sync info header - contains high level information about the stream - sample rate...
Definition: mlp_parser.c:145
int channels
number of audio channels
Definition: avcodec.h:2422
int group1_bits
The bit depth of the first substream.
Definition: mlp_parser.h:37
av_cold void ff_mlp_init_crc(void)
Definition: mlp.c:54
uint64_t layout
#define AV_CH_SURROUND_DIRECT_LEFT
#define AV_CH_FRONT_RIGHT
static const uint8_t thd_chancount[13]
Definition: mlp_parser.c:72
#define AV_CH_SIDE_LEFT
int group1_samplerate
Sample rate of first substream.
Definition: mlp_parser.h:40
#define AV_CH_LAYOUT_MONO
uint64_t request_channel_layout
Request decoder to use this channel layout if it can (0 for default)
Definition: avcodec.h:2479
int group2_samplerate
Sample rate of second substream (MLP only)
Definition: mlp_parser.h:41
#define mh
#define AV_CH_BACK_RIGHT
static av_cold int mlp_init(AVCodecParserContext *s)
Definition: mlp_parser.c:237