49 int ret,
i, last_offset = 0;
52 int substream_bytes = 0;
65 if (in_size < 4 || in_size >
pkt->size) {
85 for (
i = 0;
i <
s->hdr.num_substreams;
i++) {
86 for (
int j = 0; j < 4; j++)
91 last_offset = units[
i].
offset * 2;
95 if (units[
i].
bits[0]) {
105 int bpos = 0, reduce = end - have_header * 28 - substream_bytes;
106 uint16_t parity_nibble, dts =
AV_RB16(
pkt->data + 2);
132 for (
i = 0;
i <
FFMIN(
s->hdr.num_substreams, 3);
i++) {
133 uint16_t substr_hdr = 0;
135 substr_hdr |= (units[
i].
bits[0] << 15);
136 substr_hdr |= (units[
i].
bits[1] << 14);
137 substr_hdr |= (units[
i].
bits[2] << 13);
138 substr_hdr |= (units[
i].
bits[3] << 12);
141 AV_WB16(
pkt->data + have_header * 28 + 4 + bpos, substr_hdr);
143 parity_nibble ^= substr_hdr;
146 if (units[
i].
bits[0]) {
154 parity_nibble ^= parity_nibble >> 8;
155 parity_nibble ^= parity_nibble >> 4;
156 parity_nibble &= 0xF;
158 auheader = (parity_nibble ^ 0xF) << 12;
159 auheader |= (
out_size / 2) & 0x0fff;
176 memset(&
s->hdr, 0,
sizeof(
s->hdr));
184 .p.name =
"truehd_core",
static enum AVCodecID codec_ids[]
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
const FFBitStreamFilter ff_truehd_core_bsf
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
Called by bitstream filters to get packet for filtering.
#define i(width, name, range_min, range_max)
#define AV_PROFILE_UNKNOWN
void(* flush)(AVBSFContext *ctx)
int(* init)(AVBSFContext *ctx)
static const uint8_t bits[8]
bitstream reader API header.
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
static unsigned int get_bits1(GetBitContext *s)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static int get_bits_count(const GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
AVCodecID
Identify the syntax and semantics of the bitstream.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int av_packet_make_writable(AVPacket *pkt)
Create a writable reference for the data described by a given packet, avoiding data copy if possible.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
uint16_t ff_mlp_checksum16(const uint8_t *buf, unsigned int buf_size)
#define MAX_SUBSTREAMS
Maximum number of substreams that can be decoded.
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,...
static const uint8_t header[24]
The bitstream filter state.
This structure stores compressed data.
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
static AVFormatContext * ctx
static int truehd_core_init(AVBSFContext *ctx)
static int truehd_core_filter(AVBSFContext *ctx, AVPacket *pkt)
static void truehd_core_flush(AVBSFContext *ctx)