Coverage Report

Created: 2023-06-07 06:31

/src/aom/aom_scale/yv12config.h
Line
Count
Source (jump to first uncovered line)
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
#ifndef AOM_AOM_SCALE_YV12CONFIG_H_
13
#define AOM_AOM_SCALE_YV12CONFIG_H_
14
15
#ifdef __cplusplus
16
extern "C" {
17
#endif
18
19
#include "config/aom_config.h"
20
21
#include "aom/aom_codec.h"
22
#include "aom/aom_frame_buffer.h"
23
#include "aom/aom_integer.h"
24
#include "aom/internal/aom_image_internal.h"
25
26
/*!\cond */
27
28
0
#define AOMINNERBORDERINPIXELS 160
29
217M
#define AOM_INTERP_EXTEND 4
30
64.3M
#define AOM_BORDER_IN_PIXELS 288
31
#define AOM_ENC_NO_SCALE_BORDER 160
32
#define AOM_ENC_ALLINTRA_BORDER 64
33
169k
#define AOM_DEC_BORDER_IN_PIXELS 64
34
35
#if CONFIG_AV1_ENCODER && !CONFIG_REALTIME_ONLY
36
struct image_pyramid;
37
struct corner_list;
38
#endif  // CONFIG_AV1_ENCODER && !CONFIG_REALTIME_ONLY
39
40
/*!\endcond */
41
/*!
42
 * \brief YV12 frame buffer data structure
43
 */
44
typedef struct yv12_buffer_config {
45
  /*!\cond */
46
  union {
47
    struct {
48
      int y_width;
49
      int uv_width;
50
    };
51
    int widths[2];
52
  };
53
  union {
54
    struct {
55
      int y_height;
56
      int uv_height;
57
    };
58
    int heights[2];
59
  };
60
  union {
61
    struct {
62
      int y_crop_width;
63
      int uv_crop_width;
64
    };
65
    int crop_widths[2];
66
  };
67
  union {
68
    struct {
69
      int y_crop_height;
70
      int uv_crop_height;
71
    };
72
    int crop_heights[2];
73
  };
74
  union {
75
    struct {
76
      int y_stride;
77
      int uv_stride;
78
    };
79
    int strides[2];
80
  };
81
  union {
82
    struct {
83
      uint8_t *y_buffer;
84
      uint8_t *u_buffer;
85
      uint8_t *v_buffer;
86
    };
87
    uint8_t *buffers[3];
88
  };
89
90
  // Indicate whether y_buffer, u_buffer, and v_buffer points to the internally
91
  // allocated memory or external buffers.
92
  int use_external_reference_buffers;
93
  // This is needed to store y_buffer, u_buffer, and v_buffer when set reference
94
  // uses an external refernece, and restore those buffer pointers after the
95
  // external reference frame is no longer used.
96
  uint8_t *store_buf_adr[3];
97
98
  // Global motion search data
99
#if CONFIG_AV1_ENCODER && !CONFIG_REALTIME_ONLY
100
  // 8-bit downsampling pyramid for the Y plane
101
  struct image_pyramid *y_pyramid;
102
  struct corner_list *corners;
103
#endif  // CONFIG_AV1_ENCODER && !CONFIG_REALTIME_ONLY
104
105
  uint8_t *buffer_alloc;
106
  size_t buffer_alloc_sz;
107
  int border;
108
  size_t frame_size;
109
  int subsampling_x;
110
  int subsampling_y;
111
  unsigned int bit_depth;
112
  aom_color_primaries_t color_primaries;
113
  aom_transfer_characteristics_t transfer_characteristics;
114
  aom_matrix_coefficients_t matrix_coefficients;
115
  uint8_t monochrome;
116
  aom_chroma_sample_position_t chroma_sample_position;
117
  aom_color_range_t color_range;
118
  int render_width;
119
  int render_height;
120
121
  int corrupted;
122
  int flags;
123
  aom_metadata_array_t *metadata;
124
  /*!\endcond */
125
} YV12_BUFFER_CONFIG;
126
127
/*!\cond */
128
129
165M
#define YV12_FLAG_HIGHBITDEPTH 8
130
131
// Allocate a frame buffer
132
//
133
// If ybf currently contains an image, all associated memory will be freed and
134
// then reallocated. In contrast, aom_realloc_frame_buffer() will reuse any
135
// existing allocations where possible. So, if ybf is likely to already be
136
// set up, please consider aom_realloc_frame_buffer() instead.
137
//
138
// See aom_realloc_frame_buffer() for the meanings of the arguments, and
139
// available return values.
140
int aom_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
141
                           int ss_x, int ss_y, int use_highbitdepth, int border,
142
                           int byte_alignment, int num_pyramid_levels,
143
                           int alloc_y_plane_only);
