Bug Summary

File:root/firefox-clang/media/ffvpx/libavcodec/vp9dec.h
Warning:line 173, column 8
Excessive padding in 'struct VP9TileData' (100 padding bytes, where 36 is optimal). Optimal fields order: tmp_y, tmp_uv, edge_emu_buffer, left_y_nnz_ctx, left_mode_ctx, left_uv_nnz_ctx, left_mv_ctx, s, c_b, c, y_stride, uv_stride, b_base, b, left_partition_ctx, left_skip_ctx, left_txfm_ctx, left_segpred_ctx, left_intra_ctx, left_comp_ctx, left_ref_ctx, left_filter_ctx, block_base, block, eob_base, eob, block_structure, uvblock_base, uvblock, uveob_base, uveob, dst, row, row7, col, col7, tile_col_start, error_info, nb_block_structure, min_mv, max_mv, counts, 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 vp9data.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/ffvpx/libavcodec -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/media/ffvpx/libavcodec -resource-dir /usr/lib/llvm-23/lib/clang/23 -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -include libavutil_visibility.h -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D HAVE_AV_CONFIG_H -D ASSERT_LEVEL=2 -I /root/firefox-clang/media/ffvpx/libavcodec -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/media/ffvpx/libavcodec -I /root/firefox-clang/modules/fdlibm/inexact-math-override -I /root/firefox-clang/third_party/khronos/vulkan-headers/include -I /root/firefox-clang/media/mozva -I /root/firefox-clang/media/libopus/include -I /root/firefox-clang/media/libvorbis -I /root/firefox-clang/media/libvpx -I /root/firefox-clang/media/ffvpx -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 -Wno-parentheses -Wno-pointer-sign -Wno-sign-compare -Wno-switch -Wno-type-limits -Wno-unused-function -Wno-deprecated-declarations -Wno-absolute-value -Wno-incompatible-pointer-types -Wno-string-conversion -Wno-visibility -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/media/ffvpx/libavcodec/vp9data.c
1/*
2 * VP9 compatible video decoder
3 *
4 * Copyright (C) 2013 Ronald S. Bultje <rsbultje gmail com>
5 * Copyright (C) 2013 Clément Bœsch <u pkh me>
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef AVCODEC_VP9DEC_H
25#define AVCODEC_VP9DEC_H
26
27#include <stddef.h>
28#include <stdint.h>
29#include <stdatomic.h>
30
31#include "libavutil/mem_internal.h"
32#include "libavutil/pixfmt.h"
33#include "libavutil/thread.h"
34
35#include "get_bits.h"
36#include "videodsp.h"
37#include "vp9.h"
38#include "vp9dsp.h"
39#include "vp9shared.h"
40#include "vpx_rac.h"
41#include "cbs_vp9.h"
42
43#define REF_INVALID_SCALE0xFFFF 0xFFFF
44
45enum MVJoint {
46 MV_JOINT_ZERO,
47 MV_JOINT_H,
48 MV_JOINT_V,
49 MV_JOINT_HV,
50};
51
52typedef struct ProbContext {
53 uint8_t y_mode[4][9];
54 uint8_t uv_mode[10][9];
55 uint8_t filter[4][2];
56 uint8_t mv_mode[7][3];
57 uint8_t intra[4];
58 uint8_t comp[5];
59 uint8_t single_ref[5][2];
60 uint8_t comp_ref[5];
61 uint8_t tx32p[2][3];
62 uint8_t tx16p[2][2];
63 uint8_t tx8p[2];
64 uint8_t skip[3];
65 uint8_t mv_joint[3];
66 struct {
67 uint8_t sign;
68 uint8_t classes[10];
69 uint8_t class0;
70 uint8_t bits[10];
71 uint8_t class0_fp[2][3];
72 uint8_t fp[3];
73 uint8_t class0_hp;
74 uint8_t hp;
75 } mv_comp[2];
76 uint8_t partition[4][4][3];
77} ProbContext;
78
79typedef struct VP9Filter {
80 uint8_t level[8 * 8];
81 uint8_t /* bit=col */ mask[2 /* 0=y, 1=uv */][2 /* 0=col, 1=row */]
82 [8 /* rows */][4 /* 0=16, 1=8, 2=4, 3=inner4 */];
83} VP9Filter;
84
85typedef struct VP9Block {
86 uint8_t seg_id, intra, comp, ref[2], mode[4], uvmode, skip;
87 enum FilterMode filter;
88 VP9mv mv[4 /* b_idx */][2 /* ref */];
89 enum BlockSize bs;
90 enum TxfmMode tx, uvtx;
91 enum BlockLevel bl;
92 enum BlockPartition bp;
93} VP9Block;
94
95typedef struct VP9TileData VP9TileData;
96
97typedef struct VP9Context {
98 VP9SharedContext s;
99 VP9TileData *td;
100
101 CodedBitstreamContext *cbc;
102 CodedBitstreamFragment current_frag;
103 VP9RawFrame *header_ref; ///< RefStruct reference backing frame_header
104 VP9RawFrameHeader *frame_header;
105
106 VP9DSPContext dsp;
107 VideoDSPContext vdsp;
108 GetBitContext gb;
109 VPXRangeCoder c;
110 int pass, active_tile_cols;
111
112#if HAVE_THREADS1
113 pthread_mutex_t progress_mutex;
114 pthread_cond_t progress_cond;
115 atomic_int *entries;
116 unsigned pthread_init_cnt;
117#endif
118
119 uint8_t ss_h, ss_v;
120 uint8_t last_bpp, bpp_index, bytesperpixel;
121 uint8_t last_keyframe;
122 // sb_cols/rows, rows/cols and last_fmt are used for allocating all internal
123 // arrays, and are thus per-thread. w/h and gf_fmt are synced between threads
124 // and are therefore per-stream. pix_fmt represents the value in the header
125 // of the currently processed frame.
126 int w, h;
127 enum AVPixelFormat pix_fmt, last_fmt, gf_fmt;
128 unsigned sb_cols, sb_rows, rows, cols;
129 ProgressFrame next_refs[8];
130
131 struct {
132 uint8_t lim_lut[64];
133 uint8_t mblim_lut[64];
134 } filter_lut;
135 struct {
136 ProbContext p;
137 uint8_t coef[4][2][2][6][6][3];
138 } prob_ctx[4];
139 struct {
140 ProbContext p;
141 uint8_t coef[4][2][2][6][6][11];
142 } prob;
143
144 // contextual (above) cache
145 uint8_t *above_partition_ctx;
146 uint8_t *above_mode_ctx;
147 // FIXME maybe merge some of the below in a flags field?
148 uint8_t *above_y_nnz_ctx;
149 uint8_t *above_uv_nnz_ctx[2];
150 uint8_t *above_skip_ctx; // 1bit
151 uint8_t *above_txfm_ctx; // 2bit
152 uint8_t *above_segpred_ctx; // 1bit
153 uint8_t *above_intra_ctx; // 1bit
154 uint8_t *above_comp_ctx; // 1bit
155 uint8_t *above_ref_ctx; // 2bit
156 uint8_t *above_filter_ctx;
157 VP9mv (*above_mv_ctx)[2];
158
159 // whole-frame cache
160 uint8_t *intra_pred_data[3];
161 VP9Filter *lflvl;
162
163 // block reconstruction intermediates
164 int block_alloc_using_2pass;
165 uint16_t mvscale[3][2];
166 uint8_t mvstep[3][2];
167
168 // frame specific buffer pools
169 struct AVRefStructPool *frame_extradata_pool;
170 int frame_extradata_pool_size;
171} VP9Context;
172
173struct VP9TileData {
Excessive padding in 'struct VP9TileData' (100 padding bytes, where 36 is optimal). Optimal fields order: tmp_y, tmp_uv, edge_emu_buffer, left_y_nnz_ctx, left_mode_ctx, left_uv_nnz_ctx, left_mv_ctx, s, c_b, c, y_stride, uv_stride, b_base, b, left_partition_ctx, left_skip_ctx, left_txfm_ctx, left_segpred_ctx, left_intra_ctx, left_comp_ctx, left_ref_ctx, left_filter_ctx, block_base, block, eob_base, eob, block_structure, uvblock_base, uvblock, uveob_base, uveob, dst, row, row7, col, col7, tile_col_start, error_info, nb_block_structure, min_mv, max_mv, counts, consider reordering the fields or adding explicit padding members
174 const VP9Context *s;
175 VPXRangeCoder *c_b;
176 VPXRangeCoder *c;
177 int row, row7, col, col7;
178 uint8_t *dst[3];
179 ptrdiff_t y_stride, uv_stride;
180 VP9Block *b_base, *b;
181 unsigned tile_col_start;
182
183 struct {
184 unsigned y_mode[4][10];
185 unsigned uv_mode[10][10];
186 unsigned filter[4][3];
187 unsigned mv_mode[7][4];
188 unsigned intra[4][2];
189 unsigned comp[5][2];
190 unsigned single_ref[5][2][2];
191 unsigned comp_ref[5][2];
192 unsigned tx32p[2][4];
193 unsigned tx16p[2][3];
194 unsigned tx8p[2][2];
195 unsigned skip[3][2];
196 unsigned mv_joint[4];
197 struct {
198 unsigned sign[2];
199 unsigned classes[11];
200 unsigned class0[2];
201 unsigned bits[10][2];
202 unsigned class0_fp[2][4];
203 unsigned fp[4];
204 unsigned class0_hp[2];
205 unsigned hp[2];
206 } mv_comp[2];
207 unsigned partition[4][4][4];
208 unsigned coef[4][2][2][6][6][3];
209 unsigned eob[4][2][2][6][6][2];
210 } counts;
211
212 // whole-frame cache
213 DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)_Alignas(32) uint8_t edge_emu_buffer[135 * 144 * 2];
214
215 // contextual (left) cache
216 DECLARE_ALIGNED(16, uint8_t, left_y_nnz_ctx)_Alignas(16) uint8_t left_y_nnz_ctx[16];
217 DECLARE_ALIGNED(16, uint8_t, left_mode_ctx)_Alignas(16) uint8_t left_mode_ctx[16];
218 DECLARE_ALIGNED(16, VP9mv, left_mv_ctx)_Alignas(16) VP9mv left_mv_ctx[16][2];
219 DECLARE_ALIGNED(16, uint8_t, left_uv_nnz_ctx)_Alignas(16) uint8_t left_uv_nnz_ctx[2][16];
220 DECLARE_ALIGNED(8, uint8_t, left_partition_ctx)_Alignas(8) uint8_t left_partition_ctx[8];
221 DECLARE_ALIGNED(8, uint8_t, left_skip_ctx)_Alignas(8) uint8_t left_skip_ctx[8];
222 DECLARE_ALIGNED(8, uint8_t, left_txfm_ctx)_Alignas(8) uint8_t left_txfm_ctx[8];
223 DECLARE_ALIGNED(8, uint8_t, left_segpred_ctx)_Alignas(8) uint8_t left_segpred_ctx[8];
224 DECLARE_ALIGNED(8, uint8_t, left_intra_ctx)_Alignas(8) uint8_t left_intra_ctx[8];
225 DECLARE_ALIGNED(8, uint8_t, left_comp_ctx)_Alignas(8) uint8_t left_comp_ctx[8];
226 DECLARE_ALIGNED(8, uint8_t, left_ref_ctx)_Alignas(8) uint8_t left_ref_ctx[8];
227 DECLARE_ALIGNED(8, uint8_t, left_filter_ctx)_Alignas(8) uint8_t left_filter_ctx[8];
228 // block reconstruction intermediates
229 DECLARE_ALIGNED(64, uint8_t, tmp_y)_Alignas(64) uint8_t tmp_y[64 * 64 * 2];
230 DECLARE_ALIGNED(64, uint8_t, tmp_uv)_Alignas(64) uint8_t tmp_uv[2][64 * 64 * 2];
231 struct { int x, y; } min_mv, max_mv;
232 int16_t *block_base, *block, *uvblock_base[2], *uvblock[2];
233 uint8_t *eob_base, *uveob_base[2], *eob, *uveob[2];
234
235 // error message
236 int error_info;
237 struct {
238 unsigned int row:13;
239 unsigned int col:13;
240 unsigned int block_size_idx_x:2;
241 unsigned int block_size_idx_y:2;
242 } *block_structure;
243 unsigned int nb_block_structure;
244};
245
246void ff_vp9_fill_mv(VP9TileData *td, VP9mv *mv, int mode, int sb);
247
248void ff_vp9_adapt_probs(VP9Context *s);
249
250void ff_vp9_decode_block(VP9TileData *td, int row, int col,
251 VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff,
252 enum BlockLevel bl, enum BlockPartition bp);
253
254void ff_vp9_loopfilter_sb(struct AVCodecContext *avctx, VP9Filter *lflvl,
255 int row, int col, ptrdiff_t yoff, ptrdiff_t uvoff);
256
257void ff_vp9_intra_recon_8bpp(VP9TileData *td,
258 ptrdiff_t y_off, ptrdiff_t uv_off);
259void ff_vp9_intra_recon_16bpp(VP9TileData *td,
260 ptrdiff_t y_off, ptrdiff_t uv_off);
261void ff_vp9_inter_recon_8bpp(VP9TileData *td);
262void ff_vp9_inter_recon_16bpp(VP9TileData *td);
263
264#endif /* AVCODEC_VP9DEC_H */