42 int ret,
i, last_offset = 0;
45 int substream_bytes = 0;
58 if (in_size < 4 || in_size > pkt->
size) {
79 for (
int j = 0; j < 4; j++)
84 last_offset = units[
i].
offset * 2;
88 if (units[i].
bits[0]) {
96 out_size = end + 4 + last_offset;
97 if (out_size < in_size) {
98 int bpos = 0, reduce = end - have_header * 28 - substream_bytes;
99 uint16_t parity_nibble, dts =
AV_RB16(pkt->
data + 2);
106 memcpy(header, pkt->
data + 4, 28);
123 parity_nibble ^= out_size / 2;
126 uint16_t substr_hdr = 0;
128 substr_hdr |= (units[
i].
bits[0] << 15);
129 substr_hdr |= (units[
i].
bits[1] << 14);
130 substr_hdr |= (units[
i].
bits[2] << 13);
131 substr_hdr |= (units[
i].
bits[3] << 12);
134 AV_WB16(pkt->
data + have_header * 28 + 4 + bpos, substr_hdr);
136 parity_nibble ^= substr_hdr;
139 if (units[i].
bits[0]) {
147 parity_nibble ^= parity_nibble >> 8;
148 parity_nibble ^= parity_nibble >> 4;
149 parity_nibble &= 0xF;
151 auheader = (parity_nibble ^ 0xF) << 12;
152 auheader |= (out_size / 2) & 0x0fff;
156 memcpy(pkt->
data + 4, header, 28);
169 memset(&s->
hdr, 0,
sizeof(s->
hdr));
177 .
name =
"truehd_core",
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static void flush(AVCodecContext *avctx)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
const AVBitStreamFilter ff_truehd_core_bsf
uint16_t ff_mlp_checksum16(const uint8_t *buf, unsigned int buf_size)
The bitstream filter state.
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...
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_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
void * priv_data
Opaque filter-specific private data.
static void truehd_core_flush(AVBSFContext *ctx)
static av_cold int end(AVCodecContext *avctx)
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
static const uint8_t header[24]
int av_packet_make_writable(AVPacket *pkt)
Create a writable reference for the data described by a given packet, avoiding data copy if possible...
AVCodecID
Identify the syntax and semantics of the bitstream.
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
static enum AVCodecID codec_ids[]
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
static int truehd_core_filter(AVBSFContext *ctx, AVPacket *pkt)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
static unsigned int get_bits1(GetBitContext *s)
#define MAX_SUBSTREAMS
Maximum number of substreams that can be decoded.
This structure stores compressed data.
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
Called by bitstream filters to get packet for filtering.