Bug Summary

File:root/firefox-clang/third_party/dav1d/src/cdf.h
Warning:line 39, column 16
Excessive padding in 'struct CdfModeContext' (40 padding bytes, where 8 is optimal). Optimal fields order: txtp_inter2, txtp_inter1, y_mode, cfl_alpha, wedge_idx, partition, uv_mode, cfl_sign, filter_intra, seg_id, angle_delta, comp_inter_mode, pal_sz, txtp_intra1, txtp_intra2, color_map, delta_q, restore_switchable, interintra_mode, delta_lf, txsz, filter, motion_mode, restore_wiener, restore_sgrproj, intrabc, pal_uv, globalmv_mode, skip, skip_mode, drl_bit, seg_pred, txtp_inter3, intra, comp, comp_dir, newmv_mode, refmv_mode, jnt_comp, mask_comp, comp_bwd_ref, interintra, interintra_wedge, wedge_comp, comp_fwd_ref, comp_uni_ref, ref, txpart, pal_y, use_filter_intra, obmc, 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 -O2 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name cdf.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/libdav1d -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/media/libdav1d -resource-dir /usr/lib/llvm-23/lib/clang/23 -include /root/firefox-clang/config/gcc_hidden.h -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D DAV1D_API= -D STACK_ALIGNMENT=16 -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /root/firefox-clang/media/libdav1d -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/media/libdav1d -I /root/firefox-clang/third_party/dav1d -I /root/firefox-clang/third_party/dav1d/include -I /root/firefox-clang/third_party/dav1d/include/dav1d -I /root/firefox-clang/third_party/dav1d/src -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-23/lib/clang/23/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -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-character-conversion -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 -fdiagnostics-absolute-paths -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -mllvm -dwarf-linkage-names=Abstract -faddrsig -fdwarf2-cfi-asm -o /tmp/scan-build-2026-09-01-224014-2642839-1 -x c /root/firefox-clang/third_party/dav1d/src/cdf.c
1/*
2 * Copyright © 2018, VideoLAN and dav1d authors
3 * Copyright © 2018, Two Orioles, LLC
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice, this
10 * list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef DAV1D_SRC_CDF_H
29#define DAV1D_SRC_CDF_H
30
31#include <stdint.h>
32
33#include "src/levels.h"
34#include "src/ref.h"
35#include "src/thread_data.h"
36
37/* Buffers padded to [4]/[8]/[16] for SIMD where needed. */
38
39typedef struct CdfModeContext {
Excessive padding in 'struct CdfModeContext' (40 padding bytes, where 8 is optimal). Optimal fields order: txtp_inter2, txtp_inter1, y_mode, cfl_alpha, wedge_idx, partition, uv_mode, cfl_sign, filter_intra, seg_id, angle_delta, comp_inter_mode, pal_sz, txtp_intra1, txtp_intra2, color_map, delta_q, restore_switchable, interintra_mode, delta_lf, txsz, filter, motion_mode, restore_wiener, restore_sgrproj, intrabc, pal_uv, globalmv_mode, skip, skip_mode, drl_bit, seg_pred, txtp_inter3, intra, comp, comp_dir, newmv_mode, refmv_mode, jnt_comp, mask_comp, comp_bwd_ref, interintra, interintra_wedge, wedge_comp, comp_fwd_ref, comp_uni_ref, ref, txpart, pal_y, use_filter_intra, obmc, consider reordering the fields or adding explicit padding members
40 ALIGN(uint16_t uv_mode[2][N_INTRA_PRED_MODES][N_UV_INTRA_PRED_MODES + 2], 32)uint16_t uv_mode[2][N_INTRA_PRED_MODES][N_UV_INTRA_PRED_MODES
+ 2] __attribute__((aligned(32)))
;
41 ALIGN(uint16_t partition[N_BL_LEVELS][4][N_PARTITIONS + 6], 32)uint16_t partition[N_BL_LEVELS][4][N_PARTITIONS + 6] __attribute__
((aligned(32)))
;
42 ALIGN(uint16_t cfl_alpha[6][16], 32)uint16_t cfl_alpha[6][16] __attribute__((aligned(32)));
43 ALIGN(uint16_t txtp_inter1[2][16], 32)uint16_t txtp_inter1[2][16] __attribute__((aligned(32)));
44 ALIGN(uint16_t txtp_inter2[12 + 4], 32)uint16_t txtp_inter2[12 + 4] __attribute__((aligned(32)));
45 ALIGN(uint16_t txtp_intra1[2][N_INTRA_PRED_MODES][7 + 1], 16)uint16_t txtp_intra1[2][N_INTRA_PRED_MODES][7 + 1] __attribute__
((aligned(16)))
;
46 ALIGN(uint16_t txtp_intra2[3][N_INTRA_PRED_MODES][5 + 3], 16)uint16_t txtp_intra2[3][N_INTRA_PRED_MODES][5 + 3] __attribute__
((aligned(16)))
;
47 ALIGN(uint16_t cfl_sign[8], 16)uint16_t cfl_sign[8] __attribute__((aligned(16)));
48 ALIGN(uint16_t angle_delta[8][8], 16)uint16_t angle_delta[8][8] __attribute__((aligned(16)));
49 ALIGN(uint16_t filter_intra[5 + 3], 16)uint16_t filter_intra[5 + 3] __attribute__((aligned(16)));
50 ALIGN(uint16_t seg_id[3][DAV1D_MAX_SEGMENTS], 16)uint16_t seg_id[3][8] __attribute__((aligned(16)));
51 ALIGN(uint16_t pal_sz[2][7][7 + 1], 16)uint16_t pal_sz[2][7][7 + 1] __attribute__((aligned(16)));
52 ALIGN(uint16_t color_map[2][7][5][8], 16)uint16_t color_map[2][7][5][8] __attribute__((aligned(16)));
53 ALIGN(uint16_t txsz[N_TX_SIZES - 1][3][4], 8)uint16_t txsz[N_TX_SIZES - 1][3][4] __attribute__((aligned(8)
))
;
54 ALIGN(uint16_t delta_q[4], 8)uint16_t delta_q[4] __attribute__((aligned(8)));
55 ALIGN(uint16_t delta_lf[5][4], 8)uint16_t delta_lf[5][4] __attribute__((aligned(8)));
56 ALIGN(uint16_t restore_switchable[3 + 1], 8)uint16_t restore_switchable[3 + 1] __attribute__((aligned(8))
)
;
57 ALIGN(uint16_t restore_wiener[2], 4)uint16_t restore_wiener[2] __attribute__((aligned(4)));
58 ALIGN(uint16_t restore_sgrproj[2], 4)uint16_t restore_sgrproj[2] __attribute__((aligned(4)));
59 ALIGN(uint16_t txtp_inter3[4][2], 4)uint16_t txtp_inter3[4][2] __attribute__((aligned(4)));
60 ALIGN(uint16_t use_filter_intra[N_BS_SIZES][2], 4)uint16_t use_filter_intra[N_BS_SIZES][2] __attribute__((aligned
(4)))
;
61 ALIGN(uint16_t txpart[7][3][2], 4)uint16_t txpart[7][3][2] __attribute__((aligned(4)));
62 ALIGN(uint16_t skip[3][2], 4)uint16_t skip[3][2] __attribute__((aligned(4)));
63 ALIGN(uint16_t pal_y[7][3][2], 4)uint16_t pal_y[7][3][2] __attribute__((aligned(4)));
64 ALIGN(uint16_t pal_uv[2][2], 4)uint16_t pal_uv[2][2] __attribute__((aligned(4)));
65
66 /* key/intra */
67 ALIGN(uint16_t intrabc[2], 4)uint16_t intrabc[2] __attribute__((aligned(4)));
68
69 /* inter/switch */
70 ALIGN(uint16_t y_mode[4][N_INTRA_PRED_MODES + 3], 32)uint16_t y_mode[4][N_INTRA_PRED_MODES + 3] __attribute__((aligned
(32)))
;
71 ALIGN(uint16_t wedge_idx[9][16], 32)uint16_t wedge_idx[9][16] __attribute__((aligned(32)));
72 ALIGN(uint16_t comp_inter_mode[8][N_COMP_INTER_PRED_MODES], 16)uint16_t comp_inter_mode[8][N_COMP_INTER_PRED_MODES] __attribute__
((aligned(16)))
;
73 ALIGN(uint16_t filter[2][8][DAV1D_N_SWITCHABLE_FILTERS + 1], 8)uint16_t filter[2][8][DAV1D_N_SWITCHABLE_FILTERS + 1] __attribute__
((aligned(8)))
;
74 ALIGN(uint16_t interintra_mode[4][4], 8)uint16_t interintra_mode[4][4] __attribute__((aligned(8)));
75 ALIGN(uint16_t motion_mode[N_BS_SIZES][3 + 1], 8)uint16_t motion_mode[N_BS_SIZES][3 + 1] __attribute__((aligned
(8)))
;
76 ALIGN(uint16_t skip_mode[3][2], 4)uint16_t skip_mode[3][2] __attribute__((aligned(4)));
77 ALIGN(uint16_t newmv_mode[6][2], 4)uint16_t newmv_mode[6][2] __attribute__((aligned(4)));
78 ALIGN(uint16_t globalmv_mode[2][2], 4)uint16_t globalmv_mode[2][2] __attribute__((aligned(4)));
79 ALIGN(uint16_t refmv_mode[6][2], 4)uint16_t refmv_mode[6][2] __attribute__((aligned(4)));
80 ALIGN(uint16_t drl_bit[3][2], 4)uint16_t drl_bit[3][2] __attribute__((aligned(4)));
81 ALIGN(uint16_t intra[4][2], 4)uint16_t intra[4][2] __attribute__((aligned(4)));
82 ALIGN(uint16_t comp[5][2], 4)uint16_t comp[5][2] __attribute__((aligned(4)));
83 ALIGN(uint16_t comp_dir[5][2], 4)uint16_t comp_dir[5][2] __attribute__((aligned(4)));
84 ALIGN(uint16_t jnt_comp[6][2], 4)uint16_t jnt_comp[6][2] __attribute__((aligned(4)));
85 ALIGN(uint16_t mask_comp[6][2], 4)uint16_t mask_comp[6][2] __attribute__((aligned(4)));
86 ALIGN(uint16_t wedge_comp[9][2], 4)uint16_t wedge_comp[9][2] __attribute__((aligned(4)));
87 ALIGN(uint16_t ref[6][3][2], 4)uint16_t ref[6][3][2] __attribute__((aligned(4)));
88 ALIGN(uint16_t comp_fwd_ref[3][3][2], 4)uint16_t comp_fwd_ref[3][3][2] __attribute__((aligned(4)));
89 ALIGN(uint16_t comp_bwd_ref[2][3][2], 4)uint16_t comp_bwd_ref[2][3][2] __attribute__((aligned(4)));
90 ALIGN(uint16_t comp_uni_ref[3][3][2], 4)uint16_t comp_uni_ref[3][3][2] __attribute__((aligned(4)));
91 ALIGN(uint16_t seg_pred[3][2], 4)uint16_t seg_pred[3][2] __attribute__((aligned(4)));
92 ALIGN(uint16_t interintra[7][2], 4)uint16_t interintra[7][2] __attribute__((aligned(4)));
93 ALIGN(uint16_t interintra_wedge[7][2], 4)uint16_t interintra_wedge[7][2] __attribute__((aligned(4)));
94 ALIGN(uint16_t obmc[N_BS_SIZES][2], 4)uint16_t obmc[N_BS_SIZES][2] __attribute__((aligned(4)));
95} CdfModeContext;
96
97typedef struct CdfCoefContext {
98 ALIGN(uint16_t eob_bin_16[2][2][5 + 3], 16)uint16_t eob_bin_16[2][2][5 + 3] __attribute__((aligned(16)));
99 ALIGN(uint16_t eob_bin_32[2][2][6 + 2], 16)uint16_t eob_bin_32[2][2][6 + 2] __attribute__((aligned(16)));
100 ALIGN(uint16_t eob_bin_64[2][2][7 + 1], 16)uint16_t eob_bin_64[2][2][7 + 1] __attribute__((aligned(16)));
101 ALIGN(uint16_t eob_bin_128[2][2][8 + 0], 16)uint16_t eob_bin_128[2][2][8 + 0] __attribute__((aligned(16))
)
;
102 ALIGN(uint16_t eob_bin_256[2][2][9 + 7], 32)uint16_t eob_bin_256[2][2][9 + 7] __attribute__((aligned(32))
)
;
103 ALIGN(uint16_t eob_bin_512[2][10 + 6], 32)uint16_t eob_bin_512[2][10 + 6] __attribute__((aligned(32)));
104 ALIGN(uint16_t eob_bin_1024[2][11 + 5], 32)uint16_t eob_bin_1024[2][11 + 5] __attribute__((aligned(32)));
105 ALIGN(uint16_t eob_base_tok[N_TX_SIZES][2][4][4], 8)uint16_t eob_base_tok[N_TX_SIZES][2][4][4] __attribute__((aligned
(8)))
;
106 ALIGN(uint16_t base_tok[N_TX_SIZES][2][41][4], 8)uint16_t base_tok[N_TX_SIZES][2][41][4] __attribute__((aligned
(8)))
;
107 ALIGN(uint16_t br_tok[4 /*5*/][2][21][4], 8)uint16_t br_tok[4 ][2][21][4] __attribute__((aligned(8)));
108 ALIGN(uint16_t eob_hi_bit[N_TX_SIZES][2][9][2], 4)uint16_t eob_hi_bit[N_TX_SIZES][2][9][2] __attribute__((aligned
(4)))
;
109 ALIGN(uint16_t skip[N_TX_SIZES][13][2], 4)uint16_t skip[N_TX_SIZES][13][2] __attribute__((aligned(4)));
110 ALIGN(uint16_t dc_sign[2][3][2], 4)uint16_t dc_sign[2][3][2] __attribute__((aligned(4)));
111} CdfCoefContext;
112
113typedef struct CdfMvComponent {
114 ALIGN(uint16_t classes[11 + 5], 32)uint16_t classes[11 + 5] __attribute__((aligned(32)));
115 ALIGN(uint16_t sign[2], 4)uint16_t sign[2] __attribute__((aligned(4)));
116 ALIGN(uint16_t class0[2], 4)uint16_t class0[2] __attribute__((aligned(4)));
117 ALIGN(uint16_t class0_fp[2][4], 8)uint16_t class0_fp[2][4] __attribute__((aligned(8)));
118 ALIGN(uint16_t class0_hp[2], 4)uint16_t class0_hp[2] __attribute__((aligned(4)));
119 ALIGN(uint16_t classN[10][2], 4)uint16_t classN[10][2] __attribute__((aligned(4)));
120 ALIGN(uint16_t classN_fp[4], 8)uint16_t classN_fp[4] __attribute__((aligned(8)));
121 ALIGN(uint16_t classN_hp[2], 4)uint16_t classN_hp[2] __attribute__((aligned(4)));
122} CdfMvComponent;
123
124typedef struct CdfMvContext {
125 CdfMvComponent comp[2];
126 ALIGN(uint16_t joint[N_MV_JOINTS], 8)uint16_t joint[N_MV_JOINTS] __attribute__((aligned(8)));
127} CdfMvContext;
128
129typedef struct CdfContext {
130 CdfCoefContext coef;
131 CdfModeContext m;
132 CdfMvContext mv;
133 ALIGN(uint16_t kfym[5][5][N_INTRA_PRED_MODES + 3], 32)uint16_t kfym[5][5][N_INTRA_PRED_MODES + 3] __attribute__((aligned
(32)))
;
134} CdfContext;
135
136typedef struct CdfThreadContext {
137 Dav1dRef *ref; ///< allocation origin
138 union {
139 CdfContext *cdf; // if ref != NULL
140 unsigned qcat; // if ref == NULL, from static CDF tables
141 } data;
142 atomic_uint *progress;
143} CdfThreadContext;
144
145void dav1d_cdf_thread_init_static(CdfThreadContext *cdf, unsigned qidx);
146int dav1d_cdf_thread_alloc(Dav1dContext *c, CdfThreadContext *cdf,
147 const int have_frame_mt);
148void dav1d_cdf_thread_copy(CdfContext *dst, const CdfThreadContext *src);
149void dav1d_cdf_thread_ref(CdfThreadContext *dst, CdfThreadContext *src);
150void dav1d_cdf_thread_unref(CdfThreadContext *cdf);
151void dav1d_cdf_thread_update(const Dav1dFrameHeader *hdr, CdfContext *dst,
152 const CdfContext *src);
153
154#endif /* DAV1D_SRC_CDF_H */