Coverage Report

Created: 2025-06-13 07:07

/src/aom/aom_scale/yv12config.h
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
#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 <stdbool.h>
20
21
#include "config/aom_config.h"
22
23
#include "aom/aom_codec.h"
24
#include "aom/aom_frame_buffer.h"
25
#include "aom/aom_integer.h"
26
#include "aom/internal/aom_image_internal.h"
27
28
/*!\cond */
29
30
#define AOMINNERBORDERINPIXELS 160
31
138M
#define AOM_INTERP_EXTEND 4
32
38.9M
#define AOM_BORDER_IN_PIXELS 288
33
#define AOM_ENC_NO_SCALE_BORDER 160
34
#define AOM_ENC_ALLINTRA_BORDER 64
35
197k
#define AOM_DEC_BORDER_IN_PIXELS 64
36
37
#if CONFIG_AV1_ENCODER && !CONFIG_REALTIME_ONLY
38
struct image_pyramid;
39
struct corner_list;
40
#endif  // CONFIG_AV1_ENCODER && !CONFIG_REALTIME_ONLY
41
42
/*!\endcond */
43
/*!
44
 * \brief YV12 frame buffer data structure
45
 */
46
typedef struct yv12_buffer_config {
47
  /*!\cond */
48
  union {
49
    struct {
50
      // The aligned frame width of luma.
51
      // It is aligned to a multiple of 8:
52
      // y_width = (y_crop_width + 7) & ~7
53
      int y_width;
54
      // The aligned frame width of chroma.
55
      // uv_width = y_width >> subsampling_x
56
      int uv_width;
57
    };
58
    int widths[2];
59
  };
60
  union {
61
    struct {
62
      // The aligned frame height of luma.
63
      // It is aligned to a multiple of 8:
64
      // y_height = (y_crop_height + 7) & ~7
65
      int y_height;
66
      // The aligned frame height of chroma.
67
      // uv_height = y_height >> subsampling_y
68
      int uv_height;
69
    };
70
    int heights[2];
71
  };
72
  // The frame size en/decoded by AV1
73
  union {
74
    struct {
75
      int y_crop_width;
76
      int uv_crop_width;
77
    };
78
    int crop_widths[2];
79
  };
80
  union {
81
    struct {
82
      int y_crop_height;
83
      int uv_crop_height;
84
    };
85
    int crop_heights[2];
86
  };
87
  union {
88
    struct {
89
      int y_stride;
90
      int uv_stride;
91
    };
92
    int strides[2];
93
  };
94
  union {
95
    struct {
96
      uint8_t *y_buffer;
97
      uint8_t *u_buffer;
98
      uint8_t *v_buffer;
99
    };
100
    uint8_t *buffers[3];
101
  };
102
103
  // Indicate whether y_buffer, u_buffer, and v_buffer points to the internally
104
  // allocated memory or external buffers.
105
  int use_external_reference_buffers;
106
  // This is needed to store y_buffer, u_buffer, and v_buffer when set reference
107
  // uses an external refernece, and restore those buffer pointers after the
108
  // external reference frame is no longer used.
109
  uint8_t *store_buf_adr[3];
110
111
  // Global motion search data
112
#if CONFIG_AV1_ENCODER && !CONFIG_REALTIME_ONLY
113
  // 8-bit downsampling pyramid for the Y plane
114
  struct image_pyramid *y_pyramid;
115
  struct corner_list *corners;
116
#endif  // CONFIG_AV1_ENCODER && !CONFIG_REALTIME_ONLY
117
118
  uint8_t *buffer_alloc;
119
  size_t buffer_alloc_sz;
120
  int border;
121
  size_t frame_size;
122
  int subsampling_x;
123
  int subsampling_y;
124
  unsigned int bit_depth;
125
  aom_color_primaries_t color_primaries;
126
  aom_transfer_characteristics_t transfer_characteristics;
127
  aom_matrix_coefficients_t matrix_coefficients;
128
  uint8_t monochrome;
129
  aom_chroma_sample_position_t chroma_sample_position;
130
  aom_color_range_t color_range;
131
  int render_width;
132
  int render_height;
133
134
  int corrupted;
135
  int flags;
136
  aom_metadata_array_t *metadata;
137
  /*!\endcond */
138
} YV12_BUFFER_CONFIG;
139
140
/*!\cond */
141
142
158M
#define YV12_FLAG_HIGHBITDEPTH 8
143
144
// Allocate a frame buffer
145
//
146
// If ybf currently contains an image, all associated memory will be freed and
147
// then reallocated. In contrast, aom_realloc_frame_buffer() will reuse any
148
// existing allocations where possible. So, if ybf is likely to already be
149
// set up, please consider aom_realloc_frame_buffer() instead.
150
//
151
// See aom_realloc_frame_buffer() for the meanings of the arguments, and
152
// available return values.
153
int aom_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
154
                           int ss_x, int ss_y, int use_highbitdepth, int border,
