26 #include "config_components.h"
28 #define VPX_DISABLE_CTRL_TYPECHECKS 1
29 #define VPX_CODEC_DISABLE_COMPAT 1
30 #include <vpx/vpx_encoder.h>
31 #include <vpx/vp8cx.h>
97 #define VP8F_ERROR_RESILIENT 0x00000001
98 #define VP8F_AUTO_ALT_REF 0x00000002
141 #if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
142 vpx_svc_ref_frame_config_t ref_frame_config;
148 [VP8E_SET_CPUUSED] =
"VP8E_SET_CPUUSED",
149 [VP8E_SET_ENABLEAUTOALTREF] =
"VP8E_SET_ENABLEAUTOALTREF",
150 [VP8E_SET_NOISE_SENSITIVITY] =
"VP8E_SET_NOISE_SENSITIVITY",
151 [VP8E_SET_STATIC_THRESHOLD] =
"VP8E_SET_STATIC_THRESHOLD",
152 [VP8E_SET_TOKEN_PARTITIONS] =
"VP8E_SET_TOKEN_PARTITIONS",
153 [VP8E_SET_ARNR_MAXFRAMES] =
"VP8E_SET_ARNR_MAXFRAMES",
154 [VP8E_SET_ARNR_STRENGTH] =
"VP8E_SET_ARNR_STRENGTH",
155 [VP8E_SET_ARNR_TYPE] =
"VP8E_SET_ARNR_TYPE",
156 [VP8E_SET_TUNING] =
"VP8E_SET_TUNING",
157 [VP8E_SET_CQ_LEVEL] =
"VP8E_SET_CQ_LEVEL",
158 [VP8E_SET_MAX_INTRA_BITRATE_PCT] =
"VP8E_SET_MAX_INTRA_BITRATE_PCT",
159 [VP8E_SET_SHARPNESS] =
"VP8E_SET_SHARPNESS",
160 [VP8E_SET_TEMPORAL_LAYER_ID] =
"VP8E_SET_TEMPORAL_LAYER_ID",
161 #if CONFIG_LIBVPX_VP9_ENCODER
162 [VP9E_SET_LOSSLESS] =
"VP9E_SET_LOSSLESS",
163 [VP9E_SET_TILE_COLUMNS] =
"VP9E_SET_TILE_COLUMNS",
164 [VP9E_SET_TILE_ROWS] =
"VP9E_SET_TILE_ROWS",
165 [VP9E_SET_FRAME_PARALLEL_DECODING] =
"VP9E_SET_FRAME_PARALLEL_DECODING",
166 [VP9E_SET_AQ_MODE] =
"VP9E_SET_AQ_MODE",
167 [VP9E_SET_COLOR_SPACE] =
"VP9E_SET_COLOR_SPACE",
168 [VP9E_SET_SVC_LAYER_ID] =
"VP9E_SET_SVC_LAYER_ID",
169 #if VPX_ENCODER_ABI_VERSION >= 12
170 [VP9E_SET_SVC_PARAMETERS] =
"VP9E_SET_SVC_PARAMETERS",
171 [VP9E_SET_SVC_REF_FRAME_CONFIG] =
"VP9E_SET_SVC_REF_FRAME_CONFIG",
173 [VP9E_SET_SVC] =
"VP9E_SET_SVC",
174 #if VPX_ENCODER_ABI_VERSION >= 11
175 [VP9E_SET_COLOR_RANGE] =
"VP9E_SET_COLOR_RANGE",
177 #if VPX_ENCODER_ABI_VERSION >= 12
178 [VP9E_SET_TARGET_LEVEL] =
"VP9E_SET_TARGET_LEVEL",
179 [VP9E_GET_LEVEL] =
"VP9E_GET_LEVEL",
181 #ifdef VPX_CTRL_VP9E_SET_ROW_MT
182 [VP9E_SET_ROW_MT] =
"VP9E_SET_ROW_MT",
184 #ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
185 [VP9E_SET_TUNE_CONTENT] =
"VP9E_SET_TUNE_CONTENT",
187 #ifdef VPX_CTRL_VP9E_SET_TPL
188 [VP9E_SET_TPL] =
"VP9E_SET_TPL",
190 #ifdef VPX_CTRL_VP9E_SET_MIN_GF_INTERVAL
191 [VP9E_SET_MIN_GF_INTERVAL] =
"VP9E_SET_MIN_GF_INTERVAL",
199 const char *
error = vpx_codec_error(&
ctx->encoder);
200 const char *detail = vpx_codec_error_detail(&
ctx->encoder);
208 const struct vpx_codec_enc_cfg *cfg,
216 " %*s%u\n %*s%u\n %*s%u\n %*s%u\n %*s%u\n"
217 #
if CONFIG_LIBVPX_VP9_ENCODER
220 " %*s{%u/%u}\n %*s%u\n %*s%d\n %*s%u\n",
221 width,
"g_usage:", cfg->g_usage,
222 width,
"g_threads:", cfg->g_threads,
223 width,
"g_profile:", cfg->g_profile,
224 width,
"g_w:", cfg->g_w,
225 width,
"g_h:", cfg->g_h,
226 #
if CONFIG_LIBVPX_VP9_ENCODER
227 width,
"g_bit_depth:", cfg->g_bit_depth,
228 width,
"g_input_bit_depth:", cfg->g_input_bit_depth,
230 width,
"g_timebase:", cfg->g_timebase.num, cfg->g_timebase.den,
231 width,
"g_error_resilient:", cfg->g_error_resilient,
232 width,
"g_pass:", cfg->g_pass,
233 width,
"g_lag_in_frames:", cfg->g_lag_in_frames);
235 " %*s%u\n %*s%u\n %*s%u\n %*s%u\n"
237 width,
"rc_dropframe_thresh:", cfg->rc_dropframe_thresh,
238 width,
"rc_resize_allowed:", cfg->rc_resize_allowed,
239 width,
"rc_resize_up_thresh:", cfg->rc_resize_up_thresh,
240 width,
"rc_resize_down_thresh:", cfg->rc_resize_down_thresh,
241 width,
"rc_end_usage:", cfg->rc_end_usage,
242 width,
"rc_twopass_stats_in:", cfg->rc_twopass_stats_in.buf, cfg->rc_twopass_stats_in.sz,
243 width,
"rc_target_bitrate:", cfg->rc_target_bitrate);
246 width,
"rc_min_quantizer:", cfg->rc_min_quantizer,
247 width,
"rc_max_quantizer:", cfg->rc_max_quantizer);
250 width,
"rc_undershoot_pct:", cfg->rc_undershoot_pct,
251 width,
"rc_overshoot_pct:", cfg->rc_overshoot_pct);
252 av_log(avctx,
level,
"temporal layering settings\n"
253 " %*s%u\n",
width,
"ts_number_layers:", cfg->ts_number_layers);
256 "\n %*s",
width,
"ts_target_bitrate:");
257 for (
i = 0;
i < VPX_TS_MAX_LAYERS;
i++)
259 "%u ", cfg->ts_target_bitrate[
i]);
261 #if (VPX_ENCODER_ABI_VERSION >= 12) && CONFIG_LIBVPX_VP9_ENCODER
264 "\n %*s",
width,
"layer_target_bitrate:");
265 for (
i = 0;
i < VPX_TS_MAX_LAYERS;
i++)
267 "%u ", cfg->layer_target_bitrate[
i]);
272 "\n %*s",
width,
"ts_rate_decimator:");
273 for (
i = 0;
i < VPX_TS_MAX_LAYERS;
i++)
277 "\n %*s%u\n",
width,
"ts_periodicity:", cfg->ts_periodicity);
279 "\n %*s",
width,
"ts_layer_id:");
280 for (
i = 0;
i < VPX_TS_MAX_PERIODICITY;
i++)
284 " %*s%u\n %*s%u\n %*s%u\n",
285 width,
"rc_buf_sz:", cfg->rc_buf_sz,
286 width,
"rc_buf_initial_sz:", cfg->rc_buf_initial_sz,
287 width,
"rc_buf_optimal_sz:", cfg->rc_buf_optimal_sz);
288 av_log(avctx,
level,
"2 pass rate control settings\n"
289 " %*s%u\n %*s%u\n %*s%u\n",
290 width,
"rc_2pass_vbr_bias_pct:", cfg->rc_2pass_vbr_bias_pct,
291 width,
"rc_2pass_vbr_minsection_pct:", cfg->rc_2pass_vbr_minsection_pct,
292 width,
"rc_2pass_vbr_maxsection_pct:", cfg->rc_2pass_vbr_maxsection_pct);
293 #if VPX_ENCODER_ABI_VERSION >= 14
295 width,
"rc_2pass_vbr_corpus_complexity:", cfg->rc_2pass_vbr_corpus_complexity);
298 " %*s%d\n %*s%u\n %*s%u\n",
299 width,
"kf_mode:", cfg->kf_mode,
300 width,
"kf_min_dist:", cfg->kf_min_dist,
301 width,
"kf_max_dist:", cfg->kf_max_dist);
362 enum vp8e_enc_control_id
id,
int val)
372 res = vpx_codec_control(&
ctx->encoder,
id,
val);
373 if (res != VPX_CODEC_OK) {
381 int res_alpha = vpx_codec_control(&
ctx->encoder_alpha,
id,
val);
382 if (res_alpha != VPX_CODEC_OK) {
383 snprintf(
buf,
sizeof(
buf),
"Failed to set %s alpha codec control",
393 #if VPX_ENCODER_ABI_VERSION >= 12
395 enum vp8e_enc_control_id
id,
int *
val)
405 res = vpx_codec_control(&
ctx->encoder,
id,
val);
406 if (res != VPX_CODEC_OK) {
414 int res_alpha = vpx_codec_control(&
ctx->encoder_alpha,
id,
val);
415 if (res_alpha != VPX_CODEC_OK) {
416 snprintf(
buf,
sizeof(
buf),
"Failed to set %s alpha codec control",
431 #if VPX_ENCODER_ABI_VERSION >= 12
435 if (!codecctl_intp(avctx, VP9E_GET_LEVEL, &level_out))
442 vpx_codec_destroy(&
ctx->encoder);
444 vpx_codec_destroy(&
ctx->encoder_alpha);
452 if (
ctx->hdr10_plus_fifo)
460 char *saveptr =
NULL;
463 while (token && dest_idx < max_entries) {
464 dest[dest_idx++] = strtoul(token,
NULL, 10);
469 #if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
470 static void vp8_ts_parse_int64_array(int64_t *dest,
char *
value,
size_t value_len,
int max_entries)
473 char *saveptr =
NULL;
476 while (token && dest_idx < max_entries) {
477 dest[dest_idx++] = strtoull(token,
NULL, 10);
484 int *layer_flags,
int *flag_periodicity)
486 switch (layering_mode) {
491 static const int ids[2] = { 0, 1 };
492 cfg->ts_periodicity = 2;
493 *flag_periodicity = 2;
494 cfg->ts_number_layers = 2;
495 cfg->ts_rate_decimator[0] = 2;
496 cfg->ts_rate_decimator[1] = 1;
497 memcpy(cfg->ts_layer_id, ids,
sizeof(ids));
500 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
501 VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
503 VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_GF |
504 VP8_EFLAG_NO_UPD_LAST |
505 VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_GF;
515 static const int ids[4] = { 0, 2, 1, 2 };
516 cfg->ts_periodicity = 4;
517 *flag_periodicity = 4;
518 cfg->ts_number_layers = 3;
519 cfg->ts_rate_decimator[0] = 4;
520 cfg->ts_rate_decimator[1] = 2;
521 cfg->ts_rate_decimator[2] = 1;
522 memcpy(cfg->ts_layer_id, ids,
sizeof(ids));
529 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
530 VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
532 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
533 VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
534 VP8_EFLAG_NO_UPD_ARF;
536 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
537 VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
539 VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_ARF |
540 VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
541 VP8_EFLAG_NO_UPD_ARF;
550 static const int ids[4] = { 0, 2, 1, 2 };
551 cfg->ts_periodicity = 4;
552 *flag_periodicity = 4;
553 cfg->ts_number_layers = 3;
554 cfg->ts_rate_decimator[0] = 4;
555 cfg->ts_rate_decimator[1] = 2;
556 cfg->ts_rate_decimator[2] = 1;
557 memcpy(cfg->ts_layer_id, ids,
sizeof(ids));
563 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
564 VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
566 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
567 VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF;
569 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
570 VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
572 VP8_EFLAG_NO_REF_LAST |
573 VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
574 VP8_EFLAG_NO_UPD_ARF;
590 size_t value_len = strlen(
value);
591 int ts_layering_mode = 0;
596 if (!strcmp(
key,
"ts_number_layers"))
597 enccfg->ts_number_layers = strtoul(
value, &
value, 10);
598 else if (!strcmp(
key,
"ts_target_bitrate")) {
601 #if (VPX_ENCODER_ABI_VERSION >= 12) && CONFIG_LIBVPX_VP9_ENCODER
605 }
else if (!strcmp(
key,
"ts_rate_decimator")) {
607 }
else if (!strcmp(
key,
"ts_periodicity")) {
608 enccfg->ts_periodicity = strtoul(
value, &
value, 10);
609 }
else if (!strcmp(
key,
"ts_layer_id")) {
611 }
else if (!strcmp(
key,
"ts_layering_mode")) {
616 #if (VPX_ENCODER_ABI_VERSION >= 12) && CONFIG_LIBVPX_VP9_ENCODER
617 enccfg->temporal_layering_mode = VP9E_TEMPORAL_LAYERING_MODE_BYPASS;
618 enccfg->ss_number_layers = 1;
620 if (ts_layering_mode) {
630 #if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
631 static int vpx_ref_frame_config_set_value(vpx_svc_ref_frame_config_t *ref_frame_config,
632 int ss_number_layers,
char *
key,
char *
value)
634 size_t value_len = strlen(
value);
639 if (!strcmp(
key,
"rfc_update_buffer_slot")) {
641 }
else if (!strcmp(
key,
"rfc_update_last")) {
643 }
else if (!strcmp(
key,
"rfc_update_golden")) {
645 }
else if (!strcmp(
key,
"rfc_update_alt_ref")) {
647 }
else if (!strcmp(
key,
"rfc_lst_fb_idx")) {
649 }
else if (!strcmp(
key,
"rfc_gld_fb_idx")) {
651 }
else if (!strcmp(
key,
"rfc_alt_fb_idx")) {
653 }
else if (!strcmp(
key,
"rfc_reference_last")) {
655 }
else if (!strcmp(
key,
"rfc_reference_golden")) {
657 }
else if (!strcmp(
key,
"rfc_reference_alt_ref")) {
659 }
else if (!strcmp(
key,
"rfc_reference_duration")) {
660 vp8_ts_parse_int64_array(ref_frame_config->duration,
value, value_len, ss_number_layers);
666 static int vpx_parse_ref_frame_config_element(vpx_svc_ref_frame_config_t *ref_frame_config,
667 int ss_number_layers,
const char **
buf)
669 const char key_val_sep[] =
"=";
670 const char pairs_sep[] =
":";
675 if (
key && *
key && strspn(*
buf, key_val_sep)) {
681 ret = vpx_ref_frame_config_set_value(ref_frame_config, ss_number_layers,
key,
val);
691 static int vpx_parse_ref_frame_config(vpx_svc_ref_frame_config_t *ref_frame_config,
692 int ss_number_layers,
const char *
str)
698 vpx_parse_ref_frame_config_element(ref_frame_config, ss_number_layers, &
str);
710 #if CONFIG_LIBVPX_VP9_ENCODER
712 struct vpx_codec_enc_cfg *enccfg, vpx_codec_flags_t *
flags,
713 vpx_img_fmt_t *img_fmt)
717 enccfg->g_bit_depth = enccfg->g_input_bit_depth =
desc->comp[0].depth;
721 enccfg->g_profile = 0;
722 *img_fmt = VPX_IMG_FMT_I420;
725 enccfg->g_profile = 1;
726 *img_fmt = VPX_IMG_FMT_I422;
729 enccfg->g_profile = 1;
730 *img_fmt = VPX_IMG_FMT_I440;
733 ctx->vpx_cs = VPX_CS_SRGB;
735 enccfg->g_profile = 1;
736 *img_fmt = VPX_IMG_FMT_I444;
740 if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) {
741 enccfg->g_profile = 2;
742 *img_fmt = VPX_IMG_FMT_I42016;
743 *
flags |= VPX_CODEC_USE_HIGHBITDEPTH;
749 if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) {
750 enccfg->g_profile = 3;
751 *img_fmt = VPX_IMG_FMT_I42216;
752 *
flags |= VPX_CODEC_USE_HIGHBITDEPTH;
758 if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) {
759 enccfg->g_profile = 3;
760 *img_fmt = VPX_IMG_FMT_I44016;
761 *
flags |= VPX_CODEC_USE_HIGHBITDEPTH;
767 ctx->vpx_cs = VPX_CS_SRGB;
770 if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) {
771 enccfg->g_profile = 3;
772 *img_fmt = VPX_IMG_FMT_I44416;
773 *
flags |= VPX_CODEC_USE_HIGHBITDEPTH;
786 enum vpx_color_space vpx_cs;
790 vpx_cs =
ctx->vpx_cs;
810 #if VPX_ENCODER_ABI_VERSION >= 11
813 enum vpx_color_range vpx_cr;
833 struct vpx_codec_enc_cfg *enccfg)
837 avctx->
bit_rate = enccfg->rc_target_bitrate * 1000;
838 if (enccfg->rc_end_usage == VPX_CQ) {
840 "Bitrate not specified for constrained quality mode, using default of %dkbit/sec\n",
841 enccfg->rc_target_bitrate);
843 enccfg->rc_end_usage = VPX_CQ;
846 "Neither bitrate nor constrained quality specified, using default CRF of %d and bitrate of %dkbit/sec\n",
847 ctx->crf, enccfg->rc_target_bitrate);
852 #if CONFIG_LIBVPX_VP9_ENCODER
858 struct vpx_codec_enc_cfg *enccfg)
862 if (enccfg->rc_end_usage != VPX_Q &&
ctx->lossless < 0) {
863 enccfg->rc_end_usage = VPX_Q;
866 "Neither bitrate nor constrained quality specified, using default CRF of %d\n",
877 struct vpx_codec_enc_cfg *enccfg)
880 #if CONFIG_LIBVPX_VP9_ENCODER
882 set_vp9_defaults(avctx, enccfg);
890 const struct vpx_codec_iface *iface)
893 struct vpx_codec_enc_cfg enccfg = { 0 };
894 struct vpx_codec_enc_cfg enccfg_alpha;
898 vpx_img_fmt_t img_fmt = VPX_IMG_FMT_I420;
899 #if CONFIG_LIBVPX_VP9_ENCODER
900 vpx_codec_caps_t codec_caps = vpx_codec_get_caps(iface);
901 vpx_svc_extra_cfg_t svc_params;
911 if ((res = vpx_codec_enc_config_default(iface, &enccfg, 0)) != VPX_CODEC_OK) {
913 vpx_codec_err_to_string(res));
917 #if CONFIG_LIBVPX_VP9_ENCODER
926 if (!
ctx->hdr10_plus_fifo)
940 enccfg.g_w = avctx->
width;
941 enccfg.g_h = avctx->
height;
946 enccfg.g_lag_in_frames=
ctx->lag_in_frames;
949 enccfg.g_pass = VPX_RC_FIRST_PASS;
951 enccfg.g_pass = VPX_RC_LAST_PASS;
953 enccfg.g_pass = VPX_RC_ONE_PASS;
957 enccfg.rc_end_usage = VPX_CBR;
958 }
else if (
ctx->crf >= 0) {
959 enccfg.rc_end_usage = VPX_CQ;
960 #if CONFIG_LIBVPX_VP9_ENCODER
962 enccfg.rc_end_usage = VPX_Q;
969 #if CONFIG_LIBVPX_VP9_ENCODER
970 enccfg.ss_target_bitrate[0] = enccfg.rc_target_bitrate;
978 enccfg.rc_min_quantizer =
979 enccfg.rc_max_quantizer = 0;
981 if (avctx->
qmin >= 0)
982 enccfg.rc_min_quantizer = avctx->
qmin;
983 if (avctx->
qmax >= 0)
984 enccfg.rc_max_quantizer = avctx->
qmax;
987 if (enccfg.rc_end_usage == VPX_CQ
988 #
if CONFIG_LIBVPX_VP9_ENCODER
989 || enccfg.rc_end_usage == VPX_Q
992 if (
ctx->crf < enccfg.rc_min_quantizer ||
ctx->crf > enccfg.rc_max_quantizer) {
994 "CQ level %d must be between minimum and maximum quantizer value (%d-%d)\n",
995 ctx->crf, enccfg.rc_min_quantizer, enccfg.rc_max_quantizer);
1000 enccfg.rc_dropframe_thresh =
ctx->drop_threshold;
1005 enccfg.rc_2pass_vbr_minsection_pct =
1008 enccfg.rc_2pass_vbr_maxsection_pct =
1010 #if CONFIG_LIBVPX_VP9_ENCODER
1012 #if VPX_ENCODER_ABI_VERSION >= 14
1013 if (
ctx->corpus_complexity >= 0)
1014 enccfg.rc_2pass_vbr_corpus_complexity =
ctx->corpus_complexity;
1023 enccfg.rc_buf_initial_sz =
1025 enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
1026 if (
ctx->rc_undershoot_pct >= 0)
1027 enccfg.rc_undershoot_pct =
ctx->rc_undershoot_pct;
1028 if (
ctx->rc_overshoot_pct >= 0)
1029 enccfg.rc_overshoot_pct =
ctx->rc_overshoot_pct;
1035 enccfg.kf_max_dist = avctx->
gop_size;
1037 if (enccfg.g_pass == VPX_RC_FIRST_PASS)
1038 enccfg.g_lag_in_frames = 0;
1039 else if (enccfg.g_pass == VPX_RC_LAST_PASS) {
1040 int decode_size,
ret;
1047 ctx->twopass_stats.sz = strlen(avctx->
stats_in) * 3 / 4;
1052 ctx->twopass_stats.sz);
1053 ctx->twopass_stats.sz = 0;
1057 ctx->twopass_stats.sz);
1058 if (decode_size < 0) {
1063 ctx->twopass_stats.sz = decode_size;
1064 enccfg.rc_twopass_stats_in =
ctx->twopass_stats;
1071 enccfg.g_profile = avctx->
profile;
1078 "Error parsing option '%s = %s'.\n",
1083 res = vpx_codec_enc_init(&
ctx->encoder, iface, &enccfg,
flags);
1084 if (res != VPX_CODEC_OK) {
1091 #if CONFIG_LIBVPX_VP9_ENCODER
1093 memset(&svc_params, 0,
sizeof(svc_params));
1094 for (
int i = 0;
i < enccfg.ts_number_layers; ++
i) {
1095 svc_params.max_quantizers[
i] = enccfg.rc_max_quantizer;
1096 svc_params.min_quantizers[
i] = enccfg.rc_min_quantizer;
1098 svc_params.scaling_factor_num[0] = enccfg.g_h;
1099 svc_params.scaling_factor_den[0] = enccfg.g_h;
1100 #if VPX_ENCODER_ABI_VERSION >= 12
1102 codecctl_intp(avctx, VP9E_SET_SVC_PARAMETERS, (
int *)&svc_params);
1106 if (
ctx->is_alpha) {
1107 enccfg_alpha = enccfg;
1108 res = vpx_codec_enc_init(&
ctx->encoder_alpha, iface, &enccfg_alpha,
flags);
1109 if (res != VPX_CODEC_OK) {
1119 ctx->auto_alt_ref = 1;
1120 if (
ctx->auto_alt_ref >= 0)
1123 if (
ctx->arnr_max_frames >= 0)
1125 if (
ctx->arnr_strength >= 0)
1127 if (
ctx->arnr_type >= 0)
1133 av_log(avctx,
AV_LOG_ERROR,
"Transparency encoding with auto_alt_ref does not work\n");
1137 if (
ctx->sharpness >= 0)
1141 codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY,
ctx->noise_sensitivity);
1147 if (
ctx->max_intra_rate >= 0)
1148 codecctl_int(avctx, VP8E_SET_MAX_INTRA_BITRATE_PCT,
ctx->max_intra_rate);
1150 #if CONFIG_LIBVPX_VP9_ENCODER
1152 if (
ctx->lossless >= 0)
1154 if (
ctx->tile_columns >= 0)
1156 if (
ctx->tile_rows >= 0)
1158 if (
ctx->frame_parallel >= 0)
1159 codecctl_int(avctx, VP9E_SET_FRAME_PARALLEL_DECODING,
ctx->frame_parallel);
1160 if (
ctx->aq_mode >= 0)
1162 set_colorspace(avctx);
1163 #if VPX_ENCODER_ABI_VERSION >= 11
1166 #if VPX_ENCODER_ABI_VERSION >= 12
1169 #ifdef VPX_CTRL_VP9E_SET_ROW_MT
1170 if (
ctx->row_mt >= 0)
1173 #ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
1174 if (
ctx->tune_content >= 0)
1177 #ifdef VPX_CTRL_VP9E_SET_TPL
1178 if (
ctx->tpl_model >= 0)
1181 #ifdef VPX_CTRL_VP9E_SET_MIN_GF_INTERVAL
1182 if (
ctx->min_gf_interval >= 0)
1191 vpx_img_wrap(&
ctx->rawimg, img_fmt, avctx->
width, avctx->
height, 1,
1193 #if CONFIG_LIBVPX_VP9_ENCODER
1195 ctx->rawimg.bit_depth = enccfg.g_bit_depth;
1202 if (enccfg.rc_end_usage == VPX_CBR ||
1203 enccfg.g_pass != VPX_RC_ONE_PASS) {
1214 const struct vpx_codec_cx_pkt *
src,
1217 dst->
pts =
src->data.frame.pts;
1219 dst->
flags =
src->data.frame.flags;
1220 dst->
sz =
src->data.frame.sz;
1221 dst->
buf =
src->data.frame.buf;
1224 if (!(dst->
flags & VPX_FRAME_IS_INVISIBLE)) {
1227 if (
ctx->have_sse) {
1232 memcpy(dst->
sse,
ctx->sse,
sizeof(dst->
sse));
1262 if (!!(cx_frame->
flags & VPX_FRAME_IS_KEY)) {
1269 ret = vpx_codec_control(&
ctx->encoder, VP8E_GET_LAST_QUANTIZER_64, &
quality);
1270 if (
ret != VPX_CODEC_OK)
1273 cx_frame->
have_sse ? 3 : 0, pict_type);
1277 for (
int i = 0;
i < 3; ++
i)
1281 if (alpha_cx_frame) {
1284 alpha_cx_frame->
sz + 8);
1290 memcpy(side_data + 8, alpha_cx_frame->
buf, alpha_cx_frame->
sz);
1293 if (
ctx->hdr10_plus_fifo) {
1315 const struct vpx_codec_cx_pkt *
pkt;
1316 const void *iter =
NULL;
1319 if (!
ctx->is_alpha && *frame_list) {
1325 *frame_list = cx_frame->
next;
1331 while (
pkt = vpx_codec_get_cx_data(encoder, &iter)) {
1332 switch (
pkt->kind) {
1333 case VPX_CODEC_CX_FRAME_PKT:
1334 if (!
ctx->is_alpha && !
size) {
1349 "Frame queue element alloc failed\n");
1355 if (!cx_frame->
buf) {
1366 case VPX_CODEC_STATS_PKT: {
1367 struct vpx_fixed_buf *
stats = &
ctx->twopass_stats;
1372 &
ctx->twopass_stats_size,
1387 case VPX_CODEC_PSNR_PKT:
1397 case VPX_CODEC_CUSTOM_PKT:
1407 vpx_roi_map_t *roi_map,
int block_size,
int segment_cnt)
1412 #define MAX_DELTA_Q 63
1427 memset(roi_map, 0,
sizeof(*roi_map));
1438 if (!self_size || sd->
size % self_size) {
1442 nb_rois = sd->
size / self_size;
1448 for (
int i = 0;
i < nb_rois;
i++) {
1462 if (!segment_mapping[mapping_index]) {
1463 if (segment_id == segment_cnt) {
1465 "ROI only supports %d segments (and segment 0 is reserved for non-ROIs), skipping the left ones.\n",
1470 segment_mapping[mapping_index] = segment_id + 1;
1471 roi_map->delta_q[segment_id] =
delta_q;
1476 roi_map->rows = (frame_height + block_size - 1) / block_size;
1477 roi_map->cols = (frame_width + block_size - 1) / block_size;
1478 roi_map->roi_map =
av_calloc(roi_map->rows * roi_map->cols,
sizeof(*roi_map->roi_map));
1479 if (!roi_map->roi_map) {
1487 for (
int i = nb_rois - 1;
i >= 0;
i--) {
1490 int starty, endy, startx, endx;
1494 starty =
av_clip(roi->
top / block_size, 0, roi_map->rows);
1495 endy =
av_clip((roi->
bottom + block_size - 1) / block_size, 0, roi_map->rows);
1496 startx =
av_clip(roi->
left / block_size, 0, roi_map->cols);
1497 endx =
av_clip((roi->
right + block_size - 1) / block_size, 0, roi_map->cols);
1503 if (mapping_value) {
1504 for (
int y = starty; y < endy; y++)
1505 for (
int x = startx; x < endx; x++)
1506 roi_map->roi_map[x + y * roi_map->cols] = mapping_value - 1;
1517 #ifdef VPX_CTRL_VP9E_SET_ROI_MAP
1518 int version = vpx_codec_version();
1521 int patch = VPX_VERSION_PATCH(
version);
1524 vpx_roi_map_t roi_map;
1525 const int segment_cnt = 8;
1526 const int block_size = 8;
1529 if (
ctx->aq_mode > 0 ||
ctx->cpu_used < 5 ||
ctx->deadline != VPX_DL_REALTIME) {
1530 if (!
ctx->roi_warned) {
1531 ctx->roi_warned = 1;
1533 "and deadline is REALTIME, so skipping ROI.\n");
1538 ret =
set_roi_map(avctx, sd, frame_width, frame_height, &roi_map, block_size, segment_cnt);
1544 memset(roi_map.ref_frame, -1,
sizeof(roi_map.ref_frame));
1546 if (vpx_codec_control(&
ctx->encoder, VP9E_SET_ROI_MAP, &roi_map)) {
1555 if (!
ctx->roi_warned) {
1556 ctx->roi_warned = 1;
1557 av_log(avctx,
AV_LOG_WARNING,
"ROI is not supported, please upgrade libvpx to version >= 1.8.1. "
1558 "You may need to rebuild ffmpeg.\n");
1565 vpx_roi_map_t roi_map;
1566 const int segment_cnt = 4;
1567 const int block_size = 16;
1570 int ret =
set_roi_map(avctx, sd, frame_width, frame_height, &roi_map, block_size, segment_cnt);
1576 if (vpx_codec_control(&
ctx->encoder, VP8E_SET_ROI_MAP, &roi_map)) {
1588 struct vpx_image *rawimg_alpha = &
ctx->rawimg_alpha;
1589 unsigned char **
planes = rawimg_alpha->planes;
1590 int *
stride = rawimg_alpha->stride;
1592 if (!
planes[VPX_PLANE_U] ||
1594 width != (
int)rawimg_alpha->d_w ||
1595 height != (
int)rawimg_alpha->d_h) {
1599 vpx_img_wrap(rawimg_alpha, VPX_IMG_FMT_I420,
width,
height, 1,
1617 struct vpx_image *rawimg =
NULL;
1618 struct vpx_image *rawimg_alpha =
NULL;
1619 int64_t timestamp = 0;
1620 int res, coded_size;
1621 vpx_enc_frame_flags_t
flags = 0;
1622 const struct vpx_codec_enc_cfg *enccfg =
ctx->encoder.config.enc;
1623 vpx_svc_layer_id_t layer_id;
1624 int layer_id_valid = 0;
1626 if (avctx->
qmax >= 0 && enccfg->rc_max_quantizer != avctx->
qmax) {
1627 struct vpx_codec_enc_cfg cfg = *enccfg;
1628 cfg.rc_max_quantizer = avctx->
qmax;
1629 res = vpx_codec_enc_config_set(&
ctx->encoder, &cfg);
1630 if (res != VPX_CODEC_OK) {
1638 rawimg = &
ctx->rawimg;
1639 rawimg->planes[VPX_PLANE_Y] =
frame->data[0];
1640 rawimg->planes[VPX_PLANE_U] =
frame->data[1];
1641 rawimg->planes[VPX_PLANE_V] =
frame->data[2];
1642 rawimg->stride[VPX_PLANE_Y] =
frame->linesize[0];
1643 rawimg->stride[VPX_PLANE_U] =
frame->linesize[1];
1644 rawimg->stride[VPX_PLANE_V] =
frame->linesize[2];
1645 if (
ctx->is_alpha) {
1646 rawimg_alpha = &
ctx->rawimg_alpha;
1650 rawimg_alpha->planes[VPX_PLANE_Y] =
frame->data[3];
1651 rawimg_alpha->stride[VPX_PLANE_Y] =
frame->linesize[3];
1653 timestamp =
frame->pts;
1654 #if VPX_IMAGE_ABI_VERSION >= 4
1655 switch (
frame->color_range) {
1657 rawimg->range = VPX_CR_STUDIO_RANGE;
1660 rawimg->range = VPX_CR_FULL_RANGE;
1665 flags |= VPX_EFLAG_FORCE_KF;
1666 if (
frame->metadata) {
1672 memset(&layer_id, 0,
sizeof(layer_id));
1676 layer_id.temporal_layer_id = strtoul(en->
value,
NULL, 10);
1677 #ifdef VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT
1678 layer_id.temporal_layer_id_per_spatial[0] = layer_id.temporal_layer_id;
1682 #if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
1687 int ret = vpx_parse_ref_frame_config(&
ctx->ref_frame_config,
1688 enccfg->ss_number_layers, en->
value);
1691 "Error parsing ref_frame_config option %s.\n", en->
value);
1695 codecctl_intp(avctx, VP9E_SET_SVC_REF_FRAME_CONFIG, (
int *)&
ctx->ref_frame_config);
1698 "Ignoring ref-frame-config for a non-VP9 codec\n");
1712 if (
ctx->hdr10_plus_fifo) {
1716 if (hdr10_plus_metadata) {
1721 if (!
data.hdr10_plus)
1734 if (enccfg->ts_number_layers > 1 &&
ctx->ts_layer_flags) {
1735 if (
flags & VPX_EFLAG_FORCE_KF) {
1737 ctx->current_temporal_idx = 0;
1738 flags = VPX_EFLAG_FORCE_KF;
1744 flags |=
ctx->ts_layer_flags[
ctx->current_temporal_idx];
1746 memset(&layer_id, 0,
sizeof(layer_id));
1747 #if VPX_ENCODER_ABI_VERSION >= 12
1748 layer_id.spatial_layer_id = 0;
1750 layer_id.temporal_layer_id = enccfg->ts_layer_id[
ctx->current_temporal_idx];
1751 #ifdef VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT
1752 layer_id.temporal_layer_id_per_spatial[0] = layer_id.temporal_layer_id;
1757 if (layer_id_valid) {
1759 codecctl_int(avctx, VP8E_SET_TEMPORAL_LAYER_ID, layer_id.temporal_layer_id);
1761 #if CONFIG_LIBVPX_VP9_ENCODER && VPX_ENCODER_ABI_VERSION >= 12
1763 codecctl_intp(avctx, VP9E_SET_SVC_LAYER_ID, (
int *)&layer_id);
1768 res = vpx_codec_encode(&
ctx->encoder, rawimg, timestamp,
1770 if (res != VPX_CODEC_OK) {
1775 if (
ctx->is_alpha) {
1776 res = vpx_codec_encode(&
ctx->encoder_alpha, rawimg_alpha, timestamp,
1778 if (res != VPX_CODEC_OK) {
1785 if (
ctx->is_alpha) {
1788 if (
ctx->coded_frame_list &&
ctx->alpha_coded_frame_list) {
1793 coded_size =
storeframe(avctx, cx_frame, alpha_cx_frame,
pkt);
1796 ctx->coded_frame_list = cx_frame->
next;
1797 ctx->alpha_coded_frame_list = alpha_cx_frame->
next;
1813 ctx->twopass_stats.sz);
1814 }
else if (enccfg->ts_number_layers > 1 &&
ctx->ts_layer_flags) {
1815 ctx->current_temporal_idx = (
ctx->current_temporal_idx + 1) % enccfg->ts_periodicity;
1818 *got_packet = !!coded_size;
1822 #define OFFSET(x) offsetof(VPxContext, x)
1823 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1825 #define COMMON_OPTIONS \
1826 { "lag-in-frames", "Number of frames to look ahead for " \
1827 "alternate reference frame selection", OFFSET(lag_in_frames), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
1828 { "arnr-maxframes", "altref noise reduction max frame count", OFFSET(arnr_max_frames), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
1829 { "arnr-strength", "altref noise reduction filter strength", OFFSET(arnr_strength), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
1830 { "arnr-type", "altref noise reduction filter type", OFFSET(arnr_type), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE, "arnr_type"}, \
1831 { "backward", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "arnr_type" }, \
1832 { "forward", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, "arnr_type" }, \
1833 { "centered", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, VE, "arnr_type" }, \
1834 { "tune", "Tune the encoding to a specific scenario", OFFSET(tune), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE, "tune"}, \
1835 { "psnr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VP8_TUNE_PSNR}, 0, 0, VE, "tune"}, \
1836 { "ssim", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VP8_TUNE_SSIM}, 0, 0, VE, "tune"}, \
1837 { "deadline", "Time to spend encoding, in microseconds.", OFFSET(deadline), AV_OPT_TYPE_INT, {.i64 = VPX_DL_GOOD_QUALITY}, INT_MIN, INT_MAX, VE, "quality"}, \
1838 { "best", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VPX_DL_BEST_QUALITY}, 0, 0, VE, "quality"}, \
1839 { "good", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VPX_DL_GOOD_QUALITY}, 0, 0, VE, "quality"}, \
1840 { "realtime", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VPX_DL_REALTIME}, 0, 0, VE, "quality"}, \
1841 { "error-resilient", "Error resilience configuration", OFFSET(error_resilient), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, VE, "er"}, \
1842 { "max-intra-rate", "Maximum I-frame bitrate (pct) 0=unlimited", OFFSET(max_intra_rate), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
1843 { "default", "Improve resiliency against losses of whole frames", 0, AV_OPT_TYPE_CONST, {.i64 = VPX_ERROR_RESILIENT_DEFAULT}, 0, 0, VE, "er"}, \
1844 { "partitions", "The frame partitions are independently decodable " \
1845 "by the bool decoder, meaning that partitions can be decoded even " \
1846 "though earlier partitions have been lost. Note that intra prediction" \
1847 " is still done over the partition boundary.", 0, AV_OPT_TYPE_CONST, {.i64 = VPX_ERROR_RESILIENT_PARTITIONS}, 0, 0, VE, "er"}, \
1848 { "crf", "Select the quality for constant quality mode", offsetof(VPxContext, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE }, \
1849 { "static-thresh", "A change threshold on blocks below which they will be skipped by the encoder", OFFSET(static_thresh), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, \
1850 { "drop-threshold", "Frame drop threshold", offsetof(VPxContext, drop_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE }, \
1851 { "noise-sensitivity", "Noise sensitivity", OFFSET(noise_sensitivity), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 4, VE}, \
1852 { "undershoot-pct", "Datarate undershoot (min) target (%)", OFFSET(rc_undershoot_pct), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 100, VE }, \
1853 { "overshoot-pct", "Datarate overshoot (max) target (%)", OFFSET(rc_overshoot_pct), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1000, VE }, \
1854 { "ts-parameters", "Temporal scaling configuration using a :-separated list of key=value parameters", OFFSET(vpx_ts_parameters), AV_OPT_TYPE_DICT, {.str=NULL}, 0, 0, VE}, \
1856 #define LEGACY_OPTIONS \
1857 {"speed", "", offsetof(VPxContext, cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, -16, 16, VE}, \
1858 {"quality", "", offsetof(VPxContext, deadline), AV_OPT_TYPE_INT, {.i64 = VPX_DL_GOOD_QUALITY}, INT_MIN, INT_MAX, VE, "quality"}, \
1859 {"vp8flags", "", offsetof(VPxContext, flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, UINT_MAX, VE, "flags"}, \
1860 {"error_resilient", "enable error resilience", 0, AV_OPT_TYPE_CONST, {.i64 = VP8F_ERROR_RESILIENT}, INT_MIN, INT_MAX, VE, "flags"}, \
1861 {"altref", "enable use of alternate reference frames (VP8/2-pass only)", 0, AV_OPT_TYPE_CONST, {.i64 = VP8F_AUTO_ALT_REF}, INT_MIN, INT_MAX, VE, "flags"}, \
1862 {"arnr_max_frames", "altref noise reduction max frame count", offsetof(VPxContext, arnr_max_frames), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 15, VE}, \
1863 {"arnr_strength", "altref noise reduction filter strength", offsetof(VPxContext, arnr_strength), AV_OPT_TYPE_INT, {.i64 = 3}, 0, 6, VE}, \
1864 {"arnr_type", "altref noise reduction filter type", offsetof(VPxContext, arnr_type), AV_OPT_TYPE_INT, {.i64 = 3}, 1, 3, VE}, \
1865 {"rc_lookahead", "Number of frames to look ahead for alternate reference frame selection", offsetof(VPxContext, lag_in_frames), AV_OPT_TYPE_INT, {.i64 = 25}, 0, 25, VE}, \
1866 {"sharpness", "Increase sharpness at the expense of lower PSNR", offsetof(VPxContext, sharpness), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 7, VE},
1868 #if CONFIG_LIBVPX_VP8_ENCODER
1869 static const AVOption vp8_options[] = {
1871 {
"auto-alt-ref",
"Enable use of alternate reference "
1879 #if CONFIG_LIBVPX_VP9_ENCODER
1880 static const AVOption vp9_options[] = {
1882 {
"auto-alt-ref",
"Enable use of alternate reference "
1886 {
"tile-columns",
"Number of tile columns to use, log2",
OFFSET(tile_columns),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6,
VE},
1888 {
"frame-parallel",
"Enable frame parallel decodability features",
OFFSET(frame_parallel),
AV_OPT_TYPE_BOOL,{.i64 = -1}, -1, 1,
VE},
1889 #if VPX_ENCODER_ABI_VERSION >= 12
1890 {
"aq-mode",
"adaptive quantization mode",
OFFSET(aq_mode),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 4,
VE,
"aq_mode"},
1892 {
"aq-mode",
"adaptive quantization mode",
OFFSET(aq_mode),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 3,
VE,
"aq_mode"},
1895 {
"variance",
"Variance based Aq", 0,
AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0,
VE,
"aq_mode" },
1896 {
"complexity",
"Complexity based Aq", 0,
AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0,
VE,
"aq_mode" },
1898 #if VPX_ENCODER_ABI_VERSION >= 12
1902 #ifdef VPX_CTRL_VP9E_SET_ROW_MT
1905 #ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
1906 #if VPX_ENCODER_ABI_VERSION >= 14
1907 {
"tune-content",
"Tune content type",
OFFSET(tune_content),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2,
VE,
"tune_content" },
1909 {
"tune-content",
"Tune content type",
OFFSET(tune_content),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1,
VE,
"tune_content" },
1911 {
"default",
"Regular video content", 0,
AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0,
VE,
"tune_content" },
1912 {
"screen",
"Screen capture content", 0,
AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0,
VE,
"tune_content" },
1913 #if VPX_ENCODER_ABI_VERSION >= 14
1914 {
"film",
"Film content; improves grain retention", 0,
AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0,
VE,
"tune_content" },
1917 #if VPX_ENCODER_ABI_VERSION >= 14
1918 {
"corpus-complexity",
"corpus vbr complexity midpoint",
OFFSET(corpus_complexity),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 10000,
VE },
1920 #ifdef VPX_CTRL_VP9E_SET_TPL
1923 #ifdef VPX_CTRL_VP9E_SET_MIN_GF_INTERVAL
1924 {
"min-gf-interval",
"Minimum golden/alternate reference frame interval",
OFFSET(min_gf_interval),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX,
VE },
1931 #undef COMMON_OPTIONS
1932 #undef LEGACY_OPTIONS
1939 {
"keyint_min",
"-1" },
1943 #if CONFIG_LIBVPX_VP8_ENCODER
1946 return vpx_init(avctx, vpx_codec_vp8_cx());
1949 static const AVClass class_vp8 = {
1952 .option = vp8_options,
1963 .priv_data_size =
sizeof(VPxContext),
1970 .p.priv_class = &class_vp8,
1972 .p.wrapper_name =
"libvpx",
1976 #if CONFIG_LIBVPX_VP9_ENCODER
1979 return vpx_init(avctx, vpx_codec_vp9_cx());
1982 static const AVClass class_vp9 = {
1985 .option = vp9_options,
1990 .
p.
name =
"libvpx-vp9",
1997 .p.priv_class = &class_vp9,
1998 .p.wrapper_name =
"libvpx",
1999 .priv_data_size =
sizeof(VPxContext),