Bug Summary

File:root/firefox-clang/media/libvpx/libvpx/vp8/encoder/onyx_int.h
Warning:line 269, column 16
Excessive padding in 'struct VP8_COMP' (68 padding bytes, where 4 is optimal). Optimal fields order: mb, Y1quant, Y1quant_shift, Y1zbin, Y1round, Y2quant, Y2quant_shift, Y2zbin, Y2round, UVquant, UVquant_shift, UVzbin, UVround, zrun_zbin_boost_y1, zrun_zbin_boost_y2, zrun_zbin_boost_uv, Y1quant_fast, Y2quant_fast, UVquant_fast, common, lookahead, source, alt_ref_source, last_source, Source, un_scaled_source, last_frame_unscaled_source, tok, last_prediction_error, last_intra_error, rate_correction_factor, key_frame_rate_correction_factor, gf_rate_correction_factor, key_frame_count, output_framerate, last_time_stamp_seen, last_end_time_stamp_seen, first_time_stamp_ever, total_byte_count, framerate, ref_framerate, buffer_level, bits_off_target, total_actual_bits, total_target_vs_actual, output_pkt_list, skin_map, segmentation_map, active_map, cyclic_refresh_map, consec_zero_last, consec_zero_last_mvbias, mt_current_mb_col, h_encoding_thread, h_filter_thread, mb_row_ei, en_thread_data, h_event_start_encoding, h_event_end_encoding, tplist, find_fractional_mv_step, refining_search_sad, diamond_search_sad, mb_activity_map, gf_active_flags, lfmv, lf_ref_frame_sign_bias, lf_ref_frame, lpf_thread_data, h_event_start_lpf, h_event_end_lpf, frames_in_layer, bytes_in_layer, sum_psnr, sum_psnr_p, total_error2, total_error2_p, sum_ssim, sum_weights, total_ssimg_y_in_layer, total_ssimg_u_in_layer, total_ssimg_v_in_layer, total_ssimg_all_in_layer, partition_d, partition_d_end, scaled_source, pick_lf_lvl_frame, alt_ref_buffer, fn_ptr, frames, bc, oxcf, twopass, denoiser, layer_context, frames_till_alt_ref_frame, source_alt_ref_pending, source_alt_ref_active, is_src_frame_alt_ref, gold_is_last, alt_is_last, gold_is_alt, tok_count, frames_since_key, key_frame_frequency, this_key_frame_forced, next_key_frame_forced, ambient_err, RDMULT, RDDIV, this_frame_target, projected_frame_size, frames_since_golden, frames_till_gf_update_due, current_gf_interval, gf_overspend_bits, non_gf_bitrate_adjustment, kf_overspend_bits, kf_bitrate_adjustment, max_gf_interval, baseline_gf_interval, active_arnr_frames, per_frame_bandwidth, av_per_frame_bandwidth, min_frame_bandwidth, inter_frame_target, ni_av_qi, ni_tot_qi, ni_frames, avg_frame_qindex, buffered_mode, rolling_target_bits, rolling_actual_bits, long_rolling_target_bits, long_rolling_actual_bits, worst_quality, active_worst_quality, best_quality, active_best_quality, cq_target_quality, drop_frames_allowed, drop_frame, gfu_boost, kf_boost, last_boost, target_bandwidth, decimation_factor, decimation_count, avg_encode_time, avg_pick_mode_time, Speed, compressor_speed, auto_gold, auto_adjust_gold_quantizer, auto_worst_q, cpu_used, pass, prob_intra_coded, prob_last_coded, prob_gf_coded, prob_skip_false, this_frame_percent_intra, last_frame_percent_intra, ref_frame_flags, zeromv_count, lf_zeromv_pct, active_map_enabled, cyclic_refresh_mode_enabled, cyclic_refresh_mode_max_mbs_perframe, cyclic_refresh_mode_index, cyclic_refresh_q, temporal_pattern_counter, temporal_layer_id, mse_source_denoised, force_maxqp, frames_since_last_drop_overshoot, last_pred_err_mb, gf_update_onepass_cbr, gf_interval_onepass_cbr, gf_noboost_onepass_cbr, mt_current_mb_col_size, mt_sync_range, b_multi_threaded, encoding_thread_count, b_lpf_running, b_calculate_psnr, activity_avg, gf_active_count, output_partition, force_next_frame_intra, droppable, initial_width, initial_height, current_layer, mr_low_res_mb_cols, closest_reference_frame, use_roi_static_threshold, ext_refresh_frame_flags_pending, rt_always_update_correction_factor, rt_drop_recode_on_overshoot, last_q, last_skip_false_probs, last_skip_probs_q, recent_ref_frame_usage, segment_encode_breakout, current_ref_frames, prior_key_frame_distance, partition_sz, mode_check_freq, rd_baseline_thresh, sf, base_skip_false_prob, fixed_divide, frame_branch_ct, coding_context, rd_costs, mr_low_res_mv_avail, segment_feature_data, frame_coef_probs, update_probs, lfc_n, lfc_a, lfc_g, 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 vp8_skin_detection.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/vp8_skin_detection.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_ENCODER_ONYX_INT_H_
12#define VPX_VP8_ENCODER_ONYX_INT_H_
13
14#include <assert.h>
15#include <stdio.h>
16
17#include "vpx_config.h"
18#include "vp8/common/onyx.h"
19#include "treewriter.h"
20#include "tokenize.h"
21#include "vp8/common/onyxc_int.h"
22#include "vpx_dsp/variance.h"
23#include "vpx_util/vpx_pthread.h"
24#include "encodemb.h"
25#include "vp8/encoder/quantize.h"
26#include "vp8/common/entropy.h"
27#include "vp8/common/threading.h"
28#include "vpx_ports/mem.h"
29#include "vpx/internal/vpx_codec_internal.h"
30#include "vpx/vp8.h"
31#include "mcomp.h"
32#include "vp8/common/findnearmv.h"
33#include "lookahead.h"
34#if CONFIG_TEMPORAL_DENOISING1
35#include "vp8/encoder/denoising.h"
36#endif
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42#define MIN_GF_INTERVAL4 4
43#define DEFAULT_GF_INTERVAL7 7
44
45#define KEY_FRAME_CONTEXT5 5
46
47#define MAX_LAG_BUFFERS(0 ? 1 : 25) (CONFIG_REALTIME_ONLY0 ? 1 : 25)
48
49#define AF_THRESH25 25
50#define AF_THRESH2100 100
51#define ARF_DECAY_THRESH12 12
52
53#define MIN_THRESHMULT32 32
54#define MAX_THRESHMULT512 512
55
56#define GF_ZEROMV_ZBIN_BOOST12 12
57#define LF_ZEROMV_ZBIN_BOOST6 6
58#define MV_ZBIN_BOOST4 4
59#define ZBIN_OQ_MAX192 192
60
61#define VP8_TEMPORAL_ALT_REF!0 !CONFIG_REALTIME_ONLY0
62
63/* vp8 uses 10,000,000 ticks/second as time stamp */
64#define TICKS_PER_SEC10000000 10000000
65
66typedef struct {
67 int kf_indicated;
68 unsigned int frames_since_key;
69 unsigned int frames_since_golden;
70 int filter_level;
71 int frames_till_gf_update_due;
72 int recent_ref_frame_usage[MAX_REF_FRAMES];
73
74 MV_CONTEXT mvc[2];
75 int mvcosts[2][MVvals + 1];
76
77#ifdef MODE_STATS
78 int y_modes[5];
79 int uv_modes[4];
80 int b_modes[10];
81 int inter_y_modes[10];
82 int inter_uv_modes[4];
83 int inter_b_modes[10];
84#endif
85
86 vp8_prob ymode_prob[4], uv_mode_prob[3]; /* interframe intra mode probs */
87 vp8_prob kf_ymode_prob[4], kf_uv_mode_prob[3]; /* keyframe "" */
88
89 int ymode_count[5], uv_mode_count[4]; /* intra MB type cts this frame */
90
91 int count_mb_ref_frame_usage[MAX_REF_FRAMES];
92
93 int this_frame_percent_intra;
94 int last_frame_percent_intra;
95
96} CODING_CONTEXT;
97
98typedef struct {
99 double frame;
100 double intra_error;
101 double coded_error;
102 double ssim_weighted_pred_err;
103 double pcnt_inter;
104 double pcnt_motion;
105 double pcnt_second_ref;
106 double pcnt_neutral;
107 double MVr;
108 double mvr_abs;
109 double MVc;
110 double mvc_abs;
111 double MVrv;
112 double MVcv;
113 double mv_in_out_count;
114 double new_mv_count;
115 double duration;
116 double count;
117} FIRSTPASS_STATS;
118
119typedef struct {
120 int frames_so_far;
121 double frame_intra_error;
122 double frame_coded_error;
123 double frame_pcnt_inter;
124 double frame_pcnt_motion;
125 double frame_mvr;
126 double frame_mvr_abs;
127 double frame_mvc;
128 double frame_mvc_abs;
129
130} ONEPASS_FRAMESTATS;
131
132typedef enum {
133 THR_ZERO1 = 0,
134 THR_DC = 1,
135
136 THR_NEAREST1 = 2,
137 THR_NEAR1 = 3,
138
139 THR_ZERO2 = 4,
140 THR_NEAREST2 = 5,
141
142 THR_ZERO3 = 6,
143 THR_NEAREST3 = 7,
144
145 THR_NEAR2 = 8,
146 THR_NEAR3 = 9,
147
148 THR_V_PRED = 10,
149 THR_H_PRED = 11,
150 THR_TM = 12,
151
152 THR_NEW1 = 13,
153 THR_NEW2 = 14,
154 THR_NEW3 = 15,
155
156 THR_SPLIT1 = 16,
157 THR_SPLIT2 = 17,
158 THR_SPLIT3 = 18,
159
160 THR_B_PRED = 19
161} THR_MODES;
162
163typedef enum { DIAMOND = 0, NSTEP = 1, HEX = 2 } SEARCH_METHODS;
164
165typedef struct {
166 int RD;
167 SEARCH_METHODS search_method;
168 int improved_quant;
169 int improved_dct;
170 int auto_filter;
171 int recode_loop;
172 int iterative_sub_pixel;
173 int half_pixel_search;
174 int quarter_pixel_search;
175 int thresh_mult[MAX_MODES20];
176 int max_step_search_steps;
177 int first_step;
178 int optimize_coefficients;
179
180 int use_fastquant_for_pick;
181 int no_skip_block4x4_search;
182 int improved_mv_pred;
183
184} SPEED_FEATURES;
185
186typedef struct {
187 MACROBLOCK mb;
188 int segment_counts[MAX_MB_SEGMENTS4];
189 int totalrate;
190} MB_ROW_COMP;
191
192typedef struct {
193 TOKENEXTRA *start;
194 TOKENEXTRA *stop;
195} TOKENLIST;
196
197typedef struct {
198 int ithread;
199 void *ptr1;
200 void *ptr2;
201} ENCODETHREAD_DATA;
202typedef struct {
203 int ithread;
204 void *ptr1;
205} LPFTHREAD_DATA;
206
207enum {
208 BLOCK_16X8,
209 BLOCK_8X16,
210 BLOCK_8X8,
211 BLOCK_4X4,
212 BLOCK_16X16,
213 BLOCK_MAX_SEGMENTS
214};
215
216typedef struct {
217 /* Layer configuration */
218 double framerate;
219 int target_bandwidth; /* bits per second */
220
221 /* Layer specific coding parameters */
222 int64_t starting_buffer_level;
223 int64_t optimal_buffer_level;
224 int64_t maximum_buffer_size;
225 int64_t starting_buffer_level_in_ms;
226 int64_t optimal_buffer_level_in_ms;
227 int64_t maximum_buffer_size_in_ms;
228
229 int avg_frame_size_for_layer;
230
231 int64_t buffer_level;
232 int64_t bits_off_target;
233
234 int64_t total_actual_bits;
235 int64_t total_target_vs_actual;
236
237 int worst_quality;
238 int active_worst_quality;
239 int best_quality;
240 int active_best_quality;
241
242 int ni_av_qi;
243 int ni_tot_qi;
244 int ni_frames;
245 int avg_frame_qindex;
246
247 double rate_correction_factor;
248 double key_frame_rate_correction_factor;
249 double gf_rate_correction_factor;
250
251 int zbin_over_quant;
252
253 int inter_frame_target;
254 int64_t total_byte_count;
255
256 int filter_level;
257
258 int frames_since_last_drop_overshoot;
259
260 int force_maxqp;
261
262 int last_frame_percent_intra;
263
264 int count_mb_ref_frame_usage[MAX_REF_FRAMES];
265
266 int last_q[2];
267} LAYER_CONTEXT;
268
269typedef struct VP8_COMP {
Excessive padding in 'struct VP8_COMP' (68 padding bytes, where 4 is optimal). Optimal fields order: mb, Y1quant, Y1quant_shift, Y1zbin, Y1round, Y2quant, Y2quant_shift, Y2zbin, Y2round, UVquant, UVquant_shift, UVzbin, UVround, zrun_zbin_boost_y1, zrun_zbin_boost_y2, zrun_zbin_boost_uv, Y1quant_fast, Y2quant_fast, UVquant_fast, common, lookahead, source, alt_ref_source, last_source, Source, un_scaled_source, last_frame_unscaled_source, tok, last_prediction_error, last_intra_error, rate_correction_factor, key_frame_rate_correction_factor, gf_rate_correction_factor, key_frame_count, output_framerate, last_time_stamp_seen, last_end_time_stamp_seen, first_time_stamp_ever, total_byte_count, framerate, ref_framerate, buffer_level, bits_off_target, total_actual_bits, total_target_vs_actual, output_pkt_list, skin_map, segmentation_map, active_map, cyclic_refresh_map, consec_zero_last, consec_zero_last_mvbias, mt_current_mb_col, h_encoding_thread, h_filter_thread, mb_row_ei, en_thread_data, h_event_start_encoding, h_event_end_encoding, tplist, find_fractional_mv_step, refining_search_sad, diamond_search_sad, mb_activity_map, gf_active_flags, lfmv, lf_ref_frame_sign_bias, lf_ref_frame, lpf_thread_data, h_event_start_lpf, h_event_end_lpf, frames_in_layer, bytes_in_layer, sum_psnr, sum_psnr_p, total_error2, total_error2_p, sum_ssim, sum_weights, total_ssimg_y_in_layer, total_ssimg_u_in_layer, total_ssimg_v_in_layer, total_ssimg_all_in_layer, partition_d, partition_d_end, scaled_source, pick_lf_lvl_frame, alt_ref_buffer, fn_ptr, frames, bc, oxcf, twopass, denoiser, layer_context, frames_till_alt_ref_frame, source_alt_ref_pending, source_alt_ref_active, is_src_frame_alt_ref, gold_is_last, alt_is_last, gold_is_alt, tok_count, frames_since_key, key_frame_frequency, this_key_frame_forced, next_key_frame_forced, ambient_err, RDMULT, RDDIV, this_frame_target, projected_frame_size, frames_since_golden, frames_till_gf_update_due, current_gf_interval, gf_overspend_bits, non_gf_bitrate_adjustment, kf_overspend_bits, kf_bitrate_adjustment, max_gf_interval, baseline_gf_interval, active_arnr_frames, per_frame_bandwidth, av_per_frame_bandwidth, min_frame_bandwidth, inter_frame_target, ni_av_qi, ni_tot_qi, ni_frames, avg_frame_qindex, buffered_mode, rolling_target_bits, rolling_actual_bits, long_rolling_target_bits, long_rolling_actual_bits, worst_quality, active_worst_quality, best_quality, active_best_quality, cq_target_quality, drop_frames_allowed, drop_frame, gfu_boost, kf_boost, last_boost, target_bandwidth, decimation_factor, decimation_count, avg_encode_time, avg_pick_mode_time, Speed, compressor_speed, auto_gold, auto_adjust_gold_quantizer, auto_worst_q, cpu_used, pass, prob_intra_coded, prob_last_coded, prob_gf_coded, prob_skip_false, this_frame_percent_intra, last_frame_percent_intra, ref_frame_flags, zeromv_count, lf_zeromv_pct, active_map_enabled, cyclic_refresh_mode_enabled, cyclic_refresh_mode_max_mbs_perframe, cyclic_refresh_mode_index, cyclic_refresh_q, temporal_pattern_counter, temporal_layer_id, mse_source_denoised, force_maxqp, frames_since_last_drop_overshoot, last_pred_err_mb, gf_update_onepass_cbr, gf_interval_onepass_cbr, gf_noboost_onepass_cbr, mt_current_mb_col_size, mt_sync_range, b_multi_threaded, encoding_thread_count, b_lpf_running, b_calculate_psnr, activity_avg, gf_active_count, output_partition, force_next_frame_intra, droppable, initial_width, initial_height, current_layer, mr_low_res_mb_cols, closest_reference_frame, use_roi_static_threshold, ext_refresh_frame_flags_pending, rt_always_update_correction_factor, rt_drop_recode_on_overshoot, last_q, last_skip_false_probs, last_skip_probs_q, recent_ref_frame_usage, segment_encode_breakout, current_ref_frames, prior_key_frame_distance, partition_sz, mode_check_freq, rd_baseline_thresh, sf, base_skip_false_prob, fixed_divide, frame_branch_ct, coding_context, rd_costs, mr_low_res_mv_avail, segment_feature_data, frame_coef_probs, update_probs, lfc_n, lfc_a, lfc_g, consider reordering the fields or adding explicit padding members
270 DECLARE_ALIGNED(16, short, Y1quant[QINDEX_RANGE][16])short Y1quant[(127 + 1)][16] __attribute__((aligned(16)));
271 DECLARE_ALIGNED(16, short, Y1quant_shift[QINDEX_RANGE][16])short Y1quant_shift[(127 + 1)][16] __attribute__((aligned(16)
))
;
272 DECLARE_ALIGNED(16, short, Y1zbin[QINDEX_RANGE][16])short Y1zbin[(127 + 1)][16] __attribute__((aligned(16)));
273 DECLARE_ALIGNED(16, short, Y1round[QINDEX_RANGE][16])short Y1round[(127 + 1)][16] __attribute__((aligned(16)));
274
275 DECLARE_ALIGNED(16, short, Y2quant[QINDEX_RANGE][16])short Y2quant[(127 + 1)][16] __attribute__((aligned(16)));
276 DECLARE_ALIGNED(16, short, Y2quant_shift[QINDEX_RANGE][16])short Y2quant_shift[(127 + 1)][16] __attribute__((aligned(16)
))
;
277 DECLARE_ALIGNED(16, short, Y2zbin[QINDEX_RANGE][16])short Y2zbin[(127 + 1)][16] __attribute__((aligned(16)));
278 DECLARE_ALIGNED(16, short, Y2round[QINDEX_RANGE][16])short Y2round[(127 + 1)][16] __attribute__((aligned(16)));
279
280 DECLARE_ALIGNED(16, short, UVquant[QINDEX_RANGE][16])short UVquant[(127 + 1)][16] __attribute__((aligned(16)));
281 DECLARE_ALIGNED(16, short, UVquant_shift[QINDEX_RANGE][16])short UVquant_shift[(127 + 1)][16] __attribute__((aligned(16)
))
;
282 DECLARE_ALIGNED(16, short, UVzbin[QINDEX_RANGE][16])short UVzbin[(127 + 1)][16] __attribute__((aligned(16)));
283 DECLARE_ALIGNED(16, short, UVround[QINDEX_RANGE][16])short UVround[(127 + 1)][16] __attribute__((aligned(16)));
284
285 DECLARE_ALIGNED(16, short, zrun_zbin_boost_y1[QINDEX_RANGE][16])short zrun_zbin_boost_y1[(127 + 1)][16] __attribute__((aligned
(16)))
;
286 DECLARE_ALIGNED(16, short, zrun_zbin_boost_y2[QINDEX_RANGE][16])short zrun_zbin_boost_y2[(127 + 1)][16] __attribute__((aligned
(16)))
;
287 DECLARE_ALIGNED(16, short, zrun_zbin_boost_uv[QINDEX_RANGE][16])short zrun_zbin_boost_uv[(127 + 1)][16] __attribute__((aligned
(16)))
;
288 DECLARE_ALIGNED(16, short, Y1quant_fast[QINDEX_RANGE][16])short Y1quant_fast[(127 + 1)][16] __attribute__((aligned(16))
)
;
289 DECLARE_ALIGNED(16, short, Y2quant_fast[QINDEX_RANGE][16])short Y2quant_fast[(127 + 1)][16] __attribute__((aligned(16))
)
;
290 DECLARE_ALIGNED(16, short, UVquant_fast[QINDEX_RANGE][16])short UVquant_fast[(127 + 1)][16] __attribute__((aligned(16))
)
;
291
292 MACROBLOCK mb;
293 VP8_COMMON common;
294 vp8_writer bc[9]; /* one boolcoder for each partition */
295
296 VP8_CONFIG oxcf;
297
298 struct lookahead_ctx *lookahead;
299 struct lookahead_entry *source;
300 struct lookahead_entry *alt_ref_source;
301 struct lookahead_entry *last_source;
302
303 YV12_BUFFER_CONFIG *Source;
304 YV12_BUFFER_CONFIG *un_scaled_source;
305 YV12_BUFFER_CONFIG scaled_source;
306 YV12_BUFFER_CONFIG *last_frame_unscaled_source;
307
308 unsigned int frames_till_alt_ref_frame;
309 /* frame in src_buffers has been identified to be encoded as an alt ref */
310 int source_alt_ref_pending;
311 /* an alt ref frame has been encoded and is usable */
312 int source_alt_ref_active;
313 /* source of frame to encode is an exact copy of an alt ref frame */
314 int is_src_frame_alt_ref;
315
316 /* golden frame same as last frame ( short circuit gold searches) */
317 int gold_is_last;
318 /* Alt reference frame same as last ( short circuit altref search) */
319 int alt_is_last;
320 /* don't do both alt and gold search ( just do gold). */
321 int gold_is_alt;
322
323 YV12_BUFFER_CONFIG pick_lf_lvl_frame;
324
325 TOKENEXTRA *tok;
326 unsigned int tok_count;
327
328 unsigned int frames_since_key;
329 unsigned int key_frame_frequency;
330 unsigned int this_key_frame_forced;
331 unsigned int next_key_frame_forced;
332
333 /* Ambient reconstruction err target for force key frames */
334 int ambient_err;
335
336 unsigned int mode_check_freq[MAX_MODES20];
337
338 int rd_baseline_thresh[MAX_MODES20];
339
340 int RDMULT;
341 int RDDIV;
342
343 CODING_CONTEXT coding_context;
344
345 /* Rate targeting variables */
346 int64_t last_prediction_error;
347 int64_t last_intra_error;
348
349 int this_frame_target;
350 int projected_frame_size;
351 int last_q[2]; /* Separate values for Intra/Inter */
352
353 double rate_correction_factor;
354 double key_frame_rate_correction_factor;
355 double gf_rate_correction_factor;
356
357 int frames_since_golden;
358 /* Count down till next GF */
359 int frames_till_gf_update_due;
360
361 /* GF interval chosen when we coded the last GF */
362 int current_gf_interval;
363
364 /* Total bits overspent because of GF boost (cumulative) */
365 int gf_overspend_bits;
366
367 /* Used in the few frames following a GF to recover the extra bits
368 * spent in that GF
369 */
370 int non_gf_bitrate_adjustment;
371
372 /* Extra bits spent on key frames that need to be recovered */
373 int kf_overspend_bits;
374
375 /* Current number of bit s to try and recover on each inter frame. */
376 int kf_bitrate_adjustment;
377 int max_gf_interval;
378 int baseline_gf_interval;
379 int active_arnr_frames;
380
381 int64_t key_frame_count;
382 int prior_key_frame_distance[KEY_FRAME_CONTEXT5];
383 /* Current section per frame bandwidth target */
384 int per_frame_bandwidth;
385 /* Average frame size target for clip */
386 int av_per_frame_bandwidth;
387 /* Minimum allocation that should be used for any frame */
388 int min_frame_bandwidth;
389 int inter_frame_target;
390 double output_framerate;
391 int64_t last_time_stamp_seen;
392 int64_t last_end_time_stamp_seen;
393 int64_t first_time_stamp_ever;
394
395 int ni_av_qi;
396 int ni_tot_qi;
397 int ni_frames;
398 int avg_frame_qindex;
399
400 int64_t total_byte_count;
401
402 int buffered_mode;
403
404 double framerate;
405 double ref_framerate;
406 int64_t buffer_level;
407 int64_t bits_off_target;
408
409 int rolling_target_bits;
410 int rolling_actual_bits;
411
412 int long_rolling_target_bits;
413 int long_rolling_actual_bits;
414
415 int64_t total_actual_bits;
416 int64_t total_target_vs_actual; /* debug stats */
417
418 int worst_quality;
419 int active_worst_quality;
420 int best_quality;
421 int active_best_quality;
422
423 int cq_target_quality;
424
425 int drop_frames_allowed; /* Are we permitted to drop frames? */
426 int drop_frame; /* Drop this frame? */
427#if defined(DROP_UNCODED_FRAMES)
428 int drop_frame_count;
429#endif
430
431 vp8_prob frame_coef_probs[BLOCK_TYPES4][COEF_BANDS8][PREV_COEF_CONTEXTS3]
432 [ENTROPY_NODES11];
433 char update_probs[BLOCK_TYPES4][COEF_BANDS8][PREV_COEF_CONTEXTS3][ENTROPY_NODES11];
434
435 unsigned int frame_branch_ct[BLOCK_TYPES4][COEF_BANDS8][PREV_COEF_CONTEXTS3]
436 [ENTROPY_NODES11][2];
437
438 int gfu_boost;
439 int kf_boost;
440 int last_boost;
441
442 int target_bandwidth; /* bits per second */
443 struct vpx_codec_pkt_list *output_pkt_list;
444
445#if 0
446 /* Experimental code for lagged and one pass */
447 ONEPASS_FRAMESTATS one_pass_frame_stats[MAX_LAG_BUFFERS(0 ? 1 : 25)];
448 int one_pass_frame_index;
449#endif
450
451 int decimation_factor;
452 int decimation_count;
453
454 /* for real time encoding */
455 int avg_encode_time; /* microsecond */
456 int avg_pick_mode_time; /* microsecond */
457 int Speed;
458 int compressor_speed;
459
460 int auto_gold;
461 int auto_adjust_gold_quantizer;
462 int auto_worst_q;
463 int cpu_used;
464 int pass;
465
466 int prob_intra_coded;
467 int prob_last_coded;
468 int prob_gf_coded;
469 int prob_skip_false;
470 int last_skip_false_probs[3];
471 int last_skip_probs_q[3];
472 int recent_ref_frame_usage[MAX_REF_FRAMES];
473
474 int this_frame_percent_intra;
475 int last_frame_percent_intra;
476
477 int ref_frame_flags;
478
479 SPEED_FEATURES sf;
480
481 /* Count ZEROMV on all reference frames. */
482 int zeromv_count;
483 int lf_zeromv_pct;
484
485 unsigned char *skin_map;
486
487 unsigned char *segmentation_map;
488 signed char segment_feature_data[MB_LVL_MAX][MAX_MB_SEGMENTS4];
489 unsigned int segment_encode_breakout[MAX_MB_SEGMENTS4];
490
491 unsigned char *active_map;
492 unsigned int active_map_enabled;
493
494 /* Video conferencing cyclic refresh mode flags. This is a mode
495 * designed to clean up the background over time in live encoding
496 * scenarious. It uses segmentation.
497 */
498 int cyclic_refresh_mode_enabled;
499 int cyclic_refresh_mode_max_mbs_perframe;
500 int cyclic_refresh_mode_index;
501 int cyclic_refresh_q;
502 signed char *cyclic_refresh_map;
503 // Count on how many (consecutive) times a macroblock uses ZER0MV_LAST.
504 unsigned char *consec_zero_last;
505 // Counter that is reset when a block is checked for a mode-bias against
506 // ZEROMV_LASTREF.
507 unsigned char *consec_zero_last_mvbias;
508
509 // Frame counter for the temporal pattern. Counter is rest when the temporal
510 // layers are changed dynamically (run-time change).
511 unsigned int temporal_pattern_counter;
512 // Temporal layer id.
513 int temporal_layer_id;
514
515 // Measure of average squared difference between source and denoised signal.
516 int mse_source_denoised;
517
518 int force_maxqp;
519 int frames_since_last_drop_overshoot;
520 int last_pred_err_mb;
521
522 // GF update for 1 pass cbr.
523 int gf_update_onepass_cbr;
524 int gf_interval_onepass_cbr;
525 int gf_noboost_onepass_cbr;
526
527#if CONFIG_MULTITHREAD1
528 /* multithread data */
529 vpx_atomic_int *mt_current_mb_col;
530 int mt_current_mb_col_size;
531 int mt_sync_range;
532 vpx_atomic_int b_multi_threaded;
533 int encoding_thread_count;
534 int b_lpf_running;
535
536 pthread_t *h_encoding_thread;
537 pthread_t h_filter_thread;
538
539 MB_ROW_COMP *mb_row_ei;
540 ENCODETHREAD_DATA *en_thread_data;
541 LPFTHREAD_DATA lpf_thread_data;
542
543 /* events */
544 vp8_sem_tsem_t *h_event_start_encoding;
545 vp8_sem_tsem_t *h_event_end_encoding;
546 vp8_sem_tsem_t h_event_start_lpf;
547 vp8_sem_tsem_t h_event_end_lpf;
548#endif
549
550 TOKENLIST *tplist;
551 unsigned int partition_sz[MAX_PARTITIONS9];
552 unsigned char *partition_d[MAX_PARTITIONS9];
553 unsigned char *partition_d_end[MAX_PARTITIONS9];
554
555 fractional_mv_step_fp *find_fractional_mv_step;
556 vp8_refining_search_fn_t refining_search_sad;
557 vp8_diamond_search_fn_t diamond_search_sad;
558 vp8_variance_fn_ptr_t fn_ptr[BLOCK_MAX_SEGMENTS];
559#if CONFIG_INTERNAL_STATS0
560 uint64_t time_receive_data;
561 uint64_t time_compress_data;
562 uint64_t time_pick_lpf;
563 uint64_t time_encode_mb_row;
564#endif
565
566 int base_skip_false_prob[128];
567
568 FRAME_CONTEXT lfc_n; /* last frame entropy */
569 FRAME_CONTEXT lfc_a; /* last alt ref entropy */
570 FRAME_CONTEXT lfc_g; /* last gold ref entropy */
571
572 struct twopass_rc {
573 unsigned int section_intra_rating;
574 double section_max_qfactor;
575 unsigned int next_iiratio;
576 unsigned int this_iiratio;
577 FIRSTPASS_STATS total_stats;
578 FIRSTPASS_STATS this_frame_stats;
579 FIRSTPASS_STATS *stats_in, *stats_in_end, *stats_in_start;
580 FIRSTPASS_STATS total_left_stats;
581 int first_pass_done;
582 int64_t bits_left;
583 int64_t clip_bits_total;
584 double avg_iiratio;
585 double modified_error_total;
586 double modified_error_used;
587 double modified_error_left;
588 double kf_intra_err_min;
589 double gf_intra_err_min;
590 int frames_to_key;
591 int maxq_max_limit;
592 int maxq_min_limit;
593 int gf_decay_rate;
594 int static_scene_max_gf_interval;
595 int kf_bits;
596 /* Remaining error from uncoded frames in a gf group. */
597 int gf_group_error_left;
598 /* Projected total bits available for a key frame group of frames */
599 int64_t kf_group_bits;
600 /* Error score of frames still to be coded in kf group */
601 int64_t kf_group_error_left;
602 /* Projected Bits available for a group including 1 GF or ARF */
603 int64_t gf_group_bits;
604 /* Bits for the golden frame or ARF */
605 int gf_bits;
606 int alt_extra_bits;
607 double est_max_qcorrection_factor;
608 } twopass;
609
610#if VP8_TEMPORAL_ALT_REF!0
611 YV12_BUFFER_CONFIG alt_ref_buffer;
612 YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS(0 ? 1 : 25)];
613 int fixed_divide[512];
614#endif
615
616#if CONFIG_INTERNAL_STATS0
617 int count;
618 double total_y;
619 double total_u;
620 double total_v;
621 double total;
622 double total_sq_error;
623 double totalp_y;
624 double totalp_u;
625 double totalp_v;
626 double totalp;
627 double total_sq_error2;
628 uint64_t bytes;
629 double summed_quality;
630 double summed_weights;
631 unsigned int tot_recode_hits;
632
633 int b_calculate_ssimg;
634#endif
635 int b_calculate_psnr;
636
637 /* Per MB activity measurement */
638 unsigned int activity_avg;
639 unsigned int *mb_activity_map;
640
641 /* Record of which MBs still refer to last golden frame either
642 * directly or through 0,0
643 */
644 unsigned char *gf_active_flags;
645 int gf_active_count;
646
647 int output_partition;
648
649 /* Store last frame's MV info for next frame MV prediction */
650 int_mv *lfmv;
651 int *lf_ref_frame_sign_bias;
652 int *lf_ref_frame;
653
654 /* force next frame to intra when kf_auto says so */
655 int force_next_frame_intra;
656
657 int droppable;
658
659 int initial_width;
660 int initial_height;
661
662#if CONFIG_TEMPORAL_DENOISING1
663 VP8_DENOISER denoiser;
664#endif
665
666 /* Coding layer state variables */
667 unsigned int current_layer;
668 LAYER_CONTEXT layer_context[VPX_TS_MAX_LAYERS5];
669
670 int64_t frames_in_layer[VPX_TS_MAX_LAYERS5];
671 int64_t bytes_in_layer[VPX_TS_MAX_LAYERS5];
672 double sum_psnr[VPX_TS_MAX_LAYERS5];
673 double sum_psnr_p[VPX_TS_MAX_LAYERS5];
674 double total_error2[VPX_TS_MAX_LAYERS5];
675 double total_error2_p[VPX_TS_MAX_LAYERS5];
676 double sum_ssim[VPX_TS_MAX_LAYERS5];
677 double sum_weights[VPX_TS_MAX_LAYERS5];
678
679 double total_ssimg_y_in_layer[VPX_TS_MAX_LAYERS5];
680 double total_ssimg_u_in_layer[VPX_TS_MAX_LAYERS5];
681 double total_ssimg_v_in_layer[VPX_TS_MAX_LAYERS5];
682 double total_ssimg_all_in_layer[VPX_TS_MAX_LAYERS5];
683
684#if CONFIG_MULTI_RES_ENCODING1
685 /* Number of MBs per row at lower-resolution level */
686 int mr_low_res_mb_cols;
687 /* Indicate if lower-res mv info is available */
688 unsigned char mr_low_res_mv_avail;
689#endif
690 /* The frame number of each reference frames */
691 unsigned int current_ref_frames[MAX_REF_FRAMES];
692 // Closest reference frame to current frame.
693 MV_REFERENCE_FRAME closest_reference_frame;
694
695 struct rd_costs_struct {
696 int mvcosts[2][MVvals + 1];
697 int mvsadcosts[2][MVfpvals + 1];
698 int mbmode_cost[2][MB_MODE_COUNT];
699 int intra_uv_mode_cost[2][MB_MODE_COUNT];
700 int bmode_costs[10][10][10];
701 int inter_bmode_costs[B_MODE_COUNT];
702 int token_costs[BLOCK_TYPES4][COEF_BANDS8][PREV_COEF_CONTEXTS3]
703 [MAX_ENTROPY_TOKENS12];
704 } rd_costs;
705
706 // Use the static threshold from ROI settings.
707 int use_roi_static_threshold;
708
709 int ext_refresh_frame_flags_pending;
710
711 // Always update correction factor used for rate control after each frame for
712 // realtime encoding.
713 int rt_always_update_correction_factor;
714
715 // Flag to indicate frame may be dropped due to large expected overshoot,
716 // and re-encoded on next frame at max_qp.
717 int rt_drop_recode_on_overshoot;
718} VP8_COMP;
719
720void vp8_initialize_enc(void);
721
722void vp8_alloc_compressor_data(VP8_COMP *cpi);
723int vp8_reverse_trans(int x);
724void vp8_reset_temporal_layer_change(VP8_COMP *cpi, const VP8_CONFIG *oxcf,
725 const int prev_num_layers);
726void vp8_init_temporal_layer_context(VP8_COMP *cpi, const VP8_CONFIG *oxcf,
727 const int layer,
728 double prev_layer_framerate);
729void vp8_update_layer_contexts(VP8_COMP *cpi);
730void vp8_save_layer_context(VP8_COMP *cpi);
731void vp8_restore_layer_context(VP8_COMP *cpi, const int layer);
732void vp8_new_framerate(VP8_COMP *cpi, double framerate);
733void vp8_loopfilter_frame(VP8_COMP *cpi, VP8_COMMON *cm);
734
735void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest,
736 unsigned char *dest_end, size_t *size);
737
738void vp8_tokenize_mb(VP8_COMP *, MACROBLOCK *, TOKENEXTRA **);
739
740void vp8_set_speed_features(VP8_COMP *cpi);
741
742int vp8_check_drop_buffer(VP8_COMP *cpi);
743
744#ifdef __cplusplus
745} // extern "C"
746#endif
747
748#endif // VPX_VP8_ENCODER_ONYX_INT_H_