Coverage Report

Created: 2022-08-24 06:15

/src/aom/av1/encoder/external_partition.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2021, 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 "av1/common/common.h"
13
#include "av1/encoder/external_partition.h"
14
15
aom_codec_err_t av1_ext_part_create(aom_ext_part_funcs_t funcs,
16
                                    aom_ext_part_config_t config,
17
0
                                    ExtPartController *ext_part_controller) {
18
0
  if (ext_part_controller == NULL) {
19
0
    return AOM_CODEC_INVALID_PARAM;
20
0
  }
21
0
  ext_part_controller->funcs = funcs;
22
0
  ext_part_controller->config = config;
23
0
  const aom_ext_part_status_t status = ext_part_controller->funcs.create_model(
24
0
      ext_part_controller->funcs.priv, &ext_part_controller->config,
25
0
      &ext_part_controller->model);
26
0
  if (status == AOM_EXT_PART_ERROR) {
27
0
    return AOM_CODEC_ERROR;
28
0
  } else if (status == AOM_EXT_PART_TEST) {
29
0
    ext_part_controller->test_mode = 1;
30
0
    ext_part_controller->ready = 0;
31
0
    return AOM_CODEC_OK;
32
0
  }
33
0
  assert(status == AOM_EXT_PART_OK);
34
0
  ext_part_controller->ready = 1;
35
0
  return AOM_CODEC_OK;
36
0
}
37
38
1.26k
aom_codec_err_t av1_ext_part_init(ExtPartController *ext_part_controller) {
39
1.26k
  if (ext_part_controller == NULL) {
40
0
    return AOM_CODEC_INVALID_PARAM;
41
0
  }
42
1.26k
  av1_zero(ext_part_controller);
43
1.26k
  return AOM_CODEC_OK;
44
1.26k
}
45
46
1.26k
aom_codec_err_t av1_ext_part_delete(ExtPartController *ext_part_controller) {
47
1.26k
  if (ext_part_controller == NULL) {
48
0
    return AOM_CODEC_INVALID_PARAM;
49
0
  }
50
1.26k
  if (ext_part_controller->ready) {
51
0
    const aom_ext_part_status_t status =
52
0
        ext_part_controller->funcs.delete_model(ext_part_controller->model);
53
0
    if (status != AOM_EXT_PART_OK) {
54
0
      return AOM_CODEC_ERROR;
55
0
    }
56
0
  }
57
1.26k
  return av1_ext_part_init(ext_part_controller);
58
1.26k
}
59
60
bool av1_ext_part_get_partition_decision(ExtPartController *ext_part_controller,
61
0
                                         aom_partition_decision_t *decision) {
62
0
  assert(ext_part_controller != NULL);
63
0
  assert(ext_part_controller->ready);
64
0
  assert(decision != NULL);
65
0
  const aom_ext_part_status_t status =
66
0
      ext_part_controller->funcs.get_partition_decision(
67
0
          ext_part_controller->model, decision);
68
0
  if (status != AOM_EXT_PART_OK) return false;
69
0
  return true;
70
0
}
71
72
bool av1_ext_part_send_partition_stats(ExtPartController *ext_part_controller,
73
0
                                       const aom_partition_stats_t *stats) {
74
0
  assert(ext_part_controller != NULL);
75
0
  assert(ext_part_controller->ready);
76
0
  assert(stats != NULL);
77
0
  const aom_ext_part_status_t status =
78
0
      ext_part_controller->funcs.send_partition_stats(
79
0
          ext_part_controller->model, stats);
80
0
  if (status != AOM_EXT_PART_OK) return false;
81
0
  return true;
82
0
}
83
84
bool av1_ext_part_send_features(ExtPartController *ext_part_controller,
85
0
                                const aom_partition_features_t *features) {
86
0
  assert(ext_part_controller != NULL);
87
0
  assert(ext_part_controller->ready);
88
0
  assert(features != NULL);
89
0
  const aom_ext_part_status_t status = ext_part_controller->funcs.send_features(
90
0
      ext_part_controller->model, features);
91
0
  if (status != AOM_EXT_PART_OK) return false;
92
0
  return true;
93
0
}
94
95
aom_ext_part_decision_mode_t av1_get_ext_part_decision_mode(
96
0
    const ExtPartController *ext_part_controller) {
97
0
  return ext_part_controller->funcs.decision_mode;
98
0
}