24 #include "common/args.h"
25 #include "common/tools_common.h"
26 #include "common/video_writer.h"
27 #include "examples/encoder_util.h"
28 #include "aom_ports/aom_timer.h"
30 #define OPTION_BUFFER_SIZE 1024
33 const char *output_filename;
34 char options[OPTION_BUFFER_SIZE];
35 struct AvxInputContext input_ctx;
50 static const arg_def_t outputfile =
51 ARG_DEF(
"o",
"output", 1,
"Output filename");
52 static const arg_def_t frames_arg =
53 ARG_DEF(
"f",
"frames", 1,
"Number of frames to encode");
54 static const arg_def_t threads_arg =
55 ARG_DEF(
"th",
"threads", 1,
"Number of threads to use");
56 static const arg_def_t width_arg = ARG_DEF(
"w",
"width", 1,
"Source width");
57 static const arg_def_t height_arg = ARG_DEF(
"h",
"height", 1,
"Source height");
58 static const arg_def_t timebase_arg =
59 ARG_DEF(
"t",
"timebase", 1,
"Timebase (num/den)");
60 static const arg_def_t bitrate_arg = ARG_DEF(
61 "b",
"target-bitrate", 1,
"Encoding bitrate, in kilobits per second");
62 static const arg_def_t spatial_layers_arg =
63 ARG_DEF(
"sl",
"spatial-layers", 1,
"Number of spatial SVC layers");
64 static const arg_def_t temporal_layers_arg =
65 ARG_DEF(
"tl",
"temporal-layers", 1,
"Number of temporal SVC layers");
66 static const arg_def_t layering_mode_arg =
67 ARG_DEF(
"lm",
"layering-mode", 1,
"Temporal layering scheme.");
68 static const arg_def_t kf_dist_arg =
69 ARG_DEF(
"k",
"kf-dist", 1,
"Number of frames between keyframes");
70 static const arg_def_t scale_factors_arg =
71 ARG_DEF(
"r",
"scale-factors", 1,
"Scale factors (lowest to highest layer)");
72 static const arg_def_t min_q_arg =
73 ARG_DEF(NULL,
"min-q", 1,
"Minimum quantizer");
74 static const arg_def_t max_q_arg =
75 ARG_DEF(NULL,
"max-q", 1,
"Maximum quantizer");
76 static const arg_def_t speed_arg =
77 ARG_DEF(
"sp",
"speed", 1,
"Speed configuration");
78 static const arg_def_t aqmode_arg =
79 ARG_DEF(
"aq",
"aqmode", 1,
"AQ mode off/on");
80 static const arg_def_t bitrates_arg =
81 ARG_DEF(
"bl",
"bitrates", 1,
82 "Bitrates[spatial_layer * num_temporal_layer + temporal_layer]");
83 static const arg_def_t dropframe_thresh_arg =
84 ARG_DEF(NULL,
"drop-frame", 1,
"Temporal resampling threshold (buf %)");
85 static const arg_def_t error_resilient_arg =
86 ARG_DEF(NULL,
"error-resilient", 1,
"Error resilient flag");
87 static const arg_def_t output_obu_arg =
88 ARG_DEF(NULL,
"output-obu", 1,
89 "Write OBUs when set to 1. Otherwise write IVF files.");
91 #if CONFIG_AV1_HIGHBITDEPTH
92 static const struct arg_enum_list bitdepth_enum[] = {
96 static const arg_def_t bitdepth_arg = ARG_DEF_ENUM(
97 "d",
"bit-depth", 1,
"Bit depth for codec 8, 10 or 12. ", bitdepth_enum);
100 static const arg_def_t *svc_args[] = {
101 &frames_arg, &outputfile, &width_arg,
102 &height_arg, &timebase_arg, &bitrate_arg,
103 &spatial_layers_arg, &kf_dist_arg, &scale_factors_arg,
104 &min_q_arg, &max_q_arg, &temporal_layers_arg,
105 &layering_mode_arg, &threads_arg, &aqmode_arg,
106 #if CONFIG_AV1_HIGHBITDEPTH
109 &speed_arg, &bitrates_arg, &dropframe_thresh_arg,
110 &error_resilient_arg, &output_obu_arg, NULL
113 #define zero(Dest) memset(&(Dest), 0, sizeof(Dest));
115 static const char *exec_name;
117 void usage_exit(
void) {
118 fprintf(stderr,
"Usage: %s <options> input_filename -o output_filename\n",
120 fprintf(stderr,
"Options:\n");
121 arg_show_usage(stderr, svc_args);
125 static int file_is_y4m(
const char detect[4]) {
126 return memcmp(detect,
"YUV4", 4) == 0;
129 static int fourcc_is_ivf(
const char detect[4]) {
130 if (memcmp(detect,
"DKIF", 4) == 0) {
136 static const int option_max_values[ALL_OPTION_TYPES] = { 63, INT_MAX, INT_MAX,
139 static const int option_min_values[ALL_OPTION_TYPES] = { 0, 0, 1, 0 };
141 static void open_input_file(
struct AvxInputContext *input,
144 input->file = strcmp(input->filename,
"-") ? fopen(input->filename,
"rb")
145 : set_binary_mode(stdin);
147 if (!input->file) fatal(
"Failed to open input file");
149 if (!fseeko(input->file, 0, SEEK_END)) {
153 input->length = ftello(input->file);
158 input->pixel_aspect_ratio.numerator = 1;
159 input->pixel_aspect_ratio.denominator = 1;
164 input->detect.buf_read = fread(input->detect.buf, 1, 4, input->file);
165 input->detect.position = 0;
167 if (input->detect.buf_read == 4 && file_is_y4m(input->detect.buf)) {
168 if (y4m_input_open(&input->y4m, input->file, input->detect.buf, 4, csp,
169 input->only_i420) >= 0) {
170 input->file_type = FILE_TYPE_Y4M;
171 input->width = input->y4m.pic_w;
172 input->height = input->y4m.pic_h;
173 input->pixel_aspect_ratio.numerator = input->y4m.par_n;
174 input->pixel_aspect_ratio.denominator = input->y4m.par_d;
175 input->framerate.numerator = input->y4m.fps_n;
176 input->framerate.denominator = input->y4m.fps_d;
177 input->fmt = input->y4m.aom_fmt;
178 input->bit_depth = input->y4m.bit_depth;
180 fatal(
"Unsupported Y4M stream.");
182 }
else if (input->detect.buf_read == 4 && fourcc_is_ivf(input->detect.buf)) {
183 fatal(
"IVF is not supported as input.");
185 input->file_type = FILE_TYPE_RAW;
189 static aom_codec_err_t extract_option(LAYER_OPTION_TYPE type,
char *input,
190 int *value0,
int *value1) {
191 if (type == SCALE_FACTOR) {
192 *value0 = (int)strtol(input, &input, 10);
194 *value1 = (int)strtol(input, &input, 10);
196 if (*value0 < option_min_values[SCALE_FACTOR] ||
197 *value1 < option_min_values[SCALE_FACTOR] ||
198 *value0 > option_max_values[SCALE_FACTOR] ||
199 *value1 > option_max_values[SCALE_FACTOR] ||
203 *value0 = atoi(input);
204 if (*value0 < option_min_values[type] || *value0 > option_max_values[type])
212 int *option0,
int *option1) {
216 const char *delim =
",";
224 if (input == NULL || option0 == NULL ||
225 (option1 == NULL && type == SCALE_FACTOR))
228 input_string = malloc(strlen(input));
229 memcpy(input_string, input, strlen(input));
231 token = strtok(input_string, delim);
232 for (i = 0; i < num_layers; ++i) {
234 res = extract_option(type, token, option0 + i, option1 + i);
236 token = strtok(NULL, delim);
248 static void parse_command_line(
int argc,
const char **argv_,
256 char string_options[1024] = { 0 };
261 app_input->layering_mode = 0;
262 app_input->output_obu = 0;
267 argv = argv_dup(argc - 1, argv_ + 1);
268 for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) {
271 if (arg_match(&arg, &outputfile, argi)) {
272 app_input->output_filename = arg.val;
273 }
else if (arg_match(&arg, &width_arg, argi)) {
274 enc_cfg->
g_w = arg_parse_uint(&arg);
275 }
else if (arg_match(&arg, &height_arg, argi)) {
276 enc_cfg->
g_h = arg_parse_uint(&arg);
277 }
else if (arg_match(&arg, &timebase_arg, argi)) {
278 enc_cfg->
g_timebase = arg_parse_rational(&arg);
279 }
else if (arg_match(&arg, &bitrate_arg, argi)) {
281 }
else if (arg_match(&arg, &spatial_layers_arg, argi)) {
283 }
else if (arg_match(&arg, &temporal_layers_arg, argi)) {
285 }
else if (arg_match(&arg, &speed_arg, argi)) {
286 app_input->speed = arg_parse_uint(&arg);
287 if (app_input->speed > 9) {
288 aom_tools_warn(
"Mapping speed %d to speed 9.\n", app_input->speed);
290 }
else if (arg_match(&arg, &aqmode_arg, argi)) {
291 app_input->aq_mode = arg_parse_uint(&arg);
292 }
else if (arg_match(&arg, &threads_arg, argi)) {
293 enc_cfg->
g_threads = arg_parse_uint(&arg);
294 }
else if (arg_match(&arg, &layering_mode_arg, argi)) {
295 app_input->layering_mode = arg_parse_int(&arg);
296 }
else if (arg_match(&arg, &kf_dist_arg, argi)) {
299 }
else if (arg_match(&arg, &scale_factors_arg, argi)) {
300 parse_layer_options_from_string(svc_params, SCALE_FACTOR, arg.val,
303 }
else if (arg_match(&arg, &min_q_arg, argi)) {
305 }
else if (arg_match(&arg, &max_q_arg, argi)) {
307 #if CONFIG_AV1_HIGHBITDEPTH
308 }
else if (arg_match(&arg, &bitdepth_arg, argi)) {
309 enc_cfg->
g_bit_depth = arg_parse_enum_or_int(&arg);
324 die(
"Error: Invalid bit depth selected (%d)\n", enc_cfg->
g_bit_depth);
328 }
else if (arg_match(&arg, &dropframe_thresh_arg, argi)) {
330 }
else if (arg_match(&arg, &error_resilient_arg, argi)) {
333 die(
"Invalid value for error resilient (0, 1): %d.",
335 }
else if (arg_match(&arg, &output_obu_arg, argi)) {
336 app_input->output_obu = arg_parse_uint(&arg);
337 if (app_input->output_obu != 0 && app_input->output_obu != 1)
338 die(
"Invalid value for obu output flag (0, 1): %d.",
339 app_input->output_obu);
346 for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) {
348 if (arg_match(&arg, &bitrates_arg, argi)) {
349 parse_layer_options_from_string(svc_params, BITRATE, arg.val,
357 if (strlen(string_options) > 0)
358 strncpy(app_input->options, string_options, OPTION_BUFFER_SIZE);
361 for (argi = argv; *argi; ++argi)
362 if (argi[0][0] ==
'-' && strlen(argi[0]) > 1)
363 die(
"Error: Unrecognized option %s\n", *argi);
365 if (argv[0] == NULL) {
369 app_input->input_ctx.filename = argv[0];
372 open_input_file(&app_input->input_ctx, 0);
373 if (app_input->input_ctx.file_type == FILE_TYPE_Y4M) {
374 enc_cfg->
g_w = app_input->input_ctx.width;
375 enc_cfg->
g_h = app_input->input_ctx.height;
378 if (enc_cfg->
g_w < 16 || enc_cfg->
g_w % 2 || enc_cfg->
g_h < 16 ||
380 die(
"Invalid resolution: %d x %d\n", enc_cfg->
g_w, enc_cfg->
g_h);
385 "width %u, height: %u\n"
386 "num: %d, den: %d, bitrate: %u\n"
394 static unsigned int mode_to_num_temporal_layers[11] = { 1, 2, 3, 3, 2, 1,
396 static unsigned int mode_to_num_spatial_layers[11] = { 1, 1, 1, 1, 1, 2,
400 struct RateControlMetrics {
417 double avg_st_encoding_bitrate;
419 double variance_st_encoding_bitrate;
438 static int read_frame(
struct AvxInputContext *input_ctx,
aom_image_t *img) {
439 FILE *f = input_ctx->file;
440 y4m_input *y4m = &input_ctx->y4m;
443 if (input_ctx->file_type == FILE_TYPE_Y4M) {
444 if (y4m_input_fetch_frame(y4m, f, img) < 1)
return 0;
446 shortread = read_yuv_frame(input_ctx, img);
452 static void close_input_file(
struct AvxInputContext *input) {
454 if (input->file_type == FILE_TYPE_Y4M) y4m_input_close(&input->y4m);
463 static void set_rate_control_metrics(
struct RateControlMetrics *rc,
465 unsigned int ss_number_layers,
466 unsigned int ts_number_layers) {
468 ts_rate_decimator[0] = 1;
469 if (ts_number_layers == 2) {
470 ts_rate_decimator[0] = 2;
471 ts_rate_decimator[1] = 1;
473 if (ts_number_layers == 3) {
474 ts_rate_decimator[0] = 4;
475 ts_rate_decimator[1] = 2;
476 ts_rate_decimator[2] = 1;
480 for (
unsigned int sl = 0; sl < ss_number_layers; ++sl) {
481 unsigned int i = sl * ts_number_layers;
482 rc->layer_framerate[0] = framerate / ts_rate_decimator[0];
484 1000.0 * rc->layer_target_bitrate[i] / rc->layer_framerate[0];
485 for (
unsigned int tl = 0; tl < ts_number_layers; ++tl) {
486 i = sl * ts_number_layers + tl;
488 rc->layer_framerate[tl] = framerate / ts_rate_decimator[tl];
491 (rc->layer_target_bitrate[i] - rc->layer_target_bitrate[i - 1]) /
492 (rc->layer_framerate[tl] - rc->layer_framerate[tl - 1]);
494 rc->layer_input_frames[tl] = 0;
495 rc->layer_enc_frames[tl] = 0;
496 rc->layer_encoding_bitrate[i] = 0.0;
497 rc->layer_avg_frame_size[i] = 0.0;
498 rc->layer_avg_rate_mismatch[i] = 0.0;
501 rc->window_count = 0;
502 rc->window_size = 15;
503 rc->avg_st_encoding_bitrate = 0.0;
504 rc->variance_st_encoding_bitrate = 0.0;
507 static void printout_rate_control_summary(
struct RateControlMetrics *rc,
509 unsigned int ss_number_layers,
510 unsigned int ts_number_layers) {
511 int tot_num_frames = 0;
512 double perc_fluctuation = 0.0;
513 printf(
"Total number of processed frames: %d\n\n", frame_cnt - 1);
514 printf(
"Rate control layer stats for %u layer(s):\n\n", ts_number_layers);
515 for (
unsigned int sl = 0; sl < ss_number_layers; ++sl) {
517 for (
unsigned int tl = 0; tl < ts_number_layers; ++tl) {
518 unsigned int i = sl * ts_number_layers + tl;
519 const int num_dropped =
520 tl > 0 ? rc->layer_input_frames[tl] - rc->layer_enc_frames[tl]
521 : rc->layer_input_frames[tl] - rc->layer_enc_frames[tl] - 1;
522 tot_num_frames += rc->layer_input_frames[tl];
523 rc->layer_encoding_bitrate[i] = 0.001 * rc->layer_framerate[tl] *
524 rc->layer_encoding_bitrate[i] /
526 rc->layer_avg_frame_size[i] =
527 rc->layer_avg_frame_size[i] / rc->layer_enc_frames[tl];
528 rc->layer_avg_rate_mismatch[i] =
529 100.0 * rc->layer_avg_rate_mismatch[i] / rc->layer_enc_frames[tl];
530 printf(
"For layer#: %u %u \n", sl, tl);
531 printf(
"Bitrate (target vs actual): %d %f\n", rc->layer_target_bitrate[i],
532 rc->layer_encoding_bitrate[i]);
533 printf(
"Average frame size (target vs actual): %f %f\n", rc->layer_pfb[i],
534 rc->layer_avg_frame_size[i]);
535 printf(
"Average rate_mismatch: %f\n", rc->layer_avg_rate_mismatch[i]);
537 "Number of input frames, encoded (non-key) frames, "
538 "and perc dropped frames: %d %d %f\n",
539 rc->layer_input_frames[tl], rc->layer_enc_frames[tl],
540 100.0 * num_dropped / rc->layer_input_frames[tl]);
544 rc->avg_st_encoding_bitrate = rc->avg_st_encoding_bitrate / rc->window_count;
545 rc->variance_st_encoding_bitrate =
546 rc->variance_st_encoding_bitrate / rc->window_count -
547 (rc->avg_st_encoding_bitrate * rc->avg_st_encoding_bitrate);
548 perc_fluctuation = 100.0 * sqrt(rc->variance_st_encoding_bitrate) /
549 rc->avg_st_encoding_bitrate;
550 printf(
"Short-time stats, for window of %d frames:\n", rc->window_size);
551 printf(
"Average, rms-variance, and percent-fluct: %f %f %f\n",
552 rc->avg_st_encoding_bitrate, sqrt(rc->variance_st_encoding_bitrate),
554 if (frame_cnt - 1 != tot_num_frames)
555 die(
"Error: Number of input frames not equal to output!\n");
559 static void set_layer_pattern(
563 int spatial_layer_id,
int is_key_frame,
int ksvc_mode,
int speed) {
565 int enable_longterm_temporal_ref = 1;
566 int shift = (layering_mode == 8) ? 2 : 0;
567 *use_svc_control = 1;
570 int base_count = superframe_cnt >> 2;
577 for (i = 0; i < INTER_REFS_PER_FRAME; i++) ref_frame_config->
ref_idx[i] = i;
578 for (i = 0; i < INTER_REFS_PER_FRAME; i++) ref_frame_config->
reference[i] = 0;
579 for (i = 0; i < REF_FRAMES; i++) ref_frame_config->
refresh[i] = 0;
586 switch (layering_mode) {
590 ref_frame_config->
refresh[0] = 1;
591 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
597 if (superframe_cnt % 2 == 0) {
600 ref_frame_config->
refresh[0] = 1;
601 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
605 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
613 if (superframe_cnt % 4 == 0) {
617 ref_frame_config->
refresh[0] = 1;
618 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
619 }
else if ((superframe_cnt - 1) % 4 == 0) {
622 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
623 }
else if ((superframe_cnt - 2) % 4 == 0) {
626 ref_frame_config->
refresh[1] = 1;
627 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
628 }
else if ((superframe_cnt - 3) % 4 == 0) {
633 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 1;
634 ref_frame_config->
ref_idx[SVC_LAST2_FRAME] = 0;
635 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
646 ref_frame_config->
ref_idx[SVC_GOLDEN_FRAME] = 3;
649 if (base_count > 0) {
650 lag_index = 5 + (base_count % 3);
651 if (superframe_cnt % 4 != 0) lag_index = 5 + ((base_count + 1) % 3);
654 ref_frame_config->
ref_idx[SVC_ALTREF_FRAME] = lag_index;
655 if (superframe_cnt % 4 == 0) {
659 ref_frame_config->
refresh[0] = 1;
660 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
662 if (base_count % 10 == 0) ref_frame_config->
refresh[3] = 1;
664 ref_frame_config->
refresh[lag_index] = 1;
665 }
else if ((superframe_cnt - 1) % 4 == 0) {
668 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
669 }
else if ((superframe_cnt - 2) % 4 == 0) {
672 ref_frame_config->
refresh[1] = 1;
673 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
674 }
else if ((superframe_cnt - 3) % 4 == 0) {
679 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 1;
680 ref_frame_config->
ref_idx[SVC_LAST2_FRAME] = 0;
681 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
684 ref_frame_config->
reference[SVC_GOLDEN_FRAME] = 1;
685 ref_frame_config->
reference[SVC_ALTREF_FRAME] = 1;
695 if (superframe_cnt % 4 == 0) {
699 ref_frame_config->
refresh[0] = 1;
700 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
701 }
else if ((superframe_cnt - 1) % 4 == 0) {
704 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
705 }
else if ((superframe_cnt - 2) % 4 == 0) {
708 ref_frame_config->
refresh[3] = 1;
709 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
710 }
else if ((superframe_cnt - 3) % 4 == 0) {
713 ref_frame_config->
reference[SVC_GOLDEN_FRAME] = 1;
721 ref_frame_config->
refresh[0] = 1;
722 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
726 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 1;
727 ref_frame_config->
ref_idx[SVC_GOLDEN_FRAME] = 0;
728 ref_frame_config->
refresh[1] = 1;
729 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
730 ref_frame_config->
reference[SVC_GOLDEN_FRAME] = 1;
742 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
743 ref_frame_config->
ref_idx[i] = 0;
744 ref_frame_config->
refresh[0] = 1;
745 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
750 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
751 ref_frame_config->
ref_idx[i] = 0;
752 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 1;
753 ref_frame_config->
refresh[1] = 1;
754 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
755 ref_frame_config->
reference[SVC_GOLDEN_FRAME] = 1;
760 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
761 ref_frame_config->
ref_idx[i] = 1;
762 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 2;
763 ref_frame_config->
refresh[2] = 1;
764 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
765 ref_frame_config->
reference[SVC_GOLDEN_FRAME] = 1;
768 if (enable_longterm_temporal_ref) {
769 ref_frame_config->
ref_idx[SVC_ALTREF_FRAME] = REF_FRAMES - 1;
770 ref_frame_config->
reference[SVC_ALTREF_FRAME] = 1;
771 if (base_count % 10 == 0)
772 ref_frame_config->
refresh[REF_FRAMES - 1] = 1;
778 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
779 if (superframe_cnt % 4 == 0) {
785 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
786 ref_frame_config->
ref_idx[i] = 0;
787 ref_frame_config->
refresh[0] = 1;
790 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
791 ref_frame_config->
ref_idx[i] = 0;
792 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 1;
793 ref_frame_config->
refresh[1] = 1;
795 }
else if ((superframe_cnt - 1) % 4 == 0) {
799 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
800 ref_frame_config->
ref_idx[i] = 0;
801 ref_frame_config->
ref_idx[SVC_GOLDEN_FRAME] = 3;
802 ref_frame_config->
refresh[3] = 1;
807 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
808 ref_frame_config->
ref_idx[i] = 3;
809 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 1;
811 }
else if ((superframe_cnt - 2) % 4 == 0) {
818 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
819 ref_frame_config->
ref_idx[i] = 0;
820 ref_frame_config->
ref_idx[SVC_GOLDEN_FRAME] = 5 - shift;
821 ref_frame_config->
refresh[5 - shift] = 1;
826 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
827 ref_frame_config->
ref_idx[i] = 5 - shift;
828 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 1;
829 ref_frame_config->
ref_idx[SVC_LAST3_FRAME] = 6 - shift;
830 ref_frame_config->
refresh[6 - shift] = 1;
832 }
else if ((superframe_cnt - 3) % 4 == 0) {
839 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
840 ref_frame_config->
ref_idx[i] = 0;
841 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 5 - shift;
842 ref_frame_config->
ref_idx[SVC_GOLDEN_FRAME] = 3;
843 ref_frame_config->
refresh[3] = 1;
847 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
848 ref_frame_config->
ref_idx[i] = 0;
849 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 6 - shift;
850 ref_frame_config->
ref_idx[SVC_GOLDEN_FRAME] = 3;
867 ref_frame_config->
reference[SVC_LAST_FRAME] = 1;
868 if (superframe_cnt % 4 == 0) {
874 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
875 ref_frame_config->
ref_idx[i] = 0;
876 ref_frame_config->
refresh[0] = 1;
881 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
882 ref_frame_config->
ref_idx[i] = 0;
883 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 1;
884 ref_frame_config->
refresh[1] = 1;
889 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
890 ref_frame_config->
ref_idx[i] = 1;
891 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 2;
892 ref_frame_config->
refresh[2] = 1;
894 }
else if ((superframe_cnt - 1) % 4 == 0) {
901 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
902 ref_frame_config->
ref_idx[i] = 0;
903 ref_frame_config->
ref_idx[SVC_GOLDEN_FRAME] = 3;
904 ref_frame_config->
refresh[3] = 1;
909 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
910 ref_frame_config->
ref_idx[i] = 3;
911 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 1;
912 ref_frame_config->
ref_idx[SVC_LAST2_FRAME] = 4;
913 ref_frame_config->
refresh[4] = 1;
918 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
919 ref_frame_config->
ref_idx[i] = 4;
920 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 2;
922 }
else if ((superframe_cnt - 2) % 4 == 0) {
929 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
930 ref_frame_config->
ref_idx[i] = 0;
931 ref_frame_config->
ref_idx[SVC_GOLDEN_FRAME] = 5 - shift;
932 ref_frame_config->
refresh[5 - shift] = 1;
937 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
938 ref_frame_config->
ref_idx[i] = 5 - shift;
939 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 1;
940 ref_frame_config->
ref_idx[SVC_LAST3_FRAME] = 6 - shift;
941 ref_frame_config->
refresh[6 - shift] = 1;
946 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
947 ref_frame_config->
ref_idx[i] = 6 - shift;
948 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 2;
949 ref_frame_config->
ref_idx[SVC_LAST3_FRAME] = 7 - shift;
950 ref_frame_config->
refresh[7 - shift] = 1;
952 }
else if ((superframe_cnt - 3) % 4 == 0) {
959 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
960 ref_frame_config->
ref_idx[i] = 0;
961 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 5 - shift;
962 ref_frame_config->
ref_idx[SVC_GOLDEN_FRAME] = 3;
963 ref_frame_config->
refresh[3] = 1;
967 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
968 ref_frame_config->
ref_idx[i] = 0;
969 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 6 - shift;
970 ref_frame_config->
ref_idx[SVC_GOLDEN_FRAME] = 3;
971 ref_frame_config->
ref_idx[SVC_LAST2_FRAME] = 4;
972 ref_frame_config->
refresh[4] = 1;
976 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
977 ref_frame_config->
ref_idx[i] = 0;
978 ref_frame_config->
ref_idx[SVC_LAST_FRAME] = 7 - shift;
979 ref_frame_config->
ref_idx[SVC_GOLDEN_FRAME] = 4;
984 ref_frame_config->
reference[SVC_GOLDEN_FRAME] = 1;
988 if (!is_key_frame) ref_frame_config->
reference[SVC_GOLDEN_FRAME] = 0;
993 ref_frame_config->
reference[SVC_LAST_FRAME] = 0;
1001 layering_mode == 8) {
1002 ref_frame_config->
ref_idx[SVC_ALTREF_FRAME] = REF_FRAMES - 1;
1003 ref_frame_config->
reference[SVC_ALTREF_FRAME] = 1;
1005 ref_frame_config->
refresh[REF_FRAMES - 1] = 1;
1008 default: assert(0); die(
"Error: Unsupported temporal layering mode!\n");
1012 #if CONFIG_AV1_DECODER
1014 const int frames_out,
int *mismatch_seen) {
1017 if (*mismatch_seen)
return;
1023 #if CONFIG_AV1_HIGHBITDEPTH
1029 enc_img.
d_w, enc_img.
d_h, 16);
1030 aom_img_truncate_16_to_8(&enc_hbd_img, &enc_img);
1031 enc_img = enc_hbd_img;
1036 dec_img.
d_w, dec_img.
d_h, 16);
1037 aom_img_truncate_16_to_8(&dec_hbd_img, &dec_img);
1038 dec_img = dec_hbd_img;
1043 if (!aom_compare_img(&enc_img, &dec_img)) {
1044 int y[4], u[4], v[4];
1045 #if CONFIG_AV1_HIGHBITDEPTH
1047 aom_find_mismatch_high(&enc_img, &dec_img, y, u, v);
1049 aom_find_mismatch(&enc_img, &dec_img, y, u, v);
1052 aom_find_mismatch(&enc_img, &dec_img, y, u, v);
1056 "Encode/decode mismatch on frame %d at"
1057 " Y[%d, %d] {%d/%d},"
1058 " U[%d, %d] {%d/%d},"
1059 " V[%d, %d] {%d/%d}",
1060 frames_out, y[0], y[1], y[2], y[3], u[0], u[1], u[2], u[3], v[0], v[1],
1062 *mismatch_seen = frames_out;
1070 int main(
int argc,
const char **argv) {
1074 AvxVideoWriter *total_layer_file = NULL;
1075 FILE *total_layer_obu_file = NULL;
1084 int frame_duration = 1;
1090 #if CONFIG_INTERNAL_STATS
1091 FILE *stats_file = fopen(
"opsnr.stt",
"a");
1092 if (stats_file == NULL) {
1093 die(
"Cannot open opsnr.stt\n");
1096 #if CONFIG_AV1_DECODER
1097 int mismatch_seen = 0;
1101 struct RateControlMetrics rc;
1102 int64_t cx_time = 0;
1103 int64_t cx_time_sl[3];
1104 double sum_bitrate = 0.0;
1105 double sum_bitrate2 = 0.0;
1106 double framerate = 30.0;
1107 int use_svc_control = 1;
1108 int set_err_resil_frame = 0;
1109 zero(rc.layer_target_bitrate);
1111 memset(&app_input, 0,
sizeof(AppInput));
1112 memset(&svc_params, 0,
sizeof(svc_params));
1116 const int test_dynamic_scaling_single_layer = 0;
1119 app_input.input_ctx.framerate.numerator = 30;
1120 app_input.input_ctx.framerate.denominator = 1;
1121 app_input.input_ctx.only_i420 = 1;
1122 app_input.input_ctx.bit_depth = 0;
1123 app_input.speed = 7;
1124 exec_name = argv[0];
1148 parse_command_line(argc, argv, &app_input, &svc_params, &cfg);
1153 unsigned int width = cfg.
g_w;
1154 unsigned int height = cfg.
g_h;
1156 if (app_input.layering_mode >= 0) {
1157 if (ts_number_layers !=
1158 mode_to_num_temporal_layers[app_input.layering_mode] ||
1160 mode_to_num_spatial_layers[app_input.layering_mode]) {
1161 die(
"Number of layers doesn't match layering mode.");
1166 if (app_input.input_ctx.file_type != FILE_TYPE_Y4M) {
1168 die(
"Failed to allocate image (%dx%d)", width, height);
1177 unsigned int total_rate = 0;
1178 for (i = 0; i < ss_number_layers; i++) {
1184 die(
"Incorrect total target bitrate");
1188 if (ts_number_layers == 2) {
1191 }
else if (ts_number_layers == 3) {
1197 if (app_input.input_ctx.file_type == FILE_TYPE_Y4M) {
1199 cfg.
g_w = app_input.input_ctx.width;
1200 cfg.
g_h = app_input.input_ctx.height;
1202 cfg.
g_timebase.
num = app_input.input_ctx.framerate.denominator;
1203 cfg.
g_timebase.
den = app_input.input_ctx.framerate.numerator;
1206 set_rate_control_metrics(&rc, framerate, ss_number_layers, ts_number_layers);
1209 info.codec_fourcc = get_fourcc_by_aom_encoder(encoder);
1210 info.frame_width = cfg.
g_w;
1211 info.frame_height = cfg.
g_h;
1215 for (
unsigned int sl = 0; sl < ss_number_layers; ++sl) {
1216 for (
unsigned tl = 0; tl < ts_number_layers; ++tl) {
1217 i = sl * ts_number_layers + tl;
1218 char file_name[PATH_MAX];
1219 snprintf(file_name,
sizeof(file_name),
"%s_%u.av1",
1220 app_input.output_filename, i);
1221 if (app_input.output_obu) {
1222 obu_files[i] = fopen(file_name,
"wb");
1223 if (!obu_files[i]) die(
"Failed to open %s for writing", file_name);
1225 outfile[i] = aom_video_writer_open(file_name, kContainerIVF, &info);
1226 if (!outfile[i]) die(
"Failed to open %s for writing", file_name);
1230 if (app_input.output_obu) {
1231 total_layer_obu_file = fopen(app_input.output_filename,
"wb");
1232 if (!total_layer_obu_file)
1233 die(
"Failed to open %s for writing", app_input.output_filename);
1236 aom_video_writer_open(app_input.output_filename, kContainerIVF, &info);
1237 if (!total_layer_file)
1238 die(
"Failed to open %s for writing", app_input.output_filename);
1244 die(
"Failed to initialize encoder");
1246 #if CONFIG_AV1_DECODER
1248 die(
"Failed to initialize decoder");
1274 for (i = 0; i < ss_number_layers * ts_number_layers; ++i) {
1278 for (i = 0; i < ss_number_layers; ++i) {
1282 if (ss_number_layers == 2) {
1285 }
else if (ss_number_layers == 3) {
1298 const int max_intra_size_pct = 300;
1300 max_intra_size_pct);
1303 for (
unsigned int slx = 0; slx < ss_number_layers; slx++) cx_time_sl[slx] = 0;
1305 while (frame_avail || got_data) {
1306 struct aom_usec_timer timer;
1307 frame_avail = read_frame(&(app_input.input_ctx), &raw);
1309 for (
unsigned int slx = 0; slx < ss_number_layers; slx++) {
1314 int is_key_frame = (frame_cnt % cfg.
kf_max_dist) == 0;
1316 if (app_input.layering_mode >= 0) {
1319 set_layer_pattern(app_input.layering_mode, frame_cnt, &layer_id,
1320 &ref_frame_config, &ref_frame_comp_pred,
1321 &use_svc_control, slx, is_key_frame,
1322 (app_input.layering_mode == 10), app_input.speed);
1324 if (use_svc_control) {
1328 &ref_frame_comp_pred);
1336 if (ts_number_layers == 2) {
1338 }
else if (ts_number_layers == 3) {
1339 if (frame_cnt % 2 != 0)
1341 else if ((frame_cnt > 1) && ((frame_cnt - 2) % 4 == 0))
1347 if (set_err_resil_frame) {
1350 int err_resil_mode =
1357 if (frame_avail && slx == 0) ++rc.layer_input_frames[layer];
1359 if (test_dynamic_scaling_single_layer) {
1360 if (frame_cnt >= 200 && frame_cnt <= 400) {
1372 aom_usec_timer_start(&timer);
1374 die_codec(&codec,
"Failed to encode frame");
1375 aom_usec_timer_mark(&timer);
1376 cx_time += aom_usec_timer_elapsed(&timer);
1377 cx_time_sl[slx] += aom_usec_timer_elapsed(&timer);
1382 switch (pkt->
kind) {
1385 sl < ss_number_layers; ++sl) {
1387 tl < ts_number_layers; ++tl) {
1388 unsigned int j = sl * ts_number_layers + tl;
1389 if (app_input.output_obu) {
1393 aom_video_writer_write_frame(outfile[j], pkt->
data.
frame.buf,
1397 rc.layer_encoding_bitrate[j] += 8.0 * pkt->
data.
frame.sz;
1401 if (app_input.output_obu) {
1403 total_layer_obu_file);
1405 aom_video_writer_write_frame(total_layer_file,
1413 rc.layer_avg_frame_size[j] += 8.0 * pkt->
data.
frame.sz;
1414 rc.layer_avg_rate_mismatch[j] +=
1415 fabs(8.0 * pkt->
data.
frame.sz - rc.layer_pfb[j]) /
1424 if (frame_cnt > rc.window_size && slx == ss_number_layers - 1) {
1425 sum_bitrate += 0.001 * 8.0 * pkt->
data.
frame.sz * framerate;
1426 rc.window_size = (rc.window_size <= 0) ? 1 : rc.window_size;
1427 if (frame_cnt % rc.window_size == 0) {
1428 rc.window_count += 1;
1429 rc.avg_st_encoding_bitrate += sum_bitrate / rc.window_size;
1430 rc.variance_st_encoding_bitrate +=
1431 (sum_bitrate / rc.window_size) *
1432 (sum_bitrate / rc.window_size);
1437 if (frame_cnt > rc.window_size + rc.window_size / 2 &&
1438 slx == ss_number_layers - 1) {
1439 sum_bitrate2 += 0.001 * 8.0 * pkt->
data.
frame.sz * framerate;
1440 if (frame_cnt > 2 * rc.window_size &&
1441 frame_cnt % rc.window_size == 0) {
1442 rc.window_count += 1;
1443 rc.avg_st_encoding_bitrate += sum_bitrate2 / rc.window_size;
1444 rc.variance_st_encoding_bitrate +=
1445 (sum_bitrate2 / rc.window_size) *
1446 (sum_bitrate2 / rc.window_size);
1451 #if CONFIG_AV1_DECODER
1453 (
unsigned int)pkt->
data.
frame.sz, NULL))
1454 die_codec(&decoder,
"Failed to decode frame.");
1461 #if CONFIG_AV1_DECODER
1464 if ((ss_number_layers > 1 || ts_number_layers > 1) &&
1467 test_decode(&codec, &decoder, frame_cnt, &mismatch_seen);
1472 pts += frame_duration;
1475 close_input_file(&(app_input.input_ctx));
1476 printout_rate_control_summary(&rc, frame_cnt, ss_number_layers,
1479 printf(
"Frame cnt and encoding time/FPS stats for encoding: %d %f %f\n",
1480 frame_cnt, 1000 * (
float)cx_time / (
double)(frame_cnt * 1000000),
1481 1000000 * (
double)frame_cnt / (
double)cx_time);
1483 if (ss_number_layers > 1) {
1484 printf(
"Per spatial layer: \n");
1485 for (
unsigned int slx = 0; slx < ss_number_layers; slx++)
1486 printf(
"Frame cnt and encoding time/FPS stats for encoding: %d %f %f\n",
1487 frame_cnt, (
float)cx_time_sl[slx] / (
double)(frame_cnt * 1000),
1488 1000000 * (
double)frame_cnt / (
double)cx_time_sl[slx]);
1493 #if CONFIG_INTERNAL_STATS
1494 if (mismatch_seen) {
1495 fprintf(stats_file,
"First mismatch occurred in frame %d\n", mismatch_seen);
1497 fprintf(stats_file,
"No mismatch detected in recon buffers\n");
1503 for (i = 0; i < ss_number_layers * ts_number_layers; ++i)
1504 aom_video_writer_close(outfile[i]);
1505 aom_video_writer_close(total_layer_file);
1507 if (app_input.input_ctx.file_type != FILE_TYPE_Y4M) {
1510 return EXIT_SUCCESS;
Describes the encoder algorithm interface to applications.
enum aom_chroma_sample_position aom_chroma_sample_position_t
List of chroma sample positions.
aom_image_t * aom_img_alloc(aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w, unsigned int d_h, unsigned int align)
Open a descriptor, allocating storage for the underlying image.
#define AOM_IMG_FMT_HIGHBITDEPTH
Definition: aom_image.h:38
@ AOM_IMG_FMT_I420
Definition: aom_image.h:45
void aom_img_free(aom_image_t *img)
Close an image descriptor.
Provides definitions for using AOM or AV1 encoder algorithm within the aom Codec Interface.
Declares top-level encoder structures and functions.
#define AOM_MAX_LAYERS
Definition: aomcx.h:1504
aom_codec_iface_t * aom_codec_av1_cx(void)
The interface to the AV1 encoder.
#define AOM_MAX_TS_LAYERS
Definition: aomcx.h:1506
@ AV1E_SET_ROW_MT
Codec control function to enable the row based multi-threading of the encoder, unsigned int parameter...
Definition: aomcx.h:359
@ AV1E_SET_ENABLE_TPL_MODEL
Codec control function to enable RDO modulated by frame temporal dependency, unsigned int parameter.
Definition: aomcx.h:406
@ AV1E_SET_AQ_MODE
Codec control function to set adaptive quantization mode, unsigned int parameter.
Definition: aomcx.h:466
@ AV1E_SET_SVC_LAYER_ID
Codec control function to set the layer id, aom_svc_layer_id_t* parameter.
Definition: aomcx.h:1270
@ AV1E_SET_SVC_REF_FRAME_CONFIG
Codec control function to set reference frame config: the ref_idx and the refresh flags for each buff...
Definition: aomcx.h:1281
@ AV1E_SET_CDF_UPDATE_MODE
Codec control function to set CDF update mode, unsigned int parameter.
Definition: aomcx.h:504
@ AV1E_SET_MV_COST_UPD_FREQ
Control to set frequency of the cost updates for motion vectors, unsigned int parameter.
Definition: aomcx.h:1248
@ AV1E_SET_SVC_REF_FRAME_COMP_PRED
Codec control function to set reference frame compound prediction. aom_svc_ref_frame_comp_pred_t* par...
Definition: aomcx.h:1383
@ AV1E_SET_ENABLE_WARPED_MOTION
Codec control function to turn on / off warped motion usage at sequence level, int parameter.
Definition: aomcx.h:1032
@ AV1E_SET_COEFF_COST_UPD_FREQ
Control to set frequency of the cost updates for coefficients, unsigned int parameter.
Definition: aomcx.h:1228
@ AV1E_SET_ENABLE_CDEF
Codec control function to encode with CDEF, unsigned int parameter.
Definition: aomcx.h:664
@ AV1E_SET_DV_COST_UPD_FREQ
Control to set frequency of the cost updates for intrabc motion vectors, unsigned int parameter.
Definition: aomcx.h:1352
@ AV1E_SET_SVC_PARAMS
Codec control function to set SVC paramaeters, aom_svc_params_t* parameter.
Definition: aomcx.h:1275
@ AOME_SET_MAX_INTRA_BITRATE_PCT
Codec control function to set max data rate for intra frames, unsigned int parameter.
Definition: aomcx.h:304
@ AV1E_SET_ERROR_RESILIENT_MODE
Codec control function to enable error_resilient_mode, int parameter.
Definition: aomcx.h:440
@ AV1E_SET_ENABLE_OBMC
Codec control function to predict with OBMC mode, unsigned int parameter.
Definition: aomcx.h:691
@ AV1E_SET_LOOPFILTER_CONTROL
Codec control to control loop filter.
Definition: aomcx.h:1398
@ AOME_SET_SCALEMODE
Codec control function to set encoder scaling mode, aom_scaling_mode_t* parameter.
Definition: aomcx.h:196
@ AV1E_SET_TILE_COLUMNS
Codec control function to set number of tile columns. unsigned int parameter.
Definition: aomcx.h:378
@ AV1E_SET_ENABLE_ORDER_HINT
Codec control function to turn on / off frame order hint (int parameter). Affects: joint compound mod...
Definition: aomcx.h:859
@ AV1E_SET_DELTAQ_MODE
Codec control function to set the delta q mode, unsigned int parameter.
Definition: aomcx.h:1125
@ AV1E_SET_ENABLE_GLOBAL_MOTION
Codec control function to turn on / off global motion usage for a sequence, int parameter.
Definition: aomcx.h:1022
@ AOME_SET_CPUUSED
Codec control function to set encoder internal speed settings, int parameter.
Definition: aomcx.h:218
@ AV1E_SET_GF_CBR_BOOST_PCT
Boost percentage for Golden Frame in CBR mode, unsigned int parameter.
Definition: aomcx.h:337
@ AV1E_SET_MODE_COST_UPD_FREQ
Control to set frequency of the cost updates for mode, unsigned int parameter.
Definition: aomcx.h:1238
@ AV1_GET_NEW_FRAME_IMAGE
Codec control function to get a pointer to the new frame.
Definition: aom.h:70
const char * aom_codec_iface_name(aom_codec_iface_t *iface)
Return the name for a given interface.
aom_codec_err_t aom_codec_control(aom_codec_ctx_t *ctx, int ctrl_id,...)
Algorithm Control.
const struct aom_codec_iface aom_codec_iface_t
Codec interface structure.
Definition: aom_codec.h:254
const char * aom_codec_err_to_string(aom_codec_err_t err)
Convert error number to printable string.
aom_codec_err_t aom_codec_destroy(aom_codec_ctx_t *ctx)
Destroy a codec instance.
aom_codec_err_t
Algorithm return codes.
Definition: aom_codec.h:155
#define AOM_CODEC_CONTROL_TYPECHECKED(ctx, id, data)
aom_codec_control wrapper macro (adds type-checking, less flexible)
Definition: aom_codec.h:521
const void * aom_codec_iter_t
Iterator.
Definition: aom_codec.h:288
#define AOM_FRAME_IS_KEY
Definition: aom_codec.h:271
@ AOM_BITS_12
Definition: aom_codec.h:321
@ AOM_BITS_8
Definition: aom_codec.h:319
@ AOM_BITS_10
Definition: aom_codec.h:320
@ AOM_CODEC_INVALID_PARAM
An application-supplied parameter is not valid.
Definition: aom_codec.h:200
@ AOM_CODEC_MEM_ERROR
Memory operation failed.
Definition: aom_codec.h:163
@ AOM_CODEC_OK
Operation completed without error.
Definition: aom_codec.h:157
aom_codec_err_t aom_codec_decode(aom_codec_ctx_t *ctx, const uint8_t *data, size_t data_sz, void *user_priv)
Decode data.
#define aom_codec_dec_init(ctx, iface, cfg, flags)
Convenience macro for aom_codec_dec_init_ver()
Definition: aom_decoder.h:129
aom_codec_err_t aom_codec_encode(aom_codec_ctx_t *ctx, const aom_image_t *img, aom_codec_pts_t pts, unsigned long duration, aom_enc_frame_flags_t flags)
Encode a frame.
#define aom_codec_enc_init(ctx, iface, cfg, flags)
Convenience macro for aom_codec_enc_init_ver()
Definition: aom_encoder.h:950
aom_codec_err_t aom_codec_enc_config_default(aom_codec_iface_t *iface, aom_codec_enc_cfg_t *cfg, unsigned int usage)
Get the default configuration for a usage.
#define AOM_USAGE_REALTIME
usage parameter analogous to AV1 REALTIME mode.
Definition: aom_encoder.h:1023
const aom_codec_cx_pkt_t * aom_codec_get_cx_data(aom_codec_ctx_t *ctx, aom_codec_iter_t *iter)
Encoded data iterator.
@ AOM_CBR
Definition: aom_encoder.h:186
@ AOM_KF_AUTO
Definition: aom_encoder.h:201
@ AOM_CODEC_CX_FRAME_PKT
Definition: aom_encoder.h:109
Codec context structure.
Definition: aom_codec.h:298
aom_codec_err_t err
Definition: aom_codec.h:301
Encoder output packet.
Definition: aom_encoder.h:121
enum aom_codec_cx_pkt_kind kind
Definition: aom_encoder.h:122
union aom_codec_cx_pkt::@1 data
struct aom_codec_cx_pkt::@1::@2 frame
Encoder configuration structure.
Definition: aom_encoder.h:386
unsigned int g_input_bit_depth
Bit-depth of the input frames.
Definition: aom_encoder.h:469
unsigned int rc_dropframe_thresh
Temporal resampling configuration, if supported by the codec.
Definition: aom_encoder.h:534
struct aom_rational g_timebase
Stream timebase units.
Definition: aom_encoder.h:483
unsigned int g_usage
Algorithm specific "usage" value.
Definition: aom_encoder.h:398
unsigned int rc_buf_sz
Decoder Buffer Size.
Definition: aom_encoder.h:698
unsigned int g_h
Height of the frame.
Definition: aom_encoder.h:434
enum aom_kf_mode kf_mode
Keyframe placement mode.
Definition: aom_encoder.h:761
enum aom_rc_mode rc_end_usage
Rate control algorithm to use.
Definition: aom_encoder.h:617
unsigned int g_threads
Maximum number of threads to use.
Definition: aom_encoder.h:406
unsigned int kf_min_dist
Keyframe minimum interval.
Definition: aom_encoder.h:770
unsigned int g_lag_in_frames
Allow lagged encoding.
Definition: aom_encoder.h:512
unsigned int rc_buf_initial_sz
Decoder Buffer Initial Size.
Definition: aom_encoder.h:707
unsigned int g_profile
Bitstream profile to use.
Definition: aom_encoder.h:416
aom_bit_depth_t g_bit_depth
Bit-depth of the codec.
Definition: aom_encoder.h:461
unsigned int g_w
Width of the frame.
Definition: aom_encoder.h:425
unsigned int rc_undershoot_pct
Rate control adaptation undershoot control.
Definition: aom_encoder.h:674
unsigned int kf_max_dist
Keyframe maximum interval.
Definition: aom_encoder.h:779
aom_codec_er_flags_t g_error_resilient
Enable error resilient modes.
Definition: aom_encoder.h:491
unsigned int rc_max_quantizer
Maximum (Worst Quality) Quantizer.
Definition: aom_encoder.h:661
unsigned int rc_buf_optimal_sz
Decoder Buffer Optimal Size.
Definition: aom_encoder.h:716
unsigned int rc_min_quantizer
Minimum (Best Quality) Quantizer.
Definition: aom_encoder.h:651
unsigned int rc_target_bitrate
Target data rate.
Definition: aom_encoder.h:637
unsigned int rc_resize_mode
Mode for spatial resampling, if supported by the codec.
Definition: aom_encoder.h:543
unsigned int rc_overshoot_pct
Rate control adaptation overshoot control.
Definition: aom_encoder.h:683
Image Descriptor.
Definition: aom_image.h:171
aom_img_fmt_t fmt
Definition: aom_image.h:172
unsigned int d_w
Definition: aom_image.h:186
unsigned int d_h
Definition: aom_image.h:187
int num
Definition: aom_encoder.h:164
int den
Definition: aom_encoder.h:165
aom image scaling mode
Definition: aomcx.h:1468
int temporal_layer_id
Definition: aomcx.h:1511
int spatial_layer_id
Definition: aomcx.h:1510
int max_quantizers[32]
Definition: aomcx.h:1518
int number_spatial_layers
Definition: aomcx.h:1516
int layer_target_bitrate[32]
Definition: aomcx.h:1523
int framerate_factor[8]
Definition: aomcx.h:1525
int min_quantizers[32]
Definition: aomcx.h:1519
int scaling_factor_den[4]
Definition: aomcx.h:1521
int number_temporal_layers
Definition: aomcx.h:1517
int scaling_factor_num[4]
Definition: aomcx.h:1520
int use_comp_pred[3]
Definition: aomcx.h:1542
int reference[7]
Definition: aomcx.h:1532
int refresh[8]
Definition: aomcx.h:1535
int ref_idx[7]
Definition: aomcx.h:1534