38 16, 20, 24, 0, 0, 0, 0, 0,
39 0, 0, 0, 0, 0, 0, 0, 0,
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,
69 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
74 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1
98 return (in & 8 ? 44100 : 48000) << (in & 7) ;
105 for (i = 0; i < 13; i++)
116 for (i = 0; i < 13; i++)
117 layout |=
thd_layout[i] * ((chanmap >> i) & 1);
124 int has_extension, extensions = 0;
129 if (
AV_RB32(buf) == 0xf8726fba) {
130 has_extension = buf[25] & 1;
132 extensions = buf[26] >> 4;
133 size += 2 + extensions * 2;
147 int ratebits, channel_arrangement, header_size;
153 if (header_size < 0 || gb->size_in_bits < header_size << 3) {
181 channel_arrangement =
get_bits(gb, 5);
198 channel_arrangement =
get_bits(gb, 5);
204 channel_arrangement =
get_bits(gb, 13);
245 const uint8_t **poutbuf,
int *poutbuf_size,
265 for (i = 0; i < buf_size; i++) {
267 if ((mp->
pc.
state & 0xfffffffe) == 0xf8726fba &&
298 if (mp->
pc.
index + buf_size < 2) {
323 sync_present = (
AV_RB32(buf + 4) & 0xfffffffe) == 0xf8726fba;
332 parity_bits ^= buf[p++];
333 parity_bits ^= buf[p++];
335 if (i < 0 || buf[p-2] & 0x80) {
336 parity_bits ^= buf[p++];
337 parity_bits ^= buf[p++];
341 if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) {
385 *poutbuf_size = buf_size;
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_CH_TOP_FRONT_RIGHT
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t bit_rate
the average bitrate
#define AV_CH_LAYOUT_SURROUND
uint16_t ff_mlp_checksum16(const uint8_t *buf, unsigned int buf_size)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
#define AV_CH_TOP_FRONT_LEFT
#define AV_CH_TOP_FRONT_CENTER
#define AV_CH_LOW_FREQUENCY_2
#define AV_CH_LAYOUT_4POINT0
int duration
Duration of the current frame.
#define AV_CH_SURROUND_DIRECT_RIGHT
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
#define AV_CH_LAYOUT_STEREO
enum AVSampleFormat sample_fmt
audio sample format
static const uint64_t thd_layout[13]
#define AV_CH_LOW_FREQUENCY
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)
static int get_bits_count(const GetBitContext *s)
uint64_t ff_truehd_layout(int chanmap)
bitstream reader API header.
static const uint8_t mlp_channels[32]
AVCodecParser ff_mlp_parser
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
static int truehd_channels(int chanmap)
#define AV_CH_LAYOUT_QUAD
int overread_index
the index into ParseContext.buffer of the overread bytes
uint64_t channel_layout
Audio channel layout.
void ff_parse_close(AVCodecParserContext *s)
common internal API header
audio channel layout utility functions
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int overread
the number of bytes which where irreversibly read from the next frame
#define AV_CH_FRONT_LEFT_OF_CENTER
#define AV_CH_FRONT_CENTER
static volatile int checksum
#define AV_CH_LAYOUT_5POINT1_BACK
#define AV_CH_FRONT_RIGHT_OF_CENTER
#define AV_LOG_INFO
Standard information.
static const uint8_t mlp_quants[16]
int sample_rate
samples per second
static int mlp_samplerate(int in)
main external API structure.
uint32_t state
contains the last few bytes in MSB order
static unsigned int get_bits1(GetBitContext *s)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} 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;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
static int mlp_get_major_sync_size(const uint8_t *buf, int bufsize)
const uint64_t ff_mlp_layout[32]
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define AV_CH_LAYOUT_5POINT0_BACK
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
#define AV_CH_BACK_CENTER
#define PARSER_FLAG_COMPLETE_FRAMES
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...
int channels
number of audio channels
av_cold void ff_mlp_init_crc(void)
#define AV_CH_SURROUND_DIRECT_LEFT
#define AV_CH_FRONT_RIGHT
static const uint8_t thd_chancount[13]
#define AV_CH_LAYOUT_MONO
static av_cold int mlp_init(AVCodecParserContext *s)