Coverage Report

Created: 2026-01-16 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libavif/ext/aom/aom_dsp/bitwriter.c
Line
Count
Source
1
/*
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3
 *
4
 * This source code is subject to the terms of the BSD 2 Clause License and
5
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6
 * was not distributed with this source code in the LICENSE file, you can
7
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8
 * Media Patent License 1.0 was not distributed with this source code in the
9
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10
 */
11
12
#include <string.h>
13
#include "aom_dsp/bitwriter.h"
14
15
305k
void aom_start_encode(aom_writer *w, uint8_t *source) {
16
305k
  w->buffer = source;
17
305k
  w->pos = 0;
18
305k
  od_ec_enc_init(&w->ec, 62025);
19
305k
}
20
21
306k
int aom_stop_encode(aom_writer *w) {
22
306k
  int nb_bits;
23
306k
  uint32_t bytes;
24
306k
  unsigned char *data;
25
306k
  data = od_ec_enc_done(&w->ec, &bytes);
26
306k
  if (!data) {
27
0
    od_ec_enc_clear(&w->ec);
28
0
    return -1;
29
0
  }
30
306k
  nb_bits = od_ec_enc_tell(&w->ec);
31
306k
  memcpy(w->buffer, data, bytes);
32
306k
  w->pos = bytes;
33
306k
  od_ec_enc_clear(&w->ec);
34
306k
  return nb_bits;
35
306k
}
36
37
18.5M
int aom_tell_size(aom_writer *w) {
38
18.5M
  const int nb_bits = od_ec_enc_tell(&w->ec);
39
18.5M
  return nb_bits;
40
18.5M
}