vp9_writer.c 953 B

1234567891011121314151617181920212223242526272829303132333435
  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. #include <assert.h>
  11. #include "vp9/encoder/vp9_writer.h"
  12. #include "vp9/common/vp9_entropy.h"
  13. void vp9_start_encode(vp9_writer *br, uint8_t *source) {
  14. br->lowvalue = 0;
  15. br->range = 255;
  16. br->count = -24;
  17. br->buffer = source;
  18. br->pos = 0;
  19. vp9_write_bit(br, 0);
  20. }
  21. void vp9_stop_encode(vp9_writer *br) {
  22. int i;
  23. for (i = 0; i < 32; i++)
  24. vp9_write_bit(br, 0);
  25. // Ensure there's no ambigous collision with any index marker bytes
  26. if ((br->buffer[br->pos - 1] & 0xe0) == 0xc0)
  27. br->buffer[br->pos++] = 0;
  28. }