/* * Copyright (c) 2001-2016, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
/*The entropy encoder context.*/ struct od_ec_enc { /*Buffered output. This contains only the raw bits until the final call to od_ec_enc_done(),
where all the arithmetic-coded data gets prepended to it.*/ unsignedchar *buf; /*The size of the buffer.*/
uint32_t storage; /*The offset at which the next entropy-coded byte will be written.*/
uint32_t offs; /*The low end of the current range.*/
od_ec_enc_window low; /*The number of values in the current range.*/
uint16_t rng; /*The number of bits of data in the current value.*/
int16_t cnt; /*Nonzero if an error occurred.*/ int error; #if OD_MEASURE_EC_OVERHEAD double entropy; int nb_symbols; #endif
};
// buf is the frame bitbuffer, offs is where carry to be added staticinlinevoid propagate_carry_bwd(unsignedchar *buf, uint32_t offs) {
uint16_t sum, carry = 1; do {
sum = (uint16_t)buf[offs] + 1;
buf[offs--] = (unsignedchar)sum;
carry = sum >> 8;
} while (carry);
}
// Convert to big-endian byte order and write data to buffer adding the // carry-bit staticinlinevoid write_enc_data_to_out_buf(unsignedchar *out, uint32_t offs,
uint64_t output, uint64_t carry,
uint32_t *enc_offs,
uint8_t num_bytes_ready) { const uint64_t reg = HToBE64(output << ((8 - num_bytes_ready) << 3));
memcpy(&out[offs], ®, 8); // Propagate carry backwards if exists if (carry) {
assert(offs > 0);
propagate_carry_bwd(out, offs - 1);
}
*enc_offs = offs + num_bytes_ready;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.