Bug Summary

File:root/firefox-clang/media/libvpx/libvpx/vp9/decoder/vp9_decoder.h
Warning:line 49, column 16
Excessive padding in 'struct TileWorkerData' (40 padding bytes, where 8 is optimal). Optimal fields order: dqcoeff, xd, data_end, extend_and_predict_buf, lf_data, lf_sync, bit_reader, error_info, buf_start, buf_end, 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 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name vp9_decodeframe.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/vp9/decoder/vp9_decodeframe.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_VP9_DECODER_VP9_DECODER_H_
12#define VPX_VP9_DECODER_VP9_DECODER_H_
13
14#include "./vpx_config.h"
15
16#include "vpx/vpx_codec.h"
17#include "vpx_dsp/bitreader.h"
18#include "vpx_scale/yv12config.h"
19#include "vpx_util/vpx_pthread.h"
20#include "vpx_util/vpx_thread.h"
21
22#include "vp9/common/vp9_thread_common.h"
23#include "vp9/common/vp9_onyxc_int.h"
24#include "vp9/common/vp9_ppflags.h"
25#include "./vp9_job_queue.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#define EOBS_PER_SB_LOG28 8
32#define DQCOEFFS_PER_SB_LOG212 12
33#define PARTITIONS_PER_SB85 85
34
35typedef enum JobType { PARSE_JOB, RECON_JOB, LPF_JOB } JobType;
36
37typedef struct ThreadData {
38 struct VP9Decoder *pbi;
39 LFWorkerData *lf_data;
40 VP9LfSync *lf_sync;
41} ThreadData;
42
43typedef struct TileBuffer {
44 const uint8_t *data;
45 size_t size;
46 int col; // only used with multi-threaded decoding
47} TileBuffer;
48
49typedef struct TileWorkerData {
Excessive padding in 'struct TileWorkerData' (40 padding bytes, where 8 is optimal). Optimal fields order: dqcoeff, xd, data_end, extend_and_predict_buf, lf_data, lf_sync, bit_reader, error_info, buf_start, buf_end, counts, consider reordering the fields or adding explicit padding members
50 const uint8_t *data_end;
51 int buf_start, buf_end; // pbi->tile_buffers to decode, inclusive
52 vpx_reader bit_reader;
53 FRAME_COUNTS counts;
54 LFWorkerData *lf_data;
55 VP9LfSync *lf_sync;
56 DECLARE_ALIGNED(16, MACROBLOCKD, xd)MACROBLOCKD xd __attribute__((aligned(16)));
57 /* dqcoeff are shared by all the planes. So planes must be decoded serially */
58 DECLARE_ALIGNED(32, tran_low_t, dqcoeff[32 * 32])tran_low_t dqcoeff[32 * 32] __attribute__((aligned(32)));
59 DECLARE_ALIGNED(16, uint16_t, extend_and_predict_buf[80 * 2 * 80 * 2])uint16_t extend_and_predict_buf[80 * 2 * 80 * 2] __attribute__
((aligned(16)))
;
60 struct vpx_internal_error_info error_info;
61} TileWorkerData;
62
63typedef void (*process_block_fn_t)(TileWorkerData *twd,
64 struct VP9Decoder *const pbi, int mi_row,
65 int mi_col, BLOCK_SIZE bsize, int bwl,
66 int bhl);
67
68typedef struct RowMTWorkerData {
69 int num_sbs;
70 int *eob[MAX_MB_PLANE3];
71 PARTITION_TYPE *partition;
72 tran_low_t *dqcoeff[MAX_MB_PLANE3];
73 int8_t *recon_map;
74 const uint8_t *data_end;
75 uint8_t *jobq_buf;
76 JobQueueRowMt jobq;
77 size_t jobq_size;
78 int num_tiles_done;
79 int num_jobs;
80#if CONFIG_MULTITHREAD1
81 pthread_mutex_t recon_done_mutex;
82 pthread_mutex_t *recon_sync_mutex;
83 pthread_cond_t *recon_sync_cond;
84#endif
85 ThreadData *thread_data;
86} RowMTWorkerData;
87
88/* Structure to queue and dequeue row decode jobs */
89typedef struct Job {
90 int row_num;
91 int tile_col;
92 JobType job_type;
93} Job;
94
95typedef struct VP9Decoder {
96 DECLARE_ALIGNED(16, MACROBLOCKD, mb)MACROBLOCKD mb __attribute__((aligned(16)));
97
98 DECLARE_ALIGNED(16, VP9_COMMON, common)VP9_COMMON common __attribute__((aligned(16)));
99
100 int ready_for_new_data;
101
102 int refresh_frame_flags;
103
104 // TODO(hkuang): Combine this with cur_buf in macroblockd as they are
105 // the same.
106 RefCntBuffer *cur_buf; // Current decoding frame buffer.
107
108 VPxWorker lf_worker;
109 VPxWorker *tile_workers;
110 TileWorkerData *tile_worker_data;
111 TileBuffer tile_buffers[64];
112 int num_tile_workers;
113 int total_tiles;
114
115 VP9LfSync lf_row_sync;
116
117 vpx_decrypt_cb decrypt_cb;
118 void *decrypt_state;
119
120 int max_threads;
121 int inv_tile_order;
122 int need_resync; // wait for key/intra-only frame.
123 int hold_ref_buf; // hold the reference buffer.
124
125 int row_mt;
126 int lpf_mt_opt;
127 RowMTWorkerData *row_mt_worker_data;
128} VP9Decoder;
129
130int vp9_receive_compressed_data(struct VP9Decoder *pbi, size_t size,
131 const uint8_t **psource);
132
133int vp9_get_raw_frame(struct VP9Decoder *pbi, YV12_BUFFER_CONFIG *sd,
134 vp9_ppflags_t *flags);
135
136vpx_codec_err_t vp9_copy_reference_dec(struct VP9Decoder *pbi,
137 VP9_REFFRAME ref_frame_flag,
138 YV12_BUFFER_CONFIG *sd);
139
140vpx_codec_err_t vp9_set_reference_dec(VP9_COMMON *cm,
141 VP9_REFFRAME ref_frame_flag,
142 YV12_BUFFER_CONFIG *sd);
143
144static INLINEinline uint8_t read_marker(vpx_decrypt_cb decrypt_cb,
145 void *decrypt_state, const uint8_t *data) {
146 if (decrypt_cb) {
147 uint8_t marker;
148 decrypt_cb(decrypt_state, data, &marker, 1);
149 return marker;
150 }
151 return *data;
152}
153
154// This function is exposed for use in tests, as well as the inlined function
155// "read_marker".
156vpx_codec_err_t vp9_parse_superframe_index(const uint8_t *data, size_t data_sz,
157 uint32_t sizes[8], int *count,
158 vpx_decrypt_cb decrypt_cb,
159 void *decrypt_state);
160
161struct VP9Decoder *vp9_decoder_create(BufferPool *const pool);
162
163void vp9_decoder_remove(struct VP9Decoder *pbi);
164
165void vp9_dec_alloc_row_mt_mem(RowMTWorkerData *row_mt_worker_data,
166 VP9_COMMON *cm, int num_sbs, int max_threads,
167 int num_jobs);
168void vp9_dec_free_row_mt_mem(RowMTWorkerData *row_mt_worker_data);
169
170static INLINEinline void decrease_ref_count(int idx, RefCntBuffer *const frame_bufs,
171 BufferPool *const pool) {
172 if (idx >= 0 && frame_bufs[idx].ref_count > 0) {
173 --frame_bufs[idx].ref_count;
174 // A worker may only get a free framebuffer index when calling get_free_fb.
175 // But the private buffer is not set up until finish decoding header.
176 // So any error happens during decoding header, the frame_bufs will not
177 // have valid priv buffer.
178 if (!frame_bufs[idx].released && frame_bufs[idx].ref_count == 0 &&
179 frame_bufs[idx].raw_frame_buffer.priv) {
180 pool->release_fb_cb(pool->cb_priv, &frame_bufs[idx].raw_frame_buffer);
181 frame_bufs[idx].released = 1;
182 }
183 }
184}
185
186#ifdef __cplusplus
187} // extern "C"
188#endif
189
190#endif // VPX_VP9_DECODER_VP9_DECODER_H_