Bug Summary

File:root/firefox-clang/media/ffvpx/libavcodec/libaomenc.c
Warning:line 1522, column 19
3rd function call argument is an uninitialized value

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 libaomenc.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-10-17-231001-351276-1 -x c /root/firefox-clang/media/ffvpx/libavcodec/libaomenc.c

/root/firefox-clang/media/ffvpx/libavcodec/libaomenc.c

→
1/*
2 * Copyright (c) 2010, Google, Inc.
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file
23 * AV1 encoder support via libaom
24 */
25
26#include <limits.h>
27
28#define AOM_DISABLE_CTRL_TYPECHECKS1 1
29#include <aom/aom_encoder.h>
30#include <aom/aomcx.h>
31
32#include "libavutil/avassert.h"
33#include "libavutil/avstring.h"
34#include "libavutil/base64.h"
35#include "libavutil/cpu.h"
36#include "libavutil/hdr_dynamic_metadata.h"
37#include "libavutil/imgutils.h"
38#include "libavutil/mathematics.h"
39#include "libavutil/mem.h"
40#include "libavutil/opt.h"
41#include "libavutil/pixdesc.h"
42
43#include "av1.h"
44#include "avcodec.h"
45#include "bsf.h"
46#include "bytestream.h"
47#include "codec_internal.h"
48#include "dovi_rpu.h"
49#include "encode.h"
50#include "internal.h"
51#include "itut35.h"
52#include "libaom.h"
53#include "profiles.h"
54
55/*
56 * Portion of struct aom_codec_cx_pkt from aom_encoder.h.
57 * One encoded frame returned from the library.
58 */
59struct FrameListData {
60 void *buf; /**< compressed data buffer */
61 size_t sz; /**< length of compressed data */
62 int64_t pts; /**< time stamp to show frame
63 (in timebase units) */
64 unsigned long duration; /**< duration to show frame
65 (in timebase units) */
66 uint32_t flags; /**< flags for this frame */
67 uint64_t sse[4];
68 int have_sse; /**< true if we have pending sse[] */
69 uint64_t frame_number;
70 struct FrameListData *next;
71};
72
73struct ColorConfig {
74 enum AVColorPrimaries color_primaries;
75 enum AVColorTransferCharacteristic color_trc;
76 enum AVColorSpace colorspace;
77 enum AVColorRange color_range;
78};
79
80typedef struct AOMEncoderContext {
81 AVClass *class;
82 AVBSFContext *bsf;
83 DOVIContext dovi;
84 struct aom_codec_ctx encoder;
85 struct aom_image rawimg;
86 struct aom_fixed_buf twopass_stats;
87 unsigned twopass_stats_size;
88 struct FrameListData *coded_frame_list;
89 int cpu_used;
90 int auto_alt_ref;
91 int arnr_max_frames;
92 int arnr_strength;
93 int aq_mode;
94 int lag_in_frames;
95 int has_submitted_frame;
96 int error_resilient;
97 int crf;
98 int static_thresh;
99 int drop_threshold;
100 int denoise_noise_level;
101 int denoise_block_size;
102 uint64_t sse[4];
103 int have_sse; /**< true if we have pending sse[] */
104 uint64_t frame_number;
105 int rc_undershoot_pct;
106 int rc_overshoot_pct;
107 int minsection_pct;
108 int maxsection_pct;
109 int frame_parallel;
110 int tile_cols, tile_rows;
111 int tile_cols_log2, tile_rows_log2;
112 aom_superblock_size_t superblock_size;
113 int uniform_tiles;
114 int row_mt;
115 int enable_cdef;
116 int enable_global_motion;
117 int enable_intrabc;
118 int enable_restoration;
119 int usage;
120 int tune;
121 int still_picture;
122 int enable_rect_partitions;
123 int enable_1to4_partitions;
124 int enable_ab_partitions;
125 int enable_angle_delta;
126 int enable_cfl_intra;
127 int enable_paeth_intra;
128 int enable_smooth_intra;
129 int enable_intra_edge_filter;
130 int enable_palette;
131 int enable_filter_intra;
132 int enable_flip_idtx;
133 int enable_tx64;
134 int reduced_tx_type_set;
135 int use_intra_dct_only;
136 int use_inter_dct_only;
137 int use_intra_default_tx_only;
138 int enable_ref_frame_mvs;
139 int enable_interinter_wedge;
140 int enable_interintra_wedge;
141 int enable_interintra_comp;
142 int enable_masked_comp;
143 int enable_obmc;
144 int enable_onesided_comp;
145 int enable_reduced_reference_set;
146 int enable_smooth_interintra;
147 int enable_diff_wtd_comp;
148 int enable_dist_wtd_comp;
149 int enable_dual_filter;
150 struct ColorConfig color_config;
151 AVDictionary *svc_parameters;
152 AVDictionary *aom_params;
153} AOMContext;
154
155#define OFFSET(x)__builtin_offsetof(AOMContext, x) offsetof(AOMContext, x)__builtin_offsetof(AOMContext, x)
156
157static const char *const ctlidstr[] = {
158 [AOME_SET_CPUUSED] = "AOME_SET_CPUUSED",
159 [AOME_SET_CQ_LEVEL] = "AOME_SET_CQ_LEVEL",
160 [AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF",
161 [AOME_SET_ARNR_MAXFRAMES] = "AOME_SET_ARNR_MAXFRAMES",
162 [AOME_SET_ARNR_STRENGTH] = "AOME_SET_ARNR_STRENGTH",
163 [AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD",
164 [AV1E_SET_COLOR_RANGE] = "AV1E_SET_COLOR_RANGE",
165 [AV1E_SET_COLOR_PRIMARIES] = "AV1E_SET_COLOR_PRIMARIES",
166 [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS",
167 [AV1E_SET_TRANSFER_CHARACTERISTICS] = "AV1E_SET_TRANSFER_CHARACTERISTICS",
168 [AV1E_SET_AQ_MODE] = "AV1E_SET_AQ_MODE",
169 [AV1E_SET_FRAME_PARALLEL_DECODING] = "AV1E_SET_FRAME_PARALLEL_DECODING",
170 [AV1E_SET_SUPERBLOCK_SIZE] = "AV1E_SET_SUPERBLOCK_SIZE",
171 [AV1E_SET_TILE_COLUMNS] = "AV1E_SET_TILE_COLUMNS",
172 [AV1E_SET_TILE_ROWS] = "AV1E_SET_TILE_ROWS",
173 [AV1E_SET_ENABLE_RESTORATION] = "AV1E_SET_ENABLE_RESTORATION",
174 [AV1E_SET_ROW_MT] = "AV1E_SET_ROW_MT",
175 [AV1E_SET_DENOISE_NOISE_LEVEL] = "AV1E_SET_DENOISE_NOISE_LEVEL",
176 [AV1E_SET_DENOISE_BLOCK_SIZE] = "AV1E_SET_DENOISE_BLOCK_SIZE",
177 [AV1E_SET_MAX_REFERENCE_FRAMES] = "AV1E_SET_MAX_REFERENCE_FRAMES",
178 [AV1E_SET_ENABLE_GLOBAL_MOTION] = "AV1E_SET_ENABLE_GLOBAL_MOTION",
179 [AV1E_SET_ENABLE_INTRABC] = "AV1E_SET_ENABLE_INTRABC",
180 [AV1E_SET_ENABLE_CDEF] = "AV1E_SET_ENABLE_CDEF",
181 [AOME_SET_TUNING] = "AOME_SET_TUNING",
182 [AV1E_SET_ENABLE_1TO4_PARTITIONS] = "AV1E_SET_ENABLE_1TO4_PARTITIONS",
183 [AV1E_SET_ENABLE_AB_PARTITIONS] = "AV1E_SET_ENABLE_AB_PARTITIONS",
184 [AV1E_SET_ENABLE_RECT_PARTITIONS] = "AV1E_SET_ENABLE_RECT_PARTITIONS",
185 [AV1E_SET_ENABLE_ANGLE_DELTA] = "AV1E_SET_ENABLE_ANGLE_DELTA",
186 [AV1E_SET_ENABLE_CFL_INTRA] = "AV1E_SET_ENABLE_CFL_INTRA",
187 [AV1E_SET_ENABLE_FILTER_INTRA] = "AV1E_SET_ENABLE_FILTER_INTRA",
188 [AV1E_SET_ENABLE_INTRA_EDGE_FILTER] = "AV1E_SET_ENABLE_INTRA_EDGE_FILTER",
189 [AV1E_SET_ENABLE_PAETH_INTRA] = "AV1E_SET_ENABLE_PAETH_INTRA",
190 [AV1E_SET_ENABLE_SMOOTH_INTRA] = "AV1E_SET_ENABLE_SMOOTH_INTRA",
191 [AV1E_SET_ENABLE_PALETTE] = "AV1E_SET_ENABLE_PALETTE",
192 [AV1E_SET_ENABLE_FLIP_IDTX] = "AV1E_SET_ENABLE_FLIP_IDTX",
193 [AV1E_SET_ENABLE_TX64] = "AV1E_SET_ENABLE_TX64",
194 [AV1E_SET_INTRA_DCT_ONLY] = "AV1E_SET_INTRA_DCT_ONLY",
195 [AV1E_SET_INTER_DCT_ONLY] = "AV1E_SET_INTER_DCT_ONLY",
196 [AV1E_SET_INTRA_DEFAULT_TX_ONLY] = "AV1E_SET_INTRA_DEFAULT_TX_ONLY",
197 [AV1E_SET_REDUCED_TX_TYPE_SET] = "AV1E_SET_REDUCED_TX_TYPE_SET",
198 [AV1E_SET_ENABLE_DIFF_WTD_COMP] = "AV1E_SET_ENABLE_DIFF_WTD_COMP",
199 [AV1E_SET_ENABLE_DIST_WTD_COMP] = "AV1E_SET_ENABLE_DIST_WTD_COMP",
200 [AV1E_SET_ENABLE_DUAL_FILTER] = "AV1E_SET_ENABLE_DUAL_FILTER",
201 [AV1E_SET_ENABLE_INTERINTER_WEDGE] = "AV1E_SET_ENABLE_INTERINTER_WEDGE",
202 [AV1E_SET_ENABLE_INTERINTRA_WEDGE] = "AV1E_SET_ENABLE_INTERINTRA_WEDGE",
203 [AV1E_SET_ENABLE_MASKED_COMP] = "AV1E_SET_ENABLE_MASKED_COMP",
204 [AV1E_SET_ENABLE_INTERINTRA_COMP] = "AV1E_SET_ENABLE_INTERINTRA_COMP",
205 [AV1E_SET_ENABLE_OBMC] = "AV1E_SET_ENABLE_OBMC",
206 [AV1E_SET_ENABLE_ONESIDED_COMP] = "AV1E_SET_ENABLE_ONESIDED_COMP",
207 [AV1E_SET_REDUCED_REFERENCE_SET] = "AV1E_SET_REDUCED_REFERENCE_SET",
208 [AV1E_SET_ENABLE_SMOOTH_INTERINTRA] = "AV1E_SET_ENABLE_SMOOTH_INTERINTRA",
209 [AV1E_SET_ENABLE_REF_FRAME_MVS] = "AV1E_SET_ENABLE_REF_FRAME_MVS",
210#ifdef AOM_CTRL_AV1E_GET_NUM_OPERATING_POINTS
211 [AV1E_GET_NUM_OPERATING_POINTS] = "AV1E_GET_NUM_OPERATING_POINTS",
212#endif
213 [AV1E_GET_SEQ_LEVEL_IDX] = "AV1E_GET_SEQ_LEVEL_IDX",
214#ifdef AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX
215 [AV1E_GET_TARGET_SEQ_LEVEL_IDX] = "AV1E_GET_TARGET_SEQ_LEVEL_IDX",
216#endif
217 [AV1_GET_NEW_FRAME_IMAGE] = "AV1_GET_NEW_FRAME_IMAGE",
218 [AV1E_SET_SVC_PARAMS] = "AV1E_SET_SVC_PARAMS",
219};
220
221static av_cold__attribute__((cold)) void log_encoder_error(AVCodecContext *avctx, const char *desc)
222{
223 AOMContext *ctx = avctx->priv_data;
224 const char *error = aom_codec_error(&ctx->encoder);
225 const char *detail = aom_codec_error_detail(&ctx->encoder);
226
227 av_log(avctx, AV_LOG_ERROR16, "%s: %s\n", desc, error);
228 if (detail)
229 av_log(avctx, AV_LOG_ERROR16, " Additional information: %s\n", detail);
230}
231
232static av_cold__attribute__((cold)) void dump_enc_cfg(AVCodecContext *avctx,
233 const struct aom_codec_enc_cfg *cfg,
234 int level)
235{
236 int width = -30;
237
238 av_log(avctx, level, "aom_codec_enc_cfg\n");
239 av_log(avctx, level, "generic settings\n"
240 " %*s%u\n %*s%u\n %*s%u\n %*s%u\n %*s%u\n"
241 " %*s%u\n %*s%u\n"
242 " %*s{%u/%u}\n %*s%u\n %*s%d\n %*s%u\n",
243 width, "g_usage:", cfg->g_usage,
244 width, "g_threads:", cfg->g_threads,
245 width, "g_profile:", cfg->g_profile,
246 width, "g_w:", cfg->g_w,
247 width, "g_h:", cfg->g_h,
248 width, "g_bit_depth:", cfg->g_bit_depth,
249 width, "g_input_bit_depth:", cfg->g_input_bit_depth,
250 width, "g_timebase:", cfg->g_timebase.num, cfg->g_timebase.den,
251 width, "g_error_resilient:", cfg->g_error_resilient,
252 width, "g_pass:", cfg->g_pass,
253 width, "g_lag_in_frames:", cfg->g_lag_in_frames);
254 av_log(avctx, level, "rate control settings\n"
255 " %*s%u\n %*s%d\n %*s%p(%zu)\n %*s%u\n",
256 width, "rc_dropframe_thresh:", cfg->rc_dropframe_thresh,
257 width, "rc_end_usage:", cfg->rc_end_usage,
258 width, "rc_twopass_stats_in:", cfg->rc_twopass_stats_in.buf, cfg->rc_twopass_stats_in.sz,
259 width, "rc_target_bitrate:", cfg->rc_target_bitrate);
260 av_log(avctx, level, "quantizer settings\n"
261 " %*s%u\n %*s%u\n",
262 width, "rc_min_quantizer:", cfg->rc_min_quantizer,
263 width, "rc_max_quantizer:", cfg->rc_max_quantizer);
264 av_log(avctx, level, "bitrate tolerance\n"
265 " %*s%u\n %*s%u\n",
266 width, "rc_undershoot_pct:", cfg->rc_undershoot_pct,
267 width, "rc_overshoot_pct:", cfg->rc_overshoot_pct);
268 av_log(avctx, level, "decoder buffer model\n"
269 " %*s%u\n %*s%u\n %*s%u\n",
270 width, "rc_buf_sz:", cfg->rc_buf_sz,
271 width, "rc_buf_initial_sz:", cfg->rc_buf_initial_sz,
272 width, "rc_buf_optimal_sz:", cfg->rc_buf_optimal_sz);
273 av_log(avctx, level, "2 pass rate control settings\n"
274 " %*s%u\n %*s%u\n %*s%u\n",
275 width, "rc_2pass_vbr_bias_pct:", cfg->rc_2pass_vbr_bias_pct,
276 width, "rc_2pass_vbr_minsection_pct:", cfg->rc_2pass_vbr_minsection_pct,
277 width, "rc_2pass_vbr_maxsection_pct:", cfg->rc_2pass_vbr_maxsection_pct);
278 av_log(avctx, level, "keyframing settings\n"
279 " %*s%d\n %*s%u\n %*s%u\n",
280 width, "kf_mode:", cfg->kf_mode,
281 width, "kf_min_dist:", cfg->kf_min_dist,
282 width, "kf_max_dist:", cfg->kf_max_dist);
283 av_log(avctx, level, "tile settings\n"
284 " %*s%d\n %*s%d\n",
285 width, "tile_width_count:", cfg->tile_width_count,
286 width, "tile_height_count:", cfg->tile_height_count);
287 av_log(avctx, level, "\n");
288}
289
290static void coded_frame_add(void *list, struct FrameListData *cx_frame)
291{
292 struct FrameListData **p = list;
293
294 while (*p)
295 p = &(*p)->next;
296 *p = cx_frame;
297 cx_frame->next = NULL((void*)0);
298}
299
300static av_cold__attribute__((cold)) void free_coded_frame(struct FrameListData *cx_frame)
301{
302 av_freep(&cx_frame->buf);
303 av_freep(&cx_frame);
304}
305
306static av_cold__attribute__((cold)) void free_frame_list(struct FrameListData *list)
307{
308 struct FrameListData *p = list;
309
310 while (p) {
311 list = list->next;
312 free_coded_frame(p);
313 p = list;
314 }
315}
316
317static av_cold__attribute__((cold)) int codecctl_int(AVCodecContext *avctx,
318 int id,
319 int val)
320{
321 AOMContext *ctx = avctx->priv_data;
322 char buf[80];
323 int width = -30;
324 int res;
325
326 snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
327 av_log(avctx, AV_LOG_DEBUG48, " %*s%d\n", width, buf, val);
328
329 res = aom_codec_control(&ctx->encoder, id, val);
330 if (res != AOM_CODEC_OK) {
331 snprintf(buf, sizeof(buf), "Failed to set %s codec control",
332 ctlidstr[id]);
333 log_encoder_error(avctx, buf);
334 return AVERROR(EINVAL)(-(22));
335 }
336
337 return 0;
338}
339
340static int add_hdr_plus(AVCodecContext *avctx, struct aom_image *img, const AVFrame *frame)
341{
342 // Check for HDR10+
343 AVFrameSideData *side_data =
344 av_frame_get_side_data(frame, AV_FRAME_DATA_DYNAMIC_HDR_PLUS);
345 if (!side_data)
346 return 0;
347
348 size_t payload_size;
349 AVDynamicHDRPlus *hdr_plus = (AVDynamicHDRPlus *)side_data->buf->data;
350 int res = av_dynamic_hdr_plus_to_t35(hdr_plus, NULL((void*)0), &payload_size);
351 if (res < 0) {
352 log_encoder_error(avctx, "Error finding the size of HDR10+");
353 return res;
354 }
355
356 uint8_t *hdr_plus_buf;
357 // Extra bytes for the country code, provider code, provider oriented code and app id.
358 const size_t hdr_plus_buf_size = payload_size + 6;
359 hdr_plus_buf = av_malloc(hdr_plus_buf_size);
360 if (!hdr_plus_buf)
361 return AVERROR(ENOMEM)(-(12));
362
363 uint8_t *payload = hdr_plus_buf;
364 // See "HDR10+ AV1 Metadata Handling Specification" v1.0.1, Section 2.1.
365 bytestream_put_byte(&payload, ITU_T_T35_COUNTRY_CODE_US0xB5);
366 bytestream_put_be16(&payload, ITU_T_T35_PROVIDER_CODE_SAMSUNG0x003C);
367 bytestream_put_be16(&payload, 0x0001); // provider_oriented_code
368 bytestream_put_byte(&payload, 0x04); // application_identifier
369
370 res = av_dynamic_hdr_plus_to_t35(hdr_plus, &payload, &payload_size);
371 if (res < 0) {
372 av_free(hdr_plus_buf);
373 log_encoder_error(avctx, "Error encoding HDR10+ from side data");
374 return res;
375 }
376
377 res = aom_img_add_metadata(img, OBU_METADATA_TYPE_ITUT_T35,
378 hdr_plus_buf, hdr_plus_buf_size, AOM_MIF_ANY_FRAME);
379 av_free(hdr_plus_buf);
380 if (res < 0) {
381 log_encoder_error(avctx, "Error adding HDR10+ to aom_img");
382 return res;
383 }
384 return 0;
385}
386
387static int add_hdr_smpte2094_app5(AVCodecContext *avctx, struct aom_image *img,
388 const AVFrame *frame)
389{
390 AVFrameSideData *side_data =
391 av_frame_get_side_data(frame, AV_FRAME_DATA_DYNAMIC_HDR_SMPTE_2094_APP5);
392 if (!side_data)
393 return 0;
394
395 size_t payload_size;
396 AVDynamicHDRSmpte2094App5 *hdr = (AVDynamicHDRSmpte2094App5 *)side_data->buf->data;
397 int res = av_dynamic_hdr_smpte2094_app5_to_t35(hdr, NULL((void*)0), &payload_size);
398 if (res < 0) {
399 log_encoder_error(avctx, "Error finding the size of HDR SMPTE-2094-50");
400 return res;
401 }
402
403 uint8_t *hdr_buf;
404 // Extra bytes for the country code, provider code, provider oriented code.
405 const size_t hdr_buf_size = payload_size + 5;
406 hdr_buf = av_malloc(hdr_buf_size);
407 if (!hdr_buf)
408 return AVERROR(ENOMEM)(-(12));
409
410 uint8_t *payload = hdr_buf;
411 bytestream_put_byte(&payload, ITU_T_T35_COUNTRY_CODE_US0xB5);
412 bytestream_put_be16(&payload, ITU_T_T35_PROVIDER_CODE_SMPTE0x0090);
413 bytestream_put_be16(&payload, 0x0001); // provider_oriented_code
414
415 res = av_dynamic_hdr_smpte2094_app5_to_t35(hdr, &payload, &payload_size);
416 if (res < 0) {
417 av_free(hdr_buf);
418 log_encoder_error(avctx, "Error encoding HDR SMPTE-2094-50 from side data");
419 return res;
420 }
421
422 res = aom_img_add_metadata(img, OBU_METADATA_TYPE_ITUT_T35,
423 hdr_buf, hdr_buf_size, AOM_MIF_ANY_FRAME);
424 av_free(hdr_buf);
425 if (res < 0) {
426 log_encoder_error(avctx, "Error adding HDR SMPTE-2094-50 to aom_img");
427 return res;
428 }
429 return 0;
430}
431
432#if defined(AOM_CTRL_AV1E_GET_NUM_OPERATING_POINTS) && \
433 defined(AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX) && \
434 defined(AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX)
435static av_cold__attribute__((cold)) int codecctl_intp(AVCodecContext *avctx,
436 int id,
437 int* ptr)
438{
439 AOMContext *ctx = avctx->priv_data;
440 char buf[80];
441 int width = -30;
442 int res;
443
444 res = aom_codec_control(&ctx->encoder, id, ptr);
445 if (res != AOM_CODEC_OK) {
446 snprintf(buf, sizeof(buf), "Failed to get %s codec control",
447 ctlidstr[id]);
448 log_encoder_error(avctx, buf);
449 return AVERROR(EINVAL)(-(22));
450 }
451
452 snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
453 av_log(avctx, AV_LOG_DEBUG48, " %*s%d\n", width, buf, *ptr);
454
455 return 0;
456}
457#endif
458
459static av_cold__attribute__((cold)) int codecctl_imgp(AVCodecContext *avctx,
460 int id,
461 struct aom_image *img)
462{
463 AOMContext *ctx = avctx->priv_data;
464 char buf[80];
465 int res;
466
467 snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
468
469 res = aom_codec_control(&ctx->encoder, id, img);
470 if (res != AOM_CODEC_OK) {
471 snprintf(buf, sizeof(buf), "Failed to get %s codec control",
472 ctlidstr[id]);
473 log_encoder_error(avctx, buf);
474 return AVERROR(EINVAL)(-(22));
475 }
476
477 return 0;
478}
479
480static av_cold__attribute__((cold)) int codecctl_svcp(AVCodecContext *avctx,
481#ifdef UENUM1BYTE
482 aome_enc_control_id id,
483#else
484 enum aome_enc_control_id id,
485#endif
486 aom_svc_params_t *svc_params)
487{
488 AOMContext *ctx = avctx->priv_data;
489 char buf[80];
490 int res;
491
492 snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
493
494 res = aom_codec_control(&ctx->encoder, id, svc_params);
495 if (res != AOM_CODEC_OK) {
496 snprintf(buf, sizeof(buf), "Failed to get %s codec control",
497 ctlidstr[id]);
498 log_encoder_error(avctx, buf);
499 return AVERROR(EINVAL)(-(22));
500 }
501
502 return 0;
503}
504
505static av_cold__attribute__((cold)) int aom_free(AVCodecContext *avctx)
506{
507 AOMContext *ctx = avctx->priv_data;
508
509#if defined(AOM_CTRL_AV1E_GET_NUM_OPERATING_POINTS) && \
510 defined(AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX) && \
511 defined(AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX)
512 if (ctx->encoder.iface && !(avctx->flags & AV_CODEC_FLAG_PASS1(1 << 9))) {
513 int num_operating_points;
514 int levels[32];
515 int target_levels[32];
516
517 if (!codecctl_intp(avctx, AV1E_GET_NUM_OPERATING_POINTS,
518 &num_operating_points) &&
519 !codecctl_intp(avctx, AV1E_GET_SEQ_LEVEL_IDX, levels) &&
520 !codecctl_intp(avctx, AV1E_GET_TARGET_SEQ_LEVEL_IDX,
521 target_levels)) {
522 for (int i = 0; i < num_operating_points; i++) {
523 if (levels[i] > target_levels[i]) {
524 // Warn when the target level was not met
525 av_log(avctx, AV_LOG_WARNING24,
526 "Could not encode to target level %d.%d for "
527 "operating point %d. The output level is %d.%d.\n",
528 2 + (target_levels[i] >> 2), target_levels[i] & 3,
529 i, 2 + (levels[i] >> 2), levels[i] & 3);
530 } else if (target_levels[i] < 31) {
531 // Log the encoded level if a target level was given
532 av_log(avctx, AV_LOG_INFO32,
533 "Output level for operating point %d is %d.%d.\n",
534 i, 2 + (levels[i] >> 2), levels[i] & 3);
535 }
536 }
537 }
538 }
539#endif
540
541 aom_codec_destroy(&ctx->encoder);
542 aom_img_remove_metadata(&ctx->rawimg);
543 av_freep(&ctx->twopass_stats.buf);
544 av_freep(&avctx->stats_out);
545 free_frame_list(ctx->coded_frame_list);
546 av_bsf_free(&ctx->bsf);
547 ff_dovi_ctx_unref(&ctx->dovi);
548 return 0;
549}
550
551static void aom_svc_parse_int_array(int *dest, char *value, int max_entries)
552{
553 int dest_idx = 0;
554 char *saveptr = NULL((void*)0);
555 char *token = av_strtok(value, ",", &saveptr);
556
557 while (token && dest_idx < max_entries) {
558 dest[dest_idx++] = strtoul(token, NULL((void*)0), 10);
559 token = av_strtok(NULL((void*)0), ",", &saveptr);
560 }
561}
562
563static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps,
564 struct aom_codec_enc_cfg *enccfg, aom_codec_flags_t *flags,
565 aom_img_fmt_t *img_fmt)
566{
567 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
568 enccfg->g_bit_depth = enccfg->g_input_bit_depth = desc->comp[0].depth;
569 switch (avctx->pix_fmt) {
570 case AV_PIX_FMT_GRAY8:
571 enccfg->monochrome = 1;
572 av_fallthrough__attribute__((fallthrough));
573 case AV_PIX_FMT_YUV420P:
574 enccfg->g_profile = AV_PROFILE_AV1_MAIN0;
575 *img_fmt = AOM_IMG_FMT_I420;
576 return 0;
577 case AV_PIX_FMT_YUV422P:
578 enccfg->g_profile = AV_PROFILE_AV1_PROFESSIONAL2;
579 *img_fmt = AOM_IMG_FMT_I422;
580 return 0;
581 case AV_PIX_FMT_YUV444P:
582 case AV_PIX_FMT_GBRP:
583 enccfg->g_profile = AV_PROFILE_AV1_HIGH1;
584 *img_fmt = AOM_IMG_FMT_I444;
585 return 0;
586 case AV_PIX_FMT_GRAY10AV_PIX_FMT_GRAY10LE:
587 case AV_PIX_FMT_GRAY12AV_PIX_FMT_GRAY12LE:
588 enccfg->monochrome = 1;
589 av_fallthrough__attribute__((fallthrough));
590 case AV_PIX_FMT_YUV420P10AV_PIX_FMT_YUV420P10LE:
591 case AV_PIX_FMT_YUV420P12AV_PIX_FMT_YUV420P12LE:
592 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH0x40000) {
593 enccfg->g_profile =
594 enccfg->g_bit_depth == 10 ? AV_PROFILE_AV1_MAIN0 : AV_PROFILE_AV1_PROFESSIONAL2;
595 *img_fmt = AOM_IMG_FMT_I42016;
596 *flags |= AOM_CODEC_USE_HIGHBITDEPTH0x40000;
597 return 0;
598 }
599 break;
600 case AV_PIX_FMT_YUV422P10AV_PIX_FMT_YUV422P10LE:
601 case AV_PIX_FMT_YUV422P12AV_PIX_FMT_YUV422P12LE:
602 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH0x40000) {
603 enccfg->g_profile = AV_PROFILE_AV1_PROFESSIONAL2;
604 *img_fmt = AOM_IMG_FMT_I42216;
605 *flags |= AOM_CODEC_USE_HIGHBITDEPTH0x40000;
606 return 0;
607 }
608 break;
609 case AV_PIX_FMT_YUV444P10AV_PIX_FMT_YUV444P10LE:
610 case AV_PIX_FMT_YUV444P12AV_PIX_FMT_YUV444P12LE:
611 case AV_PIX_FMT_GBRP10AV_PIX_FMT_GBRP10LE:
612 case AV_PIX_FMT_GBRP12AV_PIX_FMT_GBRP12LE:
613 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH0x40000) {
614 enccfg->g_profile =
615 enccfg->g_bit_depth == 10 ? AV_PROFILE_AV1_HIGH1 : AV_PROFILE_AV1_PROFESSIONAL2;
616 *img_fmt = AOM_IMG_FMT_I44416;
617 *flags |= AOM_CODEC_USE_HIGHBITDEPTH0x40000;
618 return 0;
619 }
620 break;
621 default:
622 break;
623 }
624 av_log(avctx, AV_LOG_ERROR16, "Unsupported pixel format.\n");
625 return AVERROR_INVALIDDATA(-(int)(('I') | (('N') << 8) | (('D') << 16) | ((
unsigned)('A') << 24)))
;
626}
627
628static int set_color_range(AVCodecContext *avctx, enum AVColorRange color_range)
629{
630 aom_color_range_t aom_cr;
631 switch (color_range) {
632 case AVCOL_RANGE_UNSPECIFIED:
633 case AVCOL_RANGE_MPEG: aom_cr = AOM_CR_STUDIO_RANGE; break;
634 case AVCOL_RANGE_JPEG: aom_cr = AOM_CR_FULL_RANGE; break;
635 default:
636 av_log(avctx, AV_LOG_WARNING24, "Unsupported color range (%d)\n",
637 color_range);
638 return AVERROR(EINVAL)(-(22));
639 }
640
641 return codecctl_int(avctx, AV1E_SET_COLOR_RANGE, aom_cr);
642}
643
644static int set_color_config(AVCodecContext *avctx,
645 const struct ColorConfig *config)
646{
647 AOMContext *ctx = avctx->priv_data;
648 struct ColorConfig *curcfg = &ctx->color_config;
649 int res;
650
651 res = codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES,
652 config->color_primaries);
653 if (res < 0) {
654 av_log(avctx, AV_LOG_ERROR16, "Failed to set color primaries to %d\n",
655 config->color_primaries);
656 return res;
657 }
658 curcfg->color_primaries = config->color_primaries;
659
660 res = codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS,
661 config->color_trc);
662 if (res < 0) {
663 av_log(avctx, AV_LOG_ERROR16,
664 "Failed to set color transfer characteristics to %d\n",
665 config->color_trc);
666 return res;
667 }
668 curcfg->color_trc = config->color_trc;
669
670 res = codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS,
671 config->colorspace);
672 if (res < 0) {
673 av_log(avctx, AV_LOG_ERROR16, "Failed to set color space to %d\n",
674 config->colorspace);
675 return res;
676 }
677 curcfg->colorspace = config->colorspace;
678
679 res = set_color_range(avctx, config->color_range);
680 if (res < 0) {
681 av_log(avctx, AV_LOG_ERROR16, "Failed to set color range to %d\n",
682 config->color_range);
683 return res;
684 }
685 curcfg->color_range = config->color_range;
686
687 return 0;
688}
689
690static int count_uniform_tiling(int dim, int sb_size, int tiles_log2)
691{
692 int sb_dim = (dim + sb_size - 1) / sb_size;
693 int tile_dim = (sb_dim + (1 << tiles_log2) - 1) >> tiles_log2;
694 av_assert0(tile_dim > 0)do { if (!(tile_dim > 0)) { av_log(((void*)0), 0, "Assertion %s failed at %s:%d\n"
, "tile_dim > 0", "/root/firefox-clang/media/ffvpx/libavcodec/libaomenc.c"
, 694); abort(); } } while (0)
;
695 return (sb_dim + tile_dim - 1) / tile_dim;
696}
697
698static int choose_tiling(AVCodecContext *avctx,
699 struct aom_codec_enc_cfg *enccfg)
700{
701 AOMContext *ctx = avctx->priv_data;
702 int sb_128x128_possible, sb_size, sb_width, sb_height;
703 int uniform_rows, uniform_cols;
704 int uniform_64x64_possible, uniform_128x128_possible;
705 int tile_size, rounding, i;
706
707 if (ctx->tile_cols_log2 >= 0)
708 ctx->tile_cols = 1 << ctx->tile_cols_log2;
709 if (ctx->tile_rows_log2 >= 0)
710 ctx->tile_rows = 1 << ctx->tile_rows_log2;
711
712 if (ctx->tile_cols == 0) {
713 ctx->tile_cols = (avctx->width + AV1_MAX_TILE_WIDTH - 1) /
714 AV1_MAX_TILE_WIDTH;
715 if (ctx->tile_cols > 1) {
716 av_log(avctx, AV_LOG_DEBUG48, "Automatically using %d tile "
717 "columns to fill width.\n", ctx->tile_cols);
718 }
719 }
720 av_assert0(ctx->tile_cols > 0)do { if (!(ctx->tile_cols > 0)) { av_log(((void*)0), 0,
"Assertion %s failed at %s:%d\n", "ctx->tile_cols > 0"
, "/root/firefox-clang/media/ffvpx/libavcodec/libaomenc.c", 720
); abort(); } } while (0)
;
721 if (ctx->tile_rows == 0) {
722 int max_tile_width =
723 FFALIGN((FFALIGN(avctx->width, 128) +(((((((avctx->width)+(128)-1)&~((128)-1)) + ctx->tile_cols
- 1) / ctx->tile_cols)+(128)-1)&~((128)-1))
724 ctx->tile_cols - 1) / ctx->tile_cols, 128)(((((((avctx->width)+(128)-1)&~((128)-1)) + ctx->tile_cols
- 1) / ctx->tile_cols)+(128)-1)&~((128)-1))
;
725 ctx->tile_rows =
726 (max_tile_width * FFALIGN(avctx->height, 128)(((avctx->height)+(128)-1)&~((128)-1)) +
727 AV1_MAX_TILE_AREA - 1) / AV1_MAX_TILE_AREA;
728 if (ctx->tile_rows > 1) {
729 av_log(avctx, AV_LOG_DEBUG48, "Automatically using %d tile "
730 "rows to fill area.\n", ctx->tile_rows);
731 }
732 }
733 av_assert0(ctx->tile_rows > 0)do { if (!(ctx->tile_rows > 0)) { av_log(((void*)0), 0,
"Assertion %s failed at %s:%d\n", "ctx->tile_rows > 0"
, "/root/firefox-clang/media/ffvpx/libavcodec/libaomenc.c", 733
); abort(); } } while (0)
;
734
735 if ((avctx->width + 63) / 64 < ctx->tile_cols ||
736 (avctx->height + 63) / 64 < ctx->tile_rows) {
737 av_log(avctx, AV_LOG_ERROR16, "Invalid tile sizing: frame not "
738 "large enough to fit specified tile arrangement.\n");
739 return AVERROR(EINVAL)(-(22));
740 }
741 if (ctx->tile_cols > AV1_MAX_TILE_COLS ||
742 ctx->tile_rows > AV1_MAX_TILE_ROWS) {
743 av_log(avctx, AV_LOG_ERROR16, "Invalid tile sizing: AV1 does "
744 "not allow more than %dx%d tiles.\n",
745 AV1_MAX_TILE_COLS, AV1_MAX_TILE_ROWS);
746 return AVERROR(EINVAL)(-(22));
747 }
748 if (avctx->width / ctx->tile_cols > AV1_MAX_TILE_WIDTH) {
749 av_log(avctx, AV_LOG_ERROR16, "Invalid tile sizing: AV1 does "
750 "not allow tiles of width greater than %d.\n",
751 AV1_MAX_TILE_WIDTH);
752 return AVERROR(EINVAL)(-(22));
753 }
754
755 ctx->superblock_size = AOM_SUPERBLOCK_SIZE_DYNAMIC;
756
757 if (ctx->tile_cols == 1 && ctx->tile_rows == 1) {
758 av_log(avctx, AV_LOG_DEBUG48, "Using a single tile.\n");
759 return 0;
760 }
761
762 sb_128x128_possible =
763 (avctx->width + 127) / 128 >= ctx->tile_cols &&
764 (avctx->height + 127) / 128 >= ctx->tile_rows;
765
766 ctx->tile_cols_log2 = ctx->tile_cols == 1 ? 0 :
767 av_log2(ctx->tile_cols - 1)(31 - __builtin_clz((ctx->tile_cols - 1)|1)) + 1;
768 ctx->tile_rows_log2 = ctx->tile_rows == 1 ? 0 :
769 av_log2(ctx->tile_rows - 1)(31 - __builtin_clz((ctx->tile_rows - 1)|1)) + 1;
770
771 uniform_cols = count_uniform_tiling(avctx->width,
772 64, ctx->tile_cols_log2);
773 uniform_rows = count_uniform_tiling(avctx->height,
774 64, ctx->tile_rows_log2);
775 av_log(avctx, AV_LOG_DEBUG48, "Uniform with 64x64 superblocks "
776 "-> %dx%d tiles.\n", uniform_cols, uniform_rows);
777 uniform_64x64_possible = uniform_cols == ctx->tile_cols &&
778 uniform_rows == ctx->tile_rows;
779
780 if (sb_128x128_possible) {
781 uniform_cols = count_uniform_tiling(avctx->width,
782 128, ctx->tile_cols_log2);
783 uniform_rows = count_uniform_tiling(avctx->height,
784 128, ctx->tile_rows_log2);
785 av_log(avctx, AV_LOG_DEBUG48, "Uniform with 128x128 superblocks "
786 "-> %dx%d tiles.\n", uniform_cols, uniform_rows);
787 uniform_128x128_possible = uniform_cols == ctx->tile_cols &&
788 uniform_rows == ctx->tile_rows;
789 } else {
790 av_log(avctx, AV_LOG_DEBUG48, "128x128 superblocks not possible.\n");
791 uniform_128x128_possible = 0;
792 }
793
794 ctx->uniform_tiles = 1;
795 if (uniform_64x64_possible && uniform_128x128_possible) {
796 av_log(avctx, AV_LOG_DEBUG48, "Using uniform tiling with dynamic "
797 "superblocks (tile_cols_log2 = %d, tile_rows_log2 = %d).\n",
798 ctx->tile_cols_log2, ctx->tile_rows_log2);
799 return 0;
800 }
801 if (uniform_64x64_possible && !sb_128x128_possible) {
802 av_log(avctx, AV_LOG_DEBUG48, "Using uniform tiling with 64x64 "
803 "superblocks (tile_cols_log2 = %d, tile_rows_log2 = %d).\n",
804 ctx->tile_cols_log2, ctx->tile_rows_log2);
805 ctx->superblock_size = AOM_SUPERBLOCK_SIZE_64X64;
806 return 0;
807 }
808 if (uniform_128x128_possible) {
809 av_log(avctx, AV_LOG_DEBUG48, "Using uniform tiling with 128x128 "
810 "superblocks (tile_cols_log2 = %d, tile_rows_log2 = %d).\n",
811 ctx->tile_cols_log2, ctx->tile_rows_log2);
812 ctx->superblock_size = AOM_SUPERBLOCK_SIZE_128X128;
813 return 0;
814 }
815 ctx->uniform_tiles = 0;
816
817 if (sb_128x128_possible) {
818 sb_size = 128;
819 ctx->superblock_size = AOM_SUPERBLOCK_SIZE_128X128;
820 } else {
821 sb_size = 64;
822 ctx->superblock_size = AOM_SUPERBLOCK_SIZE_64X64;
823 }
824 av_log(avctx, AV_LOG_DEBUG48, "Using fixed tiling with %dx%d "
825 "superblocks (tile_cols = %d, tile_rows = %d).\n",
826 sb_size, sb_size, ctx->tile_cols, ctx->tile_rows);
827
828 enccfg->tile_width_count = ctx->tile_cols;
829 enccfg->tile_height_count = ctx->tile_rows;
830
831 sb_width = (avctx->width + sb_size - 1) / sb_size;
832 sb_height = (avctx->height + sb_size - 1) / sb_size;
833
834 tile_size = sb_width / ctx->tile_cols;
835 rounding = sb_width % ctx->tile_cols;
836 for (i = 0; i < ctx->tile_cols; i++) {
837 enccfg->tile_widths[i] = tile_size +
838 (i < rounding / 2 ||
839 i > ctx->tile_cols - 1 - (rounding + 1) / 2);
840 }
841
842 tile_size = sb_height / ctx->tile_rows;
843 rounding = sb_height % ctx->tile_rows;
844 for (i = 0; i < ctx->tile_rows; i++) {
845 enccfg->tile_heights[i] = tile_size +
846 (i < rounding / 2 ||
847 i > ctx->tile_rows - 1 - (rounding + 1) / 2);
848 }
849
850 return 0;
851}
852
853
854static const struct {
855 int aom_enum;
856 unsigned offset;
857} option_map[] = {
858 { AOME_SET_ENABLEAUTOALTREF, OFFSET(auto_alt_ref)__builtin_offsetof(AOMContext, auto_alt_ref) },
859 { AOME_SET_ARNR_MAXFRAMES, OFFSET(arnr_max_frames)__builtin_offsetof(AOMContext, arnr_max_frames) },
860 { AOME_SET_ARNR_STRENGTH, OFFSET(arnr_strength)__builtin_offsetof(AOMContext, arnr_strength) },
861 { AV1E_SET_ENABLE_CDEF, OFFSET(enable_cdef)__builtin_offsetof(AOMContext, enable_cdef) },
862 { AV1E_SET_ENABLE_RESTORATION, OFFSET(enable_restoration)__builtin_offsetof(AOMContext, enable_restoration) },
863 { AV1E_SET_ENABLE_RECT_PARTITIONS, OFFSET(enable_rect_partitions)__builtin_offsetof(AOMContext, enable_rect_partitions) },
864 { AV1E_SET_ENABLE_1TO4_PARTITIONS, OFFSET(enable_1to4_partitions)__builtin_offsetof(AOMContext, enable_1to4_partitions) },
865 { AV1E_SET_ENABLE_AB_PARTITIONS, OFFSET(enable_ab_partitions)__builtin_offsetof(AOMContext, enable_ab_partitions) },
866 { AV1E_SET_ENABLE_ANGLE_DELTA, OFFSET(enable_angle_delta)__builtin_offsetof(AOMContext, enable_angle_delta) },
867 { AV1E_SET_ENABLE_CFL_INTRA, OFFSET(enable_cfl_intra)__builtin_offsetof(AOMContext, enable_cfl_intra) },
868 { AV1E_SET_ENABLE_FILTER_INTRA, OFFSET(enable_filter_intra)__builtin_offsetof(AOMContext, enable_filter_intra) },
869 { AV1E_SET_ENABLE_INTRA_EDGE_FILTER, OFFSET(enable_intra_edge_filter)__builtin_offsetof(AOMContext, enable_intra_edge_filter) },
870 { AV1E_SET_ENABLE_PAETH_INTRA, OFFSET(enable_paeth_intra)__builtin_offsetof(AOMContext, enable_paeth_intra) },
871 { AV1E_SET_ENABLE_SMOOTH_INTRA, OFFSET(enable_smooth_intra)__builtin_offsetof(AOMContext, enable_smooth_intra) },
872 { AV1E_SET_ENABLE_PALETTE, OFFSET(enable_palette)__builtin_offsetof(AOMContext, enable_palette) },
873 { AV1E_SET_ENABLE_TX64, OFFSET(enable_tx64)__builtin_offsetof(AOMContext, enable_tx64) },
874 { AV1E_SET_ENABLE_FLIP_IDTX, OFFSET(enable_flip_idtx)__builtin_offsetof(AOMContext, enable_flip_idtx) },
875 { AV1E_SET_INTRA_DCT_ONLY, OFFSET(use_intra_dct_only)__builtin_offsetof(AOMContext, use_intra_dct_only) },
876 { AV1E_SET_INTER_DCT_ONLY, OFFSET(use_inter_dct_only)__builtin_offsetof(AOMContext, use_inter_dct_only) },
877 { AV1E_SET_INTRA_DEFAULT_TX_ONLY, OFFSET(use_intra_default_tx_only)__builtin_offsetof(AOMContext, use_intra_default_tx_only) },
878 { AV1E_SET_REDUCED_TX_TYPE_SET, OFFSET(reduced_tx_type_set)__builtin_offsetof(AOMContext, reduced_tx_type_set) },
879 { AV1E_SET_ENABLE_REF_FRAME_MVS, OFFSET(enable_ref_frame_mvs)__builtin_offsetof(AOMContext, enable_ref_frame_mvs) },
880 { AV1E_SET_REDUCED_REFERENCE_SET, OFFSET(enable_reduced_reference_set)__builtin_offsetof(AOMContext, enable_reduced_reference_set) },
881 { AV1E_SET_ENABLE_DIFF_WTD_COMP, OFFSET(enable_diff_wtd_comp)__builtin_offsetof(AOMContext, enable_diff_wtd_comp) },
882 { AV1E_SET_ENABLE_DIST_WTD_COMP, OFFSET(enable_dist_wtd_comp)__builtin_offsetof(AOMContext, enable_dist_wtd_comp) },
883 { AV1E_SET_ENABLE_DUAL_FILTER, OFFSET(enable_dual_filter)__builtin_offsetof(AOMContext, enable_dual_filter) },
884 { AV1E_SET_ENABLE_INTERINTER_WEDGE, OFFSET(enable_interinter_wedge)__builtin_offsetof(AOMContext, enable_interinter_wedge) },
885 { AV1E_SET_ENABLE_MASKED_COMP, OFFSET(enable_masked_comp)__builtin_offsetof(AOMContext, enable_masked_comp) },
886 { AV1E_SET_ENABLE_INTERINTRA_COMP, OFFSET(enable_interintra_comp)__builtin_offsetof(AOMContext, enable_interintra_comp) },
887 { AV1E_SET_ENABLE_INTERINTRA_WEDGE, OFFSET(enable_interintra_wedge)__builtin_offsetof(AOMContext, enable_interintra_wedge) },
888 { AV1E_SET_ENABLE_OBMC, OFFSET(enable_obmc)__builtin_offsetof(AOMContext, enable_obmc) },
889 { AV1E_SET_ENABLE_ONESIDED_COMP, OFFSET(enable_onesided_comp)__builtin_offsetof(AOMContext, enable_onesided_comp) },
890 { AV1E_SET_ENABLE_SMOOTH_INTERINTRA, OFFSET(enable_smooth_interintra)__builtin_offsetof(AOMContext, enable_smooth_interintra) },
891};
892
893static av_cold__attribute__((cold)) int aom_init(AVCodecContext *avctx,
894 const struct aom_codec_iface *iface)
895{
896 AOMContext *ctx = avctx->priv_data;
897 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
898 struct aom_codec_enc_cfg enccfg = { 0 };
899 aom_codec_flags_t flags =
900 (avctx->flags & AV_CODEC_FLAG_PSNR(1 << 15)) ? AOM_CODEC_USE_PSNR0x10000 : 0;
901 int res;
902 aom_img_fmt_t img_fmt;
903 aom_codec_caps_t codec_caps = aom_codec_get_caps(iface);
904
905 av_log(avctx, AV_LOG_INFO32, "%s\n", aom_codec_version_str());
906 av_log(avctx, AV_LOG_VERBOSE40, "%s\n", aom_codec_build_config());
907
908 if ((res = aom_codec_enc_config_default(iface, &enccfg, ctx->usage)) != AOM_CODEC_OK) {
909 av_log(avctx, AV_LOG_ERROR16, "Failed to get config: %s\n",
910 aom_codec_err_to_string(res));
911 return AVERROR(EINVAL)(-(22));
912 }
913
914 if (set_pix_fmt(avctx, codec_caps, &enccfg, &flags, &img_fmt))
915 return AVERROR(EINVAL)(-(22));
916
917 if(!avctx->bit_rate)
918 if(avctx->rc_max_rate || avctx->rc_buffer_size || avctx->rc_initial_buffer_occupancy) {
919 av_log( avctx, AV_LOG_ERROR16, "Rate control parameters set without a bitrate\n");
920 return AVERROR(EINVAL)(-(22));
921 }
922
923 dump_enc_cfg(avctx, &enccfg, AV_LOG_DEBUG48);
924
925 enccfg.g_w = avctx->width;
926 enccfg.g_h = avctx->height;
927 enccfg.g_timebase.num = avctx->time_base.num;
928 enccfg.g_timebase.den = avctx->time_base.den;
929 enccfg.g_threads =
930 FFMIN(avctx->thread_count ? avctx->thread_count : av_cpu_count(), 64)((avctx->thread_count ? avctx->thread_count : av_cpu_count
()) > (64) ? (64) : (avctx->thread_count ? avctx->thread_count
: av_cpu_count()))
;
931
932 if (ctx->lag_in_frames >= 0)
933 enccfg.g_lag_in_frames = ctx->lag_in_frames;
934
935 if (avctx->flags & AV_CODEC_FLAG_PASS1(1 << 9))
936 enccfg.g_pass = AOM_RC_FIRST_PASS;
937 else if (avctx->flags & AV_CODEC_FLAG_PASS2(1 << 10))
938 enccfg.g_pass = AOM_RC_LAST_PASS;
939 else
940 enccfg.g_pass = AOM_RC_ONE_PASS;
941
942 if (avctx->rc_min_rate == avctx->rc_max_rate &&
943 avctx->rc_min_rate == avctx->bit_rate && avctx->bit_rate) {
944 enccfg.rc_end_usage = AOM_CBR;
945 } else if (ctx->crf >= 0) {
946 enccfg.rc_end_usage = AOM_CQ;
947 if (!avctx->bit_rate)
948 enccfg.rc_end_usage = AOM_Q;
949 }
950
951 if (avctx->bit_rate) {
952 enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000,
953 AV_ROUND_NEAR_INF);
954 } else if (enccfg.rc_end_usage != AOM_Q) {
955 enccfg.rc_end_usage = AOM_Q;
956 ctx->crf = 32;
957 av_log(avctx, AV_LOG_WARNING24,
958 "Neither bitrate nor constrained quality specified, using default CRF of %d\n",
959 ctx->crf);
960 }
961
962 if (avctx->qmin >= 0)
963 enccfg.rc_min_quantizer = avctx->qmin;
964 if (avctx->qmax >= 0) {
965 enccfg.rc_max_quantizer = avctx->qmax;
966 } else if (!ctx->crf) {
967 enccfg.rc_max_quantizer = 0;
968 }
969
970 if (enccfg.rc_end_usage == AOM_CQ || enccfg.rc_end_usage == AOM_Q) {
971 if (ctx->crf < enccfg.rc_min_quantizer || ctx->crf > enccfg.rc_max_quantizer) {
972 av_log(avctx, AV_LOG_ERROR16,
973 "CQ level %d must be between minimum and maximum quantizer value (%d-%d)\n",
974 ctx->crf, enccfg.rc_min_quantizer, enccfg.rc_max_quantizer);
975 return AVERROR(EINVAL)(-(22));
976 }
977 }
978
979 enccfg.rc_dropframe_thresh = ctx->drop_threshold;
980
981 // 0-100 (0 => CBR, 100 => VBR)
982 enccfg.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100);
983 if (ctx->minsection_pct >= 0)
984 enccfg.rc_2pass_vbr_minsection_pct = ctx->minsection_pct;
985 else if (avctx->bit_rate)
986 enccfg.rc_2pass_vbr_minsection_pct =
987 avctx->rc_min_rate * 100LL / avctx->bit_rate;
988 if (ctx->maxsection_pct >= 0)
989 enccfg.rc_2pass_vbr_maxsection_pct = ctx->maxsection_pct;
990 else if (avctx->rc_max_rate)
991 enccfg.rc_2pass_vbr_maxsection_pct =
992 avctx->rc_max_rate * 100LL / avctx->bit_rate;
993
994 if (avctx->rc_buffer_size)
995 enccfg.rc_buf_sz =
996 avctx->rc_buffer_size * 1000LL / avctx->bit_rate;
997 if (avctx->rc_initial_buffer_occupancy)
998 enccfg.rc_buf_initial_sz =
999 avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
1000 enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
1001
1002 if (ctx->rc_undershoot_pct >= 0)
1003 enccfg.rc_undershoot_pct = ctx->rc_undershoot_pct;
1004 if (ctx->rc_overshoot_pct >= 0)
1005 enccfg.rc_overshoot_pct = ctx->rc_overshoot_pct;
1006
1007 // _enc_init() will balk if kf_min_dist differs from max w/AOM_KF_AUTO
1008 if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size)
1009 enccfg.kf_min_dist = avctx->keyint_min;
1010 if (avctx->gop_size >= 0)
1011 enccfg.kf_max_dist = avctx->gop_size;
1012
1013 if (enccfg.g_pass == AOM_RC_FIRST_PASS)
1014 enccfg.g_lag_in_frames = 0;
1015 else if (enccfg.g_pass == AOM_RC_LAST_PASS) {
1016 int decode_size, ret;
1017
1018 if (!avctx->stats_in) {
1019 av_log(avctx, AV_LOG_ERROR16, "No stats file for second pass\n");
1020 return AVERROR_INVALIDDATA(-(int)(('I') | (('N') << 8) | (('D') << 16) | ((
unsigned)('A') << 24)))
;
1021 }
1022
1023 ctx->twopass_stats.sz = strlen(avctx->stats_in) * 3 / 4;
1024 ret = av_reallocp(&ctx->twopass_stats.buf, ctx->twopass_stats.sz);
1025 if (ret < 0) {
1026 av_log(avctx, AV_LOG_ERROR16,
1027 "Stat buffer alloc (%zu bytes) failed\n",
1028 ctx->twopass_stats.sz);
1029 ctx->twopass_stats.sz = 0;
1030 return ret;
1031 }
1032 decode_size = av_base64_decode(ctx->twopass_stats.buf, avctx->stats_in,
1033 ctx->twopass_stats.sz);
1034 if (decode_size < 0) {
1035 av_log(avctx, AV_LOG_ERROR16, "Stat buffer decode failed\n");
1036 return AVERROR_INVALIDDATA(-(int)(('I') | (('N') << 8) | (('D') << 16) | ((
unsigned)('A') << 24)))
;
1037 }
1038
1039 ctx->twopass_stats.sz = decode_size;
1040 enccfg.rc_twopass_stats_in = ctx->twopass_stats;
1041 }
1042
1043 /* 0-3: For non-zero values the encoder increasingly optimizes for reduced
1044 * complexity playback on low powered devices at the expense of encode
1045 * quality. */
1046 if (avctx->profile != AV_PROFILE_UNKNOWN-99)
1047 enccfg.g_profile = avctx->profile;
1048
1049 enccfg.g_error_resilient = ctx->error_resilient;
1050
1051 res = choose_tiling(avctx, &enccfg);
1052 if (res < 0)
1053 return res;
1054
1055 if (ctx->still_picture) {
1056 // Set the maximum number of frames to 1. This will let libaom set
1057 // still_picture and reduced_still_picture_header to 1 in the Sequence
1058 // Header as required by AVIF still images.
1059 enccfg.g_limit = 1;
1060 // Reduce memory usage for still images.
1061 enccfg.g_lag_in_frames = 0;
1062 // All frames will be key frames.
1063 enccfg.kf_max_dist = 0;
1064 enccfg.kf_mode = AOM_KF_DISABLED;
1065 }
1066
1067 ctx->lag_in_frames = enccfg.g_lag_in_frames;
1068
1069 /* Construct Encoder Context */
1070 res = aom_codec_enc_init(&ctx->encoder, iface, &enccfg, flags)aom_codec_enc_init_ver(&ctx->encoder, iface, &enccfg
, flags, (10 + (7 + (9)) + 3))
;
1071 if (res != AOM_CODEC_OK) {
1072 dump_enc_cfg(avctx, &enccfg, AV_LOG_WARNING24);
1073 log_encoder_error(avctx, "Failed to initialize encoder");
1074 return AVERROR(EINVAL)(-(22));
1075 }
1076 dump_enc_cfg(avctx, &enccfg, AV_LOG_DEBUG48);
1077
1078 // codec control failures are currently treated only as warnings
1079 av_log(avctx, AV_LOG_DEBUG48, "aom_codec_control\n");
1080 codecctl_int(avctx, AOME_SET_CPUUSED, ctx->cpu_used);
1081
1082 for (size_t i = 0; i < FF_ARRAY_ELEMS(option_map)(sizeof(option_map) / sizeof((option_map)[0])); ++i) {
1083 int val = *(int*)((char*)ctx + option_map[i].offset);
1084 if (val >= 0)
1085 codecctl_int(avctx, option_map[i].aom_enum, val);
1086 }
1087 codecctl_int(avctx, AOME_SET_STATIC_THRESHOLD, ctx->static_thresh);
1088 if (ctx->crf >= 0)
1089 codecctl_int(avctx, AOME_SET_CQ_LEVEL, ctx->crf);
1090 if (ctx->tune >= 0)
1091 codecctl_int(avctx, AOME_SET_TUNING, ctx->tune);
1092
1093 struct ColorConfig colorcfg;
1094 if (desc->flags & AV_PIX_FMT_FLAG_RGB(1 << 5))
1095 colorcfg = (struct ColorConfig) {
1096 .color_primaries = AVCOL_PRI_BT709,
1097 .color_trc = AVCOL_TRC_IEC61966_2_1,
1098 .colorspace = AVCOL_SPC_RGB,
1099 .color_range = avctx->color_range,
1100 };
1101 else
1102 colorcfg = (struct ColorConfig) {
1103 .color_primaries = avctx->color_primaries,
1104 .color_trc = avctx->color_trc,
1105 .colorspace = avctx->colorspace,
1106 .color_range = avctx->color_range,
1107 };
1108 // Ignore the return value to follow the convention of other codecctl_int()
1109 // calls.
1110 set_color_config(avctx, &colorcfg);
1111
1112 if (ctx->aq_mode >= 0)
1113 codecctl_int(avctx, AV1E_SET_AQ_MODE, ctx->aq_mode);
1114 if (ctx->frame_parallel >= 0)
1115 codecctl_int(avctx, AV1E_SET_FRAME_PARALLEL_DECODING, ctx->frame_parallel);
1116
1117 codecctl_int(avctx, AV1E_SET_SUPERBLOCK_SIZE, ctx->superblock_size);
1118 if (ctx->uniform_tiles) {
1119 codecctl_int(avctx, AV1E_SET_TILE_COLUMNS, ctx->tile_cols_log2);
1120 codecctl_int(avctx, AV1E_SET_TILE_ROWS, ctx->tile_rows_log2);
1121 }
1122
1123 if (ctx->denoise_noise_level >= 0)
1124 codecctl_int(avctx, AV1E_SET_DENOISE_NOISE_LEVEL, ctx->denoise_noise_level);
1125 if (ctx->denoise_block_size >= 0)
1126 codecctl_int(avctx, AV1E_SET_DENOISE_BLOCK_SIZE, ctx->denoise_block_size);
1127 if (ctx->enable_global_motion >= 0)
1128 codecctl_int(avctx, AV1E_SET_ENABLE_GLOBAL_MOTION, ctx->enable_global_motion);
1129 if (avctx->refs >= 3) {
1130 codecctl_int(avctx, AV1E_SET_MAX_REFERENCE_FRAMES, avctx->refs);
1131 }
1132 if (ctx->row_mt >= 0)
1133 codecctl_int(avctx, AV1E_SET_ROW_MT, ctx->row_mt);
1134 if (ctx->enable_intrabc >= 0)
1135 codecctl_int(avctx, AV1E_SET_ENABLE_INTRABC, ctx->enable_intrabc);
1136
1137 if (enccfg.rc_end_usage == AOM_CBR) {
1138 aom_svc_params_t svc_params = {};
1139 svc_params.framerate_factor[0] = 1;
1140 svc_params.number_spatial_layers = 1;
1141 svc_params.number_temporal_layers = 1;
1142
1143 AVDictionaryEntry *en = NULL((void*)0);
1144 while ((en = av_dict_get(ctx->svc_parameters, "", en, AV_DICT_IGNORE_SUFFIX2))) {
1145 if (!strlen(en->value))
1146 return AVERROR(EINVAL)(-(22));
1147
1148 if (!strcmp(en->key, "number_spatial_layers"))
1149 svc_params.number_spatial_layers = strtoul(en->value, NULL((void*)0), 10);
1150 else if (!strcmp(en->key, "number_temporal_layers"))
1151 svc_params.number_temporal_layers = strtoul(en->value, NULL((void*)0), 10);
1152 else if (!strcmp(en->key, "max_quantizers"))
1153 aom_svc_parse_int_array(svc_params.max_quantizers, en->value, AOM_MAX_LAYERS32);
1154 else if (!strcmp(en->key, "min_quantizers"))
1155 aom_svc_parse_int_array(svc_params.min_quantizers, en->value, AOM_MAX_LAYERS32);
1156 else if (!strcmp(en->key, "scaling_factor_num"))
1157 aom_svc_parse_int_array(svc_params.scaling_factor_num, en->value, AOM_MAX_SS_LAYERS4);
1158 else if (!strcmp(en->key, "scaling_factor_den"))
1159 aom_svc_parse_int_array(svc_params.scaling_factor_den, en->value, AOM_MAX_SS_LAYERS4);
1160 else if (!strcmp(en->key, "layer_target_bitrate"))
1161 aom_svc_parse_int_array(svc_params.layer_target_bitrate, en->value, AOM_MAX_LAYERS32);
1162 else if (!strcmp(en->key, "framerate_factor"))
1163 aom_svc_parse_int_array(svc_params.framerate_factor, en->value, AOM_MAX_TS_LAYERS8);
1164 }
1165
1166 res = codecctl_svcp(avctx, AV1E_SET_SVC_PARAMS, &svc_params);
1167 if (res < 0)
1168 return res;
1169 }
1170
1171
1172#if AOM_ENCODER_ABI_VERSION(10 + (7 + (9)) + 3) >= 23
1173 {
1174 const AVDictionaryEntry *en = NULL((void*)0);
1175
1176 while ((en = av_dict_iterate(ctx->aom_params, en))) {
1177 int ret = aom_codec_set_option(&ctx->encoder, en->key, en->value);
1178 if (ret != AOM_CODEC_OK) {
1179 log_encoder_error(avctx, en->key);
1180 return AVERROR_EXTERNAL(-(int)(('E') | (('X') << 8) | (('T') << 16) | ((
unsigned)(' ') << 24)))
;
1181 }
1182 }
1183 }
1184#endif
1185
1186 // provide dummy value to initialize wrapper, values will be updated each _encode()
1187 aom_img_wrap(&ctx->rawimg, img_fmt, avctx->width, avctx->height, 1,
1188 (unsigned char*)1);
1189
1190 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH0x40000)
1191 ctx->rawimg.bit_depth = enccfg.g_bit_depth;
1192
1193 ctx->dovi.logctx = avctx;
1194 if ((res = ff_dovi_configure(&ctx->dovi, avctx)) < 0)
1195 return res;
1196
1197 if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER(1 << 22)) {
1198 const AVBitStreamFilter *filter = av_bsf_get_by_name("extract_extradata");
1199 int ret;
1200
1201 if (!filter) {
1202 av_log(avctx, AV_LOG_ERROR16, "extract_extradata bitstream filter "
1203 "not found. This is a bug, please report it.\n");
1204 return AVERROR_BUG(-(int)(('B') | (('U') << 8) | (('G') << 16) | ((
unsigned)('!') << 24)))
;
1205 }
1206 ret = av_bsf_alloc(filter, &ctx->bsf);
1207 if (ret < 0)
1208 return ret;
1209
1210 ret = avcodec_parameters_from_context(ctx->bsf->par_in, avctx);
1211 if (ret < 0)
1212 return ret;
1213
1214 ret = av_bsf_init(ctx->bsf);
1215 if (ret < 0)
1216 return ret;
1217 }
1218
1219 AVCPBProperties *cpb_props = ff_encode_add_cpb_side_data(avctx);
1220 if (!cpb_props)
1221 return AVERROR(ENOMEM)(-(12));
1222
1223 if (enccfg.rc_end_usage == AOM_CBR ||
1224 enccfg.g_pass != AOM_RC_ONE_PASS) {
1225 cpb_props->max_bitrate = avctx->rc_max_rate;
1226 cpb_props->min_bitrate = avctx->rc_min_rate;
1227 cpb_props->avg_bitrate = avctx->bit_rate;
1228 }
1229 cpb_props->buffer_size = avctx->rc_buffer_size;
1230
1231 return 0;
1232}
1233
1234static inline void cx_pktcpy(AOMContext *ctx,
1235 struct FrameListData *dst,
1236 const struct aom_codec_cx_pkt *src)
1237{
1238 dst->pts = src->data.frame.pts;
1239 dst->duration = src->data.frame.duration;
1240 dst->flags = src->data.frame.flags;
1241 dst->sz = src->data.frame.sz;
1242 dst->buf = src->data.frame.buf;
1243 dst->frame_number = ++ctx->frame_number;
1244 dst->have_sse = ctx->have_sse;
1245 if (ctx->have_sse) {
1246 /* associate last-seen SSE to the frame. */
1247 /* Transfers ownership from ctx to dst. */
1248 memcpy(dst->sse, ctx->sse, sizeof(dst->sse));
1249 ctx->have_sse = 0;
1250 }
1251}
1252
1253/**
1254 * Store coded frame information in format suitable for return from encode2().
1255 *
1256 * Write information from @a cx_frame to @a pkt
1257 * @return packet data size on success
1258 * @return a negative AVERROR on error
1259 */
1260static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame,
1261 AVPacket *pkt)
1262{
1263 AOMContext *ctx = avctx->priv_data;
1264 enum AVPictureType pict_type;
1265 int ret = ff_get_encode_buffer(avctx, pkt, cx_frame->sz, 0);
1266 if (ret < 0) {
1267 av_log(avctx, AV_LOG_ERROR16,
1268 "Error getting output packet of size %zu.\n", cx_frame->sz);
1269 return ret;
1270 }
1271 memcpy(pkt->data, cx_frame->buf, pkt->size);
1272 pkt->pts = pkt->dts = cx_frame->pts;
1273 pkt->duration = cx_frame->duration;
1274
1275 if (!!(cx_frame->flags & AOM_FRAME_IS_KEY0x1u)) {
1276 pkt->flags |= AV_PKT_FLAG_KEY0x0001;
1277 pict_type = AV_PICTURE_TYPE_I;
1278 } else if (cx_frame->flags & AOM_FRAME_IS_INTRAONLY0x10u) {
1279 pict_type = AV_PICTURE_TYPE_I;
1280 } else {
1281 pict_type = AV_PICTURE_TYPE_P;
1282 }
1283
1284 ff_encode_add_stats_side_data(pkt, 0, cx_frame->sse + 1,
1285 cx_frame->have_sse ? 3 : 0, pict_type);
1286
1287 if (cx_frame->have_sse) {
1288 int i;
1289 for (i = 0; i < 3; ++i) {
1290 avctx->error[i] += cx_frame->sse[i + 1];
1291 }
1292 cx_frame->have_sse = 0;
1293 }
1294
1295 if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER(1 << 22)) {
1296 ret = av_bsf_send_packet(ctx->bsf, pkt);
1297 if (ret < 0) {
1298 av_log(avctx, AV_LOG_ERROR16, "extract_extradata filter "
1299 "failed to send input packet\n");
1300 return ret;
1301 }
1302 ret = av_bsf_receive_packet(ctx->bsf, pkt);
1303
1304 if (ret < 0) {
1305 av_log(avctx, AV_LOG_ERROR16, "extract_extradata filter "
1306 "failed to receive output packet\n");
1307 return ret;
1308 }
1309 }
1310 return pkt->size;
1311}
1312
1313/**
1314 * Queue multiple output frames from the encoder, returning the front-most.
1315 * In cases where aom_codec_get_cx_data() returns more than 1 frame append
1316 * the frame queue. Return the head frame if available.
1317 * @return Stored frame size
1318 * @return AVERROR(EINVAL) on output size error
1319 * @return AVERROR(ENOMEM) on coded frame queue data allocation error
1320 */
1321static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out)
1322{
1323 AOMContext *ctx = avctx->priv_data;
1324 const struct aom_codec_cx_pkt *pkt;
1325 const void *iter = NULL((void*)0);
1326 int size = 0;
1327
1328 if (ctx->coded_frame_list) {
1329 struct FrameListData *cx_frame = ctx->coded_frame_list;
1330 /* return the leading frame if we've already begun queueing */
1331 size = storeframe(avctx, cx_frame, pkt_out);
1332 if (size < 0)
1333 return size;
1334 ctx->coded_frame_list = cx_frame->next;
1335 free_coded_frame(cx_frame);
1336 }
1337
1338 /* consume all available output from the encoder before returning. buffers
1339 * are only good through the next aom_codec call */
1340 while ((pkt = aom_codec_get_cx_data(&ctx->encoder, &iter))) {
1341 switch (pkt->kind) {
1342 case AOM_CODEC_CX_FRAME_PKT:
1343 if (!size) {
1344 struct FrameListData cx_frame;
1345
1346 /* avoid storing the frame when the list is empty and we haven't yet
1347 * provided a frame for output */
1348 av_assert0(!ctx->coded_frame_list)do { if (!(!ctx->coded_frame_list)) { av_log(((void*)0), 0
, "Assertion %s failed at %s:%d\n", "!ctx->coded_frame_list"
, "/root/firefox-clang/media/ffvpx/libavcodec/libaomenc.c", 1348
); abort(); } } while (0)
;
1349 cx_pktcpy(ctx, &cx_frame, pkt);
1350 size = storeframe(avctx, &cx_frame, pkt_out);
1351 if (size < 0)
1352 return size;
1353 } else {
1354 struct FrameListData *cx_frame =
1355 av_malloc(sizeof(struct FrameListData));
1356
1357 if (!cx_frame) {
1358 av_log(avctx, AV_LOG_ERROR16,
1359 "Frame queue element alloc failed\n");
1360 return AVERROR(ENOMEM)(-(12));
1361 }
1362 cx_pktcpy(ctx, cx_frame, pkt);
1363 cx_frame->buf = av_malloc(cx_frame->sz);
1364
1365 if (!cx_frame->buf) {
1366 av_log(avctx, AV_LOG_ERROR16,
1367 "Data buffer alloc (%zu bytes) failed\n",
1368 cx_frame->sz);
1369 av_freep(&cx_frame);
1370 return AVERROR(ENOMEM)(-(12));
1371 }
1372 memcpy(cx_frame->buf, pkt->data.frame.buf, pkt->data.frame.sz);
1373 coded_frame_add(&ctx->coded_frame_list, cx_frame);
1374 }
1375 break;
1376 case AOM_CODEC_STATS_PKT:
1377 {
1378 struct aom_fixed_buf *stats = &ctx->twopass_stats;
1379 uint8_t *tmp = av_fast_realloc(stats->buf,
1380 &ctx->twopass_stats_size,
1381 stats->sz +
1382 pkt->data.twopass_stats.sz);
1383 if (!tmp) {
1384 av_freep(&stats->buf);
1385 stats->sz = 0;
1386 av_log(avctx, AV_LOG_ERROR16, "Stat buffer realloc failed\n");
1387 return AVERROR(ENOMEM)(-(12));
1388 }
1389 stats->buf = tmp;
1390 memcpy((uint8_t *)stats->buf + stats->sz,
1391 pkt->data.twopass_stats.buf, pkt->data.twopass_stats.sz);
1392 stats->sz += pkt->data.twopass_stats.sz;
1393 break;
1394 }
1395 case AOM_CODEC_PSNR_PKT:
1396 {
1397 av_assert0(!ctx->have_sse)do { if (!(!ctx->have_sse)) { av_log(((void*)0), 0, "Assertion %s failed at %s:%d\n"
, "!ctx->have_sse", "/root/firefox-clang/media/ffvpx/libavcodec/libaomenc.c"
, 1397); abort(); } } while (0)
;
1398 ctx->sse[0] = pkt->data.psnr.sse[0];
1399 ctx->sse[1] = pkt->data.psnr.sse[1];
1400 ctx->sse[2] = pkt->data.psnr.sse[2];
1401 ctx->sse[3] = pkt->data.psnr.sse[3];
1402 ctx->have_sse = 1;
1403 break;
1404 }
1405 case AOM_CODEC_CUSTOM_PKT:
1406 // ignore unsupported/unrecognized packet types
1407 break;
1408 }
1409 }
1410
1411 return size;
1412}
1413
1414static enum AVPixelFormat aomfmt_to_pixfmt(struct aom_image *img)
1415{
1416 switch (img->fmt) {
1417 case AOM_IMG_FMT_I420:
1418 case AOM_IMG_FMT_I42016:
1419 if (img->bit_depth == 8)
1420 return img->monochrome ? AV_PIX_FMT_GRAY8 : AV_PIX_FMT_YUV420P;
1421 else if (img->bit_depth == 10)
1422 return img->monochrome ? AV_PIX_FMT_GRAY10AV_PIX_FMT_GRAY10LE : AV_PIX_FMT_YUV420P10AV_PIX_FMT_YUV420P10LE;
1423 else
1424 return img->monochrome ? AV_PIX_FMT_GRAY12AV_PIX_FMT_GRAY12LE : AV_PIX_FMT_YUV420P12AV_PIX_FMT_YUV420P12LE;
1425 case AOM_IMG_FMT_I422:
1426 case AOM_IMG_FMT_I42216:
1427 if (img->bit_depth == 8)
1428 return AV_PIX_FMT_YUV422P;
1429 else if (img->bit_depth == 10)
1430 return AV_PIX_FMT_YUV422P10AV_PIX_FMT_YUV422P10LE;
1431 else
1432 return AV_PIX_FMT_YUV422P12AV_PIX_FMT_YUV422P12LE;
1433 case AOM_IMG_FMT_I444:
1434 case AOM_IMG_FMT_I44416:
1435 if (img->bit_depth == 8)
1436 return AV_PIX_FMT_YUV444P;
1437 else if (img->bit_depth == 10)
1438 return AV_PIX_FMT_YUV444P10AV_PIX_FMT_YUV444P10LE;
1439 else
1440 return AV_PIX_FMT_YUV444P12AV_PIX_FMT_YUV444P12LE;
1441 };
1442 return AV_PIX_FMT_NONE;
1443}
1444
1445static int aom_encode(AVCodecContext *avctx, AVPacket *pkt,
1446 const AVFrame *frame, int *got_packet)
1447{
1448 AOMContext *ctx = avctx->priv_data;
1449 struct aom_image *rawimg = NULL((void*)0);
1450 int64_t timestamp = 0;
1451 unsigned long duration = 0;
1452 int res, coded_size;
1453 aom_enc_frame_flags_t flags = 0;
1454 AVFrameSideData *sd;
1455
1456 if (frame) {
1
Assuming 'frame' is non-null
2
Taking true branch
1457 rawimg = &ctx->rawimg;
1458 aom_img_remove_metadata(rawimg);
1459 rawimg->planes[AOM_PLANE_Y0] = frame->data[0];
1460 rawimg->planes[AOM_PLANE_U1] = frame->data[1];
1461 rawimg->planes[AOM_PLANE_V2] = frame->data[2];
1462 rawimg->stride[AOM_PLANE_Y0] = frame->linesize[0];
1463 rawimg->stride[AOM_PLANE_U1] = frame->linesize[1];
1464 rawimg->stride[AOM_PLANE_V2] = frame->linesize[2];
1465 timestamp = frame->pts;
1466
1467 if (frame->duration > ULONG_MAX(9223372036854775807L *2UL+1UL)) {
3
Assuming the condition is false
4
Taking false branch
1468 av_log(avctx, AV_LOG_WARNING24,
1469 "Frame duration too large: %"PRId64"l" "d""\n", frame->duration);
1470 } else if (frame->duration)
5
Assuming field 'duration' is not equal to 0
6
Taking true branch
1471 duration = frame->duration;
1472 else if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
1473 duration = av_rescale_q(1, av_inv_q(avctx->framerate), avctx->time_base);
1474 else {
1475 duration = 1;
1476 }
1477
1478 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
1479 if (!(desc->flags & AV_PIX_FMT_FLAG_RGB(1 << 5))) {
7
Assuming the condition is false
8
Taking false branch
1480 const struct ColorConfig *curcfg = &ctx->color_config;
1481 const struct ColorConfig newcfg = {
1482 .color_primaries = frame->color_primaries,
1483 .color_trc = frame->color_trc,
1484 .colorspace = frame->colorspace,
1485 .color_range = frame->color_range,
1486 };
1487 if (newcfg.color_primaries != curcfg->color_primaries ||
1488 newcfg.color_trc != curcfg->color_trc ||
1489 newcfg.colorspace != curcfg->colorspace ||
1490 newcfg.color_range != curcfg->color_range) {
1491 if (ctx->has_submitted_frame && ctx->lag_in_frames != 0) {
1492 av_log(avctx, AV_LOG_WARNING24,
1493 "Ignoring color metadata change with lookahead enabled\n");
1494 } else {
1495 res = set_color_config(avctx, &newcfg);
1496 if (res < 0)
1497 return res;
1498 }
1499 }
1500 }
1501
1502 switch (frame->color_range) {
9
Control jumps to the 'default' case at line 1508
1503 case AVCOL_RANGE_JPEG:
1504 rawimg->range = AOM_CR_FULL_RANGE;
1505 break;
1506 case AVCOL_RANGE_UNSPECIFIED:
1507 case AVCOL_RANGE_MPEG:
1508 default:
1509 rawimg->range = AOM_CR_STUDIO_RANGE;
1510 break;
10
Execution continues on line 1513
1511 }
1512
1513 aom_img_remove_metadata(rawimg);
1514 sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DOVI_METADATA);
1515 if (ctx->dovi.cfg.dv_profile && sd) {
11
Assuming field 'dv_profile' is not equal to 0
12
Assuming 'sd' is non-null
13
Taking true branch
1516 const AVDOVIMetadata *metadata = (const AVDOVIMetadata *)sd->data;
1517 uint8_t *t35;
14
't35' declared without an initial value
1518 int size;
1519 if ((res = ff_dovi_rpu_generate(&ctx->dovi, metadata, FF_DOVI_WRAP_T35,
15
Calling 'ff_dovi_rpu_generate'
17
Returning from 'ff_dovi_rpu_generate'
18
Taking false branch
1520 &t35, &size)) < 0)
1521 return res;
1522 res = aom_img_add_metadata(rawimg, OBU_METADATA_TYPE_ITUT_T35,
19
3rd function call argument is an uninitialized value
1523 t35, size, AOM_MIF_ANY_FRAME);
1524 av_free(t35);
1525 if (res != AOM_CODEC_OK)
1526 return AVERROR(ENOMEM)(-(12));
1527 } else if (ctx->dovi.cfg.dv_profile) {
1528 av_log(avctx, AV_LOG_ERROR16, "Dolby Vision enabled, but received frame "
1529 "without AV_FRAME_DATA_DOVI_METADATA\n");
1530 return AVERROR_INVALIDDATA(-(int)(('I') | (('N') << 8) | (('D') << 16) | ((
unsigned)('A') << 24)))
;
1531 }
1532
1533 if (frame->pict_type == AV_PICTURE_TYPE_I)
1534 flags |= AOM_EFLAG_FORCE_KF(1 << 0);
1535
1536 AVDictionaryEntry* en = av_dict_get(frame->metadata, "temporal_id", NULL((void*)0), 0);
1537 if (en) {
1538 aom_svc_layer_id_t layer_id = {};
1539 layer_id.temporal_layer_id = strtoul(en->value, NULL((void*)0), 10);
1540 av_log(avctx, AV_LOG_DEBUG48, "Frame pts % " PRId64"l" "d" " temporal layer id %d",
1541 frame->pts, layer_id.temporal_layer_id);
1542 if (!ctx->svc_parameters) {
1543 av_log(avctx, AV_LOG_WARNING24,
1544 "Temporal SVC not enabled, but temporal layer id received.");
1545 }
1546 res = aom_codec_control(&ctx->encoder, AV1E_SET_SVC_LAYER_ID, &layer_id);
1547 if (res != AOM_CODEC_OK) {
1548 av_log(avctx, AV_LOG_ERROR16,
1549 "Error setting temporal layer id %d on frame pts % " PRId64"l" "d" "\n",
1550 layer_id.temporal_layer_id, frame->pts);
1551 return res;
1552 }
1553 }
1554
1555 res = add_hdr_plus(avctx, rawimg, frame);
1556 if (res < 0)
1557 return res;
1558
1559 res = add_hdr_smpte2094_app5(avctx, rawimg, frame);
1560 if (res < 0)
1561 return res;
1562 }
1563
1564 res = aom_codec_encode(&ctx->encoder, rawimg, timestamp, duration, flags);
1565 if (res != AOM_CODEC_OK) {
1566 log_encoder_error(avctx, "Error encoding frame");
1567 return AVERROR_INVALIDDATA(-(int)(('I') | (('N') << 8) | (('D') << 16) | ((
unsigned)('A') << 24)))
;
1568 }
1569 if (frame)
1570 ctx->has_submitted_frame = 1;
1571 coded_size = queue_frames(avctx, pkt);
1572 if (coded_size < 0)
1573 return coded_size;
1574
1575 if (!frame && avctx->flags & AV_CODEC_FLAG_PASS1(1 << 9)) {
1576 size_t b64_size = AV_BASE64_SIZE(ctx->twopass_stats.sz)(((ctx->twopass_stats.sz)+2) / 3 * 4 + 1);
1577
1578 avctx->stats_out = av_malloc(b64_size);
1579 if (!avctx->stats_out) {
1580 av_log(avctx, AV_LOG_ERROR16, "Stat buffer alloc (%zu bytes) failed\n",
1581 b64_size);
1582 return AVERROR(ENOMEM)(-(12));
1583 }
1584 av_base64_encode(avctx->stats_out, b64_size, ctx->twopass_stats.buf,
1585 ctx->twopass_stats.sz);
1586 }
1587
1588 *got_packet = !!coded_size;
1589
1590 if (*got_packet && avctx->flags & AV_CODEC_FLAG_RECON_FRAME(1 << 6)) {
1591 AVCodecInternal *avci = avctx->internal;
1592 struct aom_image img;
1593
1594 av_frame_unref(avci->recon_frame);
1595
1596 res = codecctl_imgp(avctx, AV1_GET_NEW_FRAME_IMAGE, &img);
1597 if (res < 0)
1598 return res;
1599
1600 avci->recon_frame->format = aomfmt_to_pixfmt(&img);
1601 if (avci->recon_frame->format == AV_PIX_FMT_NONE) {
1602 av_log(ctx, AV_LOG_ERROR16,
1603 "Unhandled reconstructed frame colorspace: %d\n",
1604 img.fmt);
1605 return AVERROR(ENOSYS)(-(38));
1606 }
1607
1608 avci->recon_frame->width = img.d_w;
1609 avci->recon_frame->height = img.d_h;
1610
1611 res = av_frame_get_buffer(avci->recon_frame, 0);
1612 if (res < 0)
1613 return res;
1614
1615 if ((img.fmt & AOM_IMG_FMT_HIGHBITDEPTH0x800) && img.bit_depth == 8)
1616 ff_aom_image_copy_16_to_8(avci->recon_frame, &img);
1617 else {
1618 const uint8_t *planes[4] = { img.planes[0], img.planes[1], img.planes[2] };
1619 const int stride[4] = { img.stride[0], img.stride[1], img.stride[2] };
1620
1621 av_image_copy(avci->recon_frame->data, avci->recon_frame->linesize, planes,
1622 stride, avci->recon_frame->format, img.d_w, img.d_h);
1623 }
1624 }
1625
1626 return 0;
1627}
1628
1629static const enum AVPixelFormat av1_pix_fmts[] = {
1630 AV_PIX_FMT_YUV420P,
1631 AV_PIX_FMT_YUV422P,
1632 AV_PIX_FMT_YUV444P,
1633 AV_PIX_FMT_GBRP,
1634 AV_PIX_FMT_NONE
1635};
1636
1637static const enum AVPixelFormat av1_pix_fmts_with_gray[] = {
1638 AV_PIX_FMT_YUV420P,
1639 AV_PIX_FMT_YUV422P,
1640 AV_PIX_FMT_YUV444P,
1641 AV_PIX_FMT_GBRP,
1642 AV_PIX_FMT_GRAY8,
1643 AV_PIX_FMT_NONE
1644};
1645
1646static const enum AVPixelFormat av1_pix_fmts_highbd[] = {
1647 AV_PIX_FMT_YUV420P,
1648 AV_PIX_FMT_YUV422P,
1649 AV_PIX_FMT_YUV444P,
1650 AV_PIX_FMT_GBRP,
1651 AV_PIX_FMT_YUV420P10AV_PIX_FMT_YUV420P10LE,
1652 AV_PIX_FMT_YUV422P10AV_PIX_FMT_YUV422P10LE,
1653 AV_PIX_FMT_YUV444P10AV_PIX_FMT_YUV444P10LE,
1654 AV_PIX_FMT_YUV420P12AV_PIX_FMT_YUV420P12LE,
1655 AV_PIX_FMT_YUV422P12AV_PIX_FMT_YUV422P12LE,
1656 AV_PIX_FMT_YUV444P12AV_PIX_FMT_YUV444P12LE,
1657 AV_PIX_FMT_GBRP10AV_PIX_FMT_GBRP10LE,
1658 AV_PIX_FMT_GBRP12AV_PIX_FMT_GBRP12LE,
1659 AV_PIX_FMT_NONE
1660};
1661
1662static const enum AVPixelFormat av1_pix_fmts_highbd_with_gray[] = {
1663 AV_PIX_FMT_YUV420P,
1664 AV_PIX_FMT_YUV422P,
1665 AV_PIX_FMT_YUV444P,
1666 AV_PIX_FMT_GBRP,
1667 AV_PIX_FMT_YUV420P10AV_PIX_FMT_YUV420P10LE,
1668 AV_PIX_FMT_YUV422P10AV_PIX_FMT_YUV422P10LE,
1669 AV_PIX_FMT_YUV444P10AV_PIX_FMT_YUV444P10LE,
1670 AV_PIX_FMT_YUV420P12AV_PIX_FMT_YUV420P12LE,
1671 AV_PIX_FMT_YUV422P12AV_PIX_FMT_YUV422P12LE,
1672 AV_PIX_FMT_YUV444P12AV_PIX_FMT_YUV444P12LE,
1673 AV_PIX_FMT_GBRP10AV_PIX_FMT_GBRP10LE,
1674 AV_PIX_FMT_GBRP12AV_PIX_FMT_GBRP12LE,
1675 AV_PIX_FMT_GRAY8,
1676 AV_PIX_FMT_GRAY10AV_PIX_FMT_GRAY10LE,
1677 AV_PIX_FMT_GRAY12AV_PIX_FMT_GRAY12LE,
1678 AV_PIX_FMT_NONE
1679};
1680
1681static int av1_get_supported_config(const AVCodecContext *avctx,
1682 const AVCodec *codec,
1683 enum AVCodecConfig config,
1684 unsigned flags, const void **out,
1685 int *out_num)
1686{
1687 if (config == AV_CODEC_CONFIG_PIX_FORMAT) {
1688 int supports_monochrome = aom_codec_version() >= 20001;
1689 aom_codec_caps_t codec_caps = aom_codec_get_caps(aom_codec_av1_cx());
1690 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH0x40000) {
1691 if (supports_monochrome) {
1692 *out = av1_pix_fmts_highbd_with_gray;
1693 *out_num = FF_ARRAY_ELEMS(av1_pix_fmts_highbd_with_gray)(sizeof(av1_pix_fmts_highbd_with_gray) / sizeof((av1_pix_fmts_highbd_with_gray
)[0]))
- 1;
1694 } else {
1695 *out = av1_pix_fmts_highbd;
1696 *out_num = FF_ARRAY_ELEMS(av1_pix_fmts_highbd)(sizeof(av1_pix_fmts_highbd) / sizeof((av1_pix_fmts_highbd)[0
]))
- 1;
1697 }
1698 } else {
1699 if (supports_monochrome) {
1700 *out = av1_pix_fmts_with_gray;
1701 *out_num = FF_ARRAY_ELEMS(av1_pix_fmts_with_gray)(sizeof(av1_pix_fmts_with_gray) / sizeof((av1_pix_fmts_with_gray
)[0]))
- 1;
1702 } else {
1703 *out = av1_pix_fmts;
1704 *out_num = FF_ARRAY_ELEMS(av1_pix_fmts)(sizeof(av1_pix_fmts) / sizeof((av1_pix_fmts)[0])) - 1;
1705 }
1706 }
1707 return 0;
1708 }
1709
1710 return ff_default_get_supported_config(avctx, codec, config, flags, out, out_num);
1711}
1712
1713static av_cold__attribute__((cold)) int av1_init(AVCodecContext *avctx)
1714{
1715 return aom_init(avctx, aom_codec_av1_cx());
1716}
1717
1718#define VE(1 << 4) | (1 << 0) AV_OPT_FLAG_VIDEO_PARAM(1 << 4) | AV_OPT_FLAG_ENCODING_PARAM(1 << 0)
1719static const AVOption options[] = {
1720 { "cpu-used", "Quality/Speed ratio modifier", OFFSET(cpu_used)__builtin_offsetof(AOMContext, cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 8, VE(1 << 4) | (1 << 0)},
1721 { "auto-alt-ref", "Enable use of alternate reference "
1722 "frames (2-pass only)", OFFSET(auto_alt_ref)__builtin_offsetof(AOMContext, auto_alt_ref), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE(1 << 4) | (1 << 0)},
1723 { "lag-in-frames", "Number of frames to look ahead at for "
1724 "alternate reference frame selection", OFFSET(lag_in_frames)__builtin_offsetof(AOMContext, lag_in_frames), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX2147483647, VE(1 << 4) | (1 << 0)},
1725 { "arnr-max-frames", "altref noise reduction max frame count", OFFSET(arnr_max_frames)__builtin_offsetof(AOMContext, arnr_max_frames), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX2147483647, VE(1 << 4) | (1 << 0)},
1726 { "arnr-strength", "altref noise reduction filter strength", OFFSET(arnr_strength)__builtin_offsetof(AOMContext, arnr_strength), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE(1 << 4) | (1 << 0)},
1727 { "aq-mode", "adaptive quantization mode", OFFSET(aq_mode)__builtin_offsetof(AOMContext, aq_mode), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 4, VE(1 << 4) | (1 << 0), .unit = "aq_mode"},
1728 { "none", "Aq not used", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, VE(1 << 4) | (1 << 0), .unit = "aq_mode"},
1729 { "variance", "Variance based Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE(1 << 4) | (1 << 0), .unit = "aq_mode"},
1730 { "complexity", "Complexity based Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE(1 << 4) | (1 << 0), .unit = "aq_mode"},
1731 { "cyclic", "Cyclic Refresh Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, VE(1 << 4) | (1 << 0), .unit = "aq_mode"},
1732 { "error-resilience", "Error resilience configuration", OFFSET(error_resilient)__builtin_offsetof(AOMContext, error_resilient), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN(-2147483647 -1), INT_MAX2147483647, VE(1 << 4) | (1 << 0), .unit = "er"},
1733 { "default", "Improve resiliency against losses of whole frames", 0, AV_OPT_TYPE_CONST, {.i64 = AOM_ERROR_RESILIENT_DEFAULT0x1}, 0, 0, VE(1 << 4) | (1 << 0), .unit = "er"},
1734 { "crf", "Select the quality for constant quality mode", offsetof(AOMContext, crf)__builtin_offsetof(AOMContext, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE(1 << 4) | (1 << 0) },
1735 { "static-thresh", "A change threshold on blocks below which they will be skipped by the encoder", OFFSET(static_thresh)__builtin_offsetof(AOMContext, static_thresh), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX2147483647, VE(1 << 4) | (1 << 0) },
1736 { "drop-threshold", "Frame drop threshold", offsetof(AOMContext, drop_threshold)__builtin_offsetof(AOMContext, drop_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN(-2147483647 -1), INT_MAX2147483647, VE(1 << 4) | (1 << 0) },
1737 { "denoise-noise-level", "Amount of noise to be removed", OFFSET(denoise_noise_level)__builtin_offsetof(AOMContext, denoise_noise_level), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX2147483647, VE(1 << 4) | (1 << 0)},
1738 { "denoise-block-size", "Denoise block size ", OFFSET(denoise_block_size)__builtin_offsetof(AOMContext, denoise_block_size), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX2147483647, VE(1 << 4) | (1 << 0)},
1739 { "undershoot-pct", "Datarate undershoot (min) target (%)", OFFSET(rc_undershoot_pct)__builtin_offsetof(AOMContext, rc_undershoot_pct), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 100, VE(1 << 4) | (1 << 0)},
1740 { "overshoot-pct", "Datarate overshoot (max) target (%)", OFFSET(rc_overshoot_pct)__builtin_offsetof(AOMContext, rc_overshoot_pct), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1000, VE(1 << 4) | (1 << 0)},
1741 { "minsection-pct", "GOP min bitrate (% of target)", OFFSET(minsection_pct)__builtin_offsetof(AOMContext, minsection_pct), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 100, VE(1 << 4) | (1 << 0)},
1742 { "maxsection-pct", "GOP max bitrate (% of target)", OFFSET(maxsection_pct)__builtin_offsetof(AOMContext, maxsection_pct), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 5000, VE(1 << 4) | (1 << 0)},
1743 { "frame-parallel", "Enable frame parallel decodability features", OFFSET(frame_parallel)__builtin_offsetof(AOMContext, frame_parallel), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1744 { "tiles", "Tile columns x rows", OFFSET(tile_cols)__builtin_offsetof(AOMContext, tile_cols), AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL((void*)0) }, 0, 0, VE(1 << 4) | (1 << 0) },
1745 { "tile-columns", "Log2 of number of tile columns to use", OFFSET(tile_cols_log2)__builtin_offsetof(AOMContext, tile_cols_log2), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE(1 << 4) | (1 << 0)},
1746 { "tile-rows", "Log2 of number of tile rows to use", OFFSET(tile_rows_log2)__builtin_offsetof(AOMContext, tile_rows_log2), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE(1 << 4) | (1 << 0)},
1747 { "row-mt", "Enable row based multi-threading", OFFSET(row_mt)__builtin_offsetof(AOMContext, row_mt), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1748 { "enable-cdef", "Enable CDEF filtering", OFFSET(enable_cdef)__builtin_offsetof(AOMContext, enable_cdef), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1749 { "enable-global-motion", "Enable global motion", OFFSET(enable_global_motion)__builtin_offsetof(AOMContext, enable_global_motion), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1750 { "enable-intrabc", "Enable intra block copy prediction mode", OFFSET(enable_intrabc)__builtin_offsetof(AOMContext, enable_intrabc), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1751 { "enable-restoration", "Enable Loop Restoration filtering", OFFSET(enable_restoration)__builtin_offsetof(AOMContext, enable_restoration), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1752 { "usage", "Quality and compression efficiency vs speed trade-off", OFFSET(usage)__builtin_offsetof(AOMContext, usage), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX2147483647, VE(1 << 4) | (1 << 0), .unit = "usage"},
1753 { "good", "Good quality", 0, AV_OPT_TYPE_CONST, {.i64 = 0 /* AOM_USAGE_GOOD_QUALITY */}, 0, 0, VE(1 << 4) | (1 << 0), .unit = "usage"},
1754 { "realtime", "Realtime encoding", 0, AV_OPT_TYPE_CONST, {.i64 = 1 /* AOM_USAGE_REALTIME */}, 0, 0, VE(1 << 4) | (1 << 0), .unit = "usage"},
1755 { "allintra", "All Intra encoding", 0, AV_OPT_TYPE_CONST, {.i64 = 2 /* AOM_USAGE_ALL_INTRA */}, 0, 0, VE(1 << 4) | (1 << 0), .unit = "usage"},
1756 { "tune", "The metric that the encoder tunes for. Automatically chosen by the encoder by default", OFFSET(tune)__builtin_offsetof(AOMContext, tune), AV_OPT_TYPE_INT, {.i64 = -1}, -1, AOM_TUNE_SSIM, VE(1 << 4) | (1 << 0), .unit = "tune"},
1757 { "psnr", NULL((void*)0), 0, AV_OPT_TYPE_CONST, {.i64 = AOM_TUNE_PSNR}, 0, 0, VE(1 << 4) | (1 << 0), .unit = "tune"},
1758 { "ssim", NULL((void*)0), 0, AV_OPT_TYPE_CONST, {.i64 = AOM_TUNE_SSIM}, 0, 0, VE(1 << 4) | (1 << 0), .unit = "tune"},
1759 FF_AV1_PROFILE_OPTS{"main", ((void*)0), 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, (-2147483647
-1), 2147483647, (1 << 0) | (1 << 4), .unit = "avctx.profile"
}, {"high", ((void*)0), 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, (-
2147483647 -1), 2147483647, (1 << 0) | (1 << 4), .
unit = "avctx.profile"}, {"professional", ((void*)0), 0, AV_OPT_TYPE_CONST
, {.i64 = 2 }, (-2147483647 -1), 2147483647, (1 << 0) |
(1 << 4), .unit = "avctx.profile"},
1760 { "still-picture", "Encode in single frame mode (typically used for still AVIF images).", OFFSET(still_picture)__builtin_offsetof(AOMContext, still_picture), AV_OPT_TYPE_BOOL, {.i64 = 0}, -1, 1, VE(1 << 4) | (1 << 0) },
1761 { "dolbyvision", "Enable Dolby Vision RPU coding", OFFSET(dovi.enable)__builtin_offsetof(AOMContext, dovi.enable), AV_OPT_TYPE_BOOL, {.i64 = FF_DOVI_AUTOMATIC-1 }, -1, 1, VE(1 << 4) | (1 << 0), .unit = "dovi" },
1762 { "auto", NULL((void*)0), 0, AV_OPT_TYPE_CONST, {.i64 = FF_DOVI_AUTOMATIC-1}, .flags = VE(1 << 4) | (1 << 0), .unit = "dovi" },
1763 { "enable-rect-partitions", "Enable rectangular partitions", OFFSET(enable_rect_partitions)__builtin_offsetof(AOMContext, enable_rect_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1764 { "enable-1to4-partitions", "Enable 1:4/4:1 partitions", OFFSET(enable_1to4_partitions)__builtin_offsetof(AOMContext, enable_1to4_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1765 { "enable-ab-partitions", "Enable ab shape partitions", OFFSET(enable_ab_partitions)__builtin_offsetof(AOMContext, enable_ab_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1766 { "enable-angle-delta", "Enable angle delta intra prediction", OFFSET(enable_angle_delta)__builtin_offsetof(AOMContext, enable_angle_delta), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1767 { "enable-cfl-intra", "Enable chroma predicted from luma intra prediction", OFFSET(enable_cfl_intra)__builtin_offsetof(AOMContext, enable_cfl_intra), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1768 { "enable-filter-intra", "Enable filter intra predictor", OFFSET(enable_filter_intra)__builtin_offsetof(AOMContext, enable_filter_intra), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1769 { "enable-intra-edge-filter", "Enable intra edge filter", OFFSET(enable_intra_edge_filter)__builtin_offsetof(AOMContext, enable_intra_edge_filter), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1770 { "enable-smooth-intra", "Enable smooth intra prediction mode", OFFSET(enable_smooth_intra)__builtin_offsetof(AOMContext, enable_smooth_intra), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1771 { "enable-paeth-intra", "Enable paeth predictor in intra prediction", OFFSET(enable_paeth_intra)__builtin_offsetof(AOMContext, enable_paeth_intra), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1772 { "enable-palette", "Enable palette prediction mode", OFFSET(enable_palette)__builtin_offsetof(AOMContext, enable_palette), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1773 { "enable-flip-idtx", "Enable extended transform type", OFFSET(enable_flip_idtx)__builtin_offsetof(AOMContext, enable_flip_idtx), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1774 { "enable-tx64", "Enable 64-pt transform", OFFSET(enable_tx64)__builtin_offsetof(AOMContext, enable_tx64), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1775 { "reduced-tx-type-set", "Use reduced set of transform types", OFFSET(reduced_tx_type_set)__builtin_offsetof(AOMContext, reduced_tx_type_set), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1776 { "use-intra-dct-only", "Use DCT only for INTRA modes", OFFSET(use_intra_dct_only)__builtin_offsetof(AOMContext, use_intra_dct_only), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1777 { "use-inter-dct-only", "Use DCT only for INTER modes", OFFSET(use_inter_dct_only)__builtin_offsetof(AOMContext, use_inter_dct_only), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1778 { "use-intra-default-tx-only", "Use default-transform only for INTRA modes", OFFSET(use_intra_default_tx_only)__builtin_offsetof(AOMContext, use_intra_default_tx_only), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1779 { "enable-ref-frame-mvs", "Enable temporal mv prediction", OFFSET(enable_ref_frame_mvs)__builtin_offsetof(AOMContext, enable_ref_frame_mvs), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1780 { "enable-reduced-reference-set", "Use reduced set of single and compound references", OFFSET(enable_reduced_reference_set)__builtin_offsetof(AOMContext, enable_reduced_reference_set), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1781 { "enable-obmc", "Enable obmc", OFFSET(enable_obmc)__builtin_offsetof(AOMContext, enable_obmc), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1782 { "enable-dual-filter", "Enable dual filter", OFFSET(enable_dual_filter)__builtin_offsetof(AOMContext, enable_dual_filter), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1783 { "enable-diff-wtd-comp", "Enable difference-weighted compound", OFFSET(enable_diff_wtd_comp)__builtin_offsetof(AOMContext, enable_diff_wtd_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1784 { "enable-dist-wtd-comp", "Enable distance-weighted compound", OFFSET(enable_dist_wtd_comp)__builtin_offsetof(AOMContext, enable_dist_wtd_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1785 { "enable-onesided-comp", "Enable one sided compound", OFFSET(enable_onesided_comp)__builtin_offsetof(AOMContext, enable_onesided_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1786 { "enable-interinter-wedge", "Enable interinter wedge compound", OFFSET(enable_interinter_wedge)__builtin_offsetof(AOMContext, enable_interinter_wedge), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1787 { "enable-interintra-wedge", "Enable interintra wedge compound", OFFSET(enable_interintra_wedge)__builtin_offsetof(AOMContext, enable_interintra_wedge), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1788 { "enable-masked-comp", "Enable masked compound", OFFSET(enable_masked_comp)__builtin_offsetof(AOMContext, enable_masked_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1789 { "enable-interintra-comp", "Enable interintra compound", OFFSET(enable_interintra_comp)__builtin_offsetof(AOMContext, enable_interintra_comp), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1790 { "enable-smooth-interintra", "Enable smooth interintra mode", OFFSET(enable_smooth_interintra)__builtin_offsetof(AOMContext, enable_smooth_interintra), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE(1 << 4) | (1 << 0)},
1791 { "svc-parameters", "SVC configuration using a :-separated list of key=value parameters (only applied in CBR mode)", OFFSET(svc_parameters)__builtin_offsetof(AOMContext, svc_parameters), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE(1 << 4) | (1 << 0)},
1792#if AOM_ENCODER_ABI_VERSION(10 + (7 + (9)) + 3) >= 23
1793 { "aom-params", "Set libaom options using a :-separated list of key=value pairs", OFFSET(aom_params)__builtin_offsetof(AOMContext, aom_params), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE(1 << 4) | (1 << 0) },
1794#endif
1795 { NULL((void*)0) },
1796};
1797
1798static const FFCodecDefault defaults[] = {
1799 { "b", "0" },
1800 { "qmin", "-1" },
1801 { "qmax", "-1" },
1802 { "g", "-1" },
1803 { "keyint_min", "-1" },
1804 { NULL((void*)0) },
1805};
1806
1807static const AVClass class_aom = {
1808 .class_name = "libaom-av1 encoder",
1809 .item_name = av_default_item_name,
1810 .option = options,
1811 .version = LIBAVUTIL_VERSION_INT((61)<<16 | (1)<<8 | (101)),
1812};
1813
1814const FFCodec ff_libaom_av1_encoder = {
1815 .p.name = "libaom-av1",
1816 CODEC_LONG_NAME("libaom AV1").p.long_name = "libaom AV1",
1817 .p.type = AVMEDIA_TYPE_VIDEO,
1818 .p.id = AV_CODEC_ID_AV1,
1819 .p.capabilities = AV_CODEC_CAP_DR1(1 << 1) | AV_CODEC_CAP_DELAY(1 << 5) |
1820 AV_CODEC_CAP_ENCODER_RECON_FRAME(1 << 22) |
1821 AV_CODEC_CAP_OTHER_THREADS(1 << 15),
1822 .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG,
1823 .p.profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles)ff_av1_profiles,
1824 .p.priv_class = &class_aom,
1825 .p.wrapper_name = "libaom",
1826 .priv_data_size = sizeof(AOMContext),
1827 .init = av1_init,
1828 FF_CODEC_ENCODE_CB(aom_encode).is_decoder = 0, .cb_type = FF_CODEC_CB_TYPE_ENCODE, .cb.encode
= (aom_encode)
,
1829 .close = aom_free,
1830 .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE(1 << 0) |
1831 FF_CODEC_CAP_INIT_CLEANUP(1 << 1) |
1832 FF_CODEC_CAP_AUTO_THREADS(1 << 7),
1833 .defaults = defaults,
1834 .get_supported_config = av1_get_supported_config,
1835};

←

/root/firefox-clang/media/ffvpx/libavcodec/dovi_rpu.h

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5/* Stubs for dovi_rpu.{c,h} */
6
7#ifndef AVCODEC_DOVI_RPU_H
8#define AVCODEC_DOVI_RPU_H
9
10#include <stddef.h>
11#include <stdint.h>
12
13struct AVCodecContext;
14struct AVCodecParameters;
15struct AVFrame;
16
17#define DOVI_MAX_DM_ID15 15
18
19enum {
20 FF_DOVI_WRAP_NAL = 1 << 0,
21 FF_DOVI_WRAP_T35 = 1 << 1,
22 FF_DOVI_COMPRESS_RPU = 1 << 2,
23};
24
25enum AVDOVICompression {
26 AV_DOVI_COMPRESSION_NONE = 0,
27 AV_DOVI_COMPRESSION_LIMITED = 1,
28 AV_DOVI_COMPRESSION_RESERVED = 2,
29 AV_DOVI_COMPRESSION_EXTENDED = 3,
30};
31
32typedef struct AVDOVIDecoderConfigurationRecord {
33 uint8_t dv_version_major;
34 uint8_t dv_version_minor;
35 uint8_t dv_profile;
36 uint8_t dv_level;
37 uint8_t rpu_present_flag;
38 uint8_t el_present_flag;
39 uint8_t bl_present_flag;
40 uint8_t dv_bl_signal_compatibility_id;
41 uint8_t dv_md_compression;
42} AVDOVIDecoderConfigurationRecord;
43
44typedef struct AVDOVIRpuDataHeader {
45 uint8_t rpu_type;
46 uint16_t rpu_format;
47 uint8_t vdr_rpu_profile;
48 uint8_t vdr_rpu_level;
49 uint8_t chroma_resampling_explicit_filter_flag;
50 uint8_t coef_data_type;
51 uint8_t coef_log2_denom;
52 uint8_t vdr_rpu_normalized_idc;
53 uint8_t bl_video_full_range_flag;
54 uint8_t bl_bit_depth;
55 uint8_t el_bit_depth;
56 uint8_t vdr_bit_depth;
57 uint8_t spatial_resampling_filter_flag;
58 uint8_t el_spatial_resampling_filter_flag;
59 uint8_t disable_residual_flag;
60 uint8_t ext_mapping_idc_0_4;
61 uint8_t ext_mapping_idc_5_7;
62} AVDOVIRpuDataHeader;
63
64typedef struct AVDOVIMetadata AVDOVIMetadata;
65typedef struct AVDOVIDataMapping AVDOVIDataMapping;
66typedef struct AVDOVIColorMetadata AVDOVIColorMetadata;
67typedef struct DOVIExt DOVIExt;
68
69typedef struct DOVIContext {
70 void *logctx;
71
72#define FF_DOVI_AUTOMATIC-1 -1
73 int enable;
74
75 AVDOVIDecoderConfigurationRecord cfg;
76 AVDOVIRpuDataHeader header;
77
78 const AVDOVIDataMapping *mapping;
79 const AVDOVIColorMetadata *color;
80 DOVIExt *ext_blocks;
81
82 AVDOVIColorMetadata *dm;
83 AVDOVIDataMapping *vdr[DOVI_MAX_DM_ID15+1];
84 uint8_t *rpu_buf;
85 unsigned rpu_buf_sz;
86} DOVIContext;
87
88static inline void ff_dovi_ctx_replace(DOVIContext *s, const DOVIContext *s0) {
89 (void)s; (void)s0;
90}
91
92static inline void ff_dovi_ctx_unref(DOVIContext *s) {
93 (void)s;
94}
95
96static inline void ff_dovi_ctx_flush(DOVIContext *s) {
97 (void)s;
98}
99
100static inline int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu,
101 size_t rpu_size, int err_recognition) {
102 (void)s; (void)rpu; (void)rpu_size; (void)err_recognition;
103 return 0;
104}
105
106static inline int ff_dovi_get_metadata(DOVIContext *s,
107 AVDOVIMetadata **out_metadata) {
108 (void)s; (void)out_metadata;
109 return 0;
110}
111
112static inline int ff_dovi_attach_side_data(DOVIContext *s, struct AVFrame *frame) {
113 (void)s; (void)frame;
114 return 0;
115}
116
117static inline int ff_dovi_configure_from_codedpar(DOVIContext *s,
118 struct AVCodecParameters *codecpar,
119 const AVDOVIMetadata *metadata,
120 enum AVDOVICompression compression,
121 int strict_std_compliance) {
122 (void)s; (void)codecpar; (void)metadata; (void)compression;
123 (void)strict_std_compliance;
124 return 0;
125}
126
127static inline int ff_dovi_configure(DOVIContext *s, struct AVCodecContext *avctx) {
128 (void)s; (void)avctx;
129 return 0;
130}
131
132static inline int ff_dovi_rpu_generate(DOVIContext *s,
133 const AVDOVIMetadata *metadata,
134 int flags, uint8_t **out_rpu,
135 int *out_size) {
136 (void)s; (void)metadata; (void)flags; (void)out_rpu; (void)out_size;
137 return 0;
16
Returning without writing to '*out_rpu'
138}
139
140#endif /* AVCODEC_DOVI_RPU_H */