/* * Copyright (c) 2010 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
typedefstruct vpx_writer { unsignedint lowvalue; unsignedint range; int count; // Whether there has been an error. int error; // We maintain the invariant that pos <= size, i.e., we never write beyond // the end of the buffer. If pos would be incremented to be greater than // size, leave pos unchanged and set error to 1. unsignedint pos; unsignedint size;
uint8_t *buffer;
} vpx_writer;
void vpx_start_encode(vpx_writer *br, uint8_t *source, size_t size); // Returns 0 on success and returns -1 in case of error. int vpx_stop_encode(vpx_writer *br);
staticINLINE VPX_NO_UNSIGNED_SHIFT_CHECK void vpx_write(vpx_writer *br, int bit, int probability) { unsignedint split; int count = br->count; unsignedint range = br->range; unsignedint lowvalue = br->lowvalue; int shift;
#if CONFIG_BITSTREAM_DEBUG /* int queue_r = 0; int frame_idx_r = 0; int queue_w = bitstream_queue_get_write(); int frame_idx_w = bitstream_queue_get_frame_write(); if (frame_idx_w == frame_idx_r && queue_w == queue_r) { fprintf(stderr, "\n *** bitstream queue at frame_idx_w %d queue_w %d\n", frame_idx_w, queue_w); assert(0); }
*/
bitstream_queue_push(bit, probability); #endif
split = 1 + (((range - 1) * probability) >> 8);
range = split;
if (bit) {
lowvalue += split;
range = br->range - split;
}
shift = vpx_norm[range];
range <<= shift;
count += shift;
if (count >= 0) { int offset = shift - count;
if (!br->error) { if ((lowvalue << (offset - 1)) & 0x80000000) { int x = (int)br->pos - 1;
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.