• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include <assert.h>
12 
13 #include "./bitwriter.h"
14 
15 #if CONFIG_BITSTREAM_DEBUG
16 #include "vpx_util/vpx_debug_util.h"
17 #endif
18 
vpx_start_encode(vpx_writer * br,uint8_t * source)19 void vpx_start_encode(vpx_writer *br, uint8_t *source) {
20   br->lowvalue = 0;
21   br->range = 255;
22   br->count = -24;
23   br->buffer = source;
24   br->pos = 0;
25   vpx_write_bit(br, 0);
26 }
27 
vpx_stop_encode(vpx_writer * br)28 void vpx_stop_encode(vpx_writer *br) {
29   int i;
30 
31 #if CONFIG_BITSTREAM_DEBUG
32   bitstream_queue_set_skip_write(1);
33 #endif
34   for (i = 0; i < 32; i++) vpx_write_bit(br, 0);
35 
36   // Ensure there's no ambigous collision with any index marker bytes
37   if ((br->buffer[br->pos - 1] & 0xe0) == 0xc0) br->buffer[br->pos++] = 0;
38 
39 #if CONFIG_BITSTREAM_DEBUG
40   bitstream_queue_set_skip_write(0);
41 #endif
42 }
43