Bug Summary

File:root/firefox-clang/media/libvpx/libvpx/vp8/common/blockd.h
Warning:line 209, column 16
Excessive padding in 'struct macroblockd' (38 padding bytes, where 6 is optimal). Optimal fields order: y_buf, eobs, segmentation_enabled, update_mb_segmentation_map, update_mb_segmentation_data, fullpixel_mask, dequant_y1, dequant_y1_dc, dequant_y2, dequant_uv, predictor, qcoeff, dqcoeff, mode_info_context, above_context, left_context, subpixel_predict, subpixel_predict8x4, subpixel_predict8x8, subpixel_predict16x16, current_bc, recon_above, recon_left, pre, dst, error_info, block, mode_info_stride, frame_type, up_available, left_available, mb_to_left_edge, mb_to_right_edge, mb_to_top_edge, mb_to_bottom_edge, corrupted, recon_left_stride, mb_segment_abs_delta, mode_ref_lf_delta_enabled, mode_ref_lf_delta_update, mb_segment_tree_probs, last_ref_lf_deltas, ref_lf_deltas, last_mode_lf_deltas, mode_lf_deltas, segment_feature_data, consider reordering the fields or adding explicit padding members

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name alloccommon.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/media/libvpx -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/media/libvpx -resource-dir /usr/lib/llvm-21/lib/clang/21 -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D _GLIBCXX_ASSERTIONS -D DEBUG=1 -D HAVE_CONFIG_H=vpx_config.h -D MOZ_HAS_MOZGLUE -I /root/firefox-clang/media/libvpx -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/media/libvpx -I /root/firefox-clang/media/libvpx/config/linux/x64 -I /root/firefox-clang/media/libvpx/config -I /root/firefox-clang/media/libvpx/libvpx -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-error=tautological-type-limit-compare -Wno-range-loop-analysis -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-unknown-warning-option -Wno-sign-compare -Wno-unused-function -Wno-unreachable-code -Wno-unneeded-internal-declaration -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2025-06-27-100320-3286336-1 -x c /root/firefox-clang/media/libvpx/libvpx/vp8/common/alloccommon.c
1/*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef VPX_VP8_COMMON_BLOCKD_H_
12#define VPX_VP8_COMMON_BLOCKD_H_
13
14void vpx_log(const char *format, ...);
15
16#include "vpx/internal/vpx_codec_internal.h"
17#include "vpx_config.h"
18#include "vpx_scale/yv12config.h"
19#include "mv.h"
20#include "treecoder.h"
21#include "vpx_ports/mem.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/*#define DCPRED 1*/
28#define DCPREDSIMTHRESH0 0
29#define DCPREDCNTTHRESH3 3
30
31#define MB_FEATURE_TREE_PROBS3 3
32#define MAX_MB_SEGMENTS4 4
33
34#define MAX_REF_LF_DELTAS4 4
35#define MAX_MODE_LF_DELTAS4 4
36
37/* Segment Feature Masks */
38#define SEGMENT_DELTADATA0 0
39#define SEGMENT_ABSDATA1 1
40
41typedef struct {
42 int r, c;
43} POS;
44
45#define PLANE_TYPE_Y_NO_DC0 0
46#define PLANE_TYPE_Y21 1
47#define PLANE_TYPE_UV2 2
48#define PLANE_TYPE_Y_WITH_DC3 3
49
50typedef char ENTROPY_CONTEXT;
51typedef struct {
52 ENTROPY_CONTEXT y1[4];
53 ENTROPY_CONTEXT u[2];
54 ENTROPY_CONTEXT v[2];
55 ENTROPY_CONTEXT y2;
56} ENTROPY_CONTEXT_PLANES;
57
58extern const unsigned char vp8_block2left[25];
59extern const unsigned char vp8_block2above[25];
60
61#define VP8_COMBINEENTROPYCONTEXTS(Dest, A, B)Dest = (A) + (B) Dest = (A) + (B)
62
63typedef enum { KEY_FRAME = 0, INTER_FRAME = 1 } FRAME_TYPE;
64
65typedef enum {
66 DC_PRED, /* average of above and left pixels */
67 V_PRED, /* vertical prediction */
68 H_PRED, /* horizontal prediction */
69 TM_PRED, /* Truemotion prediction */
70 B_PRED, /* block based prediction, each block has its own prediction mode */
71
72 NEARESTMV,
73 NEARMV,
74 ZEROMV,
75 NEWMV,
76 SPLITMV,
77
78 MB_MODE_COUNT
79} MB_PREDICTION_MODE;
80
81/* Macroblock level features */
82typedef enum {
83 MB_LVL_ALT_Q = 0, /* Use alternate Quantizer .... */
84 MB_LVL_ALT_LF = 1, /* Use alternate loop filter value... */
85 MB_LVL_MAX = 2 /* Number of MB level features supported */
86
87} MB_LVL_FEATURES;
88
89/* Segment Feature Masks */
90#define SEGMENT_ALTQ0x01 0x01
91#define SEGMENT_ALT_LF0x02 0x02
92
93#define VP8_YMODES(B_PRED + 1) (B_PRED + 1)
94#define VP8_UV_MODES(TM_PRED + 1) (TM_PRED + 1)
95
96#define VP8_MVREFS(1 + SPLITMV - NEARESTMV) (1 + SPLITMV - NEARESTMV)
97
98typedef enum {
99 B_DC_PRED, /* average of above and left pixels */
100 B_TM_PRED,
101
102 B_VE_PRED, /* vertical prediction */
103 B_HE_PRED, /* horizontal prediction */
104
105 B_LD_PRED,
106 B_RD_PRED,
107
108 B_VR_PRED,
109 B_VL_PRED,
110 B_HD_PRED,
111 B_HU_PRED,
112
113 LEFT4X4,
114 ABOVE4X4,
115 ZERO4X4,
116 NEW4X4,
117
118 B_MODE_COUNT
119} B_PREDICTION_MODE;
120
121#define VP8_BINTRAMODES(B_HU_PRED + 1) (B_HU_PRED + 1) /* 10 */
122#define VP8_SUBMVREFS(1 + NEW4X4 - LEFT4X4) (1 + NEW4X4 - LEFT4X4)
123
124/* For keyframes, intra block modes are predicted by the (already decoded)
125 modes for the Y blocks to the left and above us; for interframes, there
126 is a single probability table. */
127
128union b_mode_info {
129 B_PREDICTION_MODE as_mode;
130 int_mv mv;
131};
132
133typedef enum {
134 INTRA_FRAME = 0,
135 LAST_FRAME = 1,
136 GOLDEN_FRAME = 2,
137 ALTREF_FRAME = 3,
138 MAX_REF_FRAMES = 4
139} MV_REFERENCE_FRAME;
140
141typedef struct {
142 uint8_t mode, uv_mode;
143 uint8_t ref_frame;
144 uint8_t is_4x4;
145 int_mv mv;
146
147 uint8_t partitioning;
148 /* does this mb has coefficients at all, 1=no coefficients, 0=need decode
149 tokens */
150 uint8_t mb_skip_coeff;
151 uint8_t need_to_clamp_mvs;
152 /* Which set of segmentation parameters should be used for this MB */
153 uint8_t segment_id;
154} MB_MODE_INFO;
155
156typedef struct modeinfo {
157 MB_MODE_INFO mbmi;
158 union b_mode_info bmi[16];
159} MODE_INFO;
160
161#if CONFIG_MULTI_RES_ENCODING1
162/* The mb-level information needed to be stored for higher-resolution encoder */
163typedef struct {
164 MB_PREDICTION_MODE mode;
165 MV_REFERENCE_FRAME ref_frame;
166 int_mv mv;
167 int dissim; /* dissimilarity level of the macroblock */
168} LOWER_RES_MB_INFO;
169
170/* The frame-level information needed to be stored for higher-resolution
171 * encoder */
172typedef struct {
173 FRAME_TYPE frame_type;
174 int is_frame_dropped;
175 // If frame is dropped due to overshoot after encode_frame. This triggers a
176 // drop and resets rate control with Q forced to max for following frame.
177 // The check for this dropping due to overshoot is only done on lowest stream,
178 // and if set will force drop on all spatial streams for that current frame.
179 int is_frame_dropped_overshoot_maxqp;
180 // The frame rate for the lowest resolution.
181 double low_res_framerate;
182 /* The frame number of each reference frames */
183 unsigned int low_res_ref_frames[MAX_REF_FRAMES];
184 // The video frame counter value for the key frame, for lowest resolution.
185 unsigned int key_frame_counter_value;
186 // Flags to signal skipped encoding of previous and base layer stream.
187 unsigned int skip_encoding_prev_stream;
188 unsigned int skip_encoding_base_stream;
189 LOWER_RES_MB_INFO *mb_info;
190} LOWER_RES_FRAME_INFO;
191#endif
192
193typedef struct blockd {
194 short *qcoeff;
195 short *dqcoeff;
196 unsigned char *predictor;
197 short *dequant;
198
199 int offset;
200 char *eob;
201
202 union b_mode_info bmi;
203} BLOCKD;
204
205typedef void (*vp8_subpix_fn_t)(unsigned char *src_ptr, int src_pixels_per_line,
206 int xoffset, int yoffset,
207 unsigned char *dst_ptr, int dst_pitch);
208
209typedef struct macroblockd {
Excessive padding in 'struct macroblockd' (38 padding bytes, where 6 is optimal). Optimal fields order: y_buf, eobs, segmentation_enabled, update_mb_segmentation_map, update_mb_segmentation_data, fullpixel_mask, dequant_y1, dequant_y1_dc, dequant_y2, dequant_uv, predictor, qcoeff, dqcoeff, mode_info_context, above_context, left_context, subpixel_predict, subpixel_predict8x4, subpixel_predict8x8, subpixel_predict16x16, current_bc, recon_above, recon_left, pre, dst, error_info, block, mode_info_stride, frame_type, up_available, left_available, mb_to_left_edge, mb_to_right_edge, mb_to_top_edge, mb_to_bottom_edge, corrupted, recon_left_stride, mb_segment_abs_delta, mode_ref_lf_delta_enabled, mode_ref_lf_delta_update, mb_segment_tree_probs, last_ref_lf_deltas, ref_lf_deltas, last_mode_lf_deltas, mode_lf_deltas, segment_feature_data, consider reordering the fields or adding explicit padding members
210 DECLARE_ALIGNED(16, unsigned char, predictor[384])unsigned char predictor[384] __attribute__((aligned(16)));
211 DECLARE_ALIGNED(16, short, qcoeff[400])short qcoeff[400] __attribute__((aligned(16)));
212 DECLARE_ALIGNED(16, short, dqcoeff[400])short dqcoeff[400] __attribute__((aligned(16)));
213 DECLARE_ALIGNED(16, char, eobs[25])char eobs[25] __attribute__((aligned(16)));
214
215 DECLARE_ALIGNED(16, short, dequant_y1[16])short dequant_y1[16] __attribute__((aligned(16)));
216 DECLARE_ALIGNED(16, short, dequant_y1_dc[16])short dequant_y1_dc[16] __attribute__((aligned(16)));
217 DECLARE_ALIGNED(16, short, dequant_y2[16])short dequant_y2[16] __attribute__((aligned(16)));
218 DECLARE_ALIGNED(16, short, dequant_uv[16])short dequant_uv[16] __attribute__((aligned(16)));
219
220 /* 16 Y blocks, 4 U, 4 V, 1 DC 2nd order block, each with 16 entries. */
221 BLOCKD block[25];
222 int fullpixel_mask;
223
224 YV12_BUFFER_CONFIG pre; /* Filtered copy of previous frame reconstruction */
225 YV12_BUFFER_CONFIG dst;
226
227 MODE_INFO *mode_info_context;
228 int mode_info_stride;
229
230 FRAME_TYPE frame_type;
231
232 int up_available;
233 int left_available;
234
235 unsigned char *recon_above[3];
236 unsigned char *recon_left[3];
237 int recon_left_stride[2];
238
239 /* Y,U,V,Y2 */
240 ENTROPY_CONTEXT_PLANES *above_context;
241 ENTROPY_CONTEXT_PLANES *left_context;
242
243 /* 0 indicates segmentation at MB level is not enabled. Otherwise the
244 * individual bits indicate which features are active. */
245 unsigned char segmentation_enabled;
246
247 /* 0 (do not update) 1 (update) the macroblock segmentation map. */
248 unsigned char update_mb_segmentation_map;
249
250 /* 0 (do not update) 1 (update) the macroblock segmentation feature data. */
251 unsigned char update_mb_segmentation_data;
252
253 /* 0 (do not update) 1 (update) the macroblock segmentation feature data. */
254 unsigned char mb_segment_abs_delta;
255
256 /* Per frame flags that define which MB level features (such as quantizer or
257 * loop filter level) */
258 /* are enabled and when enabled the proabilities used to decode the per MB
259 * flags in MB_MODE_INFO */
260 /* Probability Tree used to code Segment number */
261 vp8_prob mb_segment_tree_probs[MB_FEATURE_TREE_PROBS3];
262 /* Segment parameters */
263 signed char segment_feature_data[MB_LVL_MAX][MAX_MB_SEGMENTS4];
264
265 /* mode_based Loop filter adjustment */
266 unsigned char mode_ref_lf_delta_enabled;
267 unsigned char mode_ref_lf_delta_update;
268
269 /* Delta values have the range +/- MAX_LOOP_FILTER */
270 signed char
271 last_ref_lf_deltas[MAX_REF_LF_DELTAS4]; /* 0 = Intra, Last, GF, ARF */
272 signed char ref_lf_deltas[MAX_REF_LF_DELTAS4]; /* 0 = Intra, Last, GF, ARF */
273 /* 0 = BPRED, ZERO_MV, MV, SPLIT */
274 signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS4];
275 signed char
276 mode_lf_deltas[MAX_MODE_LF_DELTAS4]; /* 0 = BPRED, ZERO_MV, MV, SPLIT */
277
278 /* Distance of MB away from frame edges */
279 int mb_to_left_edge;
280 int mb_to_right_edge;
281 int mb_to_top_edge;
282 int mb_to_bottom_edge;
283
284 vp8_subpix_fn_t subpixel_predict;
285 vp8_subpix_fn_t subpixel_predict8x4;
286 vp8_subpix_fn_t subpixel_predict8x8;
287 vp8_subpix_fn_t subpixel_predict16x16;
288
289 void *current_bc;
290
291 int corrupted;
292
293 struct vpx_internal_error_info error_info;
294
295#if VPX_ARCH_X860 || VPX_ARCH_X86_641
296 /* This is an intermediate buffer currently used in sub-pixel motion search
297 * to keep a copy of the reference area. This buffer can be used for other
298 * purpose.
299 */
300 DECLARE_ALIGNED(32, unsigned char, y_buf[22 * 32])unsigned char y_buf[22 * 32] __attribute__((aligned(32)));
301#endif
302} MACROBLOCKD;
303
304extern void vp8_build_block_doffsets(MACROBLOCKD *x);
305extern void vp8_setup_block_dptrs(MACROBLOCKD *x);
306
307#ifdef __cplusplus
308} // extern "C"
309#endif
310
311#endif // VPX_VP8_COMMON_BLOCKD_H_