2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
2012-11-27 20:16:15 +01:00
|
|
|
#include <assert.h>
|
2015-07-20 20:05:04 +02:00
|
|
|
|
2015-07-20 20:18:57 +02:00
|
|
|
#include "./bitwriter.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2015-07-20 23:13:38 +02:00
|
|
|
void vpx_start_encode(vpx_writer *br, uint8_t *source) {
|
2012-07-14 00:21:29 +02:00
|
|
|
br->lowvalue = 0;
|
2016-07-23 05:07:03 +02:00
|
|
|
br->range = 255;
|
|
|
|
br->count = -24;
|
|
|
|
br->buffer = source;
|
|
|
|
br->pos = 0;
|
2015-07-20 23:13:38 +02:00
|
|
|
vpx_write_bit(br, 0);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2015-07-20 23:13:38 +02:00
|
|
|
void vpx_stop_encode(vpx_writer *br) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int i;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2016-07-23 05:07:03 +02:00
|
|
|
for (i = 0; i < 32; i++) vpx_write_bit(br, 0);
|
2013-03-12 22:30:18 +01:00
|
|
|
|
|
|
|
// Ensure there's no ambigous collision with any index marker bytes
|
2016-07-23 05:07:03 +02:00
|
|
|
if ((br->buffer[br->pos - 1] & 0xe0) == 0xc0) br->buffer[br->pos++] = 0;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|