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>
96 #define VP8F_ERROR_RESILIENT 0x00000001
97 #define VP8F_AUTO_ALT_REF 0x00000002
139 #if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
140 vpx_svc_ref_frame_config_t ref_frame_config;
146 [VP8E_SET_CPUUSED] =
"VP8E_SET_CPUUSED",
147 [VP8E_SET_ENABLEAUTOALTREF] =
"VP8E_SET_ENABLEAUTOALTREF",
148 [VP8E_SET_NOISE_SENSITIVITY] =
"VP8E_SET_NOISE_SENSITIVITY",
149 [VP8E_SET_STATIC_THRESHOLD] =
"VP8E_SET_STATIC_THRESHOLD",
150 [VP8E_SET_TOKEN_PARTITIONS] =
"VP8E_SET_TOKEN_PARTITIONS",
151 [VP8E_SET_ARNR_MAXFRAMES] =
"VP8E_SET_ARNR_MAXFRAMES",
152 [VP8E_SET_ARNR_STRENGTH] =
"VP8E_SET_ARNR_STRENGTH",
153 [VP8E_SET_ARNR_TYPE] =
"VP8E_SET_ARNR_TYPE",
154 [VP8E_SET_TUNING] =
"VP8E_SET_TUNING",
155 [VP8E_SET_CQ_LEVEL] =
"VP8E_SET_CQ_LEVEL",
156 [VP8E_SET_MAX_INTRA_BITRATE_PCT] =
"VP8E_SET_MAX_INTRA_BITRATE_PCT",
157 [VP8E_SET_SHARPNESS] =
"VP8E_SET_SHARPNESS",
158 [VP8E_SET_TEMPORAL_LAYER_ID] =
"VP8E_SET_TEMPORAL_LAYER_ID",
159 #if CONFIG_LIBVPX_VP9_ENCODER
160 [VP9E_SET_LOSSLESS] =
"VP9E_SET_LOSSLESS",
161 [VP9E_SET_TILE_COLUMNS] =
"VP9E_SET_TILE_COLUMNS",
162 [VP9E_SET_TILE_ROWS] =
"VP9E_SET_TILE_ROWS",
163 [VP9E_SET_FRAME_PARALLEL_DECODING] =
"VP9E_SET_FRAME_PARALLEL_DECODING",
164 [VP9E_SET_AQ_MODE] =
"VP9E_SET_AQ_MODE",
165 [VP9E_SET_COLOR_SPACE] =
"VP9E_SET_COLOR_SPACE",
166 [VP9E_SET_SVC_LAYER_ID] =
"VP9E_SET_SVC_LAYER_ID",
167 #if VPX_ENCODER_ABI_VERSION >= 12
168 [VP9E_SET_SVC_PARAMETERS] =
"VP9E_SET_SVC_PARAMETERS",
169 [VP9E_SET_SVC_REF_FRAME_CONFIG] =
"VP9E_SET_SVC_REF_FRAME_CONFIG",
171 [VP9E_SET_SVC] =
"VP9E_SET_SVC",
172 #if VPX_ENCODER_ABI_VERSION >= 11
173 [VP9E_SET_COLOR_RANGE] =
"VP9E_SET_COLOR_RANGE",
175 #if VPX_ENCODER_ABI_VERSION >= 12
176 [VP9E_SET_TARGET_LEVEL] =
"VP9E_SET_TARGET_LEVEL",
177 [VP9E_GET_LEVEL] =
"VP9E_GET_LEVEL",
179 #ifdef VPX_CTRL_VP9E_SET_ROW_MT
180 [VP9E_SET_ROW_MT] =
"VP9E_SET_ROW_MT",
182 #ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
183 [VP9E_SET_TUNE_CONTENT] =
"VP9E_SET_TUNE_CONTENT",
185 #ifdef VPX_CTRL_VP9E_SET_TPL
186 [VP9E_SET_TPL] =
"VP9E_SET_TPL",
194 const char *
error = vpx_codec_error(&
ctx->encoder);
195 const char *detail = vpx_codec_error_detail(&
ctx->encoder);
203 const struct vpx_codec_enc_cfg *cfg,
211 " %*s%u\n %*s%u\n %*s%u\n %*s%u\n %*s%u\n"
212 #
if CONFIG_LIBVPX_VP9_ENCODER
215 " %*s{%u/%u}\n %*s%u\n %*s%d\n %*s%u\n",
216 width,
"g_usage:", cfg->g_usage,
217 width,
"g_threads:", cfg->g_threads,
218 width,
"g_profile:", cfg->g_profile,
219 width,
"g_w:", cfg->g_w,
220 width,
"g_h:", cfg->g_h,
221 #
if CONFIG_LIBVPX_VP9_ENCODER
222 width,
"g_bit_depth:", cfg->g_bit_depth,
223 width,
"g_input_bit_depth:", cfg->g_input_bit_depth,
225 width,
"g_timebase:", cfg->g_timebase.num, cfg->g_timebase.den,
226 width,
"g_error_resilient:", cfg->g_error_resilient,
227 width,
"g_pass:", cfg->g_pass,
228 width,
"g_lag_in_frames:", cfg->g_lag_in_frames);
230 " %*s%u\n %*s%u\n %*s%u\n %*s%u\n"
232 width,
"rc_dropframe_thresh:", cfg->rc_dropframe_thresh,
233 width,
"rc_resize_allowed:", cfg->rc_resize_allowed,
234 width,
"rc_resize_up_thresh:", cfg->rc_resize_up_thresh,
235 width,
"rc_resize_down_thresh:", cfg->rc_resize_down_thresh,
236 width,
"rc_end_usage:", cfg->rc_end_usage,
237 width,
"rc_twopass_stats_in:", cfg->rc_twopass_stats_in.buf, cfg->rc_twopass_stats_in.sz,
238 width,
"rc_target_bitrate:", cfg->rc_target_bitrate);
241 width,
"rc_min_quantizer:", cfg->rc_min_quantizer,
242 width,
"rc_max_quantizer:", cfg->rc_max_quantizer);
245 width,
"rc_undershoot_pct:", cfg->rc_undershoot_pct,
246 width,
"rc_overshoot_pct:", cfg->rc_overshoot_pct);
247 av_log(avctx,
level,
"temporal layering settings\n"
248 " %*s%u\n",
width,
"ts_number_layers:", cfg->ts_number_layers);
251 "\n %*s",
width,
"ts_target_bitrate:");
252 for (
i = 0;
i < VPX_TS_MAX_LAYERS;
i++)
254 "%u ", cfg->ts_target_bitrate[
i]);
256 #if (VPX_ENCODER_ABI_VERSION >= 12) && CONFIG_LIBVPX_VP9_ENCODER
259 "\n %*s",
width,
"layer_target_bitrate:");
260 for (
i = 0;
i < VPX_TS_MAX_LAYERS;
i++)
262 "%u ", cfg->layer_target_bitrate[
i]);
267 "\n %*s",
width,
"ts_rate_decimator:");
268 for (
i = 0;
i < VPX_TS_MAX_LAYERS;
i++)
272 "\n %*s%u\n",
width,
"ts_periodicity:", cfg->ts_periodicity);
274 "\n %*s",
width,
"ts_layer_id:");
275 for (
i = 0;
i < VPX_TS_MAX_PERIODICITY;
i++)
279 " %*s%u\n %*s%u\n %*s%u\n",
280 width,
"rc_buf_sz:", cfg->rc_buf_sz,
281 width,
"rc_buf_initial_sz:", cfg->rc_buf_initial_sz,
282 width,
"rc_buf_optimal_sz:", cfg->rc_buf_optimal_sz);
283 av_log(avctx,
level,
"2 pass rate control settings\n"
284 " %*s%u\n %*s%u\n %*s%u\n",
285 width,
"rc_2pass_vbr_bias_pct:", cfg->rc_2pass_vbr_bias_pct,
286 width,
"rc_2pass_vbr_minsection_pct:", cfg->rc_2pass_vbr_minsection_pct,
287 width,
"rc_2pass_vbr_maxsection_pct:", cfg->rc_2pass_vbr_maxsection_pct);
288 #if VPX_ENCODER_ABI_VERSION >= 14
290 width,
"rc_2pass_vbr_corpus_complexity:", cfg->rc_2pass_vbr_corpus_complexity);
293 " %*s%d\n %*s%u\n %*s%u\n",
294 width,
"kf_mode:", cfg->kf_mode,
295 width,
"kf_min_dist:", cfg->kf_min_dist,
296 width,
"kf_max_dist:", cfg->kf_max_dist);
357 enum vp8e_enc_control_id
id,
int val)
367 res = vpx_codec_control(&
ctx->encoder,
id,
val);
368 if (res != VPX_CODEC_OK) {
376 int res_alpha = vpx_codec_control(&
ctx->encoder_alpha,
id,
val);
377 if (res_alpha != VPX_CODEC_OK) {
378 snprintf(
buf,
sizeof(
buf),
"Failed to set %s alpha codec control",
388 #if VPX_ENCODER_ABI_VERSION >= 12
390 enum vp8e_enc_control_id
id,
int *
val)
400 res = vpx_codec_control(&
ctx->encoder,
id,
val);
401 if (res != VPX_CODEC_OK) {
409 int res_alpha = vpx_codec_control(&
ctx->encoder_alpha,
id,
val);
410 if (res_alpha != VPX_CODEC_OK) {
411 snprintf(
buf,
sizeof(
buf),
"Failed to set %s alpha codec control",
426 #if VPX_ENCODER_ABI_VERSION >= 12
430 if (!codecctl_intp(avctx, VP9E_GET_LEVEL, &level_out))
437 vpx_codec_destroy(&
ctx->encoder);
439 vpx_codec_destroy(&
ctx->encoder_alpha);
447 if (
ctx->hdr10_plus_fifo)
455 char *saveptr =
NULL;
458 while (token && dest_idx < max_entries) {
459 dest[dest_idx++] = strtoul(token,
NULL, 10);
464 #if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
465 static void vp8_ts_parse_int64_array(int64_t *dest,
char *
value,
size_t value_len,
int max_entries)
468 char *saveptr =
NULL;
471 while (token && dest_idx < max_entries) {
472 dest[dest_idx++] = strtoull(token,
NULL, 10);
479 int *layer_flags,
int *flag_periodicity)
481 switch (layering_mode) {
486 static const int ids[2] = { 0, 1 };
487 cfg->ts_periodicity = 2;
488 *flag_periodicity = 2;
489 cfg->ts_number_layers = 2;
490 cfg->ts_rate_decimator[0] = 2;
491 cfg->ts_rate_decimator[1] = 1;
492 memcpy(cfg->ts_layer_id, ids,
sizeof(ids));
495 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
496 VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
498 VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_GF |
499 VP8_EFLAG_NO_UPD_LAST |
500 VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_GF;
510 static const int ids[4] = { 0, 2, 1, 2 };
511 cfg->ts_periodicity = 4;
512 *flag_periodicity = 4;
513 cfg->ts_number_layers = 3;
514 cfg->ts_rate_decimator[0] = 4;
515 cfg->ts_rate_decimator[1] = 2;
516 cfg->ts_rate_decimator[2] = 1;
517 memcpy(cfg->ts_layer_id, ids,
sizeof(ids));
524 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
525 VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
527 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
528 VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
529 VP8_EFLAG_NO_UPD_ARF;
531 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
532 VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
534 VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_ARF |
535 VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
536 VP8_EFLAG_NO_UPD_ARF;
545 static const int ids[4] = { 0, 2, 1, 2 };
546 cfg->ts_periodicity = 4;
547 *flag_periodicity = 4;
548 cfg->ts_number_layers = 3;
549 cfg->ts_rate_decimator[0] = 4;
550 cfg->ts_rate_decimator[1] = 2;
551 cfg->ts_rate_decimator[2] = 1;
552 memcpy(cfg->ts_layer_id, ids,
sizeof(ids));
558 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
559 VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
561 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
562 VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF;
564 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
565 VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
567 VP8_EFLAG_NO_REF_LAST |
568 VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
569 VP8_EFLAG_NO_UPD_ARF;
585 size_t value_len = strlen(
value);
586 int ts_layering_mode = 0;
591 if (!strcmp(
key,
"ts_number_layers"))
592 enccfg->ts_number_layers = strtoul(
value, &
value, 10);
593 else if (!strcmp(
key,
"ts_target_bitrate")) {
596 #if (VPX_ENCODER_ABI_VERSION >= 12) && CONFIG_LIBVPX_VP9_ENCODER
600 }
else if (!strcmp(
key,
"ts_rate_decimator")) {
602 }
else if (!strcmp(
key,
"ts_periodicity")) {
603 enccfg->ts_periodicity = strtoul(
value, &
value, 10);
604 }
else if (!strcmp(
key,
"ts_layer_id")) {
606 }
else if (!strcmp(
key,
"ts_layering_mode")) {
611 #if (VPX_ENCODER_ABI_VERSION >= 12) && CONFIG_LIBVPX_VP9_ENCODER
612 enccfg->temporal_layering_mode = VP9E_TEMPORAL_LAYERING_MODE_BYPASS;
613 enccfg->ss_number_layers = 1;
615 if (ts_layering_mode) {
625 #if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
626 static int vpx_ref_frame_config_set_value(vpx_svc_ref_frame_config_t *ref_frame_config,
627 int ss_number_layers,
char *
key,
char *
value)
629 size_t value_len = strlen(
value);
634 if (!strcmp(
key,
"rfc_update_buffer_slot")) {
636 }
else if (!strcmp(
key,
"rfc_update_last")) {
638 }
else if (!strcmp(
key,
"rfc_update_golden")) {
640 }
else if (!strcmp(
key,
"rfc_update_alt_ref")) {
642 }
else if (!strcmp(
key,
"rfc_lst_fb_idx")) {
644 }
else if (!strcmp(
key,
"rfc_gld_fb_idx")) {
646 }
else if (!strcmp(
key,
"rfc_alt_fb_idx")) {
648 }
else if (!strcmp(
key,
"rfc_reference_last")) {
650 }
else if (!strcmp(
key,
"rfc_reference_golden")) {
652 }
else if (!strcmp(
key,
"rfc_reference_alt_ref")) {
654 }
else if (!strcmp(
key,
"rfc_reference_duration")) {
655 vp8_ts_parse_int64_array(ref_frame_config->duration,
value, value_len, ss_number_layers);
661 static int vpx_parse_ref_frame_config_element(vpx_svc_ref_frame_config_t *ref_frame_config,
662 int ss_number_layers,
const char **
buf)
664 const char key_val_sep[] =
"=";
665 const char pairs_sep[] =
":";
670 if (
key && *
key && strspn(*
buf, key_val_sep)) {
676 ret = vpx_ref_frame_config_set_value(ref_frame_config, ss_number_layers,
key,
val);
686 static int vpx_parse_ref_frame_config(vpx_svc_ref_frame_config_t *ref_frame_config,
687 int ss_number_layers,
const char *
str)
693 vpx_parse_ref_frame_config_element(ref_frame_config, ss_number_layers, &
str);
705 #if CONFIG_LIBVPX_VP9_ENCODER
707 struct vpx_codec_enc_cfg *enccfg, vpx_codec_flags_t *
flags,
708 vpx_img_fmt_t *img_fmt)
712 enccfg->g_bit_depth = enccfg->g_input_bit_depth =
desc->comp[0].depth;
716 enccfg->g_profile = 0;
717 *img_fmt = VPX_IMG_FMT_I420;
720 enccfg->g_profile = 1;
721 *img_fmt = VPX_IMG_FMT_I422;
724 enccfg->g_profile = 1;
725 *img_fmt = VPX_IMG_FMT_I440;
728 ctx->vpx_cs = VPX_CS_SRGB;
730 enccfg->g_profile = 1;
731 *img_fmt = VPX_IMG_FMT_I444;
735 if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) {
736 enccfg->g_profile = 2;
737 *img_fmt = VPX_IMG_FMT_I42016;
738 *
flags |= VPX_CODEC_USE_HIGHBITDEPTH;
744 if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) {
745 enccfg->g_profile = 3;
746 *img_fmt = VPX_IMG_FMT_I42216;
747 *
flags |= VPX_CODEC_USE_HIGHBITDEPTH;
753 if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) {
754 enccfg->g_profile = 3;
755 *img_fmt = VPX_IMG_FMT_I44016;
756 *
flags |= VPX_CODEC_USE_HIGHBITDEPTH;
762 ctx->vpx_cs = VPX_CS_SRGB;
765 if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) {
766 enccfg->g_profile = 3;
767 *img_fmt = VPX_IMG_FMT_I44416;
768 *
flags |= VPX_CODEC_USE_HIGHBITDEPTH;
781 enum vpx_color_space vpx_cs;
785 vpx_cs =
ctx->vpx_cs;
805 #if VPX_ENCODER_ABI_VERSION >= 11
808 enum vpx_color_range vpx_cr;
828 struct vpx_codec_enc_cfg *enccfg)
832 avctx->
bit_rate = enccfg->rc_target_bitrate * 1000;
833 if (enccfg->rc_end_usage == VPX_CQ) {
835 "Bitrate not specified for constrained quality mode, using default of %dkbit/sec\n",
836 enccfg->rc_target_bitrate);
838 enccfg->rc_end_usage = VPX_CQ;
841 "Neither bitrate nor constrained quality specified, using default CRF of %d and bitrate of %dkbit/sec\n",
842 ctx->crf, enccfg->rc_target_bitrate);
847 #if CONFIG_LIBVPX_VP9_ENCODER
853 struct vpx_codec_enc_cfg *enccfg)
857 if (enccfg->rc_end_usage != VPX_Q &&
ctx->lossless < 0) {
858 enccfg->rc_end_usage = VPX_Q;
861 "Neither bitrate nor constrained quality specified, using default CRF of %d\n",
872 struct vpx_codec_enc_cfg *enccfg)
875 #if CONFIG_LIBVPX_VP9_ENCODER
877 set_vp9_defaults(avctx, enccfg);
885 const struct vpx_codec_iface *iface)
888 struct vpx_codec_enc_cfg enccfg = { 0 };
889 struct vpx_codec_enc_cfg enccfg_alpha;
893 vpx_img_fmt_t img_fmt = VPX_IMG_FMT_I420;
894 #if CONFIG_LIBVPX_VP9_ENCODER
895 vpx_codec_caps_t codec_caps = vpx_codec_get_caps(iface);
896 vpx_svc_extra_cfg_t svc_params;
906 if ((res = vpx_codec_enc_config_default(iface, &enccfg, 0)) != VPX_CODEC_OK) {
908 vpx_codec_err_to_string(res));
912 #if CONFIG_LIBVPX_VP9_ENCODER
921 if (!
ctx->hdr10_plus_fifo)
935 enccfg.g_w = avctx->
width;
936 enccfg.g_h = avctx->
height;
941 enccfg.g_lag_in_frames=
ctx->lag_in_frames;
944 enccfg.g_pass = VPX_RC_FIRST_PASS;
946 enccfg.g_pass = VPX_RC_LAST_PASS;
948 enccfg.g_pass = VPX_RC_ONE_PASS;
952 enccfg.rc_end_usage = VPX_CBR;
953 }
else if (
ctx->crf >= 0) {
954 enccfg.rc_end_usage = VPX_CQ;
955 #if CONFIG_LIBVPX_VP9_ENCODER
957 enccfg.rc_end_usage = VPX_Q;
964 #if CONFIG_LIBVPX_VP9_ENCODER
965 enccfg.ss_target_bitrate[0] = enccfg.rc_target_bitrate;
973 enccfg.rc_min_quantizer =
974 enccfg.rc_max_quantizer = 0;
976 if (avctx->
qmin >= 0)
977 enccfg.rc_min_quantizer = avctx->
qmin;
978 if (avctx->
qmax >= 0)
979 enccfg.rc_max_quantizer = avctx->
qmax;
982 if (enccfg.rc_end_usage == VPX_CQ
983 #
if CONFIG_LIBVPX_VP9_ENCODER
984 || enccfg.rc_end_usage == VPX_Q
987 if (
ctx->crf < enccfg.rc_min_quantizer ||
ctx->crf > enccfg.rc_max_quantizer) {
989 "CQ level %d must be between minimum and maximum quantizer value (%d-%d)\n",
990 ctx->crf, enccfg.rc_min_quantizer, enccfg.rc_max_quantizer);
995 enccfg.rc_dropframe_thresh =
ctx->drop_threshold;
1000 enccfg.rc_2pass_vbr_minsection_pct =
1003 enccfg.rc_2pass_vbr_maxsection_pct =
1005 #if CONFIG_LIBVPX_VP9_ENCODER
1007 #if VPX_ENCODER_ABI_VERSION >= 14
1008 if (
ctx->corpus_complexity >= 0)
1009 enccfg.rc_2pass_vbr_corpus_complexity =
ctx->corpus_complexity;
1018 enccfg.rc_buf_initial_sz =
1020 enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
1021 if (
ctx->rc_undershoot_pct >= 0)
1022 enccfg.rc_undershoot_pct =
ctx->rc_undershoot_pct;
1023 if (
ctx->rc_overshoot_pct >= 0)
1024 enccfg.rc_overshoot_pct =
ctx->rc_overshoot_pct;
1030 enccfg.kf_max_dist = avctx->
gop_size;
1032 if (enccfg.g_pass == VPX_RC_FIRST_PASS)
1033 enccfg.g_lag_in_frames = 0;
1034 else if (enccfg.g_pass == VPX_RC_LAST_PASS) {
1035 int decode_size,
ret;
1042 ctx->twopass_stats.sz = strlen(avctx->
stats_in) * 3 / 4;
1047 ctx->twopass_stats.sz);
1048 ctx->twopass_stats.sz = 0;
1052 ctx->twopass_stats.sz);
1053 if (decode_size < 0) {
1058 ctx->twopass_stats.sz = decode_size;
1059 enccfg.rc_twopass_stats_in =
ctx->twopass_stats;
1066 enccfg.g_profile = avctx->
profile;
1073 "Error parsing option '%s = %s'.\n",
1078 res = vpx_codec_enc_init(&
ctx->encoder, iface, &enccfg,
flags);
1079 if (res != VPX_CODEC_OK) {
1086 #if CONFIG_LIBVPX_VP9_ENCODER
1088 memset(&svc_params, 0,
sizeof(svc_params));
1089 for (
int i = 0;
i < enccfg.ts_number_layers; ++
i) {
1090 svc_params.max_quantizers[
i] = enccfg.rc_max_quantizer;
1091 svc_params.min_quantizers[
i] = enccfg.rc_min_quantizer;
1093 svc_params.scaling_factor_num[0] = enccfg.g_h;
1094 svc_params.scaling_factor_den[0] = enccfg.g_h;
1095 #if VPX_ENCODER_ABI_VERSION >= 12
1097 codecctl_intp(avctx, VP9E_SET_SVC_PARAMETERS, (
int *)&svc_params);
1101 if (
ctx->is_alpha) {
1102 enccfg_alpha = enccfg;
1103 res = vpx_codec_enc_init(&
ctx->encoder_alpha, iface, &enccfg_alpha,
flags);
1104 if (res != VPX_CODEC_OK) {
1114 ctx->auto_alt_ref = 1;
1115 if (
ctx->auto_alt_ref >= 0)
1118 if (
ctx->arnr_max_frames >= 0)
1120 if (
ctx->arnr_strength >= 0)
1122 if (
ctx->arnr_type >= 0)
1128 av_log(avctx,
AV_LOG_ERROR,
"Transparency encoding with auto_alt_ref does not work\n");
1132 if (
ctx->sharpness >= 0)
1136 codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY,
ctx->noise_sensitivity);
1142 if (
ctx->max_intra_rate >= 0)
1143 codecctl_int(avctx, VP8E_SET_MAX_INTRA_BITRATE_PCT,
ctx->max_intra_rate);
1145 #if CONFIG_LIBVPX_VP9_ENCODER
1147 if (
ctx->lossless >= 0)
1149 if (
ctx->tile_columns >= 0)
1151 if (
ctx->tile_rows >= 0)
1153 if (
ctx->frame_parallel >= 0)
1154 codecctl_int(avctx, VP9E_SET_FRAME_PARALLEL_DECODING,
ctx->frame_parallel);
1155 if (
ctx->aq_mode >= 0)
1157 set_colorspace(avctx);
1158 #if VPX_ENCODER_ABI_VERSION >= 11
1161 #if VPX_ENCODER_ABI_VERSION >= 12
1164 #ifdef VPX_CTRL_VP9E_SET_ROW_MT
1165 if (
ctx->row_mt >= 0)
1168 #ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
1169 if (
ctx->tune_content >= 0)
1172 #ifdef VPX_CTRL_VP9E_SET_TPL
1173 if (
ctx->tpl_model >= 0)
1182 vpx_img_wrap(&
ctx->rawimg, img_fmt, avctx->
width, avctx->
height, 1,
1184 #if CONFIG_LIBVPX_VP9_ENCODER
1186 ctx->rawimg.bit_depth = enccfg.g_bit_depth;
1193 if (enccfg.rc_end_usage == VPX_CBR ||
1194 enccfg.g_pass != VPX_RC_ONE_PASS) {
1205 const struct vpx_codec_cx_pkt *
src,
1208 dst->
pts =
src->data.frame.pts;
1210 dst->
flags =
src->data.frame.flags;
1211 dst->
sz =
src->data.frame.sz;
1212 dst->
buf =
src->data.frame.buf;
1215 if (!(dst->
flags & VPX_FRAME_IS_INVISIBLE)) {
1218 if (
ctx->have_sse) {
1223 memcpy(dst->
sse,
ctx->sse,
sizeof(dst->
sse));
1253 if (!!(cx_frame->
flags & VPX_FRAME_IS_KEY)) {
1260 ret = vpx_codec_control(&
ctx->encoder, VP8E_GET_LAST_QUANTIZER_64, &
quality);
1261 if (
ret != VPX_CODEC_OK)
1264 cx_frame->
have_sse ? 3 : 0, pict_type);
1268 for (
int i = 0;
i < 3; ++
i)
1272 if (alpha_cx_frame) {
1275 alpha_cx_frame->
sz + 8);
1281 memcpy(side_data + 8, alpha_cx_frame->
buf, alpha_cx_frame->
sz);
1284 if (
ctx->hdr10_plus_fifo) {
1306 const struct vpx_codec_cx_pkt *
pkt;
1307 const void *iter =
NULL;
1310 if (!
ctx->is_alpha && *frame_list) {
1316 *frame_list = cx_frame->
next;
1322 while (
pkt = vpx_codec_get_cx_data(encoder, &iter)) {
1323 switch (
pkt->kind) {
1324 case VPX_CODEC_CX_FRAME_PKT:
1325 if (!
ctx->is_alpha && !
size) {
1340 "Frame queue element alloc failed\n");
1346 if (!cx_frame->
buf) {
1357 case VPX_CODEC_STATS_PKT: {
1358 struct vpx_fixed_buf *
stats = &
ctx->twopass_stats;
1364 pkt->
data.twopass_stats.sz)) < 0) {
1374 case VPX_CODEC_PSNR_PKT:
1384 case VPX_CODEC_CUSTOM_PKT:
1394 vpx_roi_map_t *roi_map,
int block_size,
int segment_cnt)
1399 #define MAX_DELTA_Q 63
1414 memset(roi_map, 0,
sizeof(*roi_map));
1425 if (!self_size || sd->
size % self_size) {
1429 nb_rois = sd->
size / self_size;
1435 for (
int i = 0;
i < nb_rois;
i++) {
1449 if (!segment_mapping[mapping_index]) {
1450 if (segment_id == segment_cnt) {
1452 "ROI only supports %d segments (and segment 0 is reserved for non-ROIs), skipping the left ones.\n",
1457 segment_mapping[mapping_index] = segment_id + 1;
1458 roi_map->delta_q[segment_id] =
delta_q;
1463 roi_map->rows = (frame_height + block_size - 1) / block_size;
1464 roi_map->cols = (frame_width + block_size - 1) / block_size;
1465 roi_map->roi_map =
av_calloc(roi_map->rows * roi_map->cols,
sizeof(*roi_map->roi_map));
1466 if (!roi_map->roi_map) {
1474 for (
int i = nb_rois - 1;
i >= 0;
i--) {
1477 int starty, endy, startx, endx;
1481 starty =
av_clip(roi->
top / block_size, 0, roi_map->rows);
1482 endy =
av_clip((roi->
bottom + block_size - 1) / block_size, 0, roi_map->rows);
1483 startx =
av_clip(roi->
left / block_size, 0, roi_map->cols);
1484 endx =
av_clip((roi->
right + block_size - 1) / block_size, 0, roi_map->cols);
1490 if (mapping_value) {
1491 for (
int y = starty; y < endy; y++)
1492 for (
int x = startx; x < endx; x++)
1493 roi_map->roi_map[x + y * roi_map->cols] = mapping_value - 1;
1504 #ifdef VPX_CTRL_VP9E_SET_ROI_MAP
1505 int version = vpx_codec_version();
1508 int patch = VPX_VERSION_PATCH(
version);
1511 vpx_roi_map_t roi_map;
1512 const int segment_cnt = 8;
1513 const int block_size = 8;
1516 if (
ctx->aq_mode > 0 ||
ctx->cpu_used < 5 ||
ctx->deadline != VPX_DL_REALTIME) {
1517 if (!
ctx->roi_warned) {
1518 ctx->roi_warned = 1;
1520 "and deadline is REALTIME, so skipping ROI.\n");
1525 ret =
set_roi_map(avctx, sd, frame_width, frame_height, &roi_map, block_size, segment_cnt);
1531 memset(roi_map.ref_frame, -1,
sizeof(roi_map.ref_frame));
1533 if (vpx_codec_control(&
ctx->encoder, VP9E_SET_ROI_MAP, &roi_map)) {
1542 if (!
ctx->roi_warned) {
1543 ctx->roi_warned = 1;
1544 av_log(avctx,
AV_LOG_WARNING,
"ROI is not supported, please upgrade libvpx to version >= 1.8.1. "
1545 "You may need to rebuild ffmpeg.\n");
1552 vpx_roi_map_t roi_map;
1553 const int segment_cnt = 4;
1554 const int block_size = 16;
1557 int ret =
set_roi_map(avctx, sd, frame_width, frame_height, &roi_map, block_size, segment_cnt);
1563 if (vpx_codec_control(&
ctx->encoder, VP8E_SET_ROI_MAP, &roi_map)) {
1575 struct vpx_image *rawimg_alpha = &
ctx->rawimg_alpha;
1576 unsigned char **
planes = rawimg_alpha->planes;
1577 int *
stride = rawimg_alpha->stride;
1579 if (!
planes[VPX_PLANE_U] ||
1581 width != (
int)rawimg_alpha->d_w ||
1582 height != (
int)rawimg_alpha->d_h) {
1586 vpx_img_wrap(rawimg_alpha, VPX_IMG_FMT_I420,
width,
height, 1,
1604 struct vpx_image *rawimg =
NULL;
1605 struct vpx_image *rawimg_alpha =
NULL;
1606 int64_t timestamp = 0;
1607 int res, coded_size;
1608 vpx_enc_frame_flags_t
flags = 0;
1609 const struct vpx_codec_enc_cfg *enccfg =
ctx->encoder.config.enc;
1610 vpx_svc_layer_id_t layer_id;
1611 int layer_id_valid = 0;
1613 if (avctx->
qmax >= 0 && enccfg->rc_max_quantizer != avctx->
qmax) {
1614 struct vpx_codec_enc_cfg cfg = *enccfg;
1615 cfg.rc_max_quantizer = avctx->
qmax;
1616 res = vpx_codec_enc_config_set(&
ctx->encoder, &cfg);
1617 if (res != VPX_CODEC_OK) {
1625 rawimg = &
ctx->rawimg;
1626 rawimg->planes[VPX_PLANE_Y] =
frame->data[0];
1627 rawimg->planes[VPX_PLANE_U] =
frame->data[1];
1628 rawimg->planes[VPX_PLANE_V] =
frame->data[2];
1629 rawimg->stride[VPX_PLANE_Y] =
frame->linesize[0];
1630 rawimg->stride[VPX_PLANE_U] =
frame->linesize[1];
1631 rawimg->stride[VPX_PLANE_V] =
frame->linesize[2];
1632 if (
ctx->is_alpha) {
1633 rawimg_alpha = &
ctx->rawimg_alpha;
1637 rawimg_alpha->planes[VPX_PLANE_Y] =
frame->data[3];
1638 rawimg_alpha->stride[VPX_PLANE_Y] =
frame->linesize[3];
1640 timestamp =
frame->pts;
1641 #if VPX_IMAGE_ABI_VERSION >= 4
1642 switch (
frame->color_range) {
1644 rawimg->range = VPX_CR_STUDIO_RANGE;
1647 rawimg->range = VPX_CR_FULL_RANGE;
1652 flags |= VPX_EFLAG_FORCE_KF;
1653 if (
frame->metadata) {
1659 memset(&layer_id, 0,
sizeof(layer_id));
1663 layer_id.temporal_layer_id = strtoul(en->
value,
NULL, 10);
1664 #ifdef VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT
1665 layer_id.temporal_layer_id_per_spatial[0] = layer_id.temporal_layer_id;
1669 #if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
1674 int ret = vpx_parse_ref_frame_config(&
ctx->ref_frame_config,
1675 enccfg->ss_number_layers, en->
value);
1678 "Error parsing ref_frame_config option %s.\n", en->
value);
1682 codecctl_intp(avctx, VP9E_SET_SVC_REF_FRAME_CONFIG, (
int *)&
ctx->ref_frame_config);
1685 "Ignoring ref-frame-config for a non-VP9 codec\n");
1699 if (
ctx->hdr10_plus_fifo) {
1703 if (hdr10_plus_metadata) {
1708 if (!
data.hdr10_plus)
1721 if (enccfg->ts_number_layers > 1 &&
ctx->ts_layer_flags) {
1722 if (
flags & VPX_EFLAG_FORCE_KF) {
1724 ctx->current_temporal_idx = 0;
1725 flags = VPX_EFLAG_FORCE_KF;
1731 flags |=
ctx->ts_layer_flags[
ctx->current_temporal_idx];
1733 memset(&layer_id, 0,
sizeof(layer_id));
1734 #if VPX_ENCODER_ABI_VERSION >= 12
1735 layer_id.spatial_layer_id = 0;
1737 layer_id.temporal_layer_id = enccfg->ts_layer_id[
ctx->current_temporal_idx];
1738 #ifdef VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT
1739 layer_id.temporal_layer_id_per_spatial[0] = layer_id.temporal_layer_id;
1744 if (layer_id_valid) {
1746 codecctl_int(avctx, VP8E_SET_TEMPORAL_LAYER_ID, layer_id.temporal_layer_id);
1748 #if CONFIG_LIBVPX_VP9_ENCODER && VPX_ENCODER_ABI_VERSION >= 12
1750 codecctl_intp(avctx, VP9E_SET_SVC_LAYER_ID, (
int *)&layer_id);
1755 res = vpx_codec_encode(&
ctx->encoder, rawimg, timestamp,
1757 if (res != VPX_CODEC_OK) {
1762 if (
ctx->is_alpha) {
1763 res = vpx_codec_encode(&
ctx->encoder_alpha, rawimg_alpha, timestamp,
1765 if (res != VPX_CODEC_OK) {
1772 if (
ctx->is_alpha) {
1775 if (
ctx->coded_frame_list &&
ctx->alpha_coded_frame_list) {
1780 coded_size =
storeframe(avctx, cx_frame, alpha_cx_frame,
pkt);
1783 ctx->coded_frame_list = cx_frame->
next;
1784 ctx->alpha_coded_frame_list = alpha_cx_frame->
next;
1800 ctx->twopass_stats.sz);
1801 }
else if (enccfg->ts_number_layers > 1 &&
ctx->ts_layer_flags) {
1802 ctx->current_temporal_idx = (
ctx->current_temporal_idx + 1) % enccfg->ts_periodicity;
1805 *got_packet = !!coded_size;
1809 #define OFFSET(x) offsetof(VPxContext, x)
1810 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1812 #define COMMON_OPTIONS \
1813 { "lag-in-frames", "Number of frames to look ahead for " \
1814 "alternate reference frame selection", OFFSET(lag_in_frames), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
1815 { "arnr-maxframes", "altref noise reduction max frame count", OFFSET(arnr_max_frames), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
1816 { "arnr-strength", "altref noise reduction filter strength", OFFSET(arnr_strength), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
1817 { "arnr-type", "altref noise reduction filter type", OFFSET(arnr_type), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE, "arnr_type"}, \
1818 { "backward", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "arnr_type" }, \
1819 { "forward", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, "arnr_type" }, \
1820 { "centered", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, VE, "arnr_type" }, \
1821 { "tune", "Tune the encoding to a specific scenario", OFFSET(tune), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE, "tune"}, \
1822 { "psnr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VP8_TUNE_PSNR}, 0, 0, VE, "tune"}, \
1823 { "ssim", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VP8_TUNE_SSIM}, 0, 0, VE, "tune"}, \
1824 { "deadline", "Time to spend encoding, in microseconds.", OFFSET(deadline), AV_OPT_TYPE_INT, {.i64 = VPX_DL_GOOD_QUALITY}, INT_MIN, INT_MAX, VE, "quality"}, \
1825 { "best", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VPX_DL_BEST_QUALITY}, 0, 0, VE, "quality"}, \
1826 { "good", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VPX_DL_GOOD_QUALITY}, 0, 0, VE, "quality"}, \
1827 { "realtime", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VPX_DL_REALTIME}, 0, 0, VE, "quality"}, \
1828 { "error-resilient", "Error resilience configuration", OFFSET(error_resilient), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, VE, "er"}, \
1829 { "max-intra-rate", "Maximum I-frame bitrate (pct) 0=unlimited", OFFSET(max_intra_rate), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
1830 { "default", "Improve resiliency against losses of whole frames", 0, AV_OPT_TYPE_CONST, {.i64 = VPX_ERROR_RESILIENT_DEFAULT}, 0, 0, VE, "er"}, \
1831 { "partitions", "The frame partitions are independently decodable " \
1832 "by the bool decoder, meaning that partitions can be decoded even " \
1833 "though earlier partitions have been lost. Note that intra prediction" \
1834 " is still done over the partition boundary.", 0, AV_OPT_TYPE_CONST, {.i64 = VPX_ERROR_RESILIENT_PARTITIONS}, 0, 0, VE, "er"}, \
1835 { "crf", "Select the quality for constant quality mode", offsetof(VPxContext, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE }, \
1836 { "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 }, \
1837 { "drop-threshold", "Frame drop threshold", offsetof(VPxContext, drop_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE }, \
1838 { "noise-sensitivity", "Noise sensitivity", OFFSET(noise_sensitivity), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 4, VE}, \
1839 { "undershoot-pct", "Datarate undershoot (min) target (%)", OFFSET(rc_undershoot_pct), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 100, VE }, \
1840 { "overshoot-pct", "Datarate overshoot (max) target (%)", OFFSET(rc_overshoot_pct), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1000, VE }, \
1841 { "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}, \
1843 #define LEGACY_OPTIONS \
1844 {"speed", "", offsetof(VPxContext, cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, -16, 16, VE}, \
1845 {"quality", "", offsetof(VPxContext, deadline), AV_OPT_TYPE_INT, {.i64 = VPX_DL_GOOD_QUALITY}, INT_MIN, INT_MAX, VE, "quality"}, \
1846 {"vp8flags", "", offsetof(VPxContext, flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, UINT_MAX, VE, "flags"}, \
1847 {"error_resilient", "enable error resilience", 0, AV_OPT_TYPE_CONST, {.i64 = VP8F_ERROR_RESILIENT}, INT_MIN, INT_MAX, VE, "flags"}, \
1848 {"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"}, \
1849 {"arnr_max_frames", "altref noise reduction max frame count", offsetof(VPxContext, arnr_max_frames), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 15, VE}, \
1850 {"arnr_strength", "altref noise reduction filter strength", offsetof(VPxContext, arnr_strength), AV_OPT_TYPE_INT, {.i64 = 3}, 0, 6, VE}, \
1851 {"arnr_type", "altref noise reduction filter type", offsetof(VPxContext, arnr_type), AV_OPT_TYPE_INT, {.i64 = 3}, 1, 3, VE}, \
1852 {"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}, \
1853 {"sharpness", "Increase sharpness at the expense of lower PSNR", offsetof(VPxContext, sharpness), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 7, VE},
1855 #if CONFIG_LIBVPX_VP8_ENCODER
1856 static const AVOption vp8_options[] = {
1858 {
"auto-alt-ref",
"Enable use of alternate reference "
1866 #if CONFIG_LIBVPX_VP9_ENCODER
1867 static const AVOption vp9_options[] = {
1869 {
"auto-alt-ref",
"Enable use of alternate reference "
1873 {
"tile-columns",
"Number of tile columns to use, log2",
OFFSET(tile_columns),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6,
VE},
1875 {
"frame-parallel",
"Enable frame parallel decodability features",
OFFSET(frame_parallel),
AV_OPT_TYPE_BOOL,{.i64 = -1}, -1, 1,
VE},
1876 #if VPX_ENCODER_ABI_VERSION >= 12
1877 {
"aq-mode",
"adaptive quantization mode",
OFFSET(aq_mode),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 4,
VE,
"aq_mode"},
1879 {
"aq-mode",
"adaptive quantization mode",
OFFSET(aq_mode),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 3,
VE,
"aq_mode"},
1882 {
"variance",
"Variance based Aq", 0,
AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0,
VE,
"aq_mode" },
1883 {
"complexity",
"Complexity based Aq", 0,
AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0,
VE,
"aq_mode" },
1885 #if VPX_ENCODER_ABI_VERSION >= 12
1889 #ifdef VPX_CTRL_VP9E_SET_ROW_MT
1892 #ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
1893 #if VPX_ENCODER_ABI_VERSION >= 14
1894 {
"tune-content",
"Tune content type",
OFFSET(tune_content),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2,
VE,
"tune_content" },
1896 {
"tune-content",
"Tune content type",
OFFSET(tune_content),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1,
VE,
"tune_content" },
1898 {
"default",
"Regular video content", 0,
AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0,
VE,
"tune_content" },
1899 {
"screen",
"Screen capture content", 0,
AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0,
VE,
"tune_content" },
1900 #if VPX_ENCODER_ABI_VERSION >= 14
1901 {
"film",
"Film content; improves grain retention", 0,
AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0,
VE,
"tune_content" },
1904 #if VPX_ENCODER_ABI_VERSION >= 14
1905 {
"corpus-complexity",
"corpus vbr complexity midpoint",
OFFSET(corpus_complexity),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 10000,
VE },
1907 #ifdef VPX_CTRL_VP9E_SET_TPL
1915 #undef COMMON_OPTIONS
1916 #undef LEGACY_OPTIONS
1923 {
"keyint_min",
"-1" },
1927 #if CONFIG_LIBVPX_VP8_ENCODER
1930 return vpx_init(avctx, vpx_codec_vp8_cx());
1933 static const AVClass class_vp8 = {
1936 .option = vp8_options,
1947 .priv_data_size =
sizeof(VPxContext),
1953 .p.priv_class = &class_vp8,
1955 .p.wrapper_name =
"libvpx",
1959 #if CONFIG_LIBVPX_VP9_ENCODER
1962 return vpx_init(avctx, vpx_codec_vp9_cx());
1965 static const AVClass class_vp9 = {
1968 .option = vp9_options,
1973 .
p.
name =
"libvpx-vp9",
1980 .p.priv_class = &class_vp9,
1981 .p.wrapper_name =
"libvpx",
1982 .priv_data_size =
sizeof(VPxContext),