Coverage Report

Created: 2026-09-03 06:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libavif/ext/aom/av1/encoder/encoder_alloc.h
Line
Count
Source
1
/*
2
 * Copyright (c) 2020, 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
#ifndef AOM_AV1_ENCODER_ENCODER_ALLOC_H_
13
#define AOM_AV1_ENCODER_ENCODER_ALLOC_H_
14
15
#include "av1/encoder/block.h"
16
#include "av1/encoder/encodeframe_utils.h"
17
#include "av1/encoder/encoder.h"
18
#include "av1/encoder/encodetxb.h"
19
#include "av1/encoder/ethread.h"
20
#include "av1/encoder/global_motion_facade.h"
21
#include "av1/encoder/intra_mode_search_utils.h"
22
#include "av1/encoder/pickcdef.h"
23
24
#ifdef __cplusplus
25
extern "C" {
26
#endif
27
28
static inline void dealloc_context_buffers_ext(
29
182k
    MBMIExtFrameBufferInfo *mbmi_ext_info) {
30
182k
  aom_free(mbmi_ext_info->frame_base);
31
182k
  mbmi_ext_info->frame_base = NULL;
32
182k
  mbmi_ext_info->alloc_size = 0;
33
182k
}
Unexecuted instantiation: av1_cx_iface.c:dealloc_context_buffers_ext
encoder.c:dealloc_context_buffers_ext
Line
Count
Source
29
94.6k
    MBMIExtFrameBufferInfo *mbmi_ext_info) {
30
94.6k
  aom_free(mbmi_ext_info->frame_base);
31
  mbmi_ext_info->frame_base = NULL;
32
94.6k
  mbmi_ext_info->alloc_size = 0;
33
94.6k
}
Unexecuted instantiation: encoder_utils.c:dealloc_context_buffers_ext
Unexecuted instantiation: ethread.c:dealloc_context_buffers_ext
Unexecuted instantiation: superres_scale.c:dealloc_context_buffers_ext
Unexecuted instantiation: svc_layercontext.c:dealloc_context_buffers_ext
Unexecuted instantiation: compound_type.c:dealloc_context_buffers_ext
encode_strategy.c:dealloc_context_buffers_ext
Line
Count
Source
29
88.3k
    MBMIExtFrameBufferInfo *mbmi_ext_info) {
30
88.3k
  aom_free(mbmi_ext_info->frame_base);
31
  mbmi_ext_info->frame_base = NULL;
32
88.3k
  mbmi_ext_info->alloc_size = 0;
33
88.3k
}
34
35
static inline void alloc_context_buffers_ext(
36
125k
    AV1_COMMON *cm, MBMIExtFrameBufferInfo *mbmi_ext_info) {
37
125k
  const CommonModeInfoParams *const mi_params = &cm->mi_params;
38
39
125k
  const int mi_alloc_size_1d = mi_size_wide[mi_params->mi_alloc_bsize];
40
125k
  const int mi_alloc_rows =
41
125k
      (mi_params->mi_rows + mi_alloc_size_1d - 1) / mi_alloc_size_1d;
42
125k
  const int mi_alloc_cols =
43
125k
      (mi_params->mi_cols + mi_alloc_size_1d - 1) / mi_alloc_size_1d;
44
125k
  const int new_ext_mi_size = mi_alloc_rows * mi_alloc_cols;
45
46
125k
  if (new_ext_mi_size > mbmi_ext_info->alloc_size) {
47
88.3k
    dealloc_context_buffers_ext(mbmi_ext_info);
48
88.3k
    CHECK_MEM_ERROR(
49
88.3k
        cm, mbmi_ext_info->frame_base,
50
88.3k
        aom_malloc(new_ext_mi_size * sizeof(*mbmi_ext_info->frame_base)));
51
88.3k
    mbmi_ext_info->alloc_size = new_ext_mi_size;
52
88.3k
  }
53
  // The stride needs to be updated regardless of whether new allocation
54
  // happened or not.
55
125k
  mbmi_ext_info->stride = mi_alloc_cols;
56
125k
}
Unexecuted instantiation: av1_cx_iface.c:alloc_context_buffers_ext
Unexecuted instantiation: encoder.c:alloc_context_buffers_ext
Unexecuted instantiation: encoder_utils.c:alloc_context_buffers_ext
Unexecuted instantiation: ethread.c:alloc_context_buffers_ext
Unexecuted instantiation: superres_scale.c:alloc_context_buffers_ext
Unexecuted instantiation: svc_layercontext.c:alloc_context_buffers_ext
Unexecuted instantiation: compound_type.c:alloc_context_buffers_ext
encode_strategy.c:alloc_context_buffers_ext
Line
Count
Source
36
125k
    AV1_COMMON *cm, MBMIExtFrameBufferInfo *mbmi_ext_info) {
37
125k
  const CommonModeInfoParams *const mi_params = &cm->mi_params;
38
39
125k
  const int mi_alloc_size_1d = mi_size_wide[mi_params->mi_alloc_bsize];
40
125k
  const int mi_alloc_rows =
41
125k
      (mi_params->mi_rows + mi_alloc_size_1d - 1) / mi_alloc_size_1d;
42
125k
  const int mi_alloc_cols =
43
125k
      (mi_params->mi_cols + mi_alloc_size_1d - 1) / mi_alloc_size_1d;
44
125k
  const int new_ext_mi_size = mi_alloc_rows * mi_alloc_cols;
45
46
125k
  if (new_ext_mi_size > mbmi_ext_info->alloc_size) {
47
88.3k
    dealloc_context_buffers_ext(mbmi_ext_info);
48
88.3k
    CHECK_MEM_ERROR(
49
88.3k
        cm, mbmi_ext_info->frame_base,
50
88.3k
        aom_malloc(new_ext_mi_size * sizeof(*mbmi_ext_info->frame_base)));
51
88.3k
    mbmi_ext_info->alloc_size = new_ext_mi_size;
52
88.3k
  }
53
  // The stride needs to be updated regardless of whether new allocation
54
  // happened or not.
55
125k
  mbmi_ext_info->stride = mi_alloc_cols;
56
125k
}
57
58
182k
static inline void alloc_compressor_data(AV1_COMP *cpi) {
59
182k
  AV1_COMMON *cm = &cpi->common;
60
182k
  CommonModeInfoParams *const mi_params = &cm->mi_params;
61
62
  // Setup mi_params
63
182k
  mi_params->set_mb_mi(mi_params, cm->width, cm->height,
64
182k
                       cpi->sf.part_sf.default_min_partition_size);
65
66
182k
  if (!is_stat_generation_stage(cpi)) av1_alloc_txb_buf(cpi);
67
68
182k
  aom_free(cpi->td.mv_costs_alloc);
69
182k
  cpi->td.mv_costs_alloc = NULL;
70
  // Avoid the memory allocation of 'mv_costs_alloc' for allintra encoding
71
  // mode.
72
182k
  if (cpi->oxcf.kf_cfg.key_freq_max != 0) {
73
42.5k
    CHECK_MEM_ERROR(cm, cpi->td.mv_costs_alloc,
74
42.5k
                    (MvCosts *)aom_calloc(1, sizeof(*cpi->td.mv_costs_alloc)));
75
42.5k
    cpi->td.mb.mv_costs = cpi->td.mv_costs_alloc;
76
42.5k
  }
77
78
182k
  av1_setup_shared_coeff_buffer(cm->seq_params, &cpi->td.shared_coeff_buf,
79
182k
                                cm->error);
80
182k
  if (av1_setup_sms_tree(cpi, &cpi->td)) {
81
0
    aom_internal_error(cm->error, AOM_CODEC_MEM_ERROR,
82
0
                       "Failed to allocate SMS tree");
83
0
  }
84
182k
  cpi->td.firstpass_ctx =
85
182k
      av1_alloc_pmc(cpi, BLOCK_16X16, &cpi->td.shared_coeff_buf);
86
182k
  if (!cpi->td.firstpass_ctx)
87
0
    aom_internal_error(cm->error, AOM_CODEC_MEM_ERROR,
88
0
                       "Failed to allocate PICK_MODE_CONTEXT");
89
182k
}
Unexecuted instantiation: av1_cx_iface.c:alloc_compressor_data
encoder.c:alloc_compressor_data
Line
Count
Source
58
182k
static inline void alloc_compressor_data(AV1_COMP *cpi) {
59
182k
  AV1_COMMON *cm = &cpi->common;
60
182k
  CommonModeInfoParams *const mi_params = &cm->mi_params;
61
62
  // Setup mi_params
63
182k
  mi_params->set_mb_mi(mi_params, cm->width, cm->height,
64
182k
                       cpi->sf.part_sf.default_min_partition_size);
65
66
182k
  if (!is_stat_generation_stage(cpi)) av1_alloc_txb_buf(cpi);
67
68
182k
  aom_free(cpi->td.mv_costs_alloc);
69
182k
  cpi->td.mv_costs_alloc = NULL;
70
  // Avoid the memory allocation of 'mv_costs_alloc' for allintra encoding
71
  // mode.
72
182k
  if (cpi->oxcf.kf_cfg.key_freq_max != 0) {
73
42.5k
    CHECK_MEM_ERROR(cm, cpi->td.mv_costs_alloc,
74
42.5k
                    (MvCosts *)aom_calloc(1, sizeof(*cpi->td.mv_costs_alloc)));
75
42.5k
    cpi->td.mb.mv_costs = cpi->td.mv_costs_alloc;
76
42.5k
  }
77
78
182k
  av1_setup_shared_coeff_buffer(cm->seq_params, &cpi->td.shared_coeff_buf,
79
182k
                                cm->error);
80
182k
  if (av1_setup_sms_tree(cpi, &cpi->td)) {
81
0
    aom_internal_error(cm->error, AOM_CODEC_MEM_ERROR,
82
0
                       "Failed to allocate SMS tree");
83
0
  }
84
182k
  cpi->td.firstpass_ctx =
85
182k
      av1_alloc_pmc(cpi, BLOCK_16X16, &cpi->td.shared_coeff_buf);
86
182k
  if (!cpi->td.firstpass_ctx)
87
0
    aom_internal_error(cm->error, AOM_CODEC_MEM_ERROR,
88
0
                       "Failed to allocate PICK_MODE_CONTEXT");
89
182k
}
Unexecuted instantiation: encoder_utils.c:alloc_compressor_data
Unexecuted instantiation: ethread.c:alloc_compressor_data
Unexecuted instantiation: superres_scale.c:alloc_compressor_data
Unexecuted instantiation: svc_layercontext.c:alloc_compressor_data
Unexecuted instantiation: compound_type.c:alloc_compressor_data
Unexecuted instantiation: encode_strategy.c:alloc_compressor_data
90
91
// Allocate mbmi buffers which are used to store mode information at block
92
// level.
93
143k
static inline void alloc_mb_mode_info_buffers(AV1_COMP *const cpi) {
94
143k
  AV1_COMMON *const cm = &cpi->common;
95
143k
  if (av1_alloc_context_buffers(cm, cm->width, cm->height,
96
143k
                                cpi->sf.part_sf.default_min_partition_size)) {
97
0
    aom_internal_error(cm->error, AOM_CODEC_MEM_ERROR,
98
0
                       "Failed to allocate context buffers");
99
0
  }
100
101
143k
  if (!is_stat_generation_stage(cpi))
102
125k
    alloc_context_buffers_ext(cm, &cpi->mbmi_ext_info);
103
143k
}
Unexecuted instantiation: av1_cx_iface.c:alloc_mb_mode_info_buffers
Unexecuted instantiation: encoder.c:alloc_mb_mode_info_buffers
Unexecuted instantiation: encoder_utils.c:alloc_mb_mode_info_buffers
Unexecuted instantiation: ethread.c:alloc_mb_mode_info_buffers
Unexecuted instantiation: superres_scale.c:alloc_mb_mode_info_buffers
Unexecuted instantiation: svc_layercontext.c:alloc_mb_mode_info_buffers
Unexecuted instantiation: compound_type.c:alloc_mb_mode_info_buffers
encode_strategy.c:alloc_mb_mode_info_buffers
Line
Count
Source
93
143k
static inline void alloc_mb_mode_info_buffers(AV1_COMP *const cpi) {
94
143k
  AV1_COMMON *const cm = &cpi->common;
95
143k
  if (av1_alloc_context_buffers(cm, cm->width, cm->height,
96
143k
                                cpi->sf.part_sf.default_min_partition_size)) {
97
0
    aom_internal_error(cm->error, AOM_CODEC_MEM_ERROR,
98
0
                       "Failed to allocate context buffers");
99
0
  }
100
101
143k
  if (!is_stat_generation_stage(cpi))
102
125k
    alloc_context_buffers_ext(cm, &cpi->mbmi_ext_info);
103
143k
}
104
105
182k
static inline void realloc_segmentation_maps(AV1_COMP *cpi) {
106
182k
  AV1_COMMON *const cm = &cpi->common;
107
182k
  CommonModeInfoParams *const mi_params = &cm->mi_params;
108
109
  // Create the encoder segmentation map and set all entries to 0
110
182k
  aom_free(cpi->enc_seg.map);
111
182k
  CHECK_MEM_ERROR(cm, cpi->enc_seg.map,
112
182k
                  aom_calloc(mi_params->mi_rows * mi_params->mi_cols, 1));
113
114
  // Create a map used for cyclic background refresh.
115
182k
  if (cpi->cyclic_refresh) av1_cyclic_refresh_free(cpi->cyclic_refresh);
116
182k
  CHECK_MEM_ERROR(
117
182k
      cm, cpi->cyclic_refresh,
118
182k
      av1_cyclic_refresh_alloc(mi_params->mi_rows, mi_params->mi_cols));
119
120
  // Create a map used to mark inactive areas.
121
182k
  aom_free(cpi->active_map.map);
122
182k
  CHECK_MEM_ERROR(cm, cpi->active_map.map,
123
182k
                  aom_calloc(mi_params->mi_rows * mi_params->mi_cols, 1));
124
182k
}
Unexecuted instantiation: av1_cx_iface.c:realloc_segmentation_maps
encoder.c:realloc_segmentation_maps
Line
Count
Source
105
182k
static inline void realloc_segmentation_maps(AV1_COMP *cpi) {
106
182k
  AV1_COMMON *const cm = &cpi->common;
107
182k
  CommonModeInfoParams *const mi_params = &cm->mi_params;
108
109
  // Create the encoder segmentation map and set all entries to 0
110
182k
  aom_free(cpi->enc_seg.map);
111
182k
  CHECK_MEM_ERROR(cm, cpi->enc_seg.map,
112
182k
                  aom_calloc(mi_params->mi_rows * mi_params->mi_cols, 1));
113
114
  // Create a map used for cyclic background refresh.
115
182k
  if (cpi->cyclic_refresh) av1_cyclic_refresh_free(cpi->cyclic_refresh);
116
182k
  CHECK_MEM_ERROR(
117
182k
      cm, cpi->cyclic_refresh,
118
182k
      av1_cyclic_refresh_alloc(mi_params->mi_rows, mi_params->mi_cols));
119
120
  // Create a map used to mark inactive areas.
121
182k
  aom_free(cpi->active_map.map);
122
  CHECK_MEM_ERROR(cm, cpi->active_map.map,
123
182k
                  aom_calloc(mi_params->mi_rows * mi_params->mi_cols, 1));
124
182k
}
Unexecuted instantiation: encoder_utils.c:realloc_segmentation_maps
Unexecuted instantiation: ethread.c:realloc_segmentation_maps
Unexecuted instantiation: superres_scale.c:realloc_segmentation_maps
Unexecuted instantiation: svc_layercontext.c:realloc_segmentation_maps
Unexecuted instantiation: compound_type.c:realloc_segmentation_maps
Unexecuted instantiation: encode_strategy.c:realloc_segmentation_maps
125
126
static inline void alloc_obmc_buffers(OBMCBuffer *obmc_buffer,
127
38.1k
                                      struct aom_internal_error_info *error) {
128
38.1k
  AOM_CHECK_MEM_ERROR(
129
38.1k
      error, obmc_buffer->wsrc,
130
38.1k
      (int32_t *)aom_memalign(16, MAX_SB_SQUARE * sizeof(*obmc_buffer->wsrc)));
131
38.1k
  AOM_CHECK_MEM_ERROR(
132
38.1k
      error, obmc_buffer->mask,
133
38.1k
      (int32_t *)aom_memalign(16, MAX_SB_SQUARE * sizeof(*obmc_buffer->mask)));
134
38.1k
  AOM_CHECK_MEM_ERROR(
135
38.1k
      error, obmc_buffer->above_pred,
136
38.1k
      (uint8_t *)aom_memalign(
137
38.1k
          16, MAX_MB_PLANE * MAX_SB_SQUARE * sizeof(*obmc_buffer->above_pred)));
138
38.1k
  AOM_CHECK_MEM_ERROR(
139
38.1k
      error, obmc_buffer->left_pred,
140
38.1k
      (uint8_t *)aom_memalign(
141
38.1k
          16, MAX_MB_PLANE * MAX_SB_SQUARE * sizeof(*obmc_buffer->left_pred)));
142
38.1k
}
Unexecuted instantiation: av1_cx_iface.c:alloc_obmc_buffers
encoder.c:alloc_obmc_buffers
Line
Count
Source
127
24.6k
                                      struct aom_internal_error_info *error) {
128
24.6k
  AOM_CHECK_MEM_ERROR(
129
24.6k
      error, obmc_buffer->wsrc,
130
24.6k
      (int32_t *)aom_memalign(16, MAX_SB_SQUARE * sizeof(*obmc_buffer->wsrc)));
131
24.6k
  AOM_CHECK_MEM_ERROR(
132
24.6k
      error, obmc_buffer->mask,
133
24.6k
      (int32_t *)aom_memalign(16, MAX_SB_SQUARE * sizeof(*obmc_buffer->mask)));
134
24.6k
  AOM_CHECK_MEM_ERROR(
135
24.6k
      error, obmc_buffer->above_pred,
136
24.6k
      (uint8_t *)aom_memalign(
137
24.6k
          16, MAX_MB_PLANE * MAX_SB_SQUARE * sizeof(*obmc_buffer->above_pred)));
138
  AOM_CHECK_MEM_ERROR(
139
24.6k
      error, obmc_buffer->left_pred,
140
24.6k
      (uint8_t *)aom_memalign(
141
24.6k
          16, MAX_MB_PLANE * MAX_SB_SQUARE * sizeof(*obmc_buffer->left_pred)));
142
24.6k
}
Unexecuted instantiation: encoder_utils.c:alloc_obmc_buffers
ethread.c:alloc_obmc_buffers
Line
Count
Source
127
13.4k
                                      struct aom_internal_error_info *error) {
128
13.4k
  AOM_CHECK_MEM_ERROR(
129
13.4k
      error, obmc_buffer->wsrc,
130
13.4k
      (int32_t *)aom_memalign(16, MAX_SB_SQUARE * sizeof(*obmc_buffer->wsrc)));
131
13.4k
  AOM_CHECK_MEM_ERROR(
132
13.4k
      error, obmc_buffer->mask,
133
13.4k
      (int32_t *)aom_memalign(16, MAX_SB_SQUARE * sizeof(*obmc_buffer->mask)));
134
13.4k
  AOM_CHECK_MEM_ERROR(
135
13.4k
      error, obmc_buffer->above_pred,
136
13.4k
      (uint8_t *)aom_memalign(
137
13.4k
          16, MAX_MB_PLANE * MAX_SB_SQUARE * sizeof(*obmc_buffer->above_pred)));
138
  AOM_CHECK_MEM_ERROR(
139
13.4k
      error, obmc_buffer->left_pred,
140
13.4k
      (uint8_t *)aom_memalign(
141
13.4k
          16, MAX_MB_PLANE * MAX_SB_SQUARE * sizeof(*obmc_buffer->left_pred)));
142
13.4k
}
Unexecuted instantiation: superres_scale.c:alloc_obmc_buffers
Unexecuted instantiation: svc_layercontext.c:alloc_obmc_buffers
Unexecuted instantiation: compound_type.c:alloc_obmc_buffers
Unexecuted instantiation: encode_strategy.c:alloc_obmc_buffers
143
144
697k
static inline void release_obmc_buffers(OBMCBuffer *obmc_buffer) {
145
697k
  aom_free(obmc_buffer->mask);
146
697k
  aom_free(obmc_buffer->above_pred);
147
697k
  aom_free(obmc_buffer->left_pred);
148
697k
  aom_free(obmc_buffer->wsrc);
149
150
697k
  obmc_buffer->mask = NULL;
151
697k
  obmc_buffer->above_pred = NULL;
152
697k
  obmc_buffer->left_pred = NULL;
153
697k
  obmc_buffer->wsrc = NULL;
154
697k
}
Unexecuted instantiation: av1_cx_iface.c:release_obmc_buffers
encoder.c:release_obmc_buffers
Line
Count
Source
144
697k
static inline void release_obmc_buffers(OBMCBuffer *obmc_buffer) {
145
697k
  aom_free(obmc_buffer->mask);
146
697k
  aom_free(obmc_buffer->above_pred);
147
697k
  aom_free(obmc_buffer->left_pred);
148
697k
  aom_free(obmc_buffer->wsrc);
149
150
697k
  obmc_buffer->mask = NULL;
151
697k
  obmc_buffer->above_pred = NULL;
152
697k
  obmc_buffer->left_pred = NULL;
153
  obmc_buffer->wsrc = NULL;
154
697k
}
Unexecuted instantiation: encoder_utils.c:release_obmc_buffers
Unexecuted instantiation: ethread.c:release_obmc_buffers
Unexecuted instantiation: superres_scale.c:release_obmc_buffers
Unexecuted instantiation: svc_layercontext.c:release_obmc_buffers
Unexecuted instantiation: compound_type.c:release_obmc_buffers
Unexecuted instantiation: encode_strategy.c:release_obmc_buffers
155
156
static inline void alloc_compound_type_rd_buffers(
157
38.1k
    struct aom_internal_error_info *error, CompoundTypeRdBuffers *const bufs) {
158
38.1k
  AOM_CHECK_MEM_ERROR(
159
38.1k
      error, bufs->pred0,
160
38.1k
      (uint8_t *)aom_memalign(16, 2 * MAX_SB_SQUARE * sizeof(*bufs->pred0)));
161
38.1k
  AOM_CHECK_MEM_ERROR(
162
38.1k
      error, bufs->pred1,
163
38.1k
      (uint8_t *)aom_memalign(16, 2 * MAX_SB_SQUARE * sizeof(*bufs->pred1)));
164
38.1k
  AOM_CHECK_MEM_ERROR(
165
38.1k
      error, bufs->residual1,
166
38.1k
      (int16_t *)aom_memalign(32, MAX_SB_SQUARE * sizeof(*bufs->residual1)));
167
38.1k
  AOM_CHECK_MEM_ERROR(
168
38.1k
      error, bufs->diff10,
169
38.1k
      (int16_t *)aom_memalign(32, MAX_SB_SQUARE * sizeof(*bufs->diff10)));
170
38.1k
  AOM_CHECK_MEM_ERROR(error, bufs->tmp_best_mask_buf,
171
38.1k
                      (uint8_t *)aom_malloc(2 * MAX_SB_SQUARE *
172
38.1k
                                            sizeof(*bufs->tmp_best_mask_buf)));
173
38.1k
}
Unexecuted instantiation: av1_cx_iface.c:alloc_compound_type_rd_buffers
encoder.c:alloc_compound_type_rd_buffers
Line
Count
Source
157
24.6k
    struct aom_internal_error_info *error, CompoundTypeRdBuffers *const bufs) {
158
24.6k
  AOM_CHECK_MEM_ERROR(
159
24.6k
      error, bufs->pred0,
160
24.6k
      (uint8_t *)aom_memalign(16, 2 * MAX_SB_SQUARE * sizeof(*bufs->pred0)));
161
24.6k
  AOM_CHECK_MEM_ERROR(
162
24.6k
      error, bufs->pred1,
163
24.6k
      (uint8_t *)aom_memalign(16, 2 * MAX_SB_SQUARE * sizeof(*bufs->pred1)));
164
24.6k
  AOM_CHECK_MEM_ERROR(
165
24.6k
      error, bufs->residual1,
166
24.6k
      (int16_t *)aom_memalign(32, MAX_SB_SQUARE * sizeof(*bufs->residual1)));
167
24.6k
  AOM_CHECK_MEM_ERROR(
168
24.6k
      error, bufs->diff10,
169
24.6k
      (int16_t *)aom_memalign(32, MAX_SB_SQUARE * sizeof(*bufs->diff10)));
170
  AOM_CHECK_MEM_ERROR(error, bufs->tmp_best_mask_buf,
171
24.6k
                      (uint8_t *)aom_malloc(2 * MAX_SB_SQUARE *
172
24.6k
                                            sizeof(*bufs->tmp_best_mask_buf)));
173
24.6k
}
Unexecuted instantiation: encoder_utils.c:alloc_compound_type_rd_buffers
ethread.c:alloc_compound_type_rd_buffers
Line
Count
Source
157
13.4k
    struct aom_internal_error_info *error, CompoundTypeRdBuffers *const bufs) {
158
13.4k
  AOM_CHECK_MEM_ERROR(
159
13.4k
      error, bufs->pred0,
160
13.4k
      (uint8_t *)aom_memalign(16, 2 * MAX_SB_SQUARE * sizeof(*bufs->pred0)));
161
13.4k
  AOM_CHECK_MEM_ERROR(
162
13.4k
      error, bufs->pred1,
163
13.4k
      (uint8_t *)aom_memalign(16, 2 * MAX_SB_SQUARE * sizeof(*bufs->pred1)));
164
13.4k
  AOM_CHECK_MEM_ERROR(
165
13.4k
      error, bufs->residual1,
166
13.4k
      (int16_t *)aom_memalign(32, MAX_SB_SQUARE * sizeof(*bufs->residual1)));
167
13.4k
  AOM_CHECK_MEM_ERROR(
168
13.4k
      error, bufs->diff10,
169
13.4k
      (int16_t *)aom_memalign(32, MAX_SB_SQUARE * sizeof(*bufs->diff10)));
170
  AOM_CHECK_MEM_ERROR(error, bufs->tmp_best_mask_buf,
171
13.4k
                      (uint8_t *)aom_malloc(2 * MAX_SB_SQUARE *
172
13.4k
                                            sizeof(*bufs->tmp_best_mask_buf)));
173
13.4k
}
Unexecuted instantiation: superres_scale.c:alloc_compound_type_rd_buffers
Unexecuted instantiation: svc_layercontext.c:alloc_compound_type_rd_buffers
Unexecuted instantiation: compound_type.c:alloc_compound_type_rd_buffers
Unexecuted instantiation: encode_strategy.c:alloc_compound_type_rd_buffers
174
175
static inline void release_compound_type_rd_buffers(
176
697k
    CompoundTypeRdBuffers *const bufs) {
177
697k
  aom_free(bufs->pred0);
178
697k
  aom_free(bufs->pred1);
179
697k
  aom_free(bufs->residual1);
180
697k
  aom_free(bufs->diff10);
181
697k
  aom_free(bufs->tmp_best_mask_buf);
182
697k
  av1_zero(*bufs);  // Set all pointers to NULL for safety.
183
697k
}
Unexecuted instantiation: av1_cx_iface.c:release_compound_type_rd_buffers
encoder.c:release_compound_type_rd_buffers
Line
Count
Source
176
697k
    CompoundTypeRdBuffers *const bufs) {
177
697k
  aom_free(bufs->pred0);
178
697k
  aom_free(bufs->pred1);
179
697k
  aom_free(bufs->residual1);
180
697k
  aom_free(bufs->diff10);
181
697k
  aom_free(bufs->tmp_best_mask_buf);
182
697k
  av1_zero(*bufs);  // Set all pointers to NULL for safety.
183
697k
}
Unexecuted instantiation: encoder_utils.c:release_compound_type_rd_buffers
Unexecuted instantiation: ethread.c:release_compound_type_rd_buffers
Unexecuted instantiation: superres_scale.c:release_compound_type_rd_buffers
Unexecuted instantiation: svc_layercontext.c:release_compound_type_rd_buffers
Unexecuted instantiation: compound_type.c:release_compound_type_rd_buffers
Unexecuted instantiation: encode_strategy.c:release_compound_type_rd_buffers
184
185
94.6k
static inline void dealloc_compressor_data(AV1_COMP *cpi) {
186
94.6k
  AV1_COMMON *const cm = &cpi->common;
187
94.6k
  TokenInfo *token_info = &cpi->token_info;
188
94.6k
  const int num_planes = av1_num_planes(cm);
189
94.6k
  dealloc_context_buffers_ext(&cpi->mbmi_ext_info);
190
191
94.6k
  aom_free(cpi->tile_data);
192
94.6k
  cpi->tile_data = NULL;
193
94.6k
  cpi->allocated_tiles = 0;
194
195
  // Delete sementation map
196
94.6k
  aom_free(cpi->enc_seg.map);
197
94.6k
  cpi->enc_seg.map = NULL;
198
199
94.6k
  av1_cyclic_refresh_free(cpi->cyclic_refresh);
200
94.6k
  cpi->cyclic_refresh = NULL;
201
202
94.6k
  aom_free(cpi->active_map.map);
203
94.6k
  cpi->active_map.map = NULL;
204
205
94.6k
  aom_free(cpi->roi.roi_map);
206
94.6k
  cpi->roi.roi_map = NULL;
207
208
94.6k
  aom_free(cpi->ssim_rdmult_scaling_factors);
209
94.6k
  cpi->ssim_rdmult_scaling_factors = NULL;
210
211
94.6k
  aom_free(cpi->tpl_rdmult_scaling_factors);
212
94.6k
  cpi->tpl_rdmult_scaling_factors = NULL;
213
214
#if CONFIG_TUNE_VMAF
215
  aom_free(cpi->vmaf_info.rdmult_scaling_factors);
216
  cpi->vmaf_info.rdmult_scaling_factors = NULL;
217
  aom_close_vmaf_model(cpi->vmaf_info.vmaf_model);
218
#endif
219
220
#if CONFIG_TUNE_BUTTERAUGLI
221
  aom_free(cpi->butteraugli_info.rdmult_scaling_factors);
222
  cpi->butteraugli_info.rdmult_scaling_factors = NULL;
223
  aom_free_frame_buffer(&cpi->butteraugli_info.source);
224
  aom_free_frame_buffer(&cpi->butteraugli_info.resized_source);
225
#endif
226
227
#if CONFIG_SALIENCY_MAP
228
  aom_free(cpi->saliency_map);
229
  aom_free(cpi->sm_scaling_factor);
230
#endif
231
232
94.6k
  release_obmc_buffers(&cpi->td.mb.obmc_buffer);
233
234
94.6k
  aom_free(cpi->td.mv_costs_alloc);
235
94.6k
  cpi->td.mv_costs_alloc = NULL;
236
94.6k
  aom_free(cpi->td.dv_costs_alloc);
237
94.6k
  cpi->td.dv_costs_alloc = NULL;
238
239
94.6k
  aom_free(cpi->td.mb.sb_stats_cache);
240
94.6k
  cpi->td.mb.sb_stats_cache = NULL;
241
242
94.6k
  aom_free(cpi->td.mb.sb_fp_stats);
243
94.6k
  cpi->td.mb.sb_fp_stats = NULL;
244
245
#if CONFIG_PARTITION_SEARCH_ORDER
246
  aom_free(cpi->td.mb.rdcost);
247
  cpi->td.mb.rdcost = NULL;
248
#endif
249
250
94.6k
  av1_free_pc_tree_recursive(cpi->td.pc_root, num_planes, 0, 0,
251
94.6k
                             cpi->sf.part_sf.partition_search_type);
252
94.6k
  cpi->td.pc_root = NULL;
253
254
283k
  for (int i = 0; i < 2; i++) {
255
189k
    aom_free(cpi->td.mb.intrabc_hash_info.hash_value_buffer[i]);
256
189k
    cpi->td.mb.intrabc_hash_info.hash_value_buffer[i] = NULL;
257
189k
  }
258
259
94.6k
  av1_hash_table_destroy(&cpi->td.mb.intrabc_hash_info.intrabc_hash_table);
260
261
94.6k
  aom_free(cm->tpl_mvs);
262
94.6k
  cm->tpl_mvs = NULL;
263
264
94.6k
  aom_free(cpi->td.pixel_gradient_info);
265
94.6k
  cpi->td.pixel_gradient_info = NULL;
266
267
94.6k
  aom_free(cpi->td.src_var_info_of_4x4_sub_blocks);
268
94.6k
  cpi->td.src_var_info_of_4x4_sub_blocks = NULL;
269
270
94.6k
  aom_free(cpi->td.vt64x64);
271
94.6k
  cpi->td.vt64x64 = NULL;
272
273
94.6k
  av1_free_pmc(cpi->td.firstpass_ctx, num_planes);
274
94.6k
  cpi->td.firstpass_ctx = NULL;
275
276
94.6k
  const int is_highbitdepth = cpi->tf_ctx.is_highbitdepth;
277
  // This call ensures that the buffers allocated by tf_alloc_and_reset_data()
278
  // in av1_temporal_filter() for single-threaded encode are freed in case an
279
  // error is encountered during temporal filtering (due to early termination
280
  // tf_dealloc_data() in av1_temporal_filter() would not be invoked).
281
94.6k
  tf_dealloc_data(&cpi->td.tf_data, is_highbitdepth);
282
283
  // This call ensures that tpl_tmp_buffers for single-threaded encode are freed
284
  // in case of an error during tpl.
285
94.6k
  tpl_dealloc_temp_buffers(&cpi->td.tpl_tmp_buffers);
286
287
  // This call ensures that the global motion (gm) data buffers for
288
  // single-threaded encode are freed in case of an error during gm.
289
94.6k
  gm_dealloc_data(&cpi->td.gm_data);
290
291
  // This call ensures that CDEF search context buffers are deallocated in case
292
  // of an error during cdef search.
293
94.6k
  av1_cdef_dealloc_data(cpi->cdef_search_ctx);
294
94.6k
  aom_free(cpi->cdef_search_ctx);
295
94.6k
  cpi->cdef_search_ctx = NULL;
296
297
94.6k
  av1_dealloc_mb_data(&cpi->td.mb, num_planes);
298
299
94.6k
  av1_dealloc_mb_wiener_var_pred_buf(&cpi->td);
300
301
94.6k
  av1_free_txb_buf(cpi);
302
94.6k
  av1_free_context_buffers(cm);
303
304
94.6k
  aom_free_frame_buffer(&cpi->last_frame_uf);
305
94.6k
#if !CONFIG_REALTIME_ONLY
306
94.6k
  av1_free_restoration_buffers(cm);
307
94.6k
  av1_free_firstpass_data(&cpi->firstpass_data);
308
94.6k
#endif
309
310
94.6k
  if (!is_stat_generation_stage(cpi)) {
311
88.3k
    av1_free_cdef_buffers(cm, &cpi->ppi->p_mt_info.cdef_worker,
312
88.3k
                          &cpi->mt_info.cdef_sync);
313
88.3k
  }
314
315
261k
  for (int plane = 0; plane < num_planes; plane++) {
316
166k
    aom_free(cpi->pick_lr_ctxt.rusi[plane]);
317
166k
    cpi->pick_lr_ctxt.rusi[plane] = NULL;
318
166k
  }
319
94.6k
  aom_free(cpi->pick_lr_ctxt.dgd_avg);
320
94.6k
  cpi->pick_lr_ctxt.dgd_avg = NULL;
321
322
94.6k
  aom_free_frame_buffer(&cpi->trial_frame_rst);
323
94.6k
  aom_free_frame_buffer(&cpi->scaled_source);
324
94.6k
  aom_free_frame_buffer(&cpi->scaled_last_source);
325
94.6k
  aom_free_frame_buffer(&cpi->orig_source);
326
94.6k
  aom_free_frame_buffer(&cpi->svc.source_last_TL0);
327
328
94.6k
  free_token_info(token_info);
329
330
94.6k
  av1_free_shared_coeff_buffer(&cpi->td.shared_coeff_buf);
331
94.6k
  av1_free_sms_tree(&cpi->td);
332
333
94.6k
  aom_free(cpi->td.mb.palette_buffer);
334
94.6k
  release_compound_type_rd_buffers(&cpi->td.mb.comp_rd_buffer);
335
94.6k
  aom_free(cpi->td.mb.tmp_conv_dst);
336
94.6k
  aom_free(cpi->td.mb.upsample_pred);
337
283k
  for (int j = 0; j < 2; ++j) {
338
189k
    aom_free(cpi->td.mb.tmp_pred_bufs[j]);
339
189k
  }
340
341
94.6k
#if CONFIG_DENOISE && !CONFIG_REALTIME_ONLY
342
94.6k
  if (cpi->denoise_and_model) {
343
0
    aom_denoise_and_model_free(cpi->denoise_and_model);
344
0
    cpi->denoise_and_model = NULL;
345
0
  }
346
94.6k
#endif
347
94.6k
#if !CONFIG_REALTIME_ONLY
348
94.6k
  if (cpi->film_grain_table) {
349
0
    aom_film_grain_table_free(cpi->film_grain_table);
350
0
    aom_free(cpi->film_grain_table);
351
0
    cpi->film_grain_table = NULL;
352
0
  }
353
94.6k
#endif
354
355
94.6k
  if (cpi->ppi->use_svc) av1_free_svc_cyclic_refresh(cpi);
356
94.6k
  aom_free(cpi->svc.layer_context);
357
94.6k
  cpi->svc.layer_context = NULL;
358
359
94.6k
  aom_free(cpi->consec_zero_mv);
360
94.6k
  cpi->consec_zero_mv = NULL;
361
94.6k
  cpi->consec_zero_mv_alloc_size = 0;
362
363
94.6k
  aom_free(cpi->src_sad_blk_64x64);
364
94.6k
  cpi->src_sad_blk_64x64 = NULL;
365
366
94.6k
  aom_free(cpi->mb_weber_stats);
367
94.6k
  cpi->mb_weber_stats = NULL;
368
369
94.6k
  if (cpi->oxcf.enable_rate_guide_deltaq) {
370
0
    aom_free(cpi->prep_rate_estimates);
371
0
    cpi->prep_rate_estimates = NULL;
372
373
0
    aom_free(cpi->ext_rate_distribution);
374
0
    cpi->ext_rate_distribution = NULL;
375
0
  }
376
377
94.6k
  aom_free(cpi->mb_delta_q);
378
94.6k
  cpi->mb_delta_q = NULL;
379
380
94.6k
#if !CONFIG_REALTIME_ONLY
381
94.6k
  av1_free_tpl_gop_stats(&cpi->extrc_tpl_gop_stats);
382
94.6k
#endif
383
94.6k
}
Unexecuted instantiation: av1_cx_iface.c:dealloc_compressor_data
encoder.c:dealloc_compressor_data
Line
Count
Source
185
94.6k
static inline void dealloc_compressor_data(AV1_COMP *cpi) {
186
94.6k
  AV1_COMMON *const cm = &cpi->common;
187
94.6k
  TokenInfo *token_info = &cpi->token_info;
188
94.6k
  const int num_planes = av1_num_planes(cm);
189
94.6k
  dealloc_context_buffers_ext(&cpi->mbmi_ext_info);
190
191
94.6k
  aom_free(cpi->tile_data);
192
94.6k
  cpi->tile_data = NULL;
193
94.6k
  cpi->allocated_tiles = 0;
194
195
  // Delete sementation map
196
94.6k
  aom_free(cpi->enc_seg.map);
197
94.6k
  cpi->enc_seg.map = NULL;
198
199
94.6k
  av1_cyclic_refresh_free(cpi->cyclic_refresh);
200
94.6k
  cpi->cyclic_refresh = NULL;
201
202
94.6k
  aom_free(cpi->active_map.map);
203
94.6k
  cpi->active_map.map = NULL;
204
205
94.6k
  aom_free(cpi->roi.roi_map);
206
94.6k
  cpi->roi.roi_map = NULL;
207
208
94.6k
  aom_free(cpi->ssim_rdmult_scaling_factors);
209
94.6k
  cpi->ssim_rdmult_scaling_factors = NULL;
210
211
94.6k
  aom_free(cpi->tpl_rdmult_scaling_factors);
212
94.6k
  cpi->tpl_rdmult_scaling_factors = NULL;
213
214
#if CONFIG_TUNE_VMAF
215
  aom_free(cpi->vmaf_info.rdmult_scaling_factors);
216
  cpi->vmaf_info.rdmult_scaling_factors = NULL;
217
  aom_close_vmaf_model(cpi->vmaf_info.vmaf_model);
218
#endif
219
220
#if CONFIG_TUNE_BUTTERAUGLI
221
  aom_free(cpi->butteraugli_info.rdmult_scaling_factors);
222
  cpi->butteraugli_info.rdmult_scaling_factors = NULL;
223
  aom_free_frame_buffer(&cpi->butteraugli_info.source);
224
  aom_free_frame_buffer(&cpi->butteraugli_info.resized_source);
225
#endif
226
227
#if CONFIG_SALIENCY_MAP
228
  aom_free(cpi->saliency_map);
229
  aom_free(cpi->sm_scaling_factor);
230
#endif
231
232
94.6k
  release_obmc_buffers(&cpi->td.mb.obmc_buffer);
233
234
94.6k
  aom_free(cpi->td.mv_costs_alloc);
235
94.6k
  cpi->td.mv_costs_alloc = NULL;
236
94.6k
  aom_free(cpi->td.dv_costs_alloc);
237
94.6k
  cpi->td.dv_costs_alloc = NULL;
238
239
94.6k
  aom_free(cpi->td.mb.sb_stats_cache);
240
94.6k
  cpi->td.mb.sb_stats_cache = NULL;
241
242
94.6k
  aom_free(cpi->td.mb.sb_fp_stats);
243
94.6k
  cpi->td.mb.sb_fp_stats = NULL;
244
245
#if CONFIG_PARTITION_SEARCH_ORDER
246
  aom_free(cpi->td.mb.rdcost);
247
  cpi->td.mb.rdcost = NULL;
248
#endif
249
250
94.6k
  av1_free_pc_tree_recursive(cpi->td.pc_root, num_planes, 0, 0,
251
94.6k
                             cpi->sf.part_sf.partition_search_type);
252
94.6k
  cpi->td.pc_root = NULL;
253
254
283k
  for (int i = 0; i < 2; i++) {
255
189k
    aom_free(cpi->td.mb.intrabc_hash_info.hash_value_buffer[i]);
256
189k
    cpi->td.mb.intrabc_hash_info.hash_value_buffer[i] = NULL;
257
189k
  }
258
259
94.6k
  av1_hash_table_destroy(&cpi->td.mb.intrabc_hash_info.intrabc_hash_table);
260
261
94.6k
  aom_free(cm->tpl_mvs);
262
94.6k
  cm->tpl_mvs = NULL;
263
264
94.6k
  aom_free(cpi->td.pixel_gradient_info);
265
94.6k
  cpi->td.pixel_gradient_info = NULL;
266
267
94.6k
  aom_free(cpi->td.src_var_info_of_4x4_sub_blocks);
268
94.6k
  cpi->td.src_var_info_of_4x4_sub_blocks = NULL;
269
270
94.6k
  aom_free(cpi->td.vt64x64);
271
94.6k
  cpi->td.vt64x64 = NULL;
272
273
94.6k
  av1_free_pmc(cpi->td.firstpass_ctx, num_planes);
274
94.6k
  cpi->td.firstpass_ctx = NULL;
275
276
94.6k
  const int is_highbitdepth = cpi->tf_ctx.is_highbitdepth;
277
  // This call ensures that the buffers allocated by tf_alloc_and_reset_data()
278
  // in av1_temporal_filter() for single-threaded encode are freed in case an
279
  // error is encountered during temporal filtering (due to early termination
280
  // tf_dealloc_data() in av1_temporal_filter() would not be invoked).
281
94.6k
  tf_dealloc_data(&cpi->td.tf_data, is_highbitdepth);
282
283
  // This call ensures that tpl_tmp_buffers for single-threaded encode are freed
284
  // in case of an error during tpl.
285
94.6k
  tpl_dealloc_temp_buffers(&cpi->td.tpl_tmp_buffers);
286
287
  // This call ensures that the global motion (gm) data buffers for
288
  // single-threaded encode are freed in case of an error during gm.
289
94.6k
  gm_dealloc_data(&cpi->td.gm_data);
290
291
  // This call ensures that CDEF search context buffers are deallocated in case
292
  // of an error during cdef search.
293
94.6k
  av1_cdef_dealloc_data(cpi->cdef_search_ctx);
294
94.6k
  aom_free(cpi->cdef_search_ctx);
295
94.6k
  cpi->cdef_search_ctx = NULL;
296
297
94.6k
  av1_dealloc_mb_data(&cpi->td.mb, num_planes);
298
299
94.6k
  av1_dealloc_mb_wiener_var_pred_buf(&cpi->td);
300
301
94.6k
  av1_free_txb_buf(cpi);
302
94.6k
  av1_free_context_buffers(cm);
303
304
94.6k
  aom_free_frame_buffer(&cpi->last_frame_uf);
305
94.6k
#if !CONFIG_REALTIME_ONLY
306
94.6k
  av1_free_restoration_buffers(cm);
307
94.6k
  av1_free_firstpass_data(&cpi->firstpass_data);
308
94.6k
#endif
309
310
94.6k
  if (!is_stat_generation_stage(cpi)) {
311
88.3k
    av1_free_cdef_buffers(cm, &cpi->ppi->p_mt_info.cdef_worker,
312
88.3k
                          &cpi->mt_info.cdef_sync);
313
88.3k
  }
314
315
261k
  for (int plane = 0; plane < num_planes; plane++) {
316
166k
    aom_free(cpi->pick_lr_ctxt.rusi[plane]);
317
166k
    cpi->pick_lr_ctxt.rusi[plane] = NULL;
318
166k
  }
319
94.6k
  aom_free(cpi->pick_lr_ctxt.dgd_avg);
320
94.6k
  cpi->pick_lr_ctxt.dgd_avg = NULL;
321
322
94.6k
  aom_free_frame_buffer(&cpi->trial_frame_rst);
323
94.6k
  aom_free_frame_buffer(&cpi->scaled_source);
324
94.6k
  aom_free_frame_buffer(&cpi->scaled_last_source);
325
94.6k
  aom_free_frame_buffer(&cpi->orig_source);
326
94.6k
  aom_free_frame_buffer(&cpi->svc.source_last_TL0);
327
328
94.6k
  free_token_info(token_info);
329
330
94.6k
  av1_free_shared_coeff_buffer(&cpi->td.shared_coeff_buf);
331
94.6k
  av1_free_sms_tree(&cpi->td);
332
333
94.6k
  aom_free(cpi->td.mb.palette_buffer);
334
94.6k
  release_compound_type_rd_buffers(&cpi->td.mb.comp_rd_buffer);
335
94.6k
  aom_free(cpi->td.mb.tmp_conv_dst);
336
94.6k
  aom_free(cpi->td.mb.upsample_pred);
337
283k
  for (int j = 0; j < 2; ++j) {
338
189k
    aom_free(cpi->td.mb.tmp_pred_bufs[j]);
339
189k
  }
340
341
94.6k
#if CONFIG_DENOISE && !CONFIG_REALTIME_ONLY
342
94.6k
  if (cpi->denoise_and_model) {
343
0
    aom_denoise_and_model_free(cpi->denoise_and_model);
344
0
    cpi->denoise_and_model = NULL;
345
0
  }
346
94.6k
#endif
347
94.6k
#if !CONFIG_REALTIME_ONLY
348
94.6k
  if (cpi->film_grain_table) {
349
0
    aom_film_grain_table_free(cpi->film_grain_table);
350
0
    aom_free(cpi->film_grain_table);
351
0
    cpi->film_grain_table = NULL;
352
0
  }
353
94.6k
#endif
354
355
94.6k
  if (cpi->ppi->use_svc) av1_free_svc_cyclic_refresh(cpi);
356
94.6k
  aom_free(cpi->svc.layer_context);
357
94.6k
  cpi->svc.layer_context = NULL;
358
359
94.6k
  aom_free(cpi->consec_zero_mv);
360
94.6k
  cpi->consec_zero_mv = NULL;
361
94.6k
  cpi->consec_zero_mv_alloc_size = 0;
362
363
94.6k
  aom_free(cpi->src_sad_blk_64x64);
364
94.6k
  cpi->src_sad_blk_64x64 = NULL;
365
366
94.6k
  aom_free(cpi->mb_weber_stats);
367
94.6k
  cpi->mb_weber_stats = NULL;
368
369
94.6k
  if (cpi->oxcf.enable_rate_guide_deltaq) {
370
0
    aom_free(cpi->prep_rate_estimates);
371
0
    cpi->prep_rate_estimates = NULL;
372
373
0
    aom_free(cpi->ext_rate_distribution);
374
0
    cpi->ext_rate_distribution = NULL;
375
0
  }
376
377
94.6k
  aom_free(cpi->mb_delta_q);
378
94.6k
  cpi->mb_delta_q = NULL;
379
380
94.6k
#if !CONFIG_REALTIME_ONLY
381
94.6k
  av1_free_tpl_gop_stats(&cpi->extrc_tpl_gop_stats);
382
94.6k
#endif
383
94.6k
}
Unexecuted instantiation: encoder_utils.c:dealloc_compressor_data
Unexecuted instantiation: ethread.c:dealloc_compressor_data
Unexecuted instantiation: superres_scale.c:dealloc_compressor_data
Unexecuted instantiation: svc_layercontext.c:dealloc_compressor_data
Unexecuted instantiation: compound_type.c:dealloc_compressor_data
Unexecuted instantiation: encode_strategy.c:dealloc_compressor_data
384
385
125k
static inline void allocate_gradient_info_for_hog(AV1_COMP *cpi) {
386
125k
  if (!is_gradient_caching_for_hog_enabled(cpi)) return;
387
388
59.4k
  PixelLevelGradientInfo *pixel_gradient_info = cpi->td.pixel_gradient_info;
389
59.4k
  if (!pixel_gradient_info) {
390
52.3k
    const AV1_COMMON *const cm = &cpi->common;
391
52.3k
    const int plane_types = PLANE_TYPES >> cm->seq_params->monochrome;
392
52.3k
    CHECK_MEM_ERROR(
393
52.3k
        cm, pixel_gradient_info,
394
52.3k
        aom_malloc(sizeof(*pixel_gradient_info) * plane_types * MAX_SB_SQUARE));
395
52.3k
    cpi->td.pixel_gradient_info = pixel_gradient_info;
396
52.3k
  }
397
398
59.4k
  cpi->td.mb.pixel_gradient_info = pixel_gradient_info;
399
59.4k
}
Unexecuted instantiation: av1_cx_iface.c:allocate_gradient_info_for_hog
encoder.c:allocate_gradient_info_for_hog
Line
Count
Source
385
125k
static inline void allocate_gradient_info_for_hog(AV1_COMP *cpi) {
386
125k
  if (!is_gradient_caching_for_hog_enabled(cpi)) return;
387
388
59.4k
  PixelLevelGradientInfo *pixel_gradient_info = cpi->td.pixel_gradient_info;
389
59.4k
  if (!pixel_gradient_info) {
390
52.3k
    const AV1_COMMON *const cm = &cpi->common;
391
52.3k
    const int plane_types = PLANE_TYPES >> cm->seq_params->monochrome;
392
52.3k
    CHECK_MEM_ERROR(
393
52.3k
        cm, pixel_gradient_info,
394
52.3k
        aom_malloc(sizeof(*pixel_gradient_info) * plane_types * MAX_SB_SQUARE));
395
52.3k
    cpi->td.pixel_gradient_info = pixel_gradient_info;
396
52.3k
  }
397
398
59.4k
  cpi->td.mb.pixel_gradient_info = pixel_gradient_info;
399
59.4k
}
Unexecuted instantiation: encoder_utils.c:allocate_gradient_info_for_hog
Unexecuted instantiation: ethread.c:allocate_gradient_info_for_hog
Unexecuted instantiation: superres_scale.c:allocate_gradient_info_for_hog
Unexecuted instantiation: svc_layercontext.c:allocate_gradient_info_for_hog
Unexecuted instantiation: compound_type.c:allocate_gradient_info_for_hog
Unexecuted instantiation: encode_strategy.c:allocate_gradient_info_for_hog
400
401
125k
static inline void allocate_src_var_of_4x4_sub_block_buf(AV1_COMP *cpi) {
402
125k
  if (!is_src_var_for_4x4_sub_blocks_caching_enabled(cpi)) return;
403
404
40.6k
  Block4x4VarInfo *source_variance_info =
405
40.6k
      cpi->td.src_var_info_of_4x4_sub_blocks;
406
40.6k
  if (!source_variance_info) {
407
40.6k
    const AV1_COMMON *const cm = &cpi->common;
408
40.6k
    const BLOCK_SIZE sb_size = cm->seq_params->sb_size;
409
40.6k
    const int mi_count_in_sb = mi_size_wide[sb_size] * mi_size_high[sb_size];
410
40.6k
    CHECK_MEM_ERROR(cm, source_variance_info,
411
40.6k
                    aom_malloc(sizeof(*source_variance_info) * mi_count_in_sb));
412
40.6k
    cpi->td.src_var_info_of_4x4_sub_blocks = source_variance_info;
413
40.6k
  }
414
415
40.6k
  cpi->td.mb.src_var_info_of_4x4_sub_blocks = source_variance_info;
416
40.6k
}
Unexecuted instantiation: av1_cx_iface.c:allocate_src_var_of_4x4_sub_block_buf
encoder.c:allocate_src_var_of_4x4_sub_block_buf
Line
Count
Source
401
125k
static inline void allocate_src_var_of_4x4_sub_block_buf(AV1_COMP *cpi) {
402
125k
  if (!is_src_var_for_4x4_sub_blocks_caching_enabled(cpi)) return;
403
404
40.6k
  Block4x4VarInfo *source_variance_info =
405
40.6k
      cpi->td.src_var_info_of_4x4_sub_blocks;
406
40.6k
  if (!source_variance_info) {
407
40.6k
    const AV1_COMMON *const cm = &cpi->common;
408
40.6k
    const BLOCK_SIZE sb_size = cm->seq_params->sb_size;
409
40.6k
    const int mi_count_in_sb = mi_size_wide[sb_size] * mi_size_high[sb_size];
410
40.6k
    CHECK_MEM_ERROR(cm, source_variance_info,
411
40.6k
                    aom_malloc(sizeof(*source_variance_info) * mi_count_in_sb));
412
40.6k
    cpi->td.src_var_info_of_4x4_sub_blocks = source_variance_info;
413
40.6k
  }
414
415
40.6k
  cpi->td.mb.src_var_info_of_4x4_sub_blocks = source_variance_info;
416
40.6k
}
Unexecuted instantiation: encoder_utils.c:allocate_src_var_of_4x4_sub_block_buf
Unexecuted instantiation: ethread.c:allocate_src_var_of_4x4_sub_block_buf
Unexecuted instantiation: superres_scale.c:allocate_src_var_of_4x4_sub_block_buf
Unexecuted instantiation: svc_layercontext.c:allocate_src_var_of_4x4_sub_block_buf
Unexecuted instantiation: compound_type.c:allocate_src_var_of_4x4_sub_block_buf
Unexecuted instantiation: encode_strategy.c:allocate_src_var_of_4x4_sub_block_buf
417
418
49.4k
static inline void variance_partition_alloc(AV1_COMP *cpi) {
419
49.4k
  AV1_COMMON *const cm = &cpi->common;
420
49.4k
  const int num_64x64_blocks = (cm->seq_params->sb_size == BLOCK_64X64) ? 1 : 4;
421
49.4k
  if (cpi->td.vt64x64) {
422
13.4k
    if (num_64x64_blocks != cpi->td.num_64x64_blocks) {
423
0
      aom_free(cpi->td.vt64x64);
424
0
      cpi->td.vt64x64 = NULL;
425
0
    }
426
13.4k
  }
427
49.4k
  if (!cpi->td.vt64x64) {
428
36.0k
    CHECK_MEM_ERROR(cm, cpi->td.vt64x64,
429
36.0k
                    aom_malloc(sizeof(*cpi->td.vt64x64) * num_64x64_blocks));
430
36.0k
    cpi->td.num_64x64_blocks = num_64x64_blocks;
431
36.0k
  }
432
49.4k
}
Unexecuted instantiation: av1_cx_iface.c:variance_partition_alloc
encoder.c:variance_partition_alloc
Line
Count
Source
418
49.4k
static inline void variance_partition_alloc(AV1_COMP *cpi) {
419
49.4k
  AV1_COMMON *const cm = &cpi->common;
420
49.4k
  const int num_64x64_blocks = (cm->seq_params->sb_size == BLOCK_64X64) ? 1 : 4;
421
49.4k
  if (cpi->td.vt64x64) {
422
13.4k
    if (num_64x64_blocks != cpi->td.num_64x64_blocks) {
423
0
      aom_free(cpi->td.vt64x64);
424
0
      cpi->td.vt64x64 = NULL;
425
0
    }
426
13.4k
  }
427
49.4k
  if (!cpi->td.vt64x64) {
428
    CHECK_MEM_ERROR(cm, cpi->td.vt64x64,
429
36.0k
                    aom_malloc(sizeof(*cpi->td.vt64x64) * num_64x64_blocks));
430
36.0k
    cpi->td.num_64x64_blocks = num_64x64_blocks;
431
36.0k
  }
432
49.4k
}
Unexecuted instantiation: encoder_utils.c:variance_partition_alloc
Unexecuted instantiation: ethread.c:variance_partition_alloc
Unexecuted instantiation: superres_scale.c:variance_partition_alloc
Unexecuted instantiation: svc_layercontext.c:variance_partition_alloc
Unexecuted instantiation: compound_type.c:variance_partition_alloc
Unexecuted instantiation: encode_strategy.c:variance_partition_alloc
433
434
static inline YV12_BUFFER_CONFIG *realloc_and_scale_source(AV1_COMP *cpi,
435
                                                           int scaled_width,
436
0
                                                           int scaled_height) {
437
0
  AV1_COMMON *cm = &cpi->common;
438
0
  const int num_planes = av1_num_planes(cm);
439
440
0
  if (scaled_width == cpi->unscaled_source->y_crop_width &&
441
0
      scaled_height == cpi->unscaled_source->y_crop_height) {
442
0
    return cpi->unscaled_source;
443
0
  }
444
445
0
  if (aom_realloc_frame_buffer(
446
0
          &cpi->scaled_source, scaled_width, scaled_height,
447
0
          cm->seq_params->subsampling_x, cm->seq_params->subsampling_y,
448
0
          cm->seq_params->use_highbitdepth, AOM_BORDER_IN_PIXELS,
449
0
          cm->features.byte_alignment, NULL, NULL, NULL, cpi->alloc_pyramid, 0))
450
0
    aom_internal_error(cm->error, AOM_CODEC_MEM_ERROR,
451
0
                       "Failed to reallocate scaled source buffer");
452
0
  assert(cpi->scaled_source.y_crop_width == scaled_width);
453
0
  assert(cpi->scaled_source.y_crop_height == scaled_height);
454
0
  if (!av1_resize_and_extend_frame_nonnormative(
455
0
          cpi->unscaled_source, &cpi->scaled_source,
456
0
          (int)cm->seq_params->bit_depth, num_planes))
457
0
    aom_internal_error(cm->error, AOM_CODEC_MEM_ERROR,
458
0
                       "Failed to reallocate buffers during resize");
459
0
  return &cpi->scaled_source;
460
0
}
Unexecuted instantiation: av1_cx_iface.c:realloc_and_scale_source
Unexecuted instantiation: encoder.c:realloc_and_scale_source
Unexecuted instantiation: encoder_utils.c:realloc_and_scale_source
Unexecuted instantiation: ethread.c:realloc_and_scale_source
Unexecuted instantiation: superres_scale.c:realloc_and_scale_source
Unexecuted instantiation: svc_layercontext.c:realloc_and_scale_source
Unexecuted instantiation: compound_type.c:realloc_and_scale_source
Unexecuted instantiation: encode_strategy.c:realloc_and_scale_source
461
462
// Deallocate allocated thread_data.
463
88.3k
static inline void free_thread_data(AV1_PRIMARY *ppi) {
464
88.3k
  PrimaryMultiThreadInfo *const p_mt_info = &ppi->p_mt_info;
465
88.3k
  const int num_tf_workers =
466
88.3k
      AOMMIN(p_mt_info->num_mod_workers[MOD_TF], p_mt_info->num_workers);
467
88.3k
  const int num_tpl_workers =
468
88.3k
      AOMMIN(p_mt_info->num_mod_workers[MOD_TPL], p_mt_info->num_workers);
469
88.3k
  const int is_highbitdepth = ppi->seq_params.use_highbitdepth;
470
88.3k
  const int num_planes = ppi->seq_params.monochrome ? 1 : MAX_MB_PLANE;
471
691k
  for (int t = 1; t < p_mt_info->num_workers; ++t) {
472
602k
    EncWorkerData *const thread_data = &p_mt_info->tile_thr_data[t];
473
602k
    thread_data->td = thread_data->original_td;
474
602k
    ThreadData *const td = thread_data->td;
475
602k
    if (!td) continue;
476
602k
    aom_free(td->tctx);
477
602k
    aom_free(td->palette_buffer);
478
602k
    aom_free(td->tmp_conv_dst);
479
602k
    aom_free(td->upsample_pred);
480
602k
    release_compound_type_rd_buffers(&td->comp_rd_buffer);
481
1.80M
    for (int j = 0; j < 2; ++j) {
482
1.20M
      aom_free(td->tmp_pred_bufs[j]);
483
1.20M
    }
484
602k
    aom_free(td->pixel_gradient_info);
485
602k
    aom_free(td->src_var_info_of_4x4_sub_blocks);
486
602k
    release_obmc_buffers(&td->obmc_buffer);
487
602k
    aom_free(td->vt64x64);
488
489
1.80M
    for (int x = 0; x < 2; x++) {
490
1.20M
      aom_free(td->hash_value_buffer[x]);
491
1.20M
      td->hash_value_buffer[x] = NULL;
492
1.20M
    }
493
602k
    aom_free(td->mv_costs_alloc);
494
602k
    td->mv_costs_alloc = NULL;
495
602k
    aom_free(td->dv_costs_alloc);
496
602k
    td->dv_costs_alloc = NULL;
497
602k
    aom_free(td->counts);
498
602k
    av1_free_pmc(td->firstpass_ctx, num_planes);
499
602k
    td->firstpass_ctx = NULL;
500
602k
    av1_free_shared_coeff_buffer(&td->shared_coeff_buf);
501
602k
    av1_free_sms_tree(td);
502
    // This call ensures that the buffers allocated by tf_alloc_and_reset_data()
503
    // in prepare_tf_workers() for MT encode are freed in case an error is
504
    // encountered during temporal filtering (due to early termination
505
    // tf_dealloc_thread_data() in av1_tf_do_filtering_mt() would not be
506
    // invoked).
507
602k
    if (t < num_tf_workers) tf_dealloc_data(&td->tf_data, is_highbitdepth);
508
    // This call ensures that tpl_tmp_buffers for MT encode are freed in case of
509
    // an error during tpl.
510
602k
    if (t < num_tpl_workers) tpl_dealloc_temp_buffers(&td->tpl_tmp_buffers);
511
    // This call ensures that the buffers in gm_data for MT encode are freed in
512
    // case of an error during gm.
513
602k
    gm_dealloc_data(&td->gm_data);
514
602k
    av1_dealloc_mb_data(&td->mb, num_planes);
515
602k
    aom_free(td->mb.sb_stats_cache);
516
602k
    td->mb.sb_stats_cache = NULL;
517
602k
    aom_free(td->mb.sb_fp_stats);
518
602k
    td->mb.sb_fp_stats = NULL;
519
#if CONFIG_PARTITION_SEARCH_ORDER
520
    aom_free(td->mb.rdcost);
521
    td->mb.rdcost = NULL;
522
#endif
523
602k
    av1_free_pc_tree_recursive(td->pc_root, num_planes, 0, 0, SEARCH_PARTITION);
524
602k
    td->pc_root = NULL;
525
602k
    av1_dealloc_mb_wiener_var_pred_buf(td);
526
602k
    aom_free(td);
527
602k
    thread_data->td = NULL;
528
    thread_data->original_td = NULL;
529
602k
  }
530
88.3k
}
Unexecuted instantiation: av1_cx_iface.c:free_thread_data
encoder.c:free_thread_data
Line
Count
Source
463
88.3k
static inline void free_thread_data(AV1_PRIMARY *ppi) {
464
88.3k
  PrimaryMultiThreadInfo *const p_mt_info = &ppi->p_mt_info;
465
88.3k
  const int num_tf_workers =
466
88.3k
      AOMMIN(p_mt_info->num_mod_workers[MOD_TF], p_mt_info->num_workers);
467
88.3k
  const int num_tpl_workers =
468
88.3k
      AOMMIN(p_mt_info->num_mod_workers[MOD_TPL], p_mt_info->num_workers);
469
88.3k
  const int is_highbitdepth = ppi->seq_params.use_highbitdepth;
470
88.3k
  const int num_planes = ppi->seq_params.monochrome ? 1 : MAX_MB_PLANE;
471
691k
  for (int t = 1; t < p_mt_info->num_workers; ++t) {
472
602k
    EncWorkerData *const thread_data = &p_mt_info->tile_thr_data[t];
473
602k
    thread_data->td = thread_data->original_td;
474
602k
    ThreadData *const td = thread_data->td;
475
602k
    if (!td) continue;
476
602k
    aom_free(td->tctx);
477
602k
    aom_free(td->palette_buffer);
478
602k
    aom_free(td->tmp_conv_dst);
479
602k
    aom_free(td->upsample_pred);
480
602k
    release_compound_type_rd_buffers(&td->comp_rd_buffer);
481
1.80M
    for (int j = 0; j < 2; ++j) {
482
1.20M
      aom_free(td->tmp_pred_bufs[j]);
483
1.20M
    }
484
602k
    aom_free(td->pixel_gradient_info);
485
602k
    aom_free(td->src_var_info_of_4x4_sub_blocks);
486
602k
    release_obmc_buffers(&td->obmc_buffer);
487
602k
    aom_free(td->vt64x64);
488
489
1.80M
    for (int x = 0; x < 2; x++) {
490
1.20M
      aom_free(td->hash_value_buffer[x]);
491
1.20M
      td->hash_value_buffer[x] = NULL;
492
1.20M
    }
493
602k
    aom_free(td->mv_costs_alloc);
494
602k
    td->mv_costs_alloc = NULL;
495
602k
    aom_free(td->dv_costs_alloc);
496
602k
    td->dv_costs_alloc = NULL;
497
602k
    aom_free(td->counts);
498
602k
    av1_free_pmc(td->firstpass_ctx, num_planes);
499
602k
    td->firstpass_ctx = NULL;
500
602k
    av1_free_shared_coeff_buffer(&td->shared_coeff_buf);
501
602k
    av1_free_sms_tree(td);
502
    // This call ensures that the buffers allocated by tf_alloc_and_reset_data()
503
    // in prepare_tf_workers() for MT encode are freed in case an error is
504
    // encountered during temporal filtering (due to early termination
505
    // tf_dealloc_thread_data() in av1_tf_do_filtering_mt() would not be
506
    // invoked).
507
602k
    if (t < num_tf_workers) tf_dealloc_data(&td->tf_data, is_highbitdepth);
508
    // This call ensures that tpl_tmp_buffers for MT encode are freed in case of
509
    // an error during tpl.
510
602k
    if (t < num_tpl_workers) tpl_dealloc_temp_buffers(&td->tpl_tmp_buffers);
511
    // This call ensures that the buffers in gm_data for MT encode are freed in
512
    // case of an error during gm.
513
602k
    gm_dealloc_data(&td->gm_data);
514
602k
    av1_dealloc_mb_data(&td->mb, num_planes);
515
602k
    aom_free(td->mb.sb_stats_cache);
516
602k
    td->mb.sb_stats_cache = NULL;
517
602k
    aom_free(td->mb.sb_fp_stats);
518
602k
    td->mb.sb_fp_stats = NULL;
519
#if CONFIG_PARTITION_SEARCH_ORDER
520
    aom_free(td->mb.rdcost);
521
    td->mb.rdcost = NULL;
522
#endif
523
602k
    av1_free_pc_tree_recursive(td->pc_root, num_planes, 0, 0, SEARCH_PARTITION);
524
602k
    td->pc_root = NULL;
525
602k
    av1_dealloc_mb_wiener_var_pred_buf(td);
526
602k
    aom_free(td);
527
602k
    thread_data->td = NULL;
528
    thread_data->original_td = NULL;
529
602k
  }
530
88.3k
}
Unexecuted instantiation: encoder_utils.c:free_thread_data
Unexecuted instantiation: ethread.c:free_thread_data
Unexecuted instantiation: superres_scale.c:free_thread_data
Unexecuted instantiation: svc_layercontext.c:free_thread_data
Unexecuted instantiation: compound_type.c:free_thread_data
Unexecuted instantiation: encode_strategy.c:free_thread_data
531
532
#ifdef __cplusplus
533
}  // extern "C"
534
#endif
535
536
#endif  // AOM_AV1_ENCODER_ENCODER_ALLOC_H_