12#include "apps/aomenc.h"
14#include "config/aom_config.h"
30#include "aom/aom_integer.h"
32#include "aom_dsp/aom_dsp_common.h"
33#include "aom_ports/aom_timer.h"
34#include "aom_ports/mem_ops.h"
35#include "common/args.h"
36#include "common/ivfenc.h"
37#include "common/tools_common.h"
38#include "common/warnings.h"
41#include "common/webmenc.h"
44#include "common/y4minput.h"
45#include "examples/encoder_util.h"
46#include "stats/aomstats.h"
47#include "stats/rate_hist.h"
50#include <libyuv/scale.h>
54static size_t wrap_fread(
void *ptr,
size_t size,
size_t nmemb, FILE *stream) {
55 return fread(ptr, size, nmemb, stream);
57#define fread wrap_fread
59static size_t wrap_fwrite(
const void *ptr,
size_t size,
size_t nmemb,
61 return fwrite(ptr, size, nmemb, stream);
63#define fwrite wrap_fwrite
65static const char *exec_name;
67static AOM_TOOLS_FORMAT_PRINTF(3, 0) void warn_or_exit_on_errorv(
72 vfprintf(stderr, s, ap);
75 if (detail) fprintf(stderr,
" %s\n", detail);
77 if (fatal) exit(EXIT_FAILURE);
81static AOM_TOOLS_FORMAT_PRINTF(2,
87 warn_or_exit_on_errorv(ctx, 1, s, ap);
91static AOM_TOOLS_FORMAT_PRINTF(3, 4) void warn_or_exit_on_error(
96 warn_or_exit_on_errorv(ctx, fatal, s, ap);
100static int read_frame(
struct AvxInputContext *input_ctx,
aom_image_t *img) {
101 FILE *f = input_ctx->file;
102 y4m_input *y4m = &input_ctx->y4m;
105 if (input_ctx->file_type == FILE_TYPE_Y4M) {
106 if (y4m_input_fetch_frame(y4m, f, img) < 1)
return 0;
108 shortread = read_yuv_frame(input_ctx, img);
114static int file_is_y4m(
const char detect[4]) {
115 if (memcmp(detect,
"YUV4", 4) == 0) {
121static int fourcc_is_ivf(
const char detect[4]) {
122 if (memcmp(detect,
"DKIF", 4) == 0) {
220 AV1E_SET_ENABLE_DNL_DENOISING,
242const arg_def_t *main_args[] = { &g_av1_codec_arg_defs.help,
243 &g_av1_codec_arg_defs.use_cfg,
244 &g_av1_codec_arg_defs.debugmode,
245 &g_av1_codec_arg_defs.outputfile,
246 &g_av1_codec_arg_defs.codecarg,
247 &g_av1_codec_arg_defs.passes,
248 &g_av1_codec_arg_defs.pass_arg,
249 &g_av1_codec_arg_defs.fpf_name,
250 &g_av1_codec_arg_defs.limit,
251 &g_av1_codec_arg_defs.skip,
252 &g_av1_codec_arg_defs.good_dl,
253 &g_av1_codec_arg_defs.rt_dl,
254 &g_av1_codec_arg_defs.ai_dl,
255 &g_av1_codec_arg_defs.quietarg,
256 &g_av1_codec_arg_defs.verbosearg,
257 &g_av1_codec_arg_defs.psnrarg,
258 &g_av1_codec_arg_defs.use_webm,
259 &g_av1_codec_arg_defs.use_ivf,
260 &g_av1_codec_arg_defs.use_obu,
261 &g_av1_codec_arg_defs.q_hist_n,
262 &g_av1_codec_arg_defs.rate_hist_n,
263 &g_av1_codec_arg_defs.disable_warnings,
264 &g_av1_codec_arg_defs.disable_warning_prompt,
265 &g_av1_codec_arg_defs.recontest,
268const arg_def_t *global_args[] = {
269 &g_av1_codec_arg_defs.use_nv12,
270 &g_av1_codec_arg_defs.use_yv12,
271 &g_av1_codec_arg_defs.use_i420,
272 &g_av1_codec_arg_defs.use_i422,
273 &g_av1_codec_arg_defs.use_i444,
274 &g_av1_codec_arg_defs.usage,
275 &g_av1_codec_arg_defs.threads,
276 &g_av1_codec_arg_defs.profile,
277 &g_av1_codec_arg_defs.width,
278 &g_av1_codec_arg_defs.height,
279 &g_av1_codec_arg_defs.forced_max_frame_width,
280 &g_av1_codec_arg_defs.forced_max_frame_height,
282 &g_av1_codec_arg_defs.stereo_mode,
284 &g_av1_codec_arg_defs.timebase,
285 &g_av1_codec_arg_defs.framerate,
286 &g_av1_codec_arg_defs.global_error_resilient,
287 &g_av1_codec_arg_defs.bitdeptharg,
288 &g_av1_codec_arg_defs.inbitdeptharg,
289 &g_av1_codec_arg_defs.lag_in_frames,
290 &g_av1_codec_arg_defs.large_scale_tile,
291 &g_av1_codec_arg_defs.monochrome,
292 &g_av1_codec_arg_defs.full_still_picture_hdr,
293 &g_av1_codec_arg_defs.use_16bit_internal,
294 &g_av1_codec_arg_defs.save_as_annexb,
298const arg_def_t *rc_args[] = { &g_av1_codec_arg_defs.dropframe_thresh,
299 &g_av1_codec_arg_defs.resize_mode,
300 &g_av1_codec_arg_defs.resize_denominator,
301 &g_av1_codec_arg_defs.resize_kf_denominator,
302 &g_av1_codec_arg_defs.superres_mode,
303 &g_av1_codec_arg_defs.superres_denominator,
304 &g_av1_codec_arg_defs.superres_kf_denominator,
305 &g_av1_codec_arg_defs.superres_qthresh,
306 &g_av1_codec_arg_defs.superres_kf_qthresh,
307 &g_av1_codec_arg_defs.end_usage,
308 &g_av1_codec_arg_defs.target_bitrate,
309 &g_av1_codec_arg_defs.min_quantizer,
310 &g_av1_codec_arg_defs.max_quantizer,
311 &g_av1_codec_arg_defs.undershoot_pct,
312 &g_av1_codec_arg_defs.overshoot_pct,
313 &g_av1_codec_arg_defs.buf_sz,
314 &g_av1_codec_arg_defs.buf_initial_sz,
315 &g_av1_codec_arg_defs.buf_optimal_sz,
316 &g_av1_codec_arg_defs.bias_pct,
317 &g_av1_codec_arg_defs.minsection_pct,
318 &g_av1_codec_arg_defs.maxsection_pct,
321const arg_def_t *kf_args[] = { &g_av1_codec_arg_defs.fwd_kf_enabled,
322 &g_av1_codec_arg_defs.kf_min_dist,
323 &g_av1_codec_arg_defs.kf_max_dist,