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>
71 #if FF_API_REORDERED_OPAQUE
72 int64_t reordered_opaque;
101 #define VP8F_ERROR_RESILIENT 0x00000001
102 #define VP8F_AUTO_ALT_REF 0x00000002
147 #if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
148 vpx_svc_ref_frame_config_t ref_frame_config;
154 [VP8E_SET_CPUUSED] =
"VP8E_SET_CPUUSED",
155 [VP8E_SET_ENABLEAUTOALTREF] =
"VP8E_SET_ENABLEAUTOALTREF",
156 [VP8E_SET_NOISE_SENSITIVITY] =
"VP8E_SET_NOISE_SENSITIVITY",
157 [VP8E_SET_STATIC_THRESHOLD] =
"VP8E_SET_STATIC_THRESHOLD",
158 [VP8E_SET_TOKEN_PARTITIONS] =
"VP8E_SET_TOKEN_PARTITIONS",
159 [VP8E_SET_ARNR_MAXFRAMES] =
"VP8E_SET_ARNR_MAXFRAMES",
160 [VP8E_SET_ARNR_STRENGTH] =
"VP8E_SET_ARNR_STRENGTH",
161 [VP8E_SET_ARNR_TYPE] =
"VP8E_SET_ARNR_TYPE",
162 [VP8E_SET_TUNING] =
"VP8E_SET_TUNING",
163 [VP8E_SET_CQ_LEVEL] =
"VP8E_SET_CQ_LEVEL",
164 [VP8E_SET_MAX_INTRA_BITRATE_PCT] =
"VP8E_SET_MAX_INTRA_BITRATE_PCT",
165 [VP8E_SET_SHARPNESS] =
"VP8E_SET_SHARPNESS",
166 [VP8E_SET_TEMPORAL_LAYER_ID] =
"VP8E_SET_TEMPORAL_LAYER_ID",
167 #if CONFIG_LIBVPX_VP9_ENCODER
168 [VP9E_SET_LOSSLESS] =
"VP9E_SET_LOSSLESS",
169 [VP9E_SET_TILE_COLUMNS] =
"VP9E_SET_TILE_COLUMNS",
170 [VP9E_SET_TILE_ROWS] =
"VP9E_SET_TILE_ROWS",
171 [VP9E_SET_FRAME_PARALLEL_DECODING] =
"VP9E_SET_FRAME_PARALLEL_DECODING",
172 [VP9E_SET_AQ_MODE] =
"VP9E_SET_AQ_MODE",
173 [VP9E_SET_COLOR_SPACE] =
"VP9E_SET_COLOR_SPACE",
174 [VP9E_SET_SVC_LAYER_ID] =
"VP9E_SET_SVC_LAYER_ID",
175 #if VPX_ENCODER_ABI_VERSION >= 12
176 [VP9E_SET_SVC_PARAMETERS] =
"VP9E_SET_SVC_PARAMETERS",
177 [VP9E_SET_SVC_REF_FRAME_CONFIG] =
"VP9E_SET_SVC_REF_FRAME_CONFIG",
179 [VP9E_SET_SVC] =
"VP9E_SET_SVC",
180 #if VPX_ENCODER_ABI_VERSION >= 11
181 [VP9E_SET_COLOR_RANGE] =
"VP9E_SET_COLOR_RANGE",
183 #if VPX_ENCODER_ABI_VERSION >= 12
184 [VP9E_SET_TARGET_LEVEL] =
"VP9E_SET_TARGET_LEVEL",
185 [VP9E_GET_LEVEL] =
"VP9E_GET_LEVEL",
187 #ifdef VPX_CTRL_VP9E_SET_ROW_MT
188 [VP9E_SET_ROW_MT] =
"VP9E_SET_ROW_MT",
190 #ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
191 [VP9E_SET_TUNE_CONTENT] =
"VP9E_SET_TUNE_CONTENT",
193 #ifdef VPX_CTRL_VP9E_SET_TPL
194 [VP9E_SET_TPL] =
"VP9E_SET_TPL",
196 #ifdef VPX_CTRL_VP9E_SET_MIN_GF_INTERVAL
197 [VP9E_SET_MIN_GF_INTERVAL] =
"VP9E_SET_MIN_GF_INTERVAL",
205 const char *
error = vpx_codec_error(&
ctx->encoder);
206 const char *detail = vpx_codec_error_detail(&
ctx->encoder);
214 const struct vpx_codec_enc_cfg *cfg,
222 " %*s%u\n %*s%u\n %*s%u\n %*s%u\n %*s%u\n"
223 #
if CONFIG_LIBVPX_VP9_ENCODER
226 " %*s{%u/%u}\n %*s%u\n %*s%d\n %*s%u\n",
227 width,
"g_usage:", cfg->g_usage,
228 width,
"g_threads:", cfg->g_threads,
229 width,
"g_profile:", cfg->g_profile,
230 width,
"g_w:", cfg->g_w,
231 width,
"g_h:", cfg->g_h,
232 #
if CONFIG_LIBVPX_VP9_ENCODER
233 width,
"g_bit_depth:", cfg->g_bit_depth,
234 width,
"g_input_bit_depth:", cfg->g_input_bit_depth,
236 width,
"g_timebase:", cfg->g_timebase.num, cfg->g_timebase.den,
237 width,
"g_error_resilient:", cfg->g_error_resilient,
238 width,
"g_pass:", cfg->g_pass,
239 width,
"g_lag_in_frames:", cfg->g_lag_in_frames);
241 " %*s%u\n %*s%u\n %*s%u\n %*s%u\n"
243 width,
"rc_dropframe_thresh:", cfg->rc_dropframe_thresh,
244 width,
"rc_resize_allowed:", cfg->rc_resize_allowed,
245 width,
"rc_resize_up_thresh:", cfg->rc_resize_up_thresh,
246 width,
"rc_resize_down_thresh:", cfg->rc_resize_down_thresh,
247 width,
"rc_end_usage:", cfg->rc_end_usage,
248 width,
"rc_twopass_stats_in:", cfg->rc_twopass_stats_in.buf, cfg->rc_twopass_stats_in.sz,
249 width,
"rc_target_bitrate:", cfg->rc_target_bitrate);
252 width,
"rc_min_quantizer:", cfg->rc_min_quantizer,
253 width,
"rc_max_quantizer:", cfg->rc_max_quantizer);
256 width,
"rc_undershoot_pct:", cfg->rc_undershoot_pct,
257 width,
"rc_overshoot_pct:", cfg->rc_overshoot_pct);
258 av_log(avctx,
level,
"temporal layering settings\n"
259 " %*s%u\n",
width,
"ts_number_layers:", cfg->ts_number_layers);
262 "\n %*s",
width,
"ts_target_bitrate:");
263 for (
i = 0;
i < VPX_TS_MAX_LAYERS;
i++)
265 "%u ", cfg->ts_target_bitrate[
i]);
267 #if (VPX_ENCODER_ABI_VERSION >= 12) && CONFIG_LIBVPX_VP9_ENCODER
270 "\n %*s",
width,
"layer_target_bitrate:");
271 for (
i = 0;
i < VPX_TS_MAX_LAYERS;
i++)
273 "%u ", cfg->layer_target_bitrate[
i]);
278 "\n %*s",
width,
"ts_rate_decimator:");
279 for (
i = 0;
i < VPX_TS_MAX_LAYERS;
i++)
283 "\n %*s%u\n",
width,
"ts_periodicity:", cfg->ts_periodicity);
285 "\n %*s",
width,
"ts_layer_id:");
286 for (
i = 0;
i < VPX_TS_MAX_PERIODICITY;
i++)
290 " %*s%u\n %*s%u\n %*s%u\n",
291 width,
"rc_buf_sz:", cfg->rc_buf_sz,
292 width,
"rc_buf_initial_sz:", cfg->rc_buf_initial_sz,
293 width,
"rc_buf_optimal_sz:", cfg->rc_buf_optimal_sz);
294 av_log(avctx,
level,
"2 pass rate control settings\n"
295 " %*s%u\n %*s%u\n %*s%u\n",
296 width,
"rc_2pass_vbr_bias_pct:", cfg->rc_2pass_vbr_bias_pct,
297 width,
"rc_2pass_vbr_minsection_pct:", cfg->rc_2pass_vbr_minsection_pct,
298 width,
"rc_2pass_vbr_maxsection_pct:", cfg->rc_2pass_vbr_maxsection_pct);
299 #if VPX_ENCODER_ABI_VERSION >= 14
301 width,
"rc_2pass_vbr_corpus_complexity:", cfg->rc_2pass_vbr_corpus_complexity);
304 " %*s%d\n %*s%u\n %*s%u\n",
305 width,
"kf_mode:", cfg->kf_mode,
306 width,
"kf_min_dist:", cfg->kf_min_dist,
307 width,
"kf_max_dist:", cfg->kf_max_dist);
356 const struct vpx_codec_enc_cfg *enccfg =
ctx->encoder.config.enc;
363 #if CONFIG_LIBVPX_VP9_ENCODER
382 #if FF_API_REORDERED_OPAQUE
408 "Mismatching timestamps: libvpx %"PRId64
" queued %"PRId64
"; "
409 "this is a bug, please report it\n",
pkt->
pts, fd.
pts);
413 #if FF_API_REORDERED_OPAQUE
415 avctx->reordered_opaque = fd.reordered_opaque;
444 enum vp8e_enc_control_id
id,
int val)
454 res = vpx_codec_control(&
ctx->encoder,
id,
val);
455 if (res != VPX_CODEC_OK) {
456 snprintf(buf,
sizeof(buf),
"Failed to set %s codec control",
463 int res_alpha = vpx_codec_control(&
ctx->encoder_alpha,
id,
val);
464 if (res_alpha != VPX_CODEC_OK) {
465 snprintf(buf,
sizeof(buf),
"Failed to set %s alpha codec control",
475 #if VPX_ENCODER_ABI_VERSION >= 12
477 enum vp8e_enc_control_id
id,
int *
val)
487 res = vpx_codec_control(&
ctx->encoder,
id,
val);
488 if (res != VPX_CODEC_OK) {
489 snprintf(buf,
sizeof(buf),
"Failed to set %s codec control",
496 int res_alpha = vpx_codec_control(&
ctx->encoder_alpha,
id,
val);
497 if (res_alpha != VPX_CODEC_OK) {
498 snprintf(buf,
sizeof(buf),
"Failed to set %s alpha codec control",
513 #if VPX_ENCODER_ABI_VERSION >= 12
517 if (!codecctl_intp(avctx, VP9E_GET_LEVEL, &level_out))
524 vpx_codec_destroy(&
ctx->encoder);
526 vpx_codec_destroy(&
ctx->encoder_alpha);
542 char *saveptr =
NULL;
545 while (token && dest_idx < max_entries) {
546 dest[dest_idx++] = strtoul(token,
NULL, 10);
551 #if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
552 static void vp8_ts_parse_int64_array(int64_t *dest,
char *
value,
size_t value_len,
int max_entries)
555 char *saveptr =
NULL;
558 while (token && dest_idx < max_entries) {
559 dest[dest_idx++] = strtoull(token,
NULL, 10);
566 int *layer_flags,
int *flag_periodicity)
568 switch (layering_mode) {
573 static const int ids[2] = { 0, 1 };
574 cfg->ts_periodicity = 2;
575 *flag_periodicity = 2;
576 cfg->ts_number_layers = 2;
577 cfg->ts_rate_decimator[0] = 2;
578 cfg->ts_rate_decimator[1] = 1;
579 memcpy(cfg->ts_layer_id, ids,
sizeof(ids));
582 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
583 VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
585 VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_GF |
586 VP8_EFLAG_NO_UPD_LAST |
587 VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_GF;
597 static const int ids[4] = { 0, 2, 1, 2 };
598 cfg->ts_periodicity = 4;
599 *flag_periodicity = 4;
600 cfg->ts_number_layers = 3;
601 cfg->ts_rate_decimator[0] = 4;
602 cfg->ts_rate_decimator[1] = 2;
603 cfg->ts_rate_decimator[2] = 1;
604 memcpy(cfg->ts_layer_id, ids,
sizeof(ids));
611 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
612 VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
614 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
615 VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
616 VP8_EFLAG_NO_UPD_ARF;
618 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
619 VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
621 VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_ARF |
622 VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
623 VP8_EFLAG_NO_UPD_ARF;
632 static const int ids[4] = { 0, 2, 1, 2 };
633 cfg->ts_periodicity = 4;
634 *flag_periodicity = 4;
635 cfg->ts_number_layers = 3;
636 cfg->ts_rate_decimator[0] = 4;
637 cfg->ts_rate_decimator[1] = 2;
638 cfg->ts_rate_decimator[2] = 1;
639 memcpy(cfg->ts_layer_id, ids,
sizeof(ids));
645 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
646 VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
648 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
649 VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF;
651 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
652 VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
654 VP8_EFLAG_NO_REF_LAST |
655 VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
656 VP8_EFLAG_NO_UPD_ARF;
672 size_t value_len = strlen(
value);
673 int ts_layering_mode = 0;
678 if (!strcmp(
key,
"ts_number_layers"))
679 enccfg->ts_number_layers = strtoul(
value, &
value, 10);
680 else if (!strcmp(
key,
"ts_target_bitrate")) {
683 #if (VPX_ENCODER_ABI_VERSION >= 12) && CONFIG_LIBVPX_VP9_ENCODER
687 }
else if (!strcmp(
key,
"ts_rate_decimator")) {
689 }
else if (!strcmp(
key,
"ts_periodicity")) {
690 enccfg->ts_periodicity = strtoul(
value, &
value, 10);
691 }
else if (!strcmp(
key,
"ts_layer_id")) {
693 }
else if (!strcmp(
key,
"ts_layering_mode")) {
698 #if (VPX_ENCODER_ABI_VERSION >= 12) && CONFIG_LIBVPX_VP9_ENCODER
699 enccfg->temporal_layering_mode = VP9E_TEMPORAL_LAYERING_MODE_BYPASS;
700 enccfg->ss_number_layers = 1;
702 if (ts_layering_mode) {
712 #if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
713 static int vpx_ref_frame_config_set_value(vpx_svc_ref_frame_config_t *ref_frame_config,
714 int ss_number_layers,
char *
key,
char *
value)
716 size_t value_len = strlen(
value);
721 if (!strcmp(
key,
"rfc_update_buffer_slot")) {
723 }
else if (!strcmp(
key,
"rfc_update_last")) {
725 }
else if (!strcmp(
key,
"rfc_update_golden")) {
727 }
else if (!strcmp(
key,
"rfc_update_alt_ref")) {
729 }
else if (!strcmp(
key,
"rfc_lst_fb_idx")) {
731 }
else if (!strcmp(
key,
"rfc_gld_fb_idx")) {
733 }
else if (!strcmp(
key,
"rfc_alt_fb_idx")) {
735 }
else if (!strcmp(
key,
"rfc_reference_last")) {
737 }
else if (!strcmp(
key,
"rfc_reference_golden")) {
739 }
else if (!strcmp(
key,
"rfc_reference_alt_ref")) {
741 }
else if (!strcmp(
key,
"rfc_reference_duration")) {
742 vp8_ts_parse_int64_array(ref_frame_config->duration,
value, value_len, ss_number_layers);
748 static int vpx_parse_ref_frame_config_element(vpx_svc_ref_frame_config_t *ref_frame_config,
749 int ss_number_layers,
const char **buf)
751 const char key_val_sep[] =
"=";
752 const char pairs_sep[] =
":";
757 if (
key && *
key && strspn(*buf, key_val_sep)) {
763 ret = vpx_ref_frame_config_set_value(ref_frame_config, ss_number_layers,
key,
val);
773 static int vpx_parse_ref_frame_config(vpx_svc_ref_frame_config_t *ref_frame_config,
774 int ss_number_layers,
const char *str)
780 vpx_parse_ref_frame_config_element(ref_frame_config, ss_number_layers, &str);
792 #if CONFIG_LIBVPX_VP9_ENCODER
794 struct vpx_codec_enc_cfg *enccfg, vpx_codec_flags_t *
flags,
795 vpx_img_fmt_t *img_fmt)
799 enccfg->g_bit_depth = enccfg->g_input_bit_depth =
desc->comp[0].depth;
803 enccfg->g_profile = 0;
804 *img_fmt = VPX_IMG_FMT_I420;
807 enccfg->g_profile = 1;
808 *img_fmt = VPX_IMG_FMT_I422;
811 enccfg->g_profile = 1;
812 *img_fmt = VPX_IMG_FMT_I440;
815 ctx->vpx_cs = VPX_CS_SRGB;
817 enccfg->g_profile = 1;
818 *img_fmt = VPX_IMG_FMT_I444;
822 if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) {
823 enccfg->g_profile = 2;
824 *img_fmt = VPX_IMG_FMT_I42016;
825 *
flags |= VPX_CODEC_USE_HIGHBITDEPTH;
831 if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) {
832 enccfg->g_profile = 3;
833 *img_fmt = VPX_IMG_FMT_I42216;
834 *
flags |= VPX_CODEC_USE_HIGHBITDEPTH;
840 if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) {
841 enccfg->g_profile = 3;
842 *img_fmt = VPX_IMG_FMT_I44016;
843 *
flags |= VPX_CODEC_USE_HIGHBITDEPTH;
849 ctx->vpx_cs = VPX_CS_SRGB;
852 if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) {
853 enccfg->g_profile = 3;
854 *img_fmt = VPX_IMG_FMT_I44416;
855 *
flags |= VPX_CODEC_USE_HIGHBITDEPTH;
868 enum vpx_color_space vpx_cs;
872 vpx_cs =
ctx->vpx_cs;
892 #if VPX_ENCODER_ABI_VERSION >= 11
895 enum vpx_color_range vpx_cr;
915 struct vpx_codec_enc_cfg *enccfg)
919 avctx->
bit_rate = enccfg->rc_target_bitrate * 1000;
920 if (enccfg->rc_end_usage == VPX_CQ) {
922 "Bitrate not specified for constrained quality mode, using default of %dkbit/sec\n",
923 enccfg->rc_target_bitrate);
925 enccfg->rc_end_usage = VPX_CQ;
928 "Neither bitrate nor constrained quality specified, using default CRF of %d and bitrate of %dkbit/sec\n",
929 ctx->crf, enccfg->rc_target_bitrate);
934 #if CONFIG_LIBVPX_VP9_ENCODER
940 struct vpx_codec_enc_cfg *enccfg)
944 if (enccfg->rc_end_usage != VPX_Q &&
ctx->lossless < 0) {
945 enccfg->rc_end_usage = VPX_Q;
948 "Neither bitrate nor constrained quality specified, using default CRF of %d\n",
959 struct vpx_codec_enc_cfg *enccfg)
962 #if CONFIG_LIBVPX_VP9_ENCODER
964 set_vp9_defaults(avctx, enccfg);
972 const struct vpx_codec_iface *iface)
975 struct vpx_codec_enc_cfg enccfg = { 0 };
976 struct vpx_codec_enc_cfg enccfg_alpha;
980 vpx_img_fmt_t img_fmt = VPX_IMG_FMT_I420;
981 #if CONFIG_LIBVPX_VP9_ENCODER
982 vpx_codec_caps_t codec_caps = vpx_codec_get_caps(iface);
983 vpx_svc_extra_cfg_t svc_params;
993 if ((res = vpx_codec_enc_config_default(iface, &enccfg, 0)) != VPX_CODEC_OK) {
995 vpx_codec_err_to_string(res));
1003 #if CONFIG_LIBVPX_VP9_ENCODER
1018 enccfg.g_w = avctx->
width;
1019 enccfg.g_h = avctx->
height;
1024 enccfg.g_lag_in_frames=
ctx->lag_in_frames;
1027 enccfg.g_pass = VPX_RC_FIRST_PASS;
1029 enccfg.g_pass = VPX_RC_LAST_PASS;
1031 enccfg.g_pass = VPX_RC_ONE_PASS;
1035 enccfg.rc_end_usage = VPX_CBR;
1036 }
else if (
ctx->crf >= 0) {
1037 enccfg.rc_end_usage = VPX_CQ;
1038 #if CONFIG_LIBVPX_VP9_ENCODER
1040 enccfg.rc_end_usage = VPX_Q;
1047 #if CONFIG_LIBVPX_VP9_ENCODER
1048 enccfg.ss_target_bitrate[0] = enccfg.rc_target_bitrate;
1056 enccfg.rc_min_quantizer =
1057 enccfg.rc_max_quantizer = 0;
1059 if (avctx->
qmin >= 0)
1060 enccfg.rc_min_quantizer = avctx->
qmin;
1061 if (avctx->
qmax >= 0)
1062 enccfg.rc_max_quantizer = avctx->
qmax;
1065 if (enccfg.rc_end_usage == VPX_CQ
1066 #
if CONFIG_LIBVPX_VP9_ENCODER
1067 || enccfg.rc_end_usage == VPX_Q
1070 if (
ctx->crf < enccfg.rc_min_quantizer ||
ctx->crf > enccfg.rc_max_quantizer) {
1072 "CQ level %d must be between minimum and maximum quantizer value (%d-%d)\n",
1073 ctx->crf, enccfg.rc_min_quantizer, enccfg.rc_max_quantizer);
1078 enccfg.rc_dropframe_thresh =
ctx->drop_threshold;
1083 enccfg.rc_2pass_vbr_minsection_pct =
1086 enccfg.rc_2pass_vbr_maxsection_pct =
1088 #if CONFIG_LIBVPX_VP9_ENCODER
1090 #if VPX_ENCODER_ABI_VERSION >= 14
1091 if (
ctx->corpus_complexity >= 0)
1092 enccfg.rc_2pass_vbr_corpus_complexity =
ctx->corpus_complexity;
1101 enccfg.rc_buf_initial_sz =
1103 enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
1104 if (
ctx->rc_undershoot_pct >= 0)
1105 enccfg.rc_undershoot_pct =
ctx->rc_undershoot_pct;
1106 if (
ctx->rc_overshoot_pct >= 0)
1107 enccfg.rc_overshoot_pct =
ctx->rc_overshoot_pct;
1113 enccfg.kf_max_dist = avctx->
gop_size;
1115 if (enccfg.g_pass == VPX_RC_FIRST_PASS)
1116 enccfg.g_lag_in_frames = 0;
1117 else if (enccfg.g_pass == VPX_RC_LAST_PASS) {
1118 int decode_size,
ret;
1125 ctx->twopass_stats.sz = strlen(avctx->
stats_in) * 3 / 4;
1130 ctx->twopass_stats.sz);
1131 ctx->twopass_stats.sz = 0;
1135 ctx->twopass_stats.sz);
1136 if (decode_size < 0) {
1141 ctx->twopass_stats.sz = decode_size;
1142 enccfg.rc_twopass_stats_in =
ctx->twopass_stats;
1149 enccfg.g_profile = avctx->
profile;
1156 "Error parsing option '%s = %s'.\n",
1161 res = vpx_codec_enc_init(&
ctx->encoder, iface, &enccfg,
flags);
1162 if (res != VPX_CODEC_OK) {
1169 #if CONFIG_LIBVPX_VP9_ENCODER
1171 memset(&svc_params, 0,
sizeof(svc_params));
1172 for (
int i = 0;
i < enccfg.ts_number_layers; ++
i) {
1173 svc_params.max_quantizers[
i] = enccfg.rc_max_quantizer;
1174 svc_params.min_quantizers[
i] = enccfg.rc_min_quantizer;
1176 svc_params.scaling_factor_num[0] = enccfg.g_h;
1177 svc_params.scaling_factor_den[0] = enccfg.g_h;
1178 #if VPX_ENCODER_ABI_VERSION >= 12
1180 codecctl_intp(avctx, VP9E_SET_SVC_PARAMETERS, (
int *)&svc_params);
1184 if (
ctx->is_alpha) {
1185 enccfg_alpha = enccfg;
1186 res = vpx_codec_enc_init(&
ctx->encoder_alpha, iface, &enccfg_alpha,
flags);
1187 if (res != VPX_CODEC_OK) {
1197 ctx->auto_alt_ref = 1;
1198 if (
ctx->auto_alt_ref >= 0)
1201 if (
ctx->arnr_max_frames >= 0)
1203 if (
ctx->arnr_strength >= 0)
1205 if (
ctx->arnr_type >= 0)
1211 av_log(avctx,
AV_LOG_ERROR,
"Transparency encoding with auto_alt_ref does not work\n");
1215 if (
ctx->sharpness >= 0)
1219 codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY,
ctx->noise_sensitivity);
1225 if (
ctx->max_intra_rate >= 0)
1226 codecctl_int(avctx, VP8E_SET_MAX_INTRA_BITRATE_PCT,
ctx->max_intra_rate);
1228 #if CONFIG_LIBVPX_VP9_ENCODER
1230 if (
ctx->lossless >= 0)
1232 if (
ctx->tile_columns >= 0)
1234 if (
ctx->tile_rows >= 0)
1236 if (
ctx->frame_parallel >= 0)
1237 codecctl_int(avctx, VP9E_SET_FRAME_PARALLEL_DECODING,
ctx->frame_parallel);
1238 if (
ctx->aq_mode >= 0)
1240 set_colorspace(avctx);
1241 #if VPX_ENCODER_ABI_VERSION >= 11
1244 #if VPX_ENCODER_ABI_VERSION >= 12
1247 #ifdef VPX_CTRL_VP9E_SET_ROW_MT
1248 if (
ctx->row_mt >= 0)
1251 #ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
1252 if (
ctx->tune_content >= 0)
1255 #ifdef VPX_CTRL_VP9E_SET_TPL
1256 if (
ctx->tpl_model >= 0)
1259 #ifdef VPX_CTRL_VP9E_SET_MIN_GF_INTERVAL
1260 if (
ctx->min_gf_interval >= 0)
1269 vpx_img_wrap(&
ctx->rawimg, img_fmt, avctx->
width, avctx->
height, 1,
1271 #if CONFIG_LIBVPX_VP9_ENCODER
1273 ctx->rawimg.bit_depth = enccfg.g_bit_depth;
1280 if (enccfg.rc_end_usage == VPX_CBR ||
1281 enccfg.g_pass != VPX_RC_ONE_PASS) {
1292 const struct vpx_codec_cx_pkt *
src,
1295 dst->
pts =
src->data.frame.pts;
1296 dst->
flags =
src->data.frame.flags;
1297 dst->
sz =
src->data.frame.sz;
1298 dst->
buf =
src->data.frame.buf;
1301 if (!(dst->
flags & VPX_FRAME_IS_INVISIBLE)) {
1303 if (
ctx->have_sse) {
1308 memcpy(dst->
sse,
ctx->sse,
sizeof(dst->
sse));
1336 if (!!(cx_frame->
flags & VPX_FRAME_IS_KEY)) {
1343 ret = vpx_codec_control(&
ctx->encoder, VP8E_GET_LAST_QUANTIZER_64, &
quality);
1344 if (
ret != VPX_CODEC_OK)
1347 cx_frame->
have_sse ? 3 : 0, pict_type);
1351 for (
int i = 0;
i < 3; ++
i)
1355 if (alpha_cx_frame) {
1358 alpha_cx_frame->
sz + 8);
1364 memcpy(side_data + 8, alpha_cx_frame->
buf, alpha_cx_frame->
sz);
1385 const struct vpx_codec_cx_pkt *
pkt;
1386 const void *iter =
NULL;
1389 if (!
ctx->is_alpha && *frame_list) {
1395 *frame_list = cx_frame->
next;
1401 while (
pkt = vpx_codec_get_cx_data(encoder, &iter)) {
1402 switch (
pkt->kind) {
1403 case VPX_CODEC_CX_FRAME_PKT:
1404 if (!
ctx->is_alpha && !
size) {
1419 "Frame queue element alloc failed\n");
1425 if (!cx_frame->
buf) {
1436 case VPX_CODEC_STATS_PKT: {
1437 struct vpx_fixed_buf *
stats = &
ctx->twopass_stats;
1442 &
ctx->twopass_stats_size,
1457 case VPX_CODEC_PSNR_PKT:
1467 case VPX_CODEC_CUSTOM_PKT:
1477 vpx_roi_map_t *roi_map,
int block_size,
int segment_cnt)
1482 #define MAX_DELTA_Q 63
1497 memset(roi_map, 0,
sizeof(*roi_map));
1508 if (!self_size || sd->
size % self_size) {
1512 nb_rois = sd->
size / self_size;
1518 for (
int i = 0;
i < nb_rois;
i++) {
1532 if (!segment_mapping[mapping_index]) {
1533 if (segment_id == segment_cnt) {
1535 "ROI only supports %d segments (and segment 0 is reserved for non-ROIs), skipping the left ones.\n",
1540 segment_mapping[mapping_index] = segment_id + 1;
1541 roi_map->delta_q[segment_id] =
delta_q;
1546 roi_map->rows = (frame_height + block_size - 1) / block_size;
1547 roi_map->cols = (frame_width + block_size - 1) / block_size;
1548 roi_map->roi_map =
av_calloc(roi_map->rows * roi_map->cols,
sizeof(*roi_map->roi_map));
1549 if (!roi_map->roi_map) {
1557 for (
int i = nb_rois - 1;
i >= 0;
i--) {
1560 int starty, endy, startx, endx;
1564 starty =
av_clip(roi->
top / block_size, 0, roi_map->rows);
1565 endy =
av_clip((roi->
bottom + block_size - 1) / block_size, 0, roi_map->rows);
1566 startx =
av_clip(roi->
left / block_size, 0, roi_map->cols);
1567 endx =
av_clip((roi->
right + block_size - 1) / block_size, 0, roi_map->cols);
1573 if (mapping_value) {
1574 for (
int y = starty; y < endy; y++)
1575 for (
int x = startx; x < endx; x++)
1576 roi_map->roi_map[x + y * roi_map->cols] = mapping_value - 1;
1587 #ifdef VPX_CTRL_VP9E_SET_ROI_MAP
1588 int version = vpx_codec_version();
1589 int major = VPX_VERSION_MAJOR(
version);
1590 int minor = VPX_VERSION_MINOR(
version);
1591 int patch = VPX_VERSION_PATCH(
version);
1593 if (major > 1 || (major == 1 && minor > 8) || (major == 1 && minor == 8 && patch >= 1)) {
1594 vpx_roi_map_t roi_map;
1595 const int segment_cnt = 8;
1596 const int block_size = 8;
1599 if (
ctx->aq_mode > 0 ||
ctx->cpu_used < 5 ||
ctx->deadline != VPX_DL_REALTIME) {
1600 if (!
ctx->roi_warned) {
1601 ctx->roi_warned = 1;
1603 "and deadline is REALTIME, so skipping ROI.\n");
1608 ret =
set_roi_map(avctx, sd, frame_width, frame_height, &roi_map, block_size, segment_cnt);
1614 memset(roi_map.ref_frame, -1,
sizeof(roi_map.ref_frame));
1616 if (vpx_codec_control(&
ctx->encoder, VP9E_SET_ROI_MAP, &roi_map)) {
1625 if (!
ctx->roi_warned) {
1626 ctx->roi_warned = 1;
1627 av_log(avctx,
AV_LOG_WARNING,
"ROI is not supported, please upgrade libvpx to version >= 1.8.1. "
1628 "You may need to rebuild ffmpeg.\n");
1635 vpx_roi_map_t roi_map;
1636 const int segment_cnt = 4;
1637 const int block_size = 16;
1640 int ret =
set_roi_map(avctx, sd, frame_width, frame_height, &roi_map, block_size, segment_cnt);
1646 if (vpx_codec_control(&
ctx->encoder, VP8E_SET_ROI_MAP, &roi_map)) {
1658 struct vpx_image *rawimg_alpha = &
ctx->rawimg_alpha;
1659 unsigned char **
planes = rawimg_alpha->planes;
1660 int *
stride = rawimg_alpha->stride;
1662 if (!
planes[VPX_PLANE_U] ||
1664 width != (
int)rawimg_alpha->d_w ||
1665 height != (
int)rawimg_alpha->d_h) {
1669 vpx_img_wrap(rawimg_alpha, VPX_IMG_FMT_I420,
width,
height, 1,
1687 struct vpx_image *rawimg =
NULL;
1688 struct vpx_image *rawimg_alpha =
NULL;
1689 int64_t timestamp = 0;
1690 int res, coded_size;
1691 vpx_enc_frame_flags_t
flags = 0;
1692 const struct vpx_codec_enc_cfg *enccfg =
ctx->encoder.config.enc;
1693 vpx_svc_layer_id_t layer_id;
1694 int layer_id_valid = 0;
1697 if (avctx->
qmax >= 0 && enccfg->rc_max_quantizer != avctx->
qmax) {
1698 struct vpx_codec_enc_cfg cfg = *enccfg;
1699 cfg.rc_max_quantizer = avctx->
qmax;
1700 res = vpx_codec_enc_config_set(&
ctx->encoder, &cfg);
1701 if (res != VPX_CODEC_OK) {
1709 rawimg = &
ctx->rawimg;
1710 rawimg->planes[VPX_PLANE_Y] =
frame->
data[0];
1711 rawimg->planes[VPX_PLANE_U] =
frame->
data[1];
1712 rawimg->planes[VPX_PLANE_V] =
frame->
data[2];
1716 if (
ctx->is_alpha) {
1717 rawimg_alpha = &
ctx->rawimg_alpha;
1721 rawimg_alpha->planes[VPX_PLANE_Y] =
frame->
data[3];
1725 #if VPX_IMAGE_ABI_VERSION >= 4
1728 rawimg->range = VPX_CR_STUDIO_RANGE;
1731 rawimg->range = VPX_CR_FULL_RANGE;
1736 flags |= VPX_EFLAG_FORCE_KF;
1743 memset(&layer_id, 0,
sizeof(layer_id));
1747 layer_id.temporal_layer_id = strtoul(en->
value,
NULL, 10);
1748 #ifdef VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT
1749 layer_id.temporal_layer_id_per_spatial[0] = layer_id.temporal_layer_id;
1753 #if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
1758 int ret = vpx_parse_ref_frame_config(&
ctx->ref_frame_config,
1759 enccfg->ss_number_layers, en->
value);
1762 "Error parsing ref_frame_config option %s.\n", en->
value);
1766 codecctl_intp(avctx, VP9E_SET_SVC_REF_FRAME_CONFIG, (
int *)&
ctx->ref_frame_config);
1769 "Ignoring ref-frame-config for a non-VP9 codec\n");
1792 if (enccfg->ts_number_layers > 1 &&
ctx->ts_layer_flags) {
1793 if (
flags & VPX_EFLAG_FORCE_KF) {
1795 ctx->current_temporal_idx = 0;
1796 flags = VPX_EFLAG_FORCE_KF;
1802 flags |=
ctx->ts_layer_flags[
ctx->current_temporal_idx];
1804 memset(&layer_id, 0,
sizeof(layer_id));
1805 #if VPX_ENCODER_ABI_VERSION >= 12
1806 layer_id.spatial_layer_id = 0;
1808 layer_id.temporal_layer_id = enccfg->ts_layer_id[
ctx->current_temporal_idx];
1809 #ifdef VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT
1810 layer_id.temporal_layer_id_per_spatial[0] = layer_id.temporal_layer_id;
1815 if (layer_id_valid) {
1817 codecctl_int(avctx, VP8E_SET_TEMPORAL_LAYER_ID, layer_id.temporal_layer_id);
1819 #if CONFIG_LIBVPX_VP9_ENCODER && VPX_ENCODER_ABI_VERSION >= 12
1821 codecctl_intp(avctx, VP9E_SET_SVC_LAYER_ID, (
int *)&layer_id);
1836 #if FF_API_TICKS_PER_FRAME
1843 res = vpx_codec_encode(&
ctx->encoder, rawimg, timestamp,
1845 if (res != VPX_CODEC_OK) {
1850 if (
ctx->is_alpha) {
1851 res = vpx_codec_encode(&
ctx->encoder_alpha, rawimg_alpha, timestamp,
1853 if (res != VPX_CODEC_OK) {
1860 if (
ctx->is_alpha) {
1863 if (
ctx->coded_frame_list &&
ctx->alpha_coded_frame_list) {
1868 coded_size =
storeframe(avctx, cx_frame, alpha_cx_frame,
pkt);
1871 ctx->coded_frame_list = cx_frame->
next;
1872 ctx->alpha_coded_frame_list = alpha_cx_frame->
next;
1888 ctx->twopass_stats.sz);
1889 }
else if (enccfg->ts_number_layers > 1 &&
ctx->ts_layer_flags) {
1890 ctx->current_temporal_idx = (
ctx->current_temporal_idx + 1) % enccfg->ts_periodicity;
1893 *got_packet = !!coded_size;
1897 #define OFFSET(x) offsetof(VPxContext, x)
1898 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1900 #define COMMON_OPTIONS \
1901 { "lag-in-frames", "Number of frames to look ahead for " \
1902 "alternate reference frame selection", OFFSET(lag_in_frames), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
1903 { "arnr-maxframes", "altref noise reduction max frame count", OFFSET(arnr_max_frames), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
1904 { "arnr-strength", "altref noise reduction filter strength", OFFSET(arnr_strength), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
1905 { "arnr-type", "altref noise reduction filter type", OFFSET(arnr_type), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE, "arnr_type"}, \
1906 { "backward", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "arnr_type" }, \
1907 { "forward", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, "arnr_type" }, \
1908 { "centered", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, VE, "arnr_type" }, \
1909 { "tune", "Tune the encoding to a specific scenario", OFFSET(tune), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE, "tune"}, \
1910 { "psnr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VP8_TUNE_PSNR}, 0, 0, VE, "tune"}, \
1911 { "ssim", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VP8_TUNE_SSIM}, 0, 0, VE, "tune"}, \
1912 { "deadline", "Time to spend encoding, in microseconds.", OFFSET(deadline), AV_OPT_TYPE_INT, {.i64 = VPX_DL_GOOD_QUALITY}, INT_MIN, INT_MAX, VE, "quality"}, \
1913 { "best", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VPX_DL_BEST_QUALITY}, 0, 0, VE, "quality"}, \
1914 { "good", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VPX_DL_GOOD_QUALITY}, 0, 0, VE, "quality"}, \
1915 { "realtime", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VPX_DL_REALTIME}, 0, 0, VE, "quality"}, \
1916 { "error-resilient", "Error resilience configuration", OFFSET(error_resilient), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, VE, "er"}, \
1917 { "max-intra-rate", "Maximum I-frame bitrate (pct) 0=unlimited", OFFSET(max_intra_rate), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
1918 { "default", "Improve resiliency against losses of whole frames", 0, AV_OPT_TYPE_CONST, {.i64 = VPX_ERROR_RESILIENT_DEFAULT}, 0, 0, VE, "er"}, \
1919 { "partitions", "The frame partitions are independently decodable " \
1920 "by the bool decoder, meaning that partitions can be decoded even " \
1921 "though earlier partitions have been lost. Note that intra prediction" \
1922 " is still done over the partition boundary.", 0, AV_OPT_TYPE_CONST, {.i64 = VPX_ERROR_RESILIENT_PARTITIONS}, 0, 0, VE, "er"}, \
1923 { "crf", "Select the quality for constant quality mode", offsetof(VPxContext, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE }, \
1924 { "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 }, \
1925 { "drop-threshold", "Frame drop threshold", offsetof(VPxContext, drop_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE }, \
1926 { "noise-sensitivity", "Noise sensitivity", OFFSET(noise_sensitivity), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 4, VE}, \
1927 { "undershoot-pct", "Datarate undershoot (min) target (%)", OFFSET(rc_undershoot_pct), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 100, VE }, \
1928 { "overshoot-pct", "Datarate overshoot (max) target (%)", OFFSET(rc_overshoot_pct), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1000, VE }, \
1929 { "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}, \
1931 #define LEGACY_OPTIONS \
1932 {"speed", "", offsetof(VPxContext, cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, -16, 16, VE}, \
1933 {"quality", "", offsetof(VPxContext, deadline), AV_OPT_TYPE_INT, {.i64 = VPX_DL_GOOD_QUALITY}, INT_MIN, INT_MAX, VE, "quality"}, \
1934 {"vp8flags", "", offsetof(VPxContext, flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, UINT_MAX, VE, "flags"}, \
1935 {"error_resilient", "enable error resilience", 0, AV_OPT_TYPE_CONST, {.i64 = VP8F_ERROR_RESILIENT}, INT_MIN, INT_MAX, VE, "flags"}, \
1936 {"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"}, \
1937 {"arnr_max_frames", "altref noise reduction max frame count", offsetof(VPxContext, arnr_max_frames), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 15, VE}, \
1938 {"arnr_strength", "altref noise reduction filter strength", offsetof(VPxContext, arnr_strength), AV_OPT_TYPE_INT, {.i64 = 3}, 0, 6, VE}, \
1939 {"arnr_type", "altref noise reduction filter type", offsetof(VPxContext, arnr_type), AV_OPT_TYPE_INT, {.i64 = 3}, 1, 3, VE}, \
1940 {"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}, \
1941 {"sharpness", "Increase sharpness at the expense of lower PSNR", offsetof(VPxContext, sharpness), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 7, VE},
1943 #if CONFIG_LIBVPX_VP8_ENCODER
1944 static const AVOption vp8_options[] = {
1946 {
"auto-alt-ref",
"Enable use of alternate reference "
1954 #if CONFIG_LIBVPX_VP9_ENCODER
1955 static const AVOption vp9_options[] = {
1957 {
"auto-alt-ref",
"Enable use of alternate reference "
1961 {
"tile-columns",
"Number of tile columns to use, log2",
OFFSET(tile_columns),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6,
VE},
1963 {
"frame-parallel",
"Enable frame parallel decodability features",
OFFSET(frame_parallel),
AV_OPT_TYPE_BOOL,{.i64 = -1}, -1, 1,
VE},
1964 #if VPX_ENCODER_ABI_VERSION >= 12
1965 {
"aq-mode",
"adaptive quantization mode",
OFFSET(aq_mode),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 4,
VE,
"aq_mode"},
1967 {
"aq-mode",
"adaptive quantization mode",
OFFSET(aq_mode),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 3,
VE,
"aq_mode"},
1970 {
"variance",
"Variance based Aq", 0,
AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0,
VE,
"aq_mode" },
1971 {
"complexity",
"Complexity based Aq", 0,
AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0,
VE,
"aq_mode" },
1973 #if VPX_ENCODER_ABI_VERSION >= 12
1977 #ifdef VPX_CTRL_VP9E_SET_ROW_MT
1980 #ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
1981 #if VPX_ENCODER_ABI_VERSION >= 14
1982 {
"tune-content",
"Tune content type",
OFFSET(tune_content),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2,
VE,
"tune_content" },
1984 {
"tune-content",
"Tune content type",
OFFSET(tune_content),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1,
VE,
"tune_content" },
1986 {
"default",
"Regular video content", 0,
AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0,
VE,
"tune_content" },
1987 {
"screen",
"Screen capture content", 0,
AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0,
VE,
"tune_content" },
1988 #if VPX_ENCODER_ABI_VERSION >= 14
1989 {
"film",
"Film content; improves grain retention", 0,
AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0,
VE,
"tune_content" },
1992 #if VPX_ENCODER_ABI_VERSION >= 14
1993 {
"corpus-complexity",
"corpus vbr complexity midpoint",
OFFSET(corpus_complexity),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 10000,
VE },
1995 #ifdef VPX_CTRL_VP9E_SET_TPL
1998 #ifdef VPX_CTRL_VP9E_SET_MIN_GF_INTERVAL
1999 {
"min-gf-interval",
"Minimum golden/alternate reference frame interval",
OFFSET(min_gf_interval),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX,
VE },
2006 #undef COMMON_OPTIONS
2007 #undef LEGACY_OPTIONS
2014 {
"keyint_min",
"-1" },
2018 #if CONFIG_LIBVPX_VP8_ENCODER
2021 return vpx_init(avctx, vpx_codec_vp8_cx());
2024 static const AVClass class_vp8 = {
2027 .option = vp8_options,
2039 .priv_data_size =
sizeof(VPxContext),
2046 .p.priv_class = &class_vp8,
2048 .p.wrapper_name =
"libvpx",
2052 #if CONFIG_LIBVPX_VP9_ENCODER
2055 return vpx_init(avctx, vpx_codec_vp9_cx());
2090 vpx_codec_caps_t codec_caps = vpx_codec_get_caps(vpx_codec_vp9_cx());
2091 if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH)
2092 codec->
p.
pix_fmts = vp9_pix_fmts_highbd;
2094 codec->
p.
pix_fmts = vp9_pix_fmts_highcol;
2097 static const AVClass class_vp9 = {
2100 .option = vp9_options,
2105 .
p.
name =
"libvpx-vp9",
2113 .p.priv_class = &class_vp9,
2114 .p.wrapper_name =
"libvpx",
2115 .priv_data_size =
sizeof(VPxContext),
2122 .init_static_data = vp9_init_static,