144
145
// Updates the yv12 buffer config with the frame buffer. |byte_alignment| must
146
// be a power of 2, from 32 to 1024. 0 sets legacy alignment. If cb is not
147
// NULL, then libaom is using the frame buffer callbacks to handle memory.
148
// If cb is not NULL, libaom will call cb with minimum size in bytes needed
149
// to decode the current frame. If cb is NULL, libaom will allocate memory
150
// internally to decode the current frame.
151
//
152
// If num_pyramid_levels > 0, then an image pyramid will be allocated with
153
// the specified number of levels.
154
//
155
// Any buffer which may become a source or ref frame buffer in the encoder
156
// must have num_pyramid_levels = cpi->image_pyramid_levels. This will cause
157
// an image pyramid to be allocated if one is needed.
158
//
159
// Any other buffers (in particular, any buffers inside the decoder)
160
// must have cpi->image_pyramid_levels = 0, as a pyramid is unneeded there.
161
//
162
// Returns 0 on success. Returns < 0  on failure.
163
int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
164
                             int ss_x, int ss_y, int use_highbitdepth,
165
                             int border, int byte_alignment,
166
                             aom_codec_frame_buffer_t *fb,
167
                             aom_get_frame_buffer_cb_fn_t cb, void *cb_priv,
168
                             int num_pyramid_levels, int alloc_y_plane_only);
169
170
int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf);
171
172
/*!\endcond */
173
/*!\brief Removes metadata from YUV_BUFFER_CONFIG struct.
174
 *
175
 * Frees metadata in frame buffer.
176
 * Frame buffer metadata pointer will be set to NULL.
177
 *
178
 * \param[in]    ybf       Frame buffer struct pointer
179
 */
180
void aom_remove_metadata_from_frame_buffer(YV12_BUFFER_CONFIG *ybf);
181
182
/*!\brief Copy metadata to YUV_BUFFER_CONFIG struct.
183
 *
184
 * Copies metadata to frame buffer.
185
 * Frame buffer will clear any previous metadata and will reallocate the
186
 * metadata array to the new metadata size. Then, it will copy the new metadata
187
 * array into it.
188
 * If arr metadata pointer points to the same address as current metadata in the
189
 * frame buffer, function will do nothing and return 0.
190
 * Returns 0 on success or -1 on failure.
191
 *
192
 * \param[in]    ybf       Frame buffer struct pointer
193
 * \param[in]    arr       Metadata array struct pointer
194
 */
195
int aom_copy_metadata_to_frame_buffer(YV12_BUFFER_CONFIG *ybf,
196
                                      const aom_metadata_array_t *arr);
197
198
/*!\brief Calculate the stride required for the image.
199
 *
200
 * Calculates the stride value for an image from aligned width and border.
201
 * Returns the y stride value.
202
 *
203
 * \param[in]    aligned_width       Aligned width of the image
204
 * \param[in]    border              Border in pixels
205
 */
