Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 4 | * This source code is subject to the terms of the BSD 2 Clause License and |
| 5 | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
| 6 | * was not distributed with this source code in the LICENSE file, you can |
| 7 | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
| 8 | * Media Patent License 1.0 was not distributed with this source code in the |
| 9 | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <stdlib.h> |
| 13 | #include <string.h> |
| 14 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 15 | #include "./aom_config.h" |
| 16 | #include "aom/aom_encoder.h" |
| 17 | #include "aom_ports/aom_once.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 18 | #include "aom_ports/system_state.h" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 19 | #include "aom/internal/aom_codec_internal.h" |
| 20 | #include "./aom_version.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 21 | #include "av1/encoder/encoder.h" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 22 | #include "aom/aomcx.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 23 | #include "av1/encoder/firstpass.h" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 24 | #include "av1/av1_iface_common.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 25 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 26 | struct av1_extracfg { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 27 | int cpu_used; // available cpu percentage in 1/16 |
| 28 | unsigned int enable_auto_alt_ref; |
| 29 | #if CONFIG_EXT_REFS |
| 30 | unsigned int enable_auto_bwd_ref; |
| 31 | #endif // CONFIG_EXT_REFS |
| 32 | unsigned int noise_sensitivity; |
| 33 | unsigned int sharpness; |
| 34 | unsigned int static_thresh; |
| 35 | unsigned int tile_columns; |
| 36 | unsigned int tile_rows; |
Fangwen Fu | 7b9f2b3 | 2017-01-17 14:01:52 -0800 | [diff] [blame] | 37 | #if CONFIG_DEPENDENT_HORZTILES |
| 38 | unsigned int dependent_horz_tiles; |
| 39 | #endif |
Ryan Lei | 9b02b0e | 2017-01-30 15:52:20 -0800 | [diff] [blame] | 40 | #if CONFIG_LOOPFILTERING_ACROSS_TILES |
Ryan Lei | 7386eda | 2016-12-08 21:08:31 -0800 | [diff] [blame] | 41 | unsigned int loop_filter_across_tiles_enabled; |
Ryan Lei | 9b02b0e | 2017-01-30 15:52:20 -0800 | [diff] [blame] | 42 | #endif // CONFIG_LOOPFILTERING_ACROSS_TILES |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 43 | unsigned int arnr_max_frames; |
| 44 | unsigned int arnr_strength; |
| 45 | unsigned int min_gf_interval; |
| 46 | unsigned int max_gf_interval; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 47 | aom_tune_metric tuning; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 48 | unsigned int cq_level; // constrained quality level |
| 49 | unsigned int rc_max_intra_bitrate_pct; |
| 50 | unsigned int rc_max_inter_bitrate_pct; |
| 51 | unsigned int gf_cbr_boost_pct; |
| 52 | unsigned int lossless; |
| 53 | #if CONFIG_AOM_QM |
| 54 | unsigned int enable_qm; |
| 55 | unsigned int qm_min; |
| 56 | unsigned int qm_max; |
| 57 | #endif |
Thomas Davies | af6df17 | 2016-11-09 14:04:18 +0000 | [diff] [blame] | 58 | #if CONFIG_TILE_GROUPS |
| 59 | unsigned int num_tg; |
| 60 | unsigned int mtu_size; |
| 61 | #endif |
Fangwen Fu | 8d164de | 2016-12-14 13:40:54 -0800 | [diff] [blame] | 62 | #if CONFIG_TEMPMV_SIGNALING |
| 63 | unsigned int disable_tempmv; |
| 64 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 65 | unsigned int frame_parallel_decoding_mode; |
| 66 | AQ_MODE aq_mode; |
| 67 | unsigned int frame_periodic_boost; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 68 | aom_bit_depth_t bit_depth; |
| 69 | aom_tune_content content; |
| 70 | aom_color_space_t color_space; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 71 | int color_range; |
| 72 | int render_width; |
| 73 | int render_height; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 74 | aom_superblock_size_t superblock_size; |
Alex Converse | eb780e7 | 2016-12-13 12:46:41 -0800 | [diff] [blame] | 75 | #if CONFIG_ANS && ANS_MAX_SYMBOLS |
| 76 | int ans_window_size_log2; |
| 77 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 78 | }; |
| 79 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 80 | static struct av1_extracfg default_extra_cfg = { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 81 | 0, // cpu_used |
| 82 | 1, // enable_auto_alt_ref |
| 83 | #if CONFIG_EXT_REFS |
| 84 | 0, // enable_auto_bwd_ref |
| 85 | #endif // CONFIG_EXT_REFS |
| 86 | 0, // noise_sensitivity |
| 87 | 0, // sharpness |
| 88 | 0, // static_thresh |
| 89 | #if CONFIG_EXT_TILE |
| 90 | UINT_MAX, // tile_columns |
| 91 | UINT_MAX, // tile_rows |
| 92 | #else |
| 93 | 0, // tile_columns |
| 94 | 0, // tile_rows |
Ryan Lei | 7386eda | 2016-12-08 21:08:31 -0800 | [diff] [blame] | 95 | #endif // CONFIG_EXT_TILE |
Fangwen Fu | 7b9f2b3 | 2017-01-17 14:01:52 -0800 | [diff] [blame] | 96 | #if CONFIG_DEPENDENT_HORZTILES |
| 97 | 0, // Depdendent Horizontal tiles |
| 98 | #endif |
Ryan Lei | 9b02b0e | 2017-01-30 15:52:20 -0800 | [diff] [blame] | 99 | #if CONFIG_LOOPFILTERING_ACROSS_TILES |
Ryan Lei | ad67d79 | 2017-02-02 17:53:19 -0800 | [diff] [blame] | 100 | 1, // loop_filter_across_tiles_enabled |
Ryan Lei | 9b02b0e | 2017-01-30 15:52:20 -0800 | [diff] [blame] | 101 | #endif // CONFIG_LOOPFILTERING_ACROSS_TILES |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 102 | 7, // arnr_max_frames |
| 103 | 5, // arnr_strength |
| 104 | 0, // min_gf_interval; 0 -> default decision |
| 105 | 0, // max_gf_interval; 0 -> default decision |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 106 | AOM_TUNE_PSNR, // tuning |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 107 | 10, // cq_level |
| 108 | 0, // rc_max_intra_bitrate_pct |
| 109 | 0, // rc_max_inter_bitrate_pct |
| 110 | 0, // gf_cbr_boost_pct |
| 111 | 0, // lossless |
| 112 | #if CONFIG_AOM_QM |
| 113 | 0, // enable_qm |
| 114 | DEFAULT_QM_FIRST, // qm_min |
| 115 | DEFAULT_QM_LAST, // qm_max |
| 116 | #endif |
Thomas Davies | af6df17 | 2016-11-09 14:04:18 +0000 | [diff] [blame] | 117 | #if CONFIG_TILE_GROUPS |
| 118 | 1, // max number of tile groups |
| 119 | 0, // mtu_size |
| 120 | #endif |
Fangwen Fu | 8d164de | 2016-12-14 13:40:54 -0800 | [diff] [blame] | 121 | #if CONFIG_TEMPMV_SIGNALING |
| 122 | 0, // disable temporal mv prediction |
| 123 | #endif |
Alex Converse | eb780e7 | 2016-12-13 12:46:41 -0800 | [diff] [blame] | 124 | 1, // frame_parallel_decoding_mode |
| 125 | NO_AQ, // aq_mode |
Rostislav Pehlivanov | 002e7b7 | 2017-02-15 19:45:54 +0000 | [diff] [blame] | 126 | CONFIG_XIPHRC, // frame_periodic_delta_q |
Alex Converse | eb780e7 | 2016-12-13 12:46:41 -0800 | [diff] [blame] | 127 | AOM_BITS_8, // Bit depth |
| 128 | AOM_CONTENT_DEFAULT, // content |
| 129 | AOM_CS_UNKNOWN, // color space |
| 130 | 0, // color range |
| 131 | 0, // render width |
| 132 | 0, // render height |
| 133 | AOM_SUPERBLOCK_SIZE_DYNAMIC, // superblock_size |
| 134 | #if CONFIG_ANS && ANS_MAX_SYMBOLS |
| 135 | 23, // ans_window_size_log2 |
| 136 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 137 | }; |
| 138 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 139 | struct aom_codec_alg_priv { |
| 140 | aom_codec_priv_t base; |
| 141 | aom_codec_enc_cfg_t cfg; |
| 142 | struct av1_extracfg extra_cfg; |
| 143 | AV1EncoderConfig oxcf; |
| 144 | AV1_COMP *cpi; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 145 | unsigned char *cx_data; |
| 146 | size_t cx_data_sz; |
| 147 | unsigned char *pending_cx_data; |
| 148 | size_t pending_cx_data_sz; |
| 149 | int pending_frame_count; |
| 150 | size_t pending_frame_sizes[8]; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 151 | aom_image_t preview_img; |
| 152 | aom_enc_frame_flags_t next_frame_flags; |
| 153 | aom_postproc_cfg_t preview_ppcfg; |
| 154 | aom_codec_pkt_list_decl(256) pkt_list; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 155 | unsigned int fixed_kf_cntr; |
| 156 | // BufferPool that holds all reference frames. |
| 157 | BufferPool *buffer_pool; |
| 158 | }; |
| 159 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 160 | static aom_codec_err_t update_error_state( |
| 161 | aom_codec_alg_priv_t *ctx, const struct aom_internal_error_info *error) { |
| 162 | const aom_codec_err_t res = error->error_code; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 163 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 164 | if (res != AOM_CODEC_OK) |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 165 | ctx->base.err_detail = error->has_detail ? error->detail : NULL; |
| 166 | |
| 167 | return res; |
| 168 | } |
| 169 | |
| 170 | #undef ERROR |
| 171 | #define ERROR(str) \ |
| 172 | do { \ |
| 173 | ctx->base.err_detail = str; \ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 174 | return AOM_CODEC_INVALID_PARAM; \ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 175 | } while (0) |
| 176 | |
Urvang Joshi | cd8ab90 | 2016-10-28 12:32:06 -0700 | [diff] [blame] | 177 | #define RANGE_CHECK(p, memb, lo, hi) \ |
| 178 | do { \ |
| 179 | if (!((p)->memb >= (lo) && (p)->memb <= (hi))) \ |
| 180 | ERROR(#memb " out of range [" #lo ".." #hi "]"); \ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 181 | } while (0) |
| 182 | |
| 183 | #define RANGE_CHECK_HI(p, memb, hi) \ |
| 184 | do { \ |
| 185 | if (!((p)->memb <= (hi))) ERROR(#memb " out of range [.." #hi "]"); \ |
| 186 | } while (0) |
| 187 | |
| 188 | #define RANGE_CHECK_LO(p, memb, lo) \ |
| 189 | do { \ |
| 190 | if (!((p)->memb >= (lo))) ERROR(#memb " out of range [" #lo "..]"); \ |
| 191 | } while (0) |
| 192 | |
| 193 | #define RANGE_CHECK_BOOL(p, memb) \ |
| 194 | do { \ |
| 195 | if (!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean"); \ |
| 196 | } while (0) |
| 197 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 198 | static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx, |
| 199 | const aom_codec_enc_cfg_t *cfg, |
| 200 | const struct av1_extracfg *extra_cfg) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 201 | RANGE_CHECK(cfg, g_w, 1, 65535); // 16 bits available |
| 202 | RANGE_CHECK(cfg, g_h, 1, 65535); // 16 bits available |
| 203 | RANGE_CHECK(cfg, g_timebase.den, 1, 1000000000); |
| 204 | RANGE_CHECK(cfg, g_timebase.num, 1, cfg->g_timebase.den); |
| 205 | RANGE_CHECK_HI(cfg, g_profile, 3); |
| 206 | |
| 207 | RANGE_CHECK_HI(cfg, rc_max_quantizer, 63); |
| 208 | RANGE_CHECK_HI(cfg, rc_min_quantizer, cfg->rc_max_quantizer); |
| 209 | RANGE_CHECK_BOOL(extra_cfg, lossless); |
| 210 | RANGE_CHECK(extra_cfg, aq_mode, 0, AQ_MODE_COUNT - 1); |
Urvang Joshi | cd8ab90 | 2016-10-28 12:32:06 -0700 | [diff] [blame] | 211 | RANGE_CHECK_HI(extra_cfg, frame_periodic_boost, 1); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 212 | RANGE_CHECK_HI(cfg, g_threads, 64); |
| 213 | RANGE_CHECK_HI(cfg, g_lag_in_frames, MAX_LAG_BUFFERS); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 214 | RANGE_CHECK(cfg, rc_end_usage, AOM_VBR, AOM_Q); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 215 | RANGE_CHECK_HI(cfg, rc_undershoot_pct, 100); |
| 216 | RANGE_CHECK_HI(cfg, rc_overshoot_pct, 100); |
| 217 | RANGE_CHECK_HI(cfg, rc_2pass_vbr_bias_pct, 100); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 218 | RANGE_CHECK(cfg, kf_mode, AOM_KF_DISABLED, AOM_KF_AUTO); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 219 | RANGE_CHECK_BOOL(cfg, rc_resize_allowed); |
| 220 | RANGE_CHECK_HI(cfg, rc_dropframe_thresh, 100); |
| 221 | RANGE_CHECK_HI(cfg, rc_resize_up_thresh, 100); |
| 222 | RANGE_CHECK_HI(cfg, rc_resize_down_thresh, 100); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 223 | RANGE_CHECK(cfg, g_pass, AOM_RC_ONE_PASS, AOM_RC_LAST_PASS); |
Urvang Joshi | cd8ab90 | 2016-10-28 12:32:06 -0700 | [diff] [blame] | 224 | RANGE_CHECK_HI(extra_cfg, min_gf_interval, MAX_LAG_BUFFERS - 1); |
| 225 | RANGE_CHECK_HI(extra_cfg, max_gf_interval, MAX_LAG_BUFFERS - 1); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 226 | if (extra_cfg->max_gf_interval > 0) { |
| 227 | RANGE_CHECK(extra_cfg, max_gf_interval, 2, (MAX_LAG_BUFFERS - 1)); |
| 228 | } |
| 229 | if (extra_cfg->min_gf_interval > 0 && extra_cfg->max_gf_interval > 0) { |
| 230 | RANGE_CHECK(extra_cfg, max_gf_interval, extra_cfg->min_gf_interval, |
| 231 | (MAX_LAG_BUFFERS - 1)); |
| 232 | } |
| 233 | |
| 234 | if (cfg->rc_resize_allowed == 1) { |
Urvang Joshi | cd8ab90 | 2016-10-28 12:32:06 -0700 | [diff] [blame] | 235 | RANGE_CHECK_HI(cfg, rc_scaled_width, cfg->g_w); |
| 236 | RANGE_CHECK_HI(cfg, rc_scaled_height, cfg->g_h); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 237 | } |
| 238 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 239 | // AV1 does not support a lower bound on the keyframe interval in |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 240 | // automatic keyframe placement mode. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 241 | if (cfg->kf_mode != AOM_KF_DISABLED && cfg->kf_min_dist != cfg->kf_max_dist && |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 242 | cfg->kf_min_dist > 0) |
| 243 | ERROR( |
| 244 | "kf_min_dist not supported in auto mode, use 0 " |
| 245 | "or kf_max_dist instead."); |
| 246 | |
Urvang Joshi | cd8ab90 | 2016-10-28 12:32:06 -0700 | [diff] [blame] | 247 | RANGE_CHECK_HI(extra_cfg, enable_auto_alt_ref, 2); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 248 | #if CONFIG_EXT_REFS |
Urvang Joshi | cd8ab90 | 2016-10-28 12:32:06 -0700 | [diff] [blame] | 249 | RANGE_CHECK_HI(extra_cfg, enable_auto_bwd_ref, 2); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 250 | #endif // CONFIG_EXT_REFS |
Alex Converse | 561d0af | 2017-03-23 12:58:04 -0700 | [diff] [blame] | 251 | RANGE_CHECK(extra_cfg, cpu_used, 0, 8); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 252 | RANGE_CHECK_HI(extra_cfg, noise_sensitivity, 6); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 253 | RANGE_CHECK(extra_cfg, superblock_size, AOM_SUPERBLOCK_SIZE_64X64, |
| 254 | AOM_SUPERBLOCK_SIZE_DYNAMIC); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 255 | #if CONFIG_EXT_TILE |
| 256 | // TODO(any): Waring. If CONFIG_EXT_TILE is true, tile_columns really |
| 257 | // means tile_width, and tile_rows really means tile_hight. The interface |
| 258 | // should be sanitized. |
| 259 | #if CONFIG_EXT_PARTITION |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 260 | if (extra_cfg->superblock_size != AOM_SUPERBLOCK_SIZE_64X64) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 261 | if (extra_cfg->tile_columns != UINT_MAX) |
| 262 | RANGE_CHECK(extra_cfg, tile_columns, 1, 32); |
| 263 | if (extra_cfg->tile_rows != UINT_MAX) |
| 264 | RANGE_CHECK(extra_cfg, tile_rows, 1, 32); |
| 265 | } else |
| 266 | #endif // CONFIG_EXT_PARTITION |
| 267 | { |
| 268 | if (extra_cfg->tile_columns != UINT_MAX) |
| 269 | RANGE_CHECK(extra_cfg, tile_columns, 1, 64); |
| 270 | if (extra_cfg->tile_rows != UINT_MAX) |
| 271 | RANGE_CHECK(extra_cfg, tile_rows, 1, 64); |
| 272 | } |
| 273 | #else |
Urvang Joshi | cd8ab90 | 2016-10-28 12:32:06 -0700 | [diff] [blame] | 274 | RANGE_CHECK_HI(extra_cfg, tile_columns, 6); |
| 275 | RANGE_CHECK_HI(extra_cfg, tile_rows, 2); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 276 | #endif // CONFIG_EXT_TILE |
Fangwen Fu | 7b9f2b3 | 2017-01-17 14:01:52 -0800 | [diff] [blame] | 277 | #if CONFIG_DEPENDENT_HORZTILES |
| 278 | RANGE_CHECK_HI(extra_cfg, dependent_horz_tiles, 1); |
| 279 | #endif |
Ryan Lei | 9b02b0e | 2017-01-30 15:52:20 -0800 | [diff] [blame] | 280 | #if CONFIG_LOOPFILTERING_ACROSS_TILES |
Ryan Lei | 7386eda | 2016-12-08 21:08:31 -0800 | [diff] [blame] | 281 | RANGE_CHECK_HI(extra_cfg, loop_filter_across_tiles_enabled, 1); |
Ryan Lei | 9b02b0e | 2017-01-30 15:52:20 -0800 | [diff] [blame] | 282 | #endif // CONFIG_LOOPFILTERING_ACROSS_TILES |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 283 | RANGE_CHECK_HI(extra_cfg, sharpness, 7); |
Urvang Joshi | cd8ab90 | 2016-10-28 12:32:06 -0700 | [diff] [blame] | 284 | RANGE_CHECK_HI(extra_cfg, arnr_max_frames, 15); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 285 | RANGE_CHECK_HI(extra_cfg, arnr_strength, 6); |
Urvang Joshi | cd8ab90 | 2016-10-28 12:32:06 -0700 | [diff] [blame] | 286 | RANGE_CHECK_HI(extra_cfg, cq_level, 63); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 287 | RANGE_CHECK(cfg, g_bit_depth, AOM_BITS_8, AOM_BITS_12); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 288 | RANGE_CHECK(cfg, g_input_bit_depth, 8, 12); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 289 | RANGE_CHECK(extra_cfg, content, AOM_CONTENT_DEFAULT, AOM_CONTENT_INVALID - 1); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 290 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 291 | // TODO(yaowu): remove this when ssim tuning is implemented for av1 |
| 292 | if (extra_cfg->tuning == AOM_TUNE_SSIM) |
| 293 | ERROR("Option --tune=ssim is not currently supported in AV1."); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 294 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 295 | if (cfg->g_pass == AOM_RC_LAST_PASS) { |
Rostislav Pehlivanov | 74021a5 | 2017-03-09 09:05:29 +0000 | [diff] [blame] | 296 | #if !CONFIG_XIPHRC |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 297 | const size_t packet_sz = sizeof(FIRSTPASS_STATS); |
| 298 | const int n_packets = (int)(cfg->rc_twopass_stats_in.sz / packet_sz); |
| 299 | const FIRSTPASS_STATS *stats; |
Rostislav Pehlivanov | 74021a5 | 2017-03-09 09:05:29 +0000 | [diff] [blame] | 300 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 301 | |
| 302 | if (cfg->rc_twopass_stats_in.buf == NULL) |
| 303 | ERROR("rc_twopass_stats_in.buf not set."); |
| 304 | |
Rostislav Pehlivanov | 74021a5 | 2017-03-09 09:05:29 +0000 | [diff] [blame] | 305 | #if !CONFIG_XIPHRC |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 306 | if (cfg->rc_twopass_stats_in.sz % packet_sz) |
| 307 | ERROR("rc_twopass_stats_in.sz indicates truncated packet."); |
| 308 | |
| 309 | if (cfg->rc_twopass_stats_in.sz < 2 * packet_sz) |
| 310 | ERROR("rc_twopass_stats_in requires at least two packets."); |
| 311 | |
| 312 | stats = |
| 313 | (const FIRSTPASS_STATS *)cfg->rc_twopass_stats_in.buf + n_packets - 1; |
| 314 | |
| 315 | if ((int)(stats->count + 0.5) != n_packets - 1) |
| 316 | ERROR("rc_twopass_stats_in missing EOS stats packet"); |
Rostislav Pehlivanov | 74021a5 | 2017-03-09 09:05:29 +0000 | [diff] [blame] | 317 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 318 | } |
| 319 | |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame^] | 320 | #if !CONFIG_HIGHBITDEPTH |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 321 | if (cfg->g_profile > (unsigned int)PROFILE_1) { |
| 322 | ERROR("Profile > 1 not supported in this build configuration"); |
| 323 | } |
| 324 | #endif |
| 325 | if (cfg->g_profile <= (unsigned int)PROFILE_1 && |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 326 | cfg->g_bit_depth > AOM_BITS_8) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 327 | ERROR("Codec high bit-depth not supported in profile < 2"); |
| 328 | } |
| 329 | if (cfg->g_profile <= (unsigned int)PROFILE_1 && cfg->g_input_bit_depth > 8) { |
| 330 | ERROR("Source high bit-depth not supported in profile < 2"); |
| 331 | } |
| 332 | if (cfg->g_profile > (unsigned int)PROFILE_1 && |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 333 | cfg->g_bit_depth == AOM_BITS_8) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 334 | ERROR("Codec bit-depth 8 not supported in profile > 1"); |
| 335 | } |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 336 | RANGE_CHECK(extra_cfg, color_space, AOM_CS_UNKNOWN, AOM_CS_SRGB); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 337 | RANGE_CHECK(extra_cfg, color_range, 0, 1); |
Alex Converse | eb780e7 | 2016-12-13 12:46:41 -0800 | [diff] [blame] | 338 | #if CONFIG_ANS && ANS_MAX_SYMBOLS |
| 339 | RANGE_CHECK(extra_cfg, ans_window_size_log2, 8, 23); |
| 340 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 341 | return AOM_CODEC_OK; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 342 | } |
| 343 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 344 | static aom_codec_err_t validate_img(aom_codec_alg_priv_t *ctx, |
| 345 | const aom_image_t *img) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 346 | switch (img->fmt) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 347 | case AOM_IMG_FMT_YV12: |
| 348 | case AOM_IMG_FMT_I420: |
| 349 | case AOM_IMG_FMT_I42016: break; |
| 350 | case AOM_IMG_FMT_I422: |
| 351 | case AOM_IMG_FMT_I444: |
| 352 | case AOM_IMG_FMT_I440: |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 353 | if (ctx->cfg.g_profile != (unsigned int)PROFILE_1) { |
| 354 | ERROR( |
| 355 | "Invalid image format. I422, I444, I440 images are " |
| 356 | "not supported in profile."); |
| 357 | } |
| 358 | break; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 359 | case AOM_IMG_FMT_I42216: |
| 360 | case AOM_IMG_FMT_I44416: |
| 361 | case AOM_IMG_FMT_I44016: |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 362 | if (ctx->cfg.g_profile != (unsigned int)PROFILE_1 && |
| 363 | ctx->cfg.g_profile != (unsigned int)PROFILE_3) { |
| 364 | ERROR( |
| 365 | "Invalid image format. 16-bit I422, I444, I440 images are " |
| 366 | "not supported in profile."); |
| 367 | } |
| 368 | break; |
| 369 | default: |
| 370 | ERROR( |
| 371 | "Invalid image format. Only YV12, I420, I422, I444 images are " |
| 372 | "supported."); |
| 373 | break; |
| 374 | } |
| 375 | |
| 376 | if (img->d_w != ctx->cfg.g_w || img->d_h != ctx->cfg.g_h) |
| 377 | ERROR("Image size must match encoder init configuration size"); |
| 378 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 379 | return AOM_CODEC_OK; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 380 | } |
| 381 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 382 | static int get_image_bps(const aom_image_t *img) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 383 | switch (img->fmt) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 384 | case AOM_IMG_FMT_YV12: |
| 385 | case AOM_IMG_FMT_I420: return 12; |
| 386 | case AOM_IMG_FMT_I422: return 16; |
| 387 | case AOM_IMG_FMT_I444: return 24; |
| 388 | case AOM_IMG_FMT_I440: return 16; |
| 389 | case AOM_IMG_FMT_I42016: return 24; |
| 390 | case AOM_IMG_FMT_I42216: return 32; |
| 391 | case AOM_IMG_FMT_I44416: return 48; |
| 392 | case AOM_IMG_FMT_I44016: return 32; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 393 | default: assert(0 && "Invalid image format"); break; |
| 394 | } |
| 395 | return 0; |
| 396 | } |
| 397 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 398 | static aom_codec_err_t set_encoder_config( |
| 399 | AV1EncoderConfig *oxcf, const aom_codec_enc_cfg_t *cfg, |
| 400 | const struct av1_extracfg *extra_cfg) { |
| 401 | const int is_vbr = cfg->rc_end_usage == AOM_VBR; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 402 | oxcf->profile = cfg->g_profile; |
| 403 | oxcf->max_threads = (int)cfg->g_threads; |
| 404 | oxcf->width = cfg->g_w; |
| 405 | oxcf->height = cfg->g_h; |
| 406 | oxcf->bit_depth = cfg->g_bit_depth; |
| 407 | oxcf->input_bit_depth = cfg->g_input_bit_depth; |
| 408 | // guess a frame rate if out of whack, use 30 |
| 409 | oxcf->init_framerate = (double)cfg->g_timebase.den / cfg->g_timebase.num; |
| 410 | if (oxcf->init_framerate > 180) oxcf->init_framerate = 30; |
| 411 | |
| 412 | oxcf->mode = GOOD; |
| 413 | |
| 414 | switch (cfg->g_pass) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 415 | case AOM_RC_ONE_PASS: oxcf->pass = 0; break; |
| 416 | case AOM_RC_FIRST_PASS: oxcf->pass = 1; break; |
| 417 | case AOM_RC_LAST_PASS: oxcf->pass = 2; break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | oxcf->lag_in_frames = |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 421 | cfg->g_pass == AOM_RC_FIRST_PASS ? 0 : cfg->g_lag_in_frames; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 422 | oxcf->rc_mode = cfg->rc_end_usage; |
| 423 | |
| 424 | // Convert target bandwidth from Kbit/s to Bit/s |
| 425 | oxcf->target_bandwidth = 1000 * cfg->rc_target_bitrate; |
| 426 | oxcf->rc_max_intra_bitrate_pct = extra_cfg->rc_max_intra_bitrate_pct; |
| 427 | oxcf->rc_max_inter_bitrate_pct = extra_cfg->rc_max_inter_bitrate_pct; |
| 428 | oxcf->gf_cbr_boost_pct = extra_cfg->gf_cbr_boost_pct; |
| 429 | |
| 430 | oxcf->best_allowed_q = |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 431 | extra_cfg->lossless ? 0 : av1_quantizer_to_qindex(cfg->rc_min_quantizer); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 432 | oxcf->worst_allowed_q = |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 433 | extra_cfg->lossless ? 0 : av1_quantizer_to_qindex(cfg->rc_max_quantizer); |
| 434 | oxcf->cq_level = av1_quantizer_to_qindex(extra_cfg->cq_level); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 435 | oxcf->fixed_q = -1; |
| 436 | |
| 437 | #if CONFIG_AOM_QM |
| 438 | oxcf->using_qm = extra_cfg->enable_qm; |
| 439 | oxcf->qm_minlevel = extra_cfg->qm_min; |
| 440 | oxcf->qm_maxlevel = extra_cfg->qm_max; |
| 441 | #endif |
| 442 | |
Thomas Davies | af6df17 | 2016-11-09 14:04:18 +0000 | [diff] [blame] | 443 | #if CONFIG_TILE_GROUPS |
| 444 | oxcf->num_tile_groups = extra_cfg->num_tg; |
| 445 | oxcf->mtu = extra_cfg->mtu_size; |
| 446 | #endif |
| 447 | |
Fangwen Fu | 8d164de | 2016-12-14 13:40:54 -0800 | [diff] [blame] | 448 | #if CONFIG_TEMPMV_SIGNALING |
| 449 | oxcf->disable_tempmv = extra_cfg->disable_tempmv; |
| 450 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 451 | oxcf->under_shoot_pct = cfg->rc_undershoot_pct; |
| 452 | oxcf->over_shoot_pct = cfg->rc_overshoot_pct; |
| 453 | |
| 454 | oxcf->scaled_frame_width = cfg->rc_scaled_width; |
| 455 | oxcf->scaled_frame_height = cfg->rc_scaled_height; |
| 456 | if (cfg->rc_resize_allowed == 1) { |
| 457 | oxcf->resize_mode = |
| 458 | (oxcf->scaled_frame_width == 0 || oxcf->scaled_frame_height == 0) |
| 459 | ? RESIZE_DYNAMIC |
| 460 | : RESIZE_FIXED; |
| 461 | } else { |
| 462 | oxcf->resize_mode = RESIZE_NONE; |
| 463 | } |
| 464 | |
| 465 | oxcf->maximum_buffer_size_ms = is_vbr ? 240000 : cfg->rc_buf_sz; |
| 466 | oxcf->starting_buffer_level_ms = is_vbr ? 60000 : cfg->rc_buf_initial_sz; |
| 467 | oxcf->optimal_buffer_level_ms = is_vbr ? 60000 : cfg->rc_buf_optimal_sz; |
| 468 | |
| 469 | oxcf->drop_frames_water_mark = cfg->rc_dropframe_thresh; |
| 470 | |
| 471 | oxcf->two_pass_vbrbias = cfg->rc_2pass_vbr_bias_pct; |
| 472 | oxcf->two_pass_vbrmin_section = cfg->rc_2pass_vbr_minsection_pct; |
| 473 | oxcf->two_pass_vbrmax_section = cfg->rc_2pass_vbr_maxsection_pct; |
| 474 | |
| 475 | oxcf->auto_key = |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 476 | cfg->kf_mode == AOM_KF_AUTO && cfg->kf_min_dist != cfg->kf_max_dist; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 477 | |
| 478 | oxcf->key_freq = cfg->kf_max_dist; |
| 479 | |
Alex Converse | 561d0af | 2017-03-23 12:58:04 -0700 | [diff] [blame] | 480 | oxcf->speed = extra_cfg->cpu_used; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 481 | oxcf->enable_auto_arf = extra_cfg->enable_auto_alt_ref; |
| 482 | #if CONFIG_EXT_REFS |
| 483 | oxcf->enable_auto_brf = extra_cfg->enable_auto_bwd_ref; |
| 484 | #endif // CONFIG_EXT_REFS |
| 485 | oxcf->noise_sensitivity = extra_cfg->noise_sensitivity; |
| 486 | oxcf->sharpness = extra_cfg->sharpness; |
| 487 | |
| 488 | oxcf->two_pass_stats_in = cfg->rc_twopass_stats_in; |
| 489 | |
| 490 | #if CONFIG_FP_MB_STATS |
| 491 | oxcf->firstpass_mb_stats_in = cfg->rc_firstpass_mb_stats_in; |
| 492 | #endif |
| 493 | |
| 494 | oxcf->color_space = extra_cfg->color_space; |
| 495 | oxcf->color_range = extra_cfg->color_range; |
| 496 | oxcf->render_width = extra_cfg->render_width; |
| 497 | oxcf->render_height = extra_cfg->render_height; |
| 498 | oxcf->arnr_max_frames = extra_cfg->arnr_max_frames; |
| 499 | oxcf->arnr_strength = extra_cfg->arnr_strength; |
| 500 | oxcf->min_gf_interval = extra_cfg->min_gf_interval; |
| 501 | oxcf->max_gf_interval = extra_cfg->max_gf_interval; |
| 502 | |
| 503 | oxcf->tuning = extra_cfg->tuning; |
| 504 | oxcf->content = extra_cfg->content; |
| 505 | |
| 506 | #if CONFIG_EXT_PARTITION |
| 507 | oxcf->superblock_size = extra_cfg->superblock_size; |
| 508 | #endif // CONFIG_EXT_PARTITION |
Alex Converse | eb780e7 | 2016-12-13 12:46:41 -0800 | [diff] [blame] | 509 | #if CONFIG_ANS && ANS_MAX_SYMBOLS |
| 510 | oxcf->ans_window_size_log2 = extra_cfg->ans_window_size_log2; |
| 511 | #endif // CONFIG_ANS && ANS_MAX_SYMBOLS |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 512 | |
| 513 | #if CONFIG_EXT_TILE |
| 514 | { |
| 515 | #if CONFIG_EXT_PARTITION |
| 516 | const unsigned int max = |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 517 | extra_cfg->superblock_size == AOM_SUPERBLOCK_SIZE_64X64 ? 64 : 32; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 518 | #else |
| 519 | const unsigned int max = 64; |
| 520 | #endif // CONFIG_EXT_PARTITION |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 521 | oxcf->tile_columns = AOMMIN(extra_cfg->tile_columns, max); |
| 522 | oxcf->tile_rows = AOMMIN(extra_cfg->tile_rows, max); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 523 | } |
| 524 | #else |
| 525 | oxcf->tile_columns = extra_cfg->tile_columns; |
| 526 | oxcf->tile_rows = extra_cfg->tile_rows; |
| 527 | #endif // CONFIG_EXT_TILE |
Fangwen Fu | 7b9f2b3 | 2017-01-17 14:01:52 -0800 | [diff] [blame] | 528 | #if CONFIG_DEPENDENT_HORZTILES |
| 529 | oxcf->dependent_horz_tiles = extra_cfg->dependent_horz_tiles; |
| 530 | #endif |
Ryan Lei | 9b02b0e | 2017-01-30 15:52:20 -0800 | [diff] [blame] | 531 | #if CONFIG_LOOPFILTERING_ACROSS_TILES |
Ryan Lei | 7386eda | 2016-12-08 21:08:31 -0800 | [diff] [blame] | 532 | oxcf->loop_filter_across_tiles_enabled = |
| 533 | extra_cfg->loop_filter_across_tiles_enabled; |
Ryan Lei | 9b02b0e | 2017-01-30 15:52:20 -0800 | [diff] [blame] | 534 | #endif // CONFIG_LOOPFILTERING_ACROSS_TILES |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 535 | oxcf->error_resilient_mode = cfg->g_error_resilient; |
| 536 | oxcf->frame_parallel_decoding_mode = extra_cfg->frame_parallel_decoding_mode; |
| 537 | |
| 538 | oxcf->aq_mode = extra_cfg->aq_mode; |
| 539 | |
| 540 | oxcf->frame_periodic_boost = extra_cfg->frame_periodic_boost; |
| 541 | |
| 542 | /* |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 543 | printf("Current AV1 Settings: \n"); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 544 | printf("target_bandwidth: %d\n", oxcf->target_bandwidth); |
| 545 | printf("noise_sensitivity: %d\n", oxcf->noise_sensitivity); |
| 546 | printf("sharpness: %d\n", oxcf->sharpness); |
| 547 | printf("cpu_used: %d\n", oxcf->cpu_used); |
| 548 | printf("Mode: %d\n", oxcf->mode); |
| 549 | printf("auto_key: %d\n", oxcf->auto_key); |
| 550 | printf("key_freq: %d\n", oxcf->key_freq); |
| 551 | printf("end_usage: %d\n", oxcf->end_usage); |
| 552 | printf("under_shoot_pct: %d\n", oxcf->under_shoot_pct); |
| 553 | printf("over_shoot_pct: %d\n", oxcf->over_shoot_pct); |
| 554 | printf("starting_buffer_level: %d\n", oxcf->starting_buffer_level); |
| 555 | printf("optimal_buffer_level: %d\n", oxcf->optimal_buffer_level); |
| 556 | printf("maximum_buffer_size: %d\n", oxcf->maximum_buffer_size); |
| 557 | printf("fixed_q: %d\n", oxcf->fixed_q); |
| 558 | printf("worst_allowed_q: %d\n", oxcf->worst_allowed_q); |
| 559 | printf("best_allowed_q: %d\n", oxcf->best_allowed_q); |
| 560 | printf("allow_spatial_resampling: %d\n", oxcf->allow_spatial_resampling); |
| 561 | printf("scaled_frame_width: %d\n", oxcf->scaled_frame_width); |
| 562 | printf("scaled_frame_height: %d\n", oxcf->scaled_frame_height); |
| 563 | printf("two_pass_vbrbias: %d\n", oxcf->two_pass_vbrbias); |
| 564 | printf("two_pass_vbrmin_section: %d\n", oxcf->two_pass_vbrmin_section); |
| 565 | printf("two_pass_vbrmax_section: %d\n", oxcf->two_pass_vbrmax_section); |
| 566 | printf("lag_in_frames: %d\n", oxcf->lag_in_frames); |
| 567 | printf("enable_auto_arf: %d\n", oxcf->enable_auto_arf); |
| 568 | printf("Version: %d\n", oxcf->Version); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 569 | printf("error resilient: %d\n", oxcf->error_resilient_mode); |
| 570 | printf("frame parallel detokenization: %d\n", |
| 571 | oxcf->frame_parallel_decoding_mode); |
| 572 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 573 | return AOM_CODEC_OK; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 574 | } |
| 575 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 576 | static aom_codec_err_t encoder_set_config(aom_codec_alg_priv_t *ctx, |
| 577 | const aom_codec_enc_cfg_t *cfg) { |
| 578 | aom_codec_err_t res; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 579 | int force_key = 0; |
| 580 | |
| 581 | if (cfg->g_w != ctx->cfg.g_w || cfg->g_h != ctx->cfg.g_h) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 582 | if (cfg->g_lag_in_frames > 1 || cfg->g_pass != AOM_RC_ONE_PASS) |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 583 | ERROR("Cannot change width or height after initialization"); |
| 584 | if (!valid_ref_frame_size(ctx->cfg.g_w, ctx->cfg.g_h, cfg->g_w, cfg->g_h) || |
| 585 | (ctx->cpi->initial_width && (int)cfg->g_w > ctx->cpi->initial_width) || |
| 586 | (ctx->cpi->initial_height && (int)cfg->g_h > ctx->cpi->initial_height)) |
| 587 | force_key = 1; |
| 588 | } |
| 589 | |
| 590 | // Prevent increasing lag_in_frames. This check is stricter than it needs |
| 591 | // to be -- the limit is not increasing past the first lag_in_frames |
| 592 | // value, but we don't track the initial config, only the last successful |
| 593 | // config. |
| 594 | if (cfg->g_lag_in_frames > ctx->cfg.g_lag_in_frames) |
| 595 | ERROR("Cannot increase lag_in_frames"); |
| 596 | |
| 597 | res = validate_config(ctx, cfg, &ctx->extra_cfg); |
| 598 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 599 | if (res == AOM_CODEC_OK) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 600 | ctx->cfg = *cfg; |
| 601 | set_encoder_config(&ctx->oxcf, &ctx->cfg, &ctx->extra_cfg); |
| 602 | // On profile change, request a key frame |
| 603 | force_key |= ctx->cpi->common.profile != ctx->oxcf.profile; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 604 | av1_change_config(ctx->cpi, &ctx->oxcf); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 605 | } |
| 606 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 607 | if (force_key) ctx->next_frame_flags |= AOM_EFLAG_FORCE_KF; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 608 | |
| 609 | return res; |
| 610 | } |
| 611 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 612 | static aom_codec_err_t ctrl_get_quantizer(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 613 | va_list args) { |
| 614 | int *const arg = va_arg(args, int *); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 615 | if (arg == NULL) return AOM_CODEC_INVALID_PARAM; |
| 616 | *arg = av1_get_quantizer(ctx->cpi); |
| 617 | return AOM_CODEC_OK; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 618 | } |
| 619 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 620 | static aom_codec_err_t ctrl_get_quantizer64(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 621 | va_list args) { |
| 622 | int *const arg = va_arg(args, int *); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 623 | if (arg == NULL) return AOM_CODEC_INVALID_PARAM; |
| 624 | *arg = av1_qindex_to_quantizer(av1_get_quantizer(ctx->cpi)); |
| 625 | return AOM_CODEC_OK; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 626 | } |
| 627 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 628 | static aom_codec_err_t update_extra_cfg(aom_codec_alg_priv_t *ctx, |
| 629 | const struct av1_extracfg *extra_cfg) { |
| 630 | const aom_codec_err_t res = validate_config(ctx, &ctx->cfg, extra_cfg); |
| 631 | if (res == AOM_CODEC_OK) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 632 | ctx->extra_cfg = *extra_cfg; |
| 633 | set_encoder_config(&ctx->oxcf, &ctx->cfg, &ctx->extra_cfg); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 634 | av1_change_config(ctx->cpi, &ctx->oxcf); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 635 | } |
| 636 | return res; |
| 637 | } |
| 638 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 639 | static aom_codec_err_t ctrl_set_cpuused(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 640 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 641 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 642 | extra_cfg.cpu_used = CAST(AOME_SET_CPUUSED, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 643 | return update_extra_cfg(ctx, &extra_cfg); |
| 644 | } |
| 645 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 646 | static aom_codec_err_t ctrl_set_enable_auto_alt_ref(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 647 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 648 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 649 | extra_cfg.enable_auto_alt_ref = CAST(AOME_SET_ENABLEAUTOALTREF, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 650 | return update_extra_cfg(ctx, &extra_cfg); |
| 651 | } |
| 652 | |
| 653 | #if CONFIG_EXT_REFS |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 654 | static aom_codec_err_t ctrl_set_enable_auto_bwd_ref(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 655 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 656 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 657 | extra_cfg.enable_auto_bwd_ref = CAST(AOME_SET_ENABLEAUTOBWDREF, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 658 | return update_extra_cfg(ctx, &extra_cfg); |
| 659 | } |
| 660 | #endif // CONFIG_EXT_REFS |
| 661 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 662 | static aom_codec_err_t ctrl_set_noise_sensitivity(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 663 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 664 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 665 | extra_cfg.noise_sensitivity = CAST(AV1E_SET_NOISE_SENSITIVITY, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 666 | return update_extra_cfg(ctx, &extra_cfg); |
| 667 | } |
| 668 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 669 | static aom_codec_err_t ctrl_set_sharpness(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 670 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 671 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 672 | extra_cfg.sharpness = CAST(AOME_SET_SHARPNESS, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 673 | return update_extra_cfg(ctx, &extra_cfg); |
| 674 | } |
| 675 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 676 | static aom_codec_err_t ctrl_set_static_thresh(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 677 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 678 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 679 | extra_cfg.static_thresh = CAST(AOME_SET_STATIC_THRESHOLD, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 680 | return update_extra_cfg(ctx, &extra_cfg); |
| 681 | } |
| 682 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 683 | static aom_codec_err_t ctrl_set_tile_columns(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 684 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 685 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 686 | extra_cfg.tile_columns = CAST(AV1E_SET_TILE_COLUMNS, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 687 | return update_extra_cfg(ctx, &extra_cfg); |
| 688 | } |
| 689 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 690 | static aom_codec_err_t ctrl_set_tile_rows(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 691 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 692 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 693 | extra_cfg.tile_rows = CAST(AV1E_SET_TILE_ROWS, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 694 | return update_extra_cfg(ctx, &extra_cfg); |
| 695 | } |
Fangwen Fu | 7b9f2b3 | 2017-01-17 14:01:52 -0800 | [diff] [blame] | 696 | #if CONFIG_DEPENDENT_HORZTILES |
| 697 | static aom_codec_err_t ctrl_set_tile_dependent_rows(aom_codec_alg_priv_t *ctx, |
| 698 | va_list args) { |
| 699 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 700 | extra_cfg.dependent_horz_tiles = CAST(AV1E_SET_TILE_DEPENDENT_ROWS, args); |
| 701 | return update_extra_cfg(ctx, &extra_cfg); |
| 702 | } |
| 703 | #endif |
Ryan Lei | 9b02b0e | 2017-01-30 15:52:20 -0800 | [diff] [blame] | 704 | #if CONFIG_LOOPFILTERING_ACROSS_TILES |
Ryan Lei | 7386eda | 2016-12-08 21:08:31 -0800 | [diff] [blame] | 705 | static aom_codec_err_t ctrl_set_tile_loopfilter(aom_codec_alg_priv_t *ctx, |
| 706 | va_list args) { |
| 707 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 708 | extra_cfg.loop_filter_across_tiles_enabled = |
| 709 | CAST(AV1E_SET_TILE_LOOPFILTER, args); |
| 710 | return update_extra_cfg(ctx, &extra_cfg); |
| 711 | } |
Ryan Lei | 9b02b0e | 2017-01-30 15:52:20 -0800 | [diff] [blame] | 712 | #endif // CONFIG_LOOPFILTERING_ACROSS_TILES |
Ryan Lei | 7386eda | 2016-12-08 21:08:31 -0800 | [diff] [blame] | 713 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 714 | static aom_codec_err_t ctrl_set_arnr_max_frames(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 715 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 716 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 717 | extra_cfg.arnr_max_frames = CAST(AOME_SET_ARNR_MAXFRAMES, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 718 | return update_extra_cfg(ctx, &extra_cfg); |
| 719 | } |
| 720 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 721 | static aom_codec_err_t ctrl_set_arnr_strength(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 722 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 723 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 724 | extra_cfg.arnr_strength = CAST(AOME_SET_ARNR_STRENGTH, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 725 | return update_extra_cfg(ctx, &extra_cfg); |
| 726 | } |
| 727 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 728 | static aom_codec_err_t ctrl_set_tuning(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 729 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 730 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 731 | extra_cfg.tuning = CAST(AOME_SET_TUNING, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 732 | return update_extra_cfg(ctx, &extra_cfg); |
| 733 | } |
| 734 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 735 | static aom_codec_err_t ctrl_set_cq_level(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 736 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 737 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 738 | extra_cfg.cq_level = CAST(AOME_SET_CQ_LEVEL, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 739 | return update_extra_cfg(ctx, &extra_cfg); |
| 740 | } |
| 741 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 742 | static aom_codec_err_t ctrl_set_rc_max_intra_bitrate_pct( |
| 743 | aom_codec_alg_priv_t *ctx, va_list args) { |
| 744 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 745 | extra_cfg.rc_max_intra_bitrate_pct = |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 746 | CAST(AOME_SET_MAX_INTRA_BITRATE_PCT, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 747 | return update_extra_cfg(ctx, &extra_cfg); |
| 748 | } |
| 749 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 750 | static aom_codec_err_t ctrl_set_rc_max_inter_bitrate_pct( |
| 751 | aom_codec_alg_priv_t *ctx, va_list args) { |
| 752 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 753 | extra_cfg.rc_max_inter_bitrate_pct = |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 754 | CAST(AOME_SET_MAX_INTER_BITRATE_PCT, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 755 | return update_extra_cfg(ctx, &extra_cfg); |
| 756 | } |
| 757 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 758 | static aom_codec_err_t ctrl_set_rc_gf_cbr_boost_pct(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 759 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 760 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 761 | extra_cfg.gf_cbr_boost_pct = CAST(AV1E_SET_GF_CBR_BOOST_PCT, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 762 | return update_extra_cfg(ctx, &extra_cfg); |
| 763 | } |
| 764 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 765 | static aom_codec_err_t ctrl_set_lossless(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 766 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 767 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 768 | extra_cfg.lossless = CAST(AV1E_SET_LOSSLESS, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 769 | return update_extra_cfg(ctx, &extra_cfg); |
| 770 | } |
| 771 | |
| 772 | #if CONFIG_AOM_QM |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 773 | static aom_codec_err_t ctrl_set_enable_qm(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 774 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 775 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 776 | extra_cfg.enable_qm = CAST(AV1E_SET_ENABLE_QM, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 777 | return update_extra_cfg(ctx, &extra_cfg); |
| 778 | } |
| 779 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 780 | static aom_codec_err_t ctrl_set_qm_min(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 781 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 782 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 783 | extra_cfg.qm_min = CAST(AV1E_SET_QM_MIN, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 784 | return update_extra_cfg(ctx, &extra_cfg); |
| 785 | } |
| 786 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 787 | static aom_codec_err_t ctrl_set_qm_max(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 788 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 789 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 790 | extra_cfg.qm_max = CAST(AV1E_SET_QM_MAX, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 791 | return update_extra_cfg(ctx, &extra_cfg); |
| 792 | } |
| 793 | #endif |
| 794 | |
Thomas Davies | af6df17 | 2016-11-09 14:04:18 +0000 | [diff] [blame] | 795 | #if CONFIG_TILE_GROUPS |
| 796 | static aom_codec_err_t ctrl_set_num_tg(aom_codec_alg_priv_t *ctx, |
| 797 | va_list args) { |
| 798 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 799 | extra_cfg.num_tg = CAST(AV1E_SET_NUM_TG, args); |
| 800 | return update_extra_cfg(ctx, &extra_cfg); |
| 801 | } |
| 802 | |
| 803 | static aom_codec_err_t ctrl_set_mtu(aom_codec_alg_priv_t *ctx, va_list args) { |
| 804 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 805 | extra_cfg.mtu_size = CAST(AV1E_SET_MTU, args); |
| 806 | return update_extra_cfg(ctx, &extra_cfg); |
| 807 | } |
| 808 | #endif |
Fangwen Fu | 8d164de | 2016-12-14 13:40:54 -0800 | [diff] [blame] | 809 | #if CONFIG_TEMPMV_SIGNALING |
| 810 | static aom_codec_err_t ctrl_set_disable_tempmv(aom_codec_alg_priv_t *ctx, |
| 811 | va_list args) { |
| 812 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 813 | extra_cfg.disable_tempmv = CAST(AV1E_SET_DISABLE_TEMPMV, args); |
| 814 | return update_extra_cfg(ctx, &extra_cfg); |
| 815 | } |
| 816 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 817 | static aom_codec_err_t ctrl_set_frame_parallel_decoding_mode( |
| 818 | aom_codec_alg_priv_t *ctx, va_list args) { |
| 819 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 820 | extra_cfg.frame_parallel_decoding_mode = |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 821 | CAST(AV1E_SET_FRAME_PARALLEL_DECODING, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 822 | return update_extra_cfg(ctx, &extra_cfg); |
| 823 | } |
| 824 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 825 | static aom_codec_err_t ctrl_set_aq_mode(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 826 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 827 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 828 | extra_cfg.aq_mode = CAST(AV1E_SET_AQ_MODE, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 829 | return update_extra_cfg(ctx, &extra_cfg); |
| 830 | } |
| 831 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 832 | static aom_codec_err_t ctrl_set_min_gf_interval(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 833 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 834 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 835 | extra_cfg.min_gf_interval = CAST(AV1E_SET_MIN_GF_INTERVAL, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 836 | return update_extra_cfg(ctx, &extra_cfg); |
| 837 | } |
| 838 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 839 | static aom_codec_err_t ctrl_set_max_gf_interval(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 840 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 841 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 842 | extra_cfg.max_gf_interval = CAST(AV1E_SET_MAX_GF_INTERVAL, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 843 | return update_extra_cfg(ctx, &extra_cfg); |
| 844 | } |
| 845 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 846 | static aom_codec_err_t ctrl_set_frame_periodic_boost(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 847 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 848 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 849 | extra_cfg.frame_periodic_boost = CAST(AV1E_SET_FRAME_PERIODIC_BOOST, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 850 | return update_extra_cfg(ctx, &extra_cfg); |
| 851 | } |
| 852 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 853 | static aom_codec_err_t encoder_init(aom_codec_ctx_t *ctx, |
| 854 | aom_codec_priv_enc_mr_cfg_t *data) { |
| 855 | aom_codec_err_t res = AOM_CODEC_OK; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 856 | (void)data; |
| 857 | |
| 858 | if (ctx->priv == NULL) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 859 | aom_codec_alg_priv_t *const priv = aom_calloc(1, sizeof(*priv)); |
| 860 | if (priv == NULL) return AOM_CODEC_MEM_ERROR; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 861 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 862 | ctx->priv = (aom_codec_priv_t *)priv; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 863 | ctx->priv->init_flags = ctx->init_flags; |
| 864 | ctx->priv->enc.total_encoders = 1; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 865 | priv->buffer_pool = (BufferPool *)aom_calloc(1, sizeof(BufferPool)); |
| 866 | if (priv->buffer_pool == NULL) return AOM_CODEC_MEM_ERROR; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 867 | |
| 868 | #if CONFIG_MULTITHREAD |
| 869 | if (pthread_mutex_init(&priv->buffer_pool->pool_mutex, NULL)) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 870 | return AOM_CODEC_MEM_ERROR; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 871 | } |
| 872 | #endif |
| 873 | |
| 874 | if (ctx->config.enc) { |
| 875 | // Update the reference to the config structure to an internal copy. |
| 876 | priv->cfg = *ctx->config.enc; |
| 877 | ctx->config.enc = &priv->cfg; |
| 878 | } |
| 879 | |
| 880 | priv->extra_cfg = default_extra_cfg; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 881 | once(av1_initialize_enc); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 882 | |
| 883 | res = validate_config(priv, &priv->cfg, &priv->extra_cfg); |
| 884 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 885 | if (res == AOM_CODEC_OK) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 886 | set_encoder_config(&priv->oxcf, &priv->cfg, &priv->extra_cfg); |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame^] | 887 | #if CONFIG_HIGHBITDEPTH |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 888 | priv->oxcf.use_highbitdepth = |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 889 | (ctx->init_flags & AOM_CODEC_USE_HIGHBITDEPTH) ? 1 : 0; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 890 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 891 | priv->cpi = av1_create_compressor(&priv->oxcf, priv->buffer_pool); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 892 | if (priv->cpi == NULL) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 893 | res = AOM_CODEC_MEM_ERROR; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 894 | else |
| 895 | priv->cpi->output_pkt_list = &priv->pkt_list.head; |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | return res; |
| 900 | } |
| 901 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 902 | static aom_codec_err_t encoder_destroy(aom_codec_alg_priv_t *ctx) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 903 | free(ctx->cx_data); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 904 | av1_remove_compressor(ctx->cpi); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 905 | #if CONFIG_MULTITHREAD |
| 906 | pthread_mutex_destroy(&ctx->buffer_pool->pool_mutex); |
| 907 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 908 | aom_free(ctx->buffer_pool); |
| 909 | aom_free(ctx); |
| 910 | return AOM_CODEC_OK; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 911 | } |
| 912 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 913 | static void pick_quickcompress_mode(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 914 | unsigned long deadline) { |
Thomas Daede | 6eca835 | 2017-03-17 14:14:12 -0700 | [diff] [blame] | 915 | MODE new_mode = GOOD; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 916 | |
| 917 | switch (ctx->cfg.g_pass) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 918 | case AOM_RC_ONE_PASS: |
Thomas Daede | ac0a380 | 2016-03-01 14:29:47 -0800 | [diff] [blame] | 919 | switch (deadline) { |
Thomas Daede | ac0a380 | 2016-03-01 14:29:47 -0800 | [diff] [blame] | 920 | case AOM_DL_REALTIME: new_mode = REALTIME; break; |
| 921 | default: new_mode = GOOD; break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 922 | } |
| 923 | break; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 924 | case AOM_RC_FIRST_PASS: break; |
Thomas Daede | 6eca835 | 2017-03-17 14:14:12 -0700 | [diff] [blame] | 925 | case AOM_RC_LAST_PASS: new_mode = GOOD; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 926 | } |
| 927 | |
| 928 | if (ctx->oxcf.mode != new_mode) { |
| 929 | ctx->oxcf.mode = new_mode; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 930 | av1_change_config(ctx->cpi, &ctx->oxcf); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 931 | } |
| 932 | } |
| 933 | |
| 934 | // Turn on to test if supplemental superframe data breaks decoding |
| 935 | // #define TEST_SUPPLEMENTAL_SUPERFRAME_DATA |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 936 | static int write_superframe_index(aom_codec_alg_priv_t *ctx) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 937 | uint8_t marker = 0xc0; |
| 938 | unsigned int mask; |
| 939 | int mag, index_sz; |
| 940 | int i; |
| 941 | size_t max_frame_sz = 0; |
| 942 | |
| 943 | assert(ctx->pending_frame_count); |
| 944 | assert(ctx->pending_frame_count <= 8); |
| 945 | |
| 946 | // Add the number of frames to the marker byte |
| 947 | marker |= ctx->pending_frame_count - 1; |
| 948 | for (i = 0; i < ctx->pending_frame_count - 1; i++) { |
| 949 | const size_t frame_sz = (unsigned int)ctx->pending_frame_sizes[i] - 1; |
| 950 | max_frame_sz = frame_sz > max_frame_sz ? frame_sz : max_frame_sz; |
| 951 | } |
| 952 | |
| 953 | // Choose the magnitude |
| 954 | for (mag = 0, mask = 0xff; mag < 4; mag++) { |
| 955 | if (max_frame_sz <= mask) break; |
| 956 | mask <<= 8; |
| 957 | mask |= 0xff; |
| 958 | } |
| 959 | marker |= mag << 3; |
| 960 | |
| 961 | // Write the index |
| 962 | index_sz = 2 + (mag + 1) * (ctx->pending_frame_count - 1); |
| 963 | if (ctx->pending_cx_data_sz + index_sz < ctx->cx_data_sz) { |
| 964 | uint8_t *x = ctx->pending_cx_data + ctx->pending_cx_data_sz; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 965 | #ifdef TEST_SUPPLEMENTAL_SUPERFRAME_DATA |
| 966 | uint8_t marker_test = 0xc0; |
| 967 | int mag_test = 2; // 1 - 4 |
| 968 | int frames_test = 4; // 1 - 8 |
| 969 | int index_sz_test = 2 + mag_test * frames_test; |
| 970 | marker_test |= frames_test - 1; |
| 971 | marker_test |= (mag_test - 1) << 3; |
| 972 | *x++ = marker_test; |
| 973 | for (i = 0; i < mag_test * frames_test; ++i) |
| 974 | *x++ = 0; // fill up with arbitrary data |
| 975 | *x++ = marker_test; |
| 976 | ctx->pending_cx_data_sz += index_sz_test; |
| 977 | printf("Added supplemental superframe data\n"); |
| 978 | #endif |
| 979 | |
| 980 | *x++ = marker; |
| 981 | for (i = 0; i < ctx->pending_frame_count - 1; i++) { |
| 982 | unsigned int this_sz; |
Urvang Joshi | 368fbc9 | 2016-10-17 16:31:34 -0700 | [diff] [blame] | 983 | int j; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 984 | |
| 985 | assert(ctx->pending_frame_sizes[i] > 0); |
| 986 | this_sz = (unsigned int)ctx->pending_frame_sizes[i] - 1; |
| 987 | for (j = 0; j <= mag; j++) { |
| 988 | *x++ = this_sz & 0xff; |
| 989 | this_sz >>= 8; |
| 990 | } |
| 991 | } |
| 992 | *x++ = marker; |
| 993 | ctx->pending_cx_data_sz += index_sz; |
| 994 | #ifdef TEST_SUPPLEMENTAL_SUPERFRAME_DATA |
| 995 | index_sz += index_sz_test; |
| 996 | #endif |
| 997 | } |
| 998 | return index_sz; |
| 999 | } |
| 1000 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1001 | // av1 uses 10,000,000 ticks/second as time stamp |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1002 | #define TICKS_PER_SEC 10000000LL |
| 1003 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1004 | static int64_t timebase_units_to_ticks(const aom_rational_t *timebase, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1005 | int64_t n) { |
| 1006 | return n * TICKS_PER_SEC * timebase->num / timebase->den; |
| 1007 | } |
| 1008 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1009 | static int64_t ticks_to_timebase_units(const aom_rational_t *timebase, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1010 | int64_t n) { |
| 1011 | const int64_t round = TICKS_PER_SEC * timebase->num / 2 - 1; |
| 1012 | return (n * timebase->den + round) / timebase->num / TICKS_PER_SEC; |
| 1013 | } |
| 1014 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1015 | static aom_codec_frame_flags_t get_frame_pkt_flags(const AV1_COMP *cpi, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1016 | unsigned int lib_flags) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1017 | aom_codec_frame_flags_t flags = lib_flags << 16; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1018 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1019 | if (lib_flags & FRAMEFLAGS_KEY) flags |= AOM_FRAME_IS_KEY; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1020 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1021 | if (cpi->droppable) flags |= AOM_FRAME_IS_DROPPABLE; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1022 | |
| 1023 | return flags; |
| 1024 | } |
| 1025 | |
Yaowu Xu | 416b0d9 | 2016-07-11 11:38:53 -0700 | [diff] [blame] | 1026 | const size_t kMinCompressedSize = 8192; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1027 | static aom_codec_err_t encoder_encode(aom_codec_alg_priv_t *ctx, |
| 1028 | const aom_image_t *img, |
| 1029 | aom_codec_pts_t pts, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1030 | unsigned long duration, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1031 | aom_enc_frame_flags_t enc_flags, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1032 | unsigned long deadline) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1033 | volatile aom_codec_err_t res = AOM_CODEC_OK; |
| 1034 | volatile aom_enc_frame_flags_t flags = enc_flags; |
| 1035 | AV1_COMP *const cpi = ctx->cpi; |
| 1036 | const aom_rational_t *const timebase = &ctx->cfg.g_timebase; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1037 | size_t data_sz; |
| 1038 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1039 | if (cpi == NULL) return AOM_CODEC_INVALID_PARAM; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1040 | |
| 1041 | if (img != NULL) { |
| 1042 | res = validate_img(ctx, img); |
| 1043 | // TODO(jzern) the checks related to cpi's validity should be treated as a |
| 1044 | // failure condition, encoder setup is done fully in init() currently. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1045 | if (res == AOM_CODEC_OK) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1046 | #if CONFIG_EXT_REFS |
Yaowu Xu | abc7d81 | 2016-07-12 11:57:51 -0700 | [diff] [blame] | 1047 | data_sz = ALIGN_POWER_OF_TWO(ctx->cfg.g_w, 5) * |
| 1048 | ALIGN_POWER_OF_TWO(ctx->cfg.g_h, 5) * get_image_bps(img); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1049 | #else |
| 1050 | // There's no codec control for multiple alt-refs so check the encoder |
| 1051 | // instance for its status to determine the compressed data size. |
Yaowu Xu | abc7d81 | 2016-07-12 11:57:51 -0700 | [diff] [blame] | 1052 | data_sz = ALIGN_POWER_OF_TWO(ctx->cfg.g_w, 5) * |
| 1053 | ALIGN_POWER_OF_TWO(ctx->cfg.g_h, 5) * get_image_bps(img) / 8 * |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1054 | (cpi->multi_arf_allowed ? 8 : 2); |
| 1055 | #endif // CONFIG_EXT_REFS |
Yaowu Xu | 416b0d9 | 2016-07-11 11:38:53 -0700 | [diff] [blame] | 1056 | if (data_sz < kMinCompressedSize) data_sz = kMinCompressedSize; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1057 | if (ctx->cx_data == NULL || ctx->cx_data_sz < data_sz) { |
| 1058 | ctx->cx_data_sz = data_sz; |
| 1059 | free(ctx->cx_data); |
| 1060 | ctx->cx_data = (unsigned char *)malloc(ctx->cx_data_sz); |
| 1061 | if (ctx->cx_data == NULL) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1062 | return AOM_CODEC_MEM_ERROR; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1063 | } |
| 1064 | } |
| 1065 | } |
| 1066 | } |
| 1067 | |
Thomas Daede | ac0a380 | 2016-03-01 14:29:47 -0800 | [diff] [blame] | 1068 | pick_quickcompress_mode(ctx, deadline); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1069 | aom_codec_pkt_list_init(&ctx->pkt_list); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1070 | |
| 1071 | // Handle Flags |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1072 | if (((flags & AOM_EFLAG_NO_UPD_GF) && (flags & AOM_EFLAG_FORCE_GF)) || |
| 1073 | ((flags & AOM_EFLAG_NO_UPD_ARF) && (flags & AOM_EFLAG_FORCE_ARF))) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1074 | ctx->base.err_detail = "Conflicting flags."; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1075 | return AOM_CODEC_INVALID_PARAM; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1076 | } |
| 1077 | |
| 1078 | if (setjmp(cpi->common.error.jmp)) { |
| 1079 | cpi->common.error.setjmp = 0; |
| 1080 | res = update_error_state(ctx, &cpi->common.error); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1081 | aom_clear_system_state(); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1082 | return res; |
| 1083 | } |
| 1084 | cpi->common.error.setjmp = 1; |
| 1085 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1086 | av1_apply_encoding_flags(cpi, flags); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1087 | |
| 1088 | // Handle fixed keyframe intervals |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1089 | if (ctx->cfg.kf_mode == AOM_KF_AUTO && |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1090 | ctx->cfg.kf_min_dist == ctx->cfg.kf_max_dist) { |
| 1091 | if (++ctx->fixed_kf_cntr > ctx->cfg.kf_min_dist) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1092 | flags |= AOM_EFLAG_FORCE_KF; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1093 | ctx->fixed_kf_cntr = 1; |
| 1094 | } |
| 1095 | } |
| 1096 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1097 | if (res == AOM_CODEC_OK) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1098 | unsigned int lib_flags = 0; |
| 1099 | YV12_BUFFER_CONFIG sd; |
| 1100 | int64_t dst_time_stamp = timebase_units_to_ticks(timebase, pts); |
| 1101 | int64_t dst_end_time_stamp = |
| 1102 | timebase_units_to_ticks(timebase, pts + duration); |
| 1103 | size_t size, cx_data_sz; |
| 1104 | unsigned char *cx_data; |
| 1105 | |
| 1106 | // Set up internal flags |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1107 | if (ctx->base.init_flags & AOM_CODEC_USE_PSNR) cpi->b_calculate_psnr = 1; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1108 | |
| 1109 | if (img != NULL) { |
| 1110 | res = image2yuvconfig(img, &sd); |
| 1111 | |
| 1112 | // Store the original flags in to the frame buffer. Will extract the |
| 1113 | // key frame flag when we actually encode this frame. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1114 | if (av1_receive_raw_frame(cpi, flags | ctx->next_frame_flags, &sd, |
| 1115 | dst_time_stamp, dst_end_time_stamp)) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1116 | res = update_error_state(ctx, &cpi->common.error); |
| 1117 | } |
| 1118 | ctx->next_frame_flags = 0; |
| 1119 | } |
| 1120 | |
| 1121 | cx_data = ctx->cx_data; |
| 1122 | cx_data_sz = ctx->cx_data_sz; |
| 1123 | |
| 1124 | /* Any pending invisible frames? */ |
| 1125 | if (ctx->pending_cx_data) { |
| 1126 | memmove(cx_data, ctx->pending_cx_data, ctx->pending_cx_data_sz); |
| 1127 | ctx->pending_cx_data = cx_data; |
| 1128 | cx_data += ctx->pending_cx_data_sz; |
| 1129 | cx_data_sz -= ctx->pending_cx_data_sz; |
| 1130 | |
| 1131 | /* TODO: this is a minimal check, the underlying codec doesn't respect |
| 1132 | * the buffer size anyway. |
| 1133 | */ |
| 1134 | if (cx_data_sz < ctx->cx_data_sz / 2) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1135 | aom_internal_error(&cpi->common.error, AOM_CODEC_ERROR, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1136 | "Compressed data buffer too small"); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1137 | return AOM_CODEC_ERROR; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1138 | } |
| 1139 | } |
| 1140 | |
| 1141 | while (cx_data_sz >= ctx->cx_data_sz / 2 && |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1142 | -1 != av1_get_compressed_data(cpi, &lib_flags, &size, cx_data, |
| 1143 | &dst_time_stamp, &dst_end_time_stamp, |
| 1144 | !img)) { |
Arild Fuldseth (arilfuld) | 5114b7b | 2016-11-09 13:32:54 +0100 | [diff] [blame] | 1145 | #if CONFIG_REFERENCE_BUFFER |
| 1146 | if (cpi->common.invalid_delta_frame_id_minus1) { |
| 1147 | ctx->base.err_detail = "Invalid delta_frame_id_minus1"; |
| 1148 | return AOM_CODEC_ERROR; |
| 1149 | } |
| 1150 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1151 | if (size) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1152 | aom_codec_cx_pkt_t pkt; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1153 | |
| 1154 | // Pack invisible frames with the next visible frame |
| 1155 | if (!cpi->common.show_frame) { |
| 1156 | if (ctx->pending_cx_data == 0) ctx->pending_cx_data = cx_data; |
| 1157 | ctx->pending_cx_data_sz += size; |
| 1158 | ctx->pending_frame_sizes[ctx->pending_frame_count++] = size; |
| 1159 | cx_data += size; |
| 1160 | cx_data_sz -= size; |
| 1161 | |
| 1162 | continue; |
| 1163 | } |
| 1164 | |
| 1165 | // Add the frame packet to the list of returned packets. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1166 | pkt.kind = AOM_CODEC_CX_FRAME_PKT; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1167 | pkt.data.frame.pts = ticks_to_timebase_units(timebase, dst_time_stamp); |
| 1168 | pkt.data.frame.duration = (unsigned long)ticks_to_timebase_units( |
| 1169 | timebase, dst_end_time_stamp - dst_time_stamp); |
| 1170 | pkt.data.frame.flags = get_frame_pkt_flags(cpi, lib_flags); |
| 1171 | |
| 1172 | if (ctx->pending_cx_data) { |
| 1173 | ctx->pending_frame_sizes[ctx->pending_frame_count++] = size; |
| 1174 | ctx->pending_cx_data_sz += size; |
| 1175 | size += write_superframe_index(ctx); |
| 1176 | pkt.data.frame.buf = ctx->pending_cx_data; |
| 1177 | pkt.data.frame.sz = ctx->pending_cx_data_sz; |
| 1178 | ctx->pending_cx_data = NULL; |
| 1179 | ctx->pending_cx_data_sz = 0; |
| 1180 | ctx->pending_frame_count = 0; |
| 1181 | } else { |
| 1182 | pkt.data.frame.buf = cx_data; |
| 1183 | pkt.data.frame.sz = size; |
| 1184 | } |
| 1185 | pkt.data.frame.partition_id = -1; |
| 1186 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1187 | aom_codec_pkt_list_add(&ctx->pkt_list.head, &pkt); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1188 | |
| 1189 | cx_data += size; |
| 1190 | cx_data_sz -= size; |
| 1191 | } |
| 1192 | } |
| 1193 | } |
| 1194 | |
| 1195 | cpi->common.error.setjmp = 0; |
| 1196 | return res; |
| 1197 | } |
| 1198 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1199 | static const aom_codec_cx_pkt_t *encoder_get_cxdata(aom_codec_alg_priv_t *ctx, |
| 1200 | aom_codec_iter_t *iter) { |
| 1201 | return aom_codec_pkt_list_get(&ctx->pkt_list.head, iter); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1202 | } |
| 1203 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1204 | static aom_codec_err_t ctrl_set_reference(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1205 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1206 | aom_ref_frame_t *const frame = va_arg(args, aom_ref_frame_t *); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1207 | |
| 1208 | if (frame != NULL) { |
| 1209 | YV12_BUFFER_CONFIG sd; |
| 1210 | |
| 1211 | image2yuvconfig(&frame->img, &sd); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1212 | av1_set_reference_enc(ctx->cpi, ref_frame_to_av1_reframe(frame->frame_type), |
| 1213 | &sd); |
| 1214 | return AOM_CODEC_OK; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1215 | } else { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1216 | return AOM_CODEC_INVALID_PARAM; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1217 | } |
| 1218 | } |
| 1219 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1220 | static aom_codec_err_t ctrl_copy_reference(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1221 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1222 | aom_ref_frame_t *const frame = va_arg(args, aom_ref_frame_t *); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1223 | |
| 1224 | if (frame != NULL) { |
| 1225 | YV12_BUFFER_CONFIG sd; |
| 1226 | |
| 1227 | image2yuvconfig(&frame->img, &sd); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1228 | av1_copy_reference_enc(ctx->cpi, |
| 1229 | ref_frame_to_av1_reframe(frame->frame_type), &sd); |
| 1230 | return AOM_CODEC_OK; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1231 | } else { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1232 | return AOM_CODEC_INVALID_PARAM; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1233 | } |
| 1234 | } |
| 1235 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1236 | static aom_codec_err_t ctrl_get_reference(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1237 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1238 | av1_ref_frame_t *const frame = va_arg(args, av1_ref_frame_t *); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1239 | |
| 1240 | if (frame != NULL) { |
| 1241 | YV12_BUFFER_CONFIG *fb = get_ref_frame(&ctx->cpi->common, frame->idx); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1242 | if (fb == NULL) return AOM_CODEC_ERROR; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1243 | |
| 1244 | yuvconfig2image(&frame->img, fb, NULL); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1245 | return AOM_CODEC_OK; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1246 | } else { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1247 | return AOM_CODEC_INVALID_PARAM; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1248 | } |
| 1249 | } |
| 1250 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1251 | static aom_codec_err_t ctrl_get_new_frame_image(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1252 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1253 | aom_image_t *const new_img = va_arg(args, aom_image_t *); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1254 | |
| 1255 | if (new_img != NULL) { |
| 1256 | YV12_BUFFER_CONFIG new_frame; |
| 1257 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1258 | if (av1_get_last_show_frame(ctx->cpi, &new_frame) == 0) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1259 | yuvconfig2image(new_img, &new_frame, NULL); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1260 | return AOM_CODEC_OK; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1261 | } else { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1262 | return AOM_CODEC_ERROR; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1263 | } |
| 1264 | } else { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1265 | return AOM_CODEC_INVALID_PARAM; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1266 | } |
| 1267 | } |
| 1268 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1269 | static aom_codec_err_t ctrl_set_previewpp(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1270 | va_list args) { |
| 1271 | (void)ctx; |
| 1272 | (void)args; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1273 | return AOM_CODEC_INCAPABLE; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1274 | } |
| 1275 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1276 | static aom_image_t *encoder_get_preview(aom_codec_alg_priv_t *ctx) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1277 | YV12_BUFFER_CONFIG sd; |
| 1278 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1279 | if (av1_get_preview_raw_frame(ctx->cpi, &sd) == 0) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1280 | yuvconfig2image(&ctx->preview_img, &sd, NULL); |
| 1281 | return &ctx->preview_img; |
| 1282 | } else { |
| 1283 | return NULL; |
| 1284 | } |
| 1285 | } |
| 1286 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1287 | static aom_codec_err_t ctrl_use_reference(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1288 | va_list args) { |
| 1289 | const int reference_flag = va_arg(args, int); |
| 1290 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1291 | av1_use_as_reference(ctx->cpi, reference_flag); |
| 1292 | return AOM_CODEC_OK; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1293 | } |
| 1294 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1295 | static aom_codec_err_t ctrl_set_roi_map(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1296 | va_list args) { |
| 1297 | (void)ctx; |
| 1298 | (void)args; |
| 1299 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1300 | // TODO(yaowu): Need to re-implement and test for AV1. |
| 1301 | return AOM_CODEC_INVALID_PARAM; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1302 | } |
| 1303 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1304 | static aom_codec_err_t ctrl_set_active_map(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1305 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1306 | aom_active_map_t *const map = va_arg(args, aom_active_map_t *); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1307 | |
| 1308 | if (map) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1309 | if (!av1_set_active_map(ctx->cpi, map->active_map, (int)map->rows, |
| 1310 | (int)map->cols)) |
| 1311 | return AOM_CODEC_OK; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1312 | else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1313 | return AOM_CODEC_INVALID_PARAM; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1314 | } else { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1315 | return AOM_CODEC_INVALID_PARAM; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1316 | } |
| 1317 | } |
| 1318 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1319 | static aom_codec_err_t ctrl_get_active_map(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1320 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1321 | aom_active_map_t *const map = va_arg(args, aom_active_map_t *); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1322 | |
| 1323 | if (map) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1324 | if (!av1_get_active_map(ctx->cpi, map->active_map, (int)map->rows, |
| 1325 | (int)map->cols)) |
| 1326 | return AOM_CODEC_OK; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1327 | else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1328 | return AOM_CODEC_INVALID_PARAM; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1329 | } else { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1330 | return AOM_CODEC_INVALID_PARAM; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1331 | } |
| 1332 | } |
| 1333 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1334 | static aom_codec_err_t ctrl_set_scale_mode(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1335 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1336 | aom_scaling_mode_t *const mode = va_arg(args, aom_scaling_mode_t *); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1337 | |
| 1338 | if (mode) { |
| 1339 | const int res = |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1340 | av1_set_internal_size(ctx->cpi, (AOM_SCALING)mode->h_scaling_mode, |
| 1341 | (AOM_SCALING)mode->v_scaling_mode); |
| 1342 | return (res == 0) ? AOM_CODEC_OK : AOM_CODEC_INVALID_PARAM; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1343 | } else { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1344 | return AOM_CODEC_INVALID_PARAM; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1345 | } |
| 1346 | } |
| 1347 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1348 | static aom_codec_err_t ctrl_set_tune_content(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1349 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1350 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 1351 | extra_cfg.content = CAST(AV1E_SET_TUNE_CONTENT, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1352 | return update_extra_cfg(ctx, &extra_cfg); |
| 1353 | } |
| 1354 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1355 | static aom_codec_err_t ctrl_set_color_space(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1356 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1357 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 1358 | extra_cfg.color_space = CAST(AV1E_SET_COLOR_SPACE, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1359 | return update_extra_cfg(ctx, &extra_cfg); |
| 1360 | } |
| 1361 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1362 | static aom_codec_err_t ctrl_set_color_range(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1363 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1364 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 1365 | extra_cfg.color_range = CAST(AV1E_SET_COLOR_RANGE, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1366 | return update_extra_cfg(ctx, &extra_cfg); |
| 1367 | } |
| 1368 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1369 | static aom_codec_err_t ctrl_set_render_size(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1370 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1371 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1372 | int *const render_size = va_arg(args, int *); |
| 1373 | extra_cfg.render_width = render_size[0]; |
| 1374 | extra_cfg.render_height = render_size[1]; |
| 1375 | return update_extra_cfg(ctx, &extra_cfg); |
| 1376 | } |
| 1377 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1378 | static aom_codec_err_t ctrl_set_superblock_size(aom_codec_alg_priv_t *ctx, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1379 | va_list args) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1380 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 1381 | extra_cfg.superblock_size = CAST(AV1E_SET_SUPERBLOCK_SIZE, args); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1382 | return update_extra_cfg(ctx, &extra_cfg); |
| 1383 | } |
| 1384 | |
Alex Converse | eb780e7 | 2016-12-13 12:46:41 -0800 | [diff] [blame] | 1385 | #if CONFIG_ANS && ANS_MAX_SYMBOLS |
| 1386 | static aom_codec_err_t ctrl_set_ans_window_size_log2(aom_codec_alg_priv_t *ctx, |
| 1387 | va_list args) { |
| 1388 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
| 1389 | extra_cfg.ans_window_size_log2 = CAST(AV1E_SET_ANS_WINDOW_SIZE_LOG2, args); |
| 1390 | return update_extra_cfg(ctx, &extra_cfg); |
| 1391 | } |
| 1392 | #endif |
| 1393 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1394 | static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = { |
| 1395 | { AOM_COPY_REFERENCE, ctrl_copy_reference }, |
| 1396 | { AOME_USE_REFERENCE, ctrl_use_reference }, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1397 | |
| 1398 | // Setters |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1399 | { AOM_SET_REFERENCE, ctrl_set_reference }, |
| 1400 | { AOM_SET_POSTPROC, ctrl_set_previewpp }, |
| 1401 | { AOME_SET_ROI_MAP, ctrl_set_roi_map }, |
| 1402 | { AOME_SET_ACTIVEMAP, ctrl_set_active_map }, |
| 1403 | { AOME_SET_SCALEMODE, ctrl_set_scale_mode }, |
| 1404 | { AOME_SET_CPUUSED, ctrl_set_cpuused }, |
| 1405 | { AOME_SET_ENABLEAUTOALTREF, ctrl_set_enable_auto_alt_ref }, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1406 | #if CONFIG_EXT_REFS |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1407 | { AOME_SET_ENABLEAUTOBWDREF, ctrl_set_enable_auto_bwd_ref }, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1408 | #endif // CONFIG_EXT_REFS |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1409 | { AOME_SET_SHARPNESS, ctrl_set_sharpness }, |
| 1410 | { AOME_SET_STATIC_THRESHOLD, ctrl_set_static_thresh }, |
| 1411 | { AV1E_SET_TILE_COLUMNS, ctrl_set_tile_columns }, |
| 1412 | { AV1E_SET_TILE_ROWS, ctrl_set_tile_rows }, |
Fangwen Fu | 7b9f2b3 | 2017-01-17 14:01:52 -0800 | [diff] [blame] | 1413 | #if CONFIG_DEPENDENT_HORZTILES |
| 1414 | { AV1E_SET_TILE_DEPENDENT_ROWS, ctrl_set_tile_dependent_rows }, |
| 1415 | #endif |
Ryan Lei | 9b02b0e | 2017-01-30 15:52:20 -0800 | [diff] [blame] | 1416 | #if CONFIG_LOOPFILTERING_ACROSS_TILES |
Ryan Lei | 7386eda | 2016-12-08 21:08:31 -0800 | [diff] [blame] | 1417 | { AV1E_SET_TILE_LOOPFILTER, ctrl_set_tile_loopfilter }, |
Ryan Lei | 9b02b0e | 2017-01-30 15:52:20 -0800 | [diff] [blame] | 1418 | #endif // CONFIG_LOOPFILTERING_ACROSS_TILES |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1419 | { AOME_SET_ARNR_MAXFRAMES, ctrl_set_arnr_max_frames }, |
| 1420 | { AOME_SET_ARNR_STRENGTH, ctrl_set_arnr_strength }, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1421 | { AOME_SET_TUNING, ctrl_set_tuning }, |
| 1422 | { AOME_SET_CQ_LEVEL, ctrl_set_cq_level }, |
| 1423 | { AOME_SET_MAX_INTRA_BITRATE_PCT, ctrl_set_rc_max_intra_bitrate_pct }, |
| 1424 | { AV1E_SET_MAX_INTER_BITRATE_PCT, ctrl_set_rc_max_inter_bitrate_pct }, |
| 1425 | { AV1E_SET_GF_CBR_BOOST_PCT, ctrl_set_rc_gf_cbr_boost_pct }, |
| 1426 | { AV1E_SET_LOSSLESS, ctrl_set_lossless }, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1427 | #if CONFIG_AOM_QM |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1428 | { AV1E_SET_ENABLE_QM, ctrl_set_enable_qm }, |
| 1429 | { AV1E_SET_QM_MIN, ctrl_set_qm_min }, |
| 1430 | { AV1E_SET_QM_MAX, ctrl_set_qm_max }, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1431 | #endif |
Thomas Davies | af6df17 | 2016-11-09 14:04:18 +0000 | [diff] [blame] | 1432 | #if CONFIG_TILE_GROUPS |
| 1433 | { AV1E_SET_NUM_TG, ctrl_set_num_tg }, |
| 1434 | { AV1E_SET_MTU, ctrl_set_mtu }, |
| 1435 | #endif |
Fangwen Fu | 8d164de | 2016-12-14 13:40:54 -0800 | [diff] [blame] | 1436 | #if CONFIG_TEMPMV_SIGNALING |
| 1437 | { AV1E_SET_DISABLE_TEMPMV, ctrl_set_disable_tempmv }, |
| 1438 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1439 | { AV1E_SET_FRAME_PARALLEL_DECODING, ctrl_set_frame_parallel_decoding_mode }, |
| 1440 | { AV1E_SET_AQ_MODE, ctrl_set_aq_mode }, |
| 1441 | { AV1E_SET_FRAME_PERIODIC_BOOST, ctrl_set_frame_periodic_boost }, |
| 1442 | { AV1E_SET_TUNE_CONTENT, ctrl_set_tune_content }, |
| 1443 | { AV1E_SET_COLOR_SPACE, ctrl_set_color_space }, |
| 1444 | { AV1E_SET_COLOR_RANGE, ctrl_set_color_range }, |
| 1445 | { AV1E_SET_NOISE_SENSITIVITY, ctrl_set_noise_sensitivity }, |
| 1446 | { AV1E_SET_MIN_GF_INTERVAL, ctrl_set_min_gf_interval }, |
| 1447 | { AV1E_SET_MAX_GF_INTERVAL, ctrl_set_max_gf_interval }, |
| 1448 | { AV1E_SET_RENDER_SIZE, ctrl_set_render_size }, |
| 1449 | { AV1E_SET_SUPERBLOCK_SIZE, ctrl_set_superblock_size }, |
Alex Converse | eb780e7 | 2016-12-13 12:46:41 -0800 | [diff] [blame] | 1450 | #if CONFIG_ANS && ANS_MAX_SYMBOLS |
| 1451 | { AV1E_SET_ANS_WINDOW_SIZE_LOG2, ctrl_set_ans_window_size_log2 }, |
| 1452 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1453 | |
| 1454 | // Getters |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1455 | { AOME_GET_LAST_QUANTIZER, ctrl_get_quantizer }, |
| 1456 | { AOME_GET_LAST_QUANTIZER_64, ctrl_get_quantizer64 }, |
| 1457 | { AV1_GET_REFERENCE, ctrl_get_reference }, |
| 1458 | { AV1E_GET_ACTIVEMAP, ctrl_get_active_map }, |
| 1459 | { AV1_GET_NEW_FRAME_IMAGE, ctrl_get_new_frame_image }, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1460 | |
| 1461 | { -1, NULL }, |
| 1462 | }; |
| 1463 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1464 | static aom_codec_enc_cfg_map_t encoder_usage_cfg_map[] = { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1465 | { 0, |
| 1466 | { |
| 1467 | // NOLINT |
| 1468 | 0, // g_usage |
| 1469 | 8, // g_threads |
| 1470 | 0, // g_profile |
| 1471 | |
| 1472 | 320, // g_width |
| 1473 | 240, // g_height |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1474 | AOM_BITS_8, // g_bit_depth |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1475 | 8, // g_input_bit_depth |
| 1476 | |
| 1477 | { 1, 30 }, // g_timebase |
| 1478 | |
| 1479 | 0, // g_error_resilient |
| 1480 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1481 | AOM_RC_ONE_PASS, // g_pass |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1482 | |
| 1483 | 25, // g_lag_in_frames |
| 1484 | |
| 1485 | 0, // rc_dropframe_thresh |
| 1486 | 0, // rc_resize_allowed |
| 1487 | 0, // rc_scaled_width |
| 1488 | 0, // rc_scaled_height |
| 1489 | 60, // rc_resize_down_thresold |
| 1490 | 30, // rc_resize_up_thresold |
| 1491 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1492 | AOM_VBR, // rc_end_usage |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1493 | { NULL, 0 }, // rc_twopass_stats_in |
| 1494 | { NULL, 0 }, // rc_firstpass_mb_stats_in |
| 1495 | 256, // rc_target_bandwidth |
| 1496 | 0, // rc_min_quantizer |
| 1497 | 63, // rc_max_quantizer |
| 1498 | 25, // rc_undershoot_pct |
| 1499 | 25, // rc_overshoot_pct |
| 1500 | |
| 1501 | 6000, // rc_max_buffer_size |
| 1502 | 4000, // rc_buffer_initial_size |
| 1503 | 5000, // rc_buffer_optimal_size |
| 1504 | |
| 1505 | 50, // rc_two_pass_vbrbias |
| 1506 | 0, // rc_two_pass_vbrmin_section |
| 1507 | 2000, // rc_two_pass_vbrmax_section |
| 1508 | |
| 1509 | // keyframing settings (kf) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1510 | AOM_KF_AUTO, // g_kfmode |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1511 | 0, // kf_min_dist |
| 1512 | 9999, // kf_max_dist |
| 1513 | } }, |
| 1514 | }; |
| 1515 | |
| 1516 | #ifndef VERSION_STRING |
| 1517 | #define VERSION_STRING |
| 1518 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1519 | CODEC_INTERFACE(aom_codec_av1_cx) = { |
| 1520 | "AOMedia Project AV1 Encoder" VERSION_STRING, |
| 1521 | AOM_CODEC_INTERNAL_ABI_VERSION, |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame^] | 1522 | #if CONFIG_HIGHBITDEPTH |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1523 | AOM_CODEC_CAP_HIGHBITDEPTH | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1524 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1525 | AOM_CODEC_CAP_ENCODER | AOM_CODEC_CAP_PSNR, // aom_codec_caps_t |
| 1526 | encoder_init, // aom_codec_init_fn_t |
| 1527 | encoder_destroy, // aom_codec_destroy_fn_t |
| 1528 | encoder_ctrl_maps, // aom_codec_ctrl_fn_map_t |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1529 | { |
| 1530 | // NOLINT |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1531 | NULL, // aom_codec_peek_si_fn_t |
| 1532 | NULL, // aom_codec_get_si_fn_t |
| 1533 | NULL, // aom_codec_decode_fn_t |
| 1534 | NULL, // aom_codec_frame_get_fn_t |
| 1535 | NULL // aom_codec_set_fb_fn_t |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1536 | }, |
| 1537 | { |
| 1538 | // NOLINT |
| 1539 | 1, // 1 cfg map |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1540 | encoder_usage_cfg_map, // aom_codec_enc_cfg_map_t |
| 1541 | encoder_encode, // aom_codec_encode_fn_t |
| 1542 | encoder_get_cxdata, // aom_codec_get_cx_data_fn_t |
| 1543 | encoder_set_config, // aom_codec_enc_config_set_fn_t |
| 1544 | NULL, // aom_codec_get_global_headers_fn_t |
| 1545 | encoder_get_preview, // aom_codec_get_preview_frame_fn_t |
| 1546 | NULL // aom_codec_enc_mr_get_mem_loc_fn_t |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1547 | } |
| 1548 | }; |