155
                           int byte_alignment, bool alloc_pyramid,
156
                           int alloc_y_plane_only);
157
158
// Updates the yv12 buffer config with the frame buffer. |byte_alignment| must
159
// be a power of 2, from 32 to 1024. 0 sets legacy alignment. If cb is not
160
// NULL, then libaom is using the frame buffer callbacks to handle memory.
161
// If cb is not NULL, libaom will call cb with minimum size in bytes needed
162
// to decode the current frame. If cb is NULL, libaom will allocate memory
163
// internally to decode the current frame.
164
//
165
// If alloc_pyramid is true, then an image pyramid will be allocated
166
// for use in global motion estimation. This is only needed if this frame
167
// buffer will be used to store a source frame or a reference frame in
168
// the encoder. Any other framebuffers (eg, intermediates for filtering,
169
// or any buffer in the decoder) can set alloc_pyramid = false.
170
//
171
// Returns 0 on success. Returns < 0  on failure.
172
int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
173
                             int ss_x, int ss_y, int use_highbitdepth,
174
                             int border, int byte_alignment,
175
                             aom_codec_frame_buffer_t *fb,
176
                             aom_get_frame_buffer_cb_fn_t cb, void *cb_priv,
177
                             bool alloc_pyramid, int alloc_y_plane_only);
178
179
int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf);
180
181
/*!\endcond */
182
/*!\brief Removes metadata from YUV_BUFFER_CONFIG struct.
183
 *
184
 * Frees metadata in frame buffer.
185
 * Frame buffer metadata pointer will be set to NULL.
186
 *
187
 * \param[in]    ybf       Frame buffer struct pointer
188
 */
189
void aom_remove_metadata_from_frame_buffer(YV12_BUFFER_CONFIG *ybf);
190
191
/*!\brief Copy metadata to YUV_BUFFER_CONFIG struct.
192
 *
193
 * Copies metadata to frame buffer.
194
 * Frame buffer will clear any previous metadata and will reallocate the
195
 * metadata array to the new metadata size. Then, it will copy the new metadata
196
 * array into it.
197
 * If arr metadata pointer points to the same address as current metadata in the
198
 * frame buffer, function will do nothing and return 0.
199
 * Returns 0 on success or -1 on failure.
200
 *
201
 * \param[in]    ybf       Frame buffer struct pointer
202
 * \param[in]    arr       Metadata array struct pointer
203
 */
204
int aom_copy_metadata_to_frame_buffer(YV12_BUFFER_CONFIG *ybf,
205
                                      const aom_metadata_array_t *arr);
206
207
/*!\brief Calculate the stride required for the image.
208
 *
209
 * Calculates the stride value for an image from aligned width and border.
210
 * Returns the y stride value.
211
 *
212
 * \param[in]    aligned_width       Aligned width of the image
213
 * \param[in]    border              Border in pixels
214
 */
215
516k
static inline int aom_calc_y_stride(int aligned_width, int border) {
216
516k
  return ((aligned_width + 2 * border) + 31) & ~31;
217
516k
}
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: 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
215
516k
static inline int aom_calc_y_stride(int aligned_width, int border) {
216
516k
  return ((aligned_width + 2 * border) + 31) & ~31;
217
516k
}
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: 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: resize_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: 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: resize_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: highbd_intrapred_sse2.c:aom_calc_y_stride
Unexecuted instantiation: av1_inv_txfm1d.c:aom_calc_y_stride
218
219
#ifdef __cplusplus
220
}
221
#endif
222
223
#endif  // AOM_AOM_SCALE_YV12CONFIG_H_