206
499k
static AOM_INLINE int aom_calc_y_stride(int aligned_width, int border) {
207
499k
  return ((aligned_width + 2 * border) + 31) & ~31;
208
499k
}
Unexecuted instantiation: av1_dx_iface.c:aom_calc_y_stride
Unexecuted instantiation: decodeframe.c:aom_calc_y_stride
Unexecuted instantiation: decodemv.c:aom_calc_y_stride
Unexecuted instantiation: decoder.c:aom_calc_y_stride
Unexecuted instantiation: decodetxb.c:aom_calc_y_stride
Unexecuted instantiation: detokenize.c:aom_calc_y_stride
Unexecuted instantiation: obu.c:aom_calc_y_stride
Unexecuted instantiation: aom_dsp_rtcd.c:aom_calc_y_stride
Unexecuted instantiation: av1_rtcd.c:aom_calc_y_stride
Unexecuted instantiation: aom_convolve.c:aom_calc_y_stride
Unexecuted instantiation: blend_a64_hmask.c:aom_calc_y_stride
Unexecuted instantiation: blend_a64_mask.c:aom_calc_y_stride
Unexecuted instantiation: blend_a64_vmask.c:aom_calc_y_stride
Unexecuted instantiation: intrapred.c:aom_calc_y_stride
Unexecuted instantiation: aom_convolve_copy_sse2.c:aom_calc_y_stride
Unexecuted instantiation: aom_asm_stubs.c:aom_calc_y_stride
Unexecuted instantiation: intrapred_sse2.c:aom_calc_y_stride
Unexecuted instantiation: loopfilter_sse2.c:aom_calc_y_stride
Unexecuted instantiation: highbd_convolve_sse2.c:aom_calc_y_stride
Unexecuted instantiation: highbd_loopfilter_sse2.c:aom_calc_y_stride
Unexecuted instantiation: aom_subpixel_8t_intrin_ssse3.c:aom_calc_y_stride
Unexecuted instantiation: intrapred_ssse3.c:aom_calc_y_stride
Unexecuted instantiation: highbd_convolve_ssse3.c:aom_calc_y_stride
Unexecuted instantiation: blend_a64_hmask_sse4.c:aom_calc_y_stride
Unexecuted instantiation: blend_a64_mask_sse4.c:aom_calc_y_stride
Unexecuted instantiation: blend_a64_vmask_sse4.c:aom_calc_y_stride
Unexecuted instantiation: intrapred_sse4.c:aom_calc_y_stride
Unexecuted instantiation: aom_convolve_copy_avx2.c:aom_calc_y_stride
Unexecuted instantiation: aom_subpixel_8t_intrin_avx2.c:aom_calc_y_stride
Unexecuted instantiation: intrapred_avx2.c:aom_calc_y_stride
Unexecuted instantiation: loopfilter_avx2.c:aom_calc_y_stride
Unexecuted instantiation: blend_a64_mask_avx2.c:aom_calc_y_stride
Unexecuted instantiation: highbd_convolve_avx2.c:aom_calc_y_stride
Unexecuted instantiation: highbd_loopfilter_avx2.c:aom_calc_y_stride
yv12config.c:aom_calc_y_stride
Line
Count
Source
206
499k
static AOM_INLINE int aom_calc_y_stride(int aligned_width, int border) {
207
499k
  return ((aligned_width + 2 * border) + 31) & ~31;
208
499k
}
Unexecuted instantiation: yv12extend.c:aom_calc_y_stride
Unexecuted instantiation: alloccommon.c:aom_calc_y_stride
Unexecuted instantiation: av1_inv_txfm2d.c:aom_calc_y_stride
Unexecuted instantiation: av1_loopfilter.c:aom_calc_y_stride
Unexecuted instantiation: av1_txfm.c:aom_calc_y_stride
Unexecuted instantiation: blockd.c:aom_calc_y_stride
Unexecuted instantiation: cdef.c:aom_calc_y_stride
Unexecuted instantiation: cdef_block.c:aom_calc_y_stride
Unexecuted instantiation: cfl.c:aom_calc_y_stride
Unexecuted instantiation: convolve.c:aom_calc_y_stride
Unexecuted instantiation: entropy.c:aom_calc_y_stride
Unexecuted instantiation: entropymode.c:aom_calc_y_stride
Unexecuted instantiation: entropymv.c:aom_calc_y_stride
Unexecuted instantiation: idct.c:aom_calc_y_stride
Unexecuted instantiation: mvref_common.c:aom_calc_y_stride
Unexecuted instantiation: pred_common.c:aom_calc_y_stride
Unexecuted instantiation: quant_common.c:aom_calc_y_stride
Unexecuted instantiation: reconinter.c:aom_calc_y_stride
Unexecuted instantiation: reconintra.c:aom_calc_y_stride
Unexecuted instantiation: resize.c:aom_calc_y_stride
Unexecuted instantiation: restoration.c:aom_calc_y_stride
Unexecuted instantiation: scale.c:aom_calc_y_stride
Unexecuted instantiation: scan.c:aom_calc_y_stride
Unexecuted instantiation: seg_common.c:aom_calc_y_stride
Unexecuted instantiation: thread_common.c:aom_calc_y_stride
Unexecuted instantiation: tile_common.c:aom_calc_y_stride
Unexecuted instantiation: txb_common.c:aom_calc_y_stride
Unexecuted instantiation: warped_motion.c:aom_calc_y_stride
Unexecuted instantiation: cdef_block_sse2.c:aom_calc_y_stride
Unexecuted instantiation: cfl_sse2.c:aom_calc_y_stride
Unexecuted instantiation: convolve_2d_sse2.c:aom_calc_y_stride
Unexecuted instantiation: convolve_sse2.c:aom_calc_y_stride
Unexecuted instantiation: jnt_convolve_sse2.c:aom_calc_y_stride
Unexecuted instantiation: warp_plane_sse2.c:aom_calc_y_stride
Unexecuted instantiation: wiener_convolve_sse2.c:aom_calc_y_stride
Unexecuted instantiation: av1_inv_txfm_ssse3.c:aom_calc_y_stride
Unexecuted instantiation: cdef_block_ssse3.c:aom_calc_y_stride
Unexecuted instantiation: cfl_ssse3.c:aom_calc_y_stride
Unexecuted instantiation: jnt_convolve_ssse3.c:aom_calc_y_stride
Unexecuted instantiation: resize_ssse3.c:aom_calc_y_stride
Unexecuted instantiation: highbd_convolve_2d_ssse3.c:aom_calc_y_stride
Unexecuted instantiation: highbd_wiener_convolve_ssse3.c:aom_calc_y_stride
Unexecuted instantiation: reconinter_ssse3.c:aom_calc_y_stride
Unexecuted instantiation: av1_convolve_horiz_rs_sse4.c:aom_calc_y_stride
Unexecuted instantiation: av1_convolve_scale_sse4.c:aom_calc_y_stride
Unexecuted instantiation: av1_txfm_sse4.c:aom_calc_y_stride
Unexecuted instantiation: cdef_block_sse4.c:aom_calc_y_stride
Unexecuted instantiation: filterintra_sse4.c:aom_calc_y_stride
Unexecuted instantiation: highbd_inv_txfm_sse4.c:aom_calc_y_stride
Unexecuted instantiation: intra_edge_sse4.c:aom_calc_y_stride
Unexecuted instantiation: reconinter_sse4.c:aom_calc_y_stride
Unexecuted instantiation: selfguided_sse4.c:aom_calc_y_stride
Unexecuted instantiation: warp_plane_sse4.c:aom_calc_y_stride
Unexecuted instantiation: highbd_convolve_2d_sse4.c:aom_calc_y_stride
Unexecuted instantiation: highbd_jnt_convolve_sse4.c:aom_calc_y_stride
Unexecuted instantiation: highbd_warp_plane_sse4.c:aom_calc_y_stride
Unexecuted instantiation: av1_inv_txfm_avx2.c:aom_calc_y_stride
Unexecuted instantiation: cdef_block_avx2.c:aom_calc_y_stride
Unexecuted instantiation: cfl_avx2.c:aom_calc_y_stride
Unexecuted instantiation: convolve_2d_avx2.c:aom_calc_y_stride
Unexecuted instantiation: convolve_avx2.c:aom_calc_y_stride
Unexecuted instantiation: highbd_inv_txfm_avx2.c:aom_calc_y_stride
Unexecuted instantiation: jnt_convolve_avx2.c:aom_calc_y_stride
Unexecuted instantiation: reconinter_avx2.c:aom_calc_y_stride
Unexecuted instantiation: selfguided_avx2.c:aom_calc_y_stride
Unexecuted instantiation: warp_plane_avx2.c:aom_calc_y_stride
Unexecuted instantiation: wiener_convolve_avx2.c:aom_calc_y_stride
Unexecuted instantiation: highbd_convolve_2d_avx2.c:aom_calc_y_stride
Unexecuted instantiation: highbd_jnt_convolve_avx2.c:aom_calc_y_stride
Unexecuted instantiation: highbd_wiener_convolve_avx2.c:aom_calc_y_stride
Unexecuted instantiation: highbd_warp_affine_avx2.c:aom_calc_y_stride
Unexecuted instantiation: aom_subpixel_8t_intrin_sse2.c:aom_calc_y_stride
Unexecuted instantiation: highbd_intrapred_sse2.c:aom_calc_y_stride
Unexecuted instantiation: av1_inv_txfm1d.c:aom_calc_y_stride
209
210
#ifdef __cplusplus
211
}
212
#endif
213
214
#endif  // AOM_AOM_SCALE_YV12CONFIG_H_