FFmpeg
libvpxenc.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, Google, Inc.
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * VP8/9 encoder support via libvpx
24  */
25 
26 #define VPX_DISABLE_CTRL_TYPECHECKS 1
27 #define VPX_CODEC_DISABLE_COMPAT 1
28 #include <vpx/vpx_encoder.h>
29 #include <vpx/vp8cx.h>
30 
31 #include "avcodec.h"
32 #include "internal.h"
33 #include "libavutil/avassert.h"
34 #include "libvpx.h"
35 #include "profiles.h"
36 #include "libavutil/avstring.h"
37 #include "libavutil/base64.h"
38 #include "libavutil/common.h"
39 #include "libavutil/internal.h"
40 #include "libavutil/intreadwrite.h"
41 #include "libavutil/mathematics.h"
42 #include "libavutil/opt.h"
43 
44 /**
45  * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h.
46  * One encoded frame returned from the library.
47  */
48 struct FrameListData {
49  void *buf; /**< compressed data buffer */
50  size_t sz; /**< length of compressed data */
51  void *buf_alpha;
52  size_t sz_alpha;
53  int64_t pts; /**< time stamp to show frame
54  (in timebase units) */
55  unsigned long duration; /**< duration to show frame
56  (in timebase units) */
57  uint32_t flags; /**< flags for this frame */
58  uint64_t sse[4];
59  int have_sse; /**< true if we have pending sse[] */
60  uint64_t frame_number;
61  struct FrameListData *next;
62 };
63 
64 typedef struct VPxEncoderContext {
65  AVClass *class;
66  struct vpx_codec_ctx encoder;
67  struct vpx_image rawimg;
68  struct vpx_codec_ctx encoder_alpha;
69  struct vpx_image rawimg_alpha;
71  struct vpx_fixed_buf twopass_stats;
72  int deadline; //i.e., RT/GOOD/BEST
73  uint64_t sse[4];
74  int have_sse; /**< true if we have pending sse[] */
75  uint64_t frame_number;
77 
78  int cpu_used;
79  int sharpness;
80  /**
81  * VP8 specific flags, see VP8F_* below.
82  */
83  int flags;
84 #define VP8F_ERROR_RESILIENT 0x00000001 ///< Enable measures appropriate for streaming over lossy links
85 #define VP8F_AUTO_ALT_REF 0x00000002 ///< Enable automatic alternate reference frame generation
86 
88 
91  int arnr_type;
92 
93  int tune;
94 
97  int crf;
102 
104 
105  // VP9-only
106  int lossless;
110  int aq_mode;
113  int vpx_cs;
114  float level;
115  int row_mt;
119 } VPxContext;
120 
121 /** String mappings for enum vp8e_enc_control_id */
122 static const char *const ctlidstr[] = {
123  [VP8E_SET_CPUUSED] = "VP8E_SET_CPUUSED",
124  [VP8E_SET_ENABLEAUTOALTREF] = "VP8E_SET_ENABLEAUTOALTREF",
125  [VP8E_SET_NOISE_SENSITIVITY] = "VP8E_SET_NOISE_SENSITIVITY",
126  [VP8E_SET_STATIC_THRESHOLD] = "VP8E_SET_STATIC_THRESHOLD",
127  [VP8E_SET_TOKEN_PARTITIONS] = "VP8E_SET_TOKEN_PARTITIONS",
128  [VP8E_SET_ARNR_MAXFRAMES] = "VP8E_SET_ARNR_MAXFRAMES",
129  [VP8E_SET_ARNR_STRENGTH] = "VP8E_SET_ARNR_STRENGTH",
130  [VP8E_SET_ARNR_TYPE] = "VP8E_SET_ARNR_TYPE",
131  [VP8E_SET_TUNING] = "VP8E_SET_TUNING",
132  [VP8E_SET_CQ_LEVEL] = "VP8E_SET_CQ_LEVEL",
133  [VP8E_SET_MAX_INTRA_BITRATE_PCT] = "VP8E_SET_MAX_INTRA_BITRATE_PCT",
134  [VP8E_SET_SHARPNESS] = "VP8E_SET_SHARPNESS",
135 #if CONFIG_LIBVPX_VP9_ENCODER
136  [VP9E_SET_LOSSLESS] = "VP9E_SET_LOSSLESS",
137  [VP9E_SET_TILE_COLUMNS] = "VP9E_SET_TILE_COLUMNS",
138  [VP9E_SET_TILE_ROWS] = "VP9E_SET_TILE_ROWS",
139  [VP9E_SET_FRAME_PARALLEL_DECODING] = "VP9E_SET_FRAME_PARALLEL_DECODING",
140  [VP9E_SET_AQ_MODE] = "VP9E_SET_AQ_MODE",
141  [VP9E_SET_COLOR_SPACE] = "VP9E_SET_COLOR_SPACE",
142 #if VPX_ENCODER_ABI_VERSION >= 11
143  [VP9E_SET_COLOR_RANGE] = "VP9E_SET_COLOR_RANGE",
144 #endif
145 #if VPX_ENCODER_ABI_VERSION >= 12
146  [VP9E_SET_TARGET_LEVEL] = "VP9E_SET_TARGET_LEVEL",
147  [VP9E_GET_LEVEL] = "VP9E_GET_LEVEL",
148 #endif
149 #ifdef VPX_CTRL_VP9E_SET_ROW_MT
150  [VP9E_SET_ROW_MT] = "VP9E_SET_ROW_MT",
151 #endif
152 #ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
153  [VP9E_SET_TUNE_CONTENT] = "VP9E_SET_TUNE_CONTENT",
154 #endif
155 #ifdef VPX_CTRL_VP9E_SET_TPL
156  [VP9E_SET_TPL] = "VP9E_SET_TPL",
157 #endif
158 #endif
159 };
160 
161 static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
162 {
163  VPxContext *ctx = avctx->priv_data;
164  const char *error = vpx_codec_error(&ctx->encoder);
165  const char *detail = vpx_codec_error_detail(&ctx->encoder);
166 
167  av_log(avctx, AV_LOG_ERROR, "%s: %s\n", desc, error);
168  if (detail)
169  av_log(avctx, AV_LOG_ERROR, " Additional information: %s\n", detail);
170 }
171 
173  const struct vpx_codec_enc_cfg *cfg)
174 {
175  int width = -30;
176  int level = AV_LOG_DEBUG;
177  int i;
178 
179  av_log(avctx, level, "vpx_codec_enc_cfg\n");
180  av_log(avctx, level, "generic settings\n"
181  " %*s%u\n %*s%u\n %*s%u\n %*s%u\n %*s%u\n"
182 #if CONFIG_LIBVPX_VP9_ENCODER
183  " %*s%u\n %*s%u\n"
184 #endif
185  " %*s{%u/%u}\n %*s%u\n %*s%d\n %*s%u\n",
186  width, "g_usage:", cfg->g_usage,
187  width, "g_threads:", cfg->g_threads,
188  width, "g_profile:", cfg->g_profile,
189  width, "g_w:", cfg->g_w,
190  width, "g_h:", cfg->g_h,
191 #if CONFIG_LIBVPX_VP9_ENCODER
192  width, "g_bit_depth:", cfg->g_bit_depth,
193  width, "g_input_bit_depth:", cfg->g_input_bit_depth,
194 #endif
195  width, "g_timebase:", cfg->g_timebase.num, cfg->g_timebase.den,
196  width, "g_error_resilient:", cfg->g_error_resilient,
197  width, "g_pass:", cfg->g_pass,
198  width, "g_lag_in_frames:", cfg->g_lag_in_frames);
199  av_log(avctx, level, "rate control settings\n"
200  " %*s%u\n %*s%u\n %*s%u\n %*s%u\n"
201  " %*s%d\n %*s%p(%"SIZE_SPECIFIER")\n %*s%u\n",
202  width, "rc_dropframe_thresh:", cfg->rc_dropframe_thresh,
203  width, "rc_resize_allowed:", cfg->rc_resize_allowed,
204  width, "rc_resize_up_thresh:", cfg->rc_resize_up_thresh,
205  width, "rc_resize_down_thresh:", cfg->rc_resize_down_thresh,
206  width, "rc_end_usage:", cfg->rc_end_usage,
207  width, "rc_twopass_stats_in:", cfg->rc_twopass_stats_in.buf, cfg->rc_twopass_stats_in.sz,
208  width, "rc_target_bitrate:", cfg->rc_target_bitrate);
209  av_log(avctx, level, "quantizer settings\n"
210  " %*s%u\n %*s%u\n",
211  width, "rc_min_quantizer:", cfg->rc_min_quantizer,
212  width, "rc_max_quantizer:", cfg->rc_max_quantizer);
213  av_log(avctx, level, "bitrate tolerance\n"
214  " %*s%u\n %*s%u\n",
215  width, "rc_undershoot_pct:", cfg->rc_undershoot_pct,
216  width, "rc_overshoot_pct:", cfg->rc_overshoot_pct);
217  av_log(avctx, level, "temporal layering settings\n"
218  " %*s%u\n", width, "ts_number_layers:", cfg->ts_number_layers);
219  av_log(avctx, level,
220  "\n %*s", width, "ts_target_bitrate:");
221  for (i = 0; i < VPX_TS_MAX_LAYERS; i++)
222  av_log(avctx, level, "%u ", cfg->ts_target_bitrate[i]);
223  av_log(avctx, level, "\n");
224  av_log(avctx, level,
225  "\n %*s", width, "ts_rate_decimator:");
226  for (i = 0; i < VPX_TS_MAX_LAYERS; i++)
227  av_log(avctx, level, "%u ", cfg->ts_rate_decimator[i]);
228  av_log(avctx, level, "\n");
229  av_log(avctx, level,
230  "\n %*s%u\n", width, "ts_periodicity:", cfg->ts_periodicity);
231  av_log(avctx, level,
232  "\n %*s", width, "ts_layer_id:");
233  for (i = 0; i < VPX_TS_MAX_PERIODICITY; i++)
234  av_log(avctx, level, "%u ", cfg->ts_layer_id[i]);
235  av_log(avctx, level, "\n");
236  av_log(avctx, level, "decoder buffer model\n"
237  " %*s%u\n %*s%u\n %*s%u\n",
238  width, "rc_buf_sz:", cfg->rc_buf_sz,
239  width, "rc_buf_initial_sz:", cfg->rc_buf_initial_sz,
240  width, "rc_buf_optimal_sz:", cfg->rc_buf_optimal_sz);
241  av_log(avctx, level, "2 pass rate control settings\n"
242  " %*s%u\n %*s%u\n %*s%u\n",
243  width, "rc_2pass_vbr_bias_pct:", cfg->rc_2pass_vbr_bias_pct,
244  width, "rc_2pass_vbr_minsection_pct:", cfg->rc_2pass_vbr_minsection_pct,
245  width, "rc_2pass_vbr_maxsection_pct:", cfg->rc_2pass_vbr_maxsection_pct);
246 #if VPX_ENCODER_ABI_VERSION >= 14
247  av_log(avctx, level, " %*s%u\n",
248  width, "rc_2pass_vbr_corpus_complexity:", cfg->rc_2pass_vbr_corpus_complexity);
249 #endif
250  av_log(avctx, level, "keyframing settings\n"
251  " %*s%d\n %*s%u\n %*s%u\n",
252  width, "kf_mode:", cfg->kf_mode,
253  width, "kf_min_dist:", cfg->kf_min_dist,
254  width, "kf_max_dist:", cfg->kf_max_dist);
255  av_log(avctx, level, "\n");
256 }
257 
258 static void coded_frame_add(void *list, struct FrameListData *cx_frame)
259 {
260  struct FrameListData **p = list;
261 
262  while (*p)
263  p = &(*p)->next;
264  *p = cx_frame;
265  cx_frame->next = NULL;
266 }
267 
268 static av_cold void free_coded_frame(struct FrameListData *cx_frame)
269 {
270  av_freep(&cx_frame->buf);
271  if (cx_frame->buf_alpha)
272  av_freep(&cx_frame->buf_alpha);
273  av_freep(&cx_frame);
274 }
275 
277 {
278  struct FrameListData *p = list;
279 
280  while (p) {
281  list = list->next;
282  free_coded_frame(p);
283  p = list;
284  }
285 }
286 
288  enum vp8e_enc_control_id id, int val)
289 {
290  VPxContext *ctx = avctx->priv_data;
291  char buf[80];
292  int width = -30;
293  int res;
294 
295  snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
296  av_log(avctx, AV_LOG_DEBUG, " %*s%d\n", width, buf, val);
297 
298  res = vpx_codec_control(&ctx->encoder, id, val);
299  if (res != VPX_CODEC_OK) {
300  snprintf(buf, sizeof(buf), "Failed to set %s codec control",
301  ctlidstr[id]);
302  log_encoder_error(avctx, buf);
303  }
304 
305  return res == VPX_CODEC_OK ? 0 : AVERROR(EINVAL);
306 }
307 
308 #if VPX_ENCODER_ABI_VERSION >= 12
309 static av_cold int codecctl_intp(AVCodecContext *avctx,
310  enum vp8e_enc_control_id id, int *val)
311 {
312  VPxContext *ctx = avctx->priv_data;
313  char buf[80];
314  int width = -30;
315  int res;
316 
317  snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
318  av_log(avctx, AV_LOG_DEBUG, " %*s%d\n", width, buf, *val);
319 
320  res = vpx_codec_control(&ctx->encoder, id, val);
321  if (res != VPX_CODEC_OK) {
322  snprintf(buf, sizeof(buf), "Failed to set %s codec control",
323  ctlidstr[id]);
324  log_encoder_error(avctx, buf);
325  }
326 
327  return res == VPX_CODEC_OK ? 0 : AVERROR(EINVAL);
328 }
329 #endif
330 
331 static av_cold int vpx_free(AVCodecContext *avctx)
332 {
333  VPxContext *ctx = avctx->priv_data;
334 
335 #if VPX_ENCODER_ABI_VERSION >= 12
336  if (avctx->codec_id == AV_CODEC_ID_VP9 && ctx->level >= 0 &&
337  !(avctx->flags & AV_CODEC_FLAG_PASS1)) {
338  int level_out = 0;
339  if (!codecctl_intp(avctx, VP9E_GET_LEVEL, &level_out))
340  av_log(avctx, AV_LOG_INFO, "Encoded level %.1f\n", level_out * 0.1);
341  }
342 #endif
343 
344  vpx_codec_destroy(&ctx->encoder);
345  if (ctx->is_alpha)
346  vpx_codec_destroy(&ctx->encoder_alpha);
347  av_freep(&ctx->twopass_stats.buf);
348  av_freep(&avctx->stats_out);
349  free_frame_list(ctx->coded_frame_list);
350  return 0;
351 }
352 
353 static void vp8_ts_parse_int_array(int *dest, char *value, size_t value_len, int max_entries)
354 {
355  int dest_idx = 0;
356  char *saveptr = NULL;
357  char *token = av_strtok(value, ",", &saveptr);
358 
359  while (token && dest_idx < max_entries) {
360  dest[dest_idx++] = strtoul(token, NULL, 10);
361  token = av_strtok(NULL, ",", &saveptr);
362  }
363 }
364 
365 static int vp8_ts_param_parse(struct vpx_codec_enc_cfg *enccfg, char *key, char *value)
366 {
367  size_t value_len = strlen(value);
368 
369  if (!value_len)
370  return -1;
371 
372  if (!strcmp(key, "ts_number_layers"))
373  enccfg->ts_number_layers = strtoul(value, &value, 10);
374  else if (!strcmp(key, "ts_target_bitrate"))
375  vp8_ts_parse_int_array(enccfg->ts_target_bitrate, value, value_len, VPX_TS_MAX_LAYERS);
376  else if (!strcmp(key, "ts_rate_decimator"))
377  vp8_ts_parse_int_array(enccfg->ts_rate_decimator, value, value_len, VPX_TS_MAX_LAYERS);
378  else if (!strcmp(key, "ts_periodicity"))
379  enccfg->ts_periodicity = strtoul(value, &value, 10);
380  else if (!strcmp(key, "ts_layer_id"))
381  vp8_ts_parse_int_array(enccfg->ts_layer_id, value, value_len, VPX_TS_MAX_PERIODICITY);
382 
383  return 0;
384 }
385 
386 #if CONFIG_LIBVPX_VP9_ENCODER
387 static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps,
388  struct vpx_codec_enc_cfg *enccfg, vpx_codec_flags_t *flags,
389  vpx_img_fmt_t *img_fmt)
390 {
391  VPxContext av_unused *ctx = avctx->priv_data;
392  enccfg->g_bit_depth = enccfg->g_input_bit_depth = 8;
393  switch (avctx->pix_fmt) {
394  case AV_PIX_FMT_YUV420P:
395  case AV_PIX_FMT_YUVA420P:
396  enccfg->g_profile = 0;
397  *img_fmt = VPX_IMG_FMT_I420;
398  return 0;
399  case AV_PIX_FMT_YUV422P:
400  enccfg->g_profile = 1;
401  *img_fmt = VPX_IMG_FMT_I422;
402  return 0;
403  case AV_PIX_FMT_YUV440P:
404  enccfg->g_profile = 1;
405  *img_fmt = VPX_IMG_FMT_I440;
406  return 0;
407  case AV_PIX_FMT_GBRP:
408  ctx->vpx_cs = VPX_CS_SRGB;
409  case AV_PIX_FMT_YUV444P:
410  enccfg->g_profile = 1;
411  *img_fmt = VPX_IMG_FMT_I444;
412  return 0;
415  if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) {
416  enccfg->g_bit_depth = enccfg->g_input_bit_depth =
417  avctx->pix_fmt == AV_PIX_FMT_YUV420P10 ? 10 : 12;
418  enccfg->g_profile = 2;
419  *img_fmt = VPX_IMG_FMT_I42016;
420  *flags |= VPX_CODEC_USE_HIGHBITDEPTH;
421  return 0;
422  }
423  break;
426  if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) {
427  enccfg->g_bit_depth = enccfg->g_input_bit_depth =
428  avctx->pix_fmt == AV_PIX_FMT_YUV422P10 ? 10 : 12;
429  enccfg->g_profile = 3;
430  *img_fmt = VPX_IMG_FMT_I42216;
431  *flags |= VPX_CODEC_USE_HIGHBITDEPTH;
432  return 0;
433  }
434  break;
437  if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) {
438  enccfg->g_bit_depth = enccfg->g_input_bit_depth =
439  avctx->pix_fmt == AV_PIX_FMT_YUV440P10 ? 10 : 12;
440  enccfg->g_profile = 3;
441  *img_fmt = VPX_IMG_FMT_I44016;
442  *flags |= VPX_CODEC_USE_HIGHBITDEPTH;
443  return 0;
444  }
445  break;
446  case AV_PIX_FMT_GBRP10:
447  case AV_PIX_FMT_GBRP12:
448  ctx->vpx_cs = VPX_CS_SRGB;
451  if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) {
452  enccfg->g_bit_depth = enccfg->g_input_bit_depth =
453  avctx->pix_fmt == AV_PIX_FMT_YUV444P10 ||
454  avctx->pix_fmt == AV_PIX_FMT_GBRP10 ? 10 : 12;
455  enccfg->g_profile = 3;
456  *img_fmt = VPX_IMG_FMT_I44416;
457  *flags |= VPX_CODEC_USE_HIGHBITDEPTH;
458  return 0;
459  }
460  break;
461  default:
462  break;
463  }
464  av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format.\n");
465  return AVERROR_INVALIDDATA;
466 }
467 
468 static void set_colorspace(AVCodecContext *avctx)
469 {
470  enum vpx_color_space vpx_cs;
471  VPxContext *ctx = avctx->priv_data;
472 
473  if (ctx->vpx_cs) {
474  vpx_cs = ctx->vpx_cs;
475  } else {
476  switch (avctx->colorspace) {
477  case AVCOL_SPC_RGB: vpx_cs = VPX_CS_SRGB; break;
478  case AVCOL_SPC_BT709: vpx_cs = VPX_CS_BT_709; break;
479  case AVCOL_SPC_UNSPECIFIED: vpx_cs = VPX_CS_UNKNOWN; break;
480  case AVCOL_SPC_RESERVED: vpx_cs = VPX_CS_RESERVED; break;
481  case AVCOL_SPC_BT470BG: vpx_cs = VPX_CS_BT_601; break;
482  case AVCOL_SPC_SMPTE170M: vpx_cs = VPX_CS_SMPTE_170; break;
483  case AVCOL_SPC_SMPTE240M: vpx_cs = VPX_CS_SMPTE_240; break;
484  case AVCOL_SPC_BT2020_NCL: vpx_cs = VPX_CS_BT_2020; break;
485  default:
486  av_log(avctx, AV_LOG_WARNING, "Unsupported colorspace (%d)\n",
487  avctx->colorspace);
488  return;
489  }
490  }
491  codecctl_int(avctx, VP9E_SET_COLOR_SPACE, vpx_cs);
492 }
493 
494 #if VPX_ENCODER_ABI_VERSION >= 11
495 static void set_color_range(AVCodecContext *avctx)
496 {
497  enum vpx_color_range vpx_cr;
498  switch (avctx->color_range) {
500  case AVCOL_RANGE_MPEG: vpx_cr = VPX_CR_STUDIO_RANGE; break;
501  case AVCOL_RANGE_JPEG: vpx_cr = VPX_CR_FULL_RANGE; break;
502  default:
503  av_log(avctx, AV_LOG_WARNING, "Unsupported color range (%d)\n",
504  avctx->color_range);
505  return;
506  }
507 
508  codecctl_int(avctx, VP9E_SET_COLOR_RANGE, vpx_cr);
509 }
510 #endif
511 #endif
512 
513 static av_cold int vpx_init(AVCodecContext *avctx,
514  const struct vpx_codec_iface *iface)
515 {
516  VPxContext *ctx = avctx->priv_data;
517  struct vpx_codec_enc_cfg enccfg = { 0 };
518  struct vpx_codec_enc_cfg enccfg_alpha;
519  vpx_codec_flags_t flags = (avctx->flags & AV_CODEC_FLAG_PSNR) ? VPX_CODEC_USE_PSNR : 0;
520  AVCPBProperties *cpb_props;
521  int res;
522  vpx_img_fmt_t img_fmt = VPX_IMG_FMT_I420;
523 #if CONFIG_LIBVPX_VP9_ENCODER
524  vpx_codec_caps_t codec_caps = vpx_codec_get_caps(iface);
525 #endif
526 
527  av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str());
528  av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config());
529 
530  if (avctx->pix_fmt == AV_PIX_FMT_YUVA420P)
531  ctx->is_alpha = 1;
532 
533  if ((res = vpx_codec_enc_config_default(iface, &enccfg, 0)) != VPX_CODEC_OK) {
534  av_log(avctx, AV_LOG_ERROR, "Failed to get config: %s\n",
535  vpx_codec_err_to_string(res));
536  return AVERROR(EINVAL);
537  }
538 
539 #if CONFIG_LIBVPX_VP9_ENCODER
540  if (avctx->codec_id == AV_CODEC_ID_VP9) {
541  if (set_pix_fmt(avctx, codec_caps, &enccfg, &flags, &img_fmt))
542  return AVERROR(EINVAL);
543  }
544 #endif
545 
546  if(!avctx->bit_rate)
547  if(avctx->rc_max_rate || avctx->rc_buffer_size || avctx->rc_initial_buffer_occupancy) {
548  av_log( avctx, AV_LOG_ERROR, "Rate control parameters set without a bitrate\n");
549  return AVERROR(EINVAL);
550  }
551 
552  dump_enc_cfg(avctx, &enccfg);
553 
554  enccfg.g_w = avctx->width;
555  enccfg.g_h = avctx->height;
556  enccfg.g_timebase.num = avctx->time_base.num;
557  enccfg.g_timebase.den = avctx->time_base.den;
558  enccfg.g_threads =
559  FFMIN(avctx->thread_count ? avctx->thread_count : av_cpu_count(), 16);
560  enccfg.g_lag_in_frames= ctx->lag_in_frames;
561 
562  if (avctx->flags & AV_CODEC_FLAG_PASS1)
563  enccfg.g_pass = VPX_RC_FIRST_PASS;
564  else if (avctx->flags & AV_CODEC_FLAG_PASS2)
565  enccfg.g_pass = VPX_RC_LAST_PASS;
566  else
567  enccfg.g_pass = VPX_RC_ONE_PASS;
568 
569  if (avctx->rc_min_rate == avctx->rc_max_rate &&
570  avctx->rc_min_rate == avctx->bit_rate && avctx->bit_rate) {
571  enccfg.rc_end_usage = VPX_CBR;
572  } else if (ctx->crf >= 0) {
573  enccfg.rc_end_usage = VPX_CQ;
574 #if CONFIG_LIBVPX_VP9_ENCODER
575  if (!avctx->bit_rate && avctx->codec_id == AV_CODEC_ID_VP9)
576  enccfg.rc_end_usage = VPX_Q;
577 #endif
578  }
579 
580  if (avctx->bit_rate) {
581  enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000,
583 #if CONFIG_LIBVPX_VP9_ENCODER
584  } else if (enccfg.rc_end_usage == VPX_Q) {
585 #endif
586  } else {
587  if (enccfg.rc_end_usage == VPX_CQ) {
588  enccfg.rc_target_bitrate = 1000000;
589  } else {
590  avctx->bit_rate = enccfg.rc_target_bitrate * 1000;
591  av_log(avctx, AV_LOG_WARNING,
592  "Neither bitrate nor constrained quality specified, using default bitrate of %dkbit/sec\n",
593  enccfg.rc_target_bitrate);
594  }
595  }
596 
597  if (avctx->codec_id == AV_CODEC_ID_VP9 && ctx->lossless == 1) {
598  enccfg.rc_min_quantizer =
599  enccfg.rc_max_quantizer = 0;
600  } else {
601  if (avctx->qmin >= 0)
602  enccfg.rc_min_quantizer = avctx->qmin;
603  if (avctx->qmax >= 0)
604  enccfg.rc_max_quantizer = avctx->qmax;
605  }
606 
607  if (enccfg.rc_end_usage == VPX_CQ
608 #if CONFIG_LIBVPX_VP9_ENCODER
609  || enccfg.rc_end_usage == VPX_Q
610 #endif
611  ) {
612  if (ctx->crf < enccfg.rc_min_quantizer || ctx->crf > enccfg.rc_max_quantizer) {
613  av_log(avctx, AV_LOG_ERROR,
614  "CQ level %d must be between minimum and maximum quantizer value (%d-%d)\n",
615  ctx->crf, enccfg.rc_min_quantizer, enccfg.rc_max_quantizer);
616  return AVERROR(EINVAL);
617  }
618  }
619 
620 #if FF_API_PRIVATE_OPT
622  if (avctx->frame_skip_threshold)
623  ctx->drop_threshold = avctx->frame_skip_threshold;
625 #endif
626  enccfg.rc_dropframe_thresh = ctx->drop_threshold;
627 
628  //0-100 (0 => CBR, 100 => VBR)
629  enccfg.rc_2pass_vbr_bias_pct = lrint(avctx->qcompress * 100);
630  if (avctx->bit_rate)
631  enccfg.rc_2pass_vbr_minsection_pct =
632  avctx->rc_min_rate * 100LL / avctx->bit_rate;
633  if (avctx->rc_max_rate)
634  enccfg.rc_2pass_vbr_maxsection_pct =
635  avctx->rc_max_rate * 100LL / avctx->bit_rate;
636 #if CONFIG_LIBVPX_VP9_ENCODER
637  if (avctx->codec_id == AV_CODEC_ID_VP9) {
638 #if VPX_ENCODER_ABI_VERSION >= 14
639  if (ctx->corpus_complexity >= 0)
640  enccfg.rc_2pass_vbr_corpus_complexity = ctx->corpus_complexity;
641 #endif
642  }
643 #endif
644 
645  if (avctx->rc_buffer_size)
646  enccfg.rc_buf_sz =
647  avctx->rc_buffer_size * 1000LL / avctx->bit_rate;
648  if (avctx->rc_initial_buffer_occupancy)
649  enccfg.rc_buf_initial_sz =
650  avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
651  enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
652  if (ctx->rc_undershoot_pct >= 0)
653  enccfg.rc_undershoot_pct = ctx->rc_undershoot_pct;
654  if (ctx->rc_overshoot_pct >= 0)
655  enccfg.rc_overshoot_pct = ctx->rc_overshoot_pct;
656 
657  //_enc_init() will balk if kf_min_dist differs from max w/VPX_KF_AUTO
658  if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size)
659  enccfg.kf_min_dist = avctx->keyint_min;
660  if (avctx->gop_size >= 0)
661  enccfg.kf_max_dist = avctx->gop_size;
662 
663  if (enccfg.g_pass == VPX_RC_FIRST_PASS)
664  enccfg.g_lag_in_frames = 0;
665  else if (enccfg.g_pass == VPX_RC_LAST_PASS) {
666  int decode_size, ret;
667 
668  if (!avctx->stats_in) {
669  av_log(avctx, AV_LOG_ERROR, "No stats file for second pass\n");
670  return AVERROR_INVALIDDATA;
671  }
672 
673  ctx->twopass_stats.sz = strlen(avctx->stats_in) * 3 / 4;
674  ret = av_reallocp(&ctx->twopass_stats.buf, ctx->twopass_stats.sz);
675  if (ret < 0) {
676  av_log(avctx, AV_LOG_ERROR,
677  "Stat buffer alloc (%"SIZE_SPECIFIER" bytes) failed\n",
678  ctx->twopass_stats.sz);
679  ctx->twopass_stats.sz = 0;
680  return ret;
681  }
682  decode_size = av_base64_decode(ctx->twopass_stats.buf, avctx->stats_in,
683  ctx->twopass_stats.sz);
684  if (decode_size < 0) {
685  av_log(avctx, AV_LOG_ERROR, "Stat buffer decode failed\n");
686  return AVERROR_INVALIDDATA;
687  }
688 
689  ctx->twopass_stats.sz = decode_size;
690  enccfg.rc_twopass_stats_in = ctx->twopass_stats;
691  }
692 
693  /* 0-3: For non-zero values the encoder increasingly optimizes for reduced
694  complexity playback on low powered devices at the expense of encode
695  quality. */
696  if (avctx->profile != FF_PROFILE_UNKNOWN)
697  enccfg.g_profile = avctx->profile;
698 
699  enccfg.g_error_resilient = ctx->error_resilient || ctx->flags & VP8F_ERROR_RESILIENT;
700 
701  if (CONFIG_LIBVPX_VP8_ENCODER && avctx->codec_id == AV_CODEC_ID_VP8 && ctx->vp8_ts_parameters) {
702  AVDictionary *dict = NULL;
703  AVDictionaryEntry* en = NULL;
704 
705  if (!av_dict_parse_string(&dict, ctx->vp8_ts_parameters, "=", ":", 0)) {
706  while ((en = av_dict_get(dict, "", en, AV_DICT_IGNORE_SUFFIX))) {
707  if (vp8_ts_param_parse(&enccfg, en->key, en->value) < 0)
708  av_log(avctx, AV_LOG_WARNING,
709  "Error parsing option '%s = %s'.\n",
710  en->key, en->value);
711  }
712 
713  av_dict_free(&dict);
714  }
715  }
716 
717  dump_enc_cfg(avctx, &enccfg);
718  /* Construct Encoder Context */
719  res = vpx_codec_enc_init(&ctx->encoder, iface, &enccfg, flags);
720  if (res != VPX_CODEC_OK) {
721  log_encoder_error(avctx, "Failed to initialize encoder");
722  return AVERROR(EINVAL);
723  }
724 
725  if (ctx->is_alpha) {
726  enccfg_alpha = enccfg;
727  res = vpx_codec_enc_init(&ctx->encoder_alpha, iface, &enccfg_alpha, flags);
728  if (res != VPX_CODEC_OK) {
729  log_encoder_error(avctx, "Failed to initialize alpha encoder");
730  return AVERROR(EINVAL);
731  }
732  }
733 
734  //codec control failures are currently treated only as warnings
735  av_log(avctx, AV_LOG_DEBUG, "vpx_codec_control\n");
736  codecctl_int(avctx, VP8E_SET_CPUUSED, ctx->cpu_used);
737  if (ctx->flags & VP8F_AUTO_ALT_REF)
738  ctx->auto_alt_ref = 1;
739  if (ctx->auto_alt_ref >= 0)
740  codecctl_int(avctx, VP8E_SET_ENABLEAUTOALTREF,
741  avctx->codec_id == AV_CODEC_ID_VP8 ? !!ctx->auto_alt_ref : ctx->auto_alt_ref);
742  if (ctx->arnr_max_frames >= 0)
743  codecctl_int(avctx, VP8E_SET_ARNR_MAXFRAMES, ctx->arnr_max_frames);
744  if (ctx->arnr_strength >= 0)
745  codecctl_int(avctx, VP8E_SET_ARNR_STRENGTH, ctx->arnr_strength);
746  if (ctx->arnr_type >= 0)
747  codecctl_int(avctx, VP8E_SET_ARNR_TYPE, ctx->arnr_type);
748  if (ctx->tune >= 0)
749  codecctl_int(avctx, VP8E_SET_TUNING, ctx->tune);
750 
751  if (ctx->auto_alt_ref && ctx->is_alpha && avctx->codec_id == AV_CODEC_ID_VP8) {
752  av_log(avctx, AV_LOG_ERROR, "Transparency encoding with auto_alt_ref does not work\n");
753  return AVERROR(EINVAL);
754  }
755 
756  if (ctx->sharpness >= 0)
757  codecctl_int(avctx, VP8E_SET_SHARPNESS, ctx->sharpness);
758 
759  if (CONFIG_LIBVPX_VP8_ENCODER && avctx->codec_id == AV_CODEC_ID_VP8) {
760 #if FF_API_PRIVATE_OPT
762  if (avctx->noise_reduction)
763  ctx->noise_sensitivity = avctx->noise_reduction;
765 #endif
766  codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, ctx->noise_sensitivity);
767  codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx->slices));
768  }
769  codecctl_int(avctx, VP8E_SET_STATIC_THRESHOLD, ctx->static_thresh);
770  if (ctx->crf >= 0)
771  codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx->crf);
772  if (ctx->max_intra_rate >= 0)
773  codecctl_int(avctx, VP8E_SET_MAX_INTRA_BITRATE_PCT, ctx->max_intra_rate);
774 
775 #if CONFIG_LIBVPX_VP9_ENCODER
776  if (avctx->codec_id == AV_CODEC_ID_VP9) {
777  if (ctx->lossless >= 0)
778  codecctl_int(avctx, VP9E_SET_LOSSLESS, ctx->lossless);
779  if (ctx->tile_columns >= 0)
780  codecctl_int(avctx, VP9E_SET_TILE_COLUMNS, ctx->tile_columns);
781  if (ctx->tile_rows >= 0)
782  codecctl_int(avctx, VP9E_SET_TILE_ROWS, ctx->tile_rows);
783  if (ctx->frame_parallel >= 0)
784  codecctl_int(avctx, VP9E_SET_FRAME_PARALLEL_DECODING, ctx->frame_parallel);
785  if (ctx->aq_mode >= 0)
786  codecctl_int(avctx, VP9E_SET_AQ_MODE, ctx->aq_mode);
787  set_colorspace(avctx);
788 #if VPX_ENCODER_ABI_VERSION >= 11
789  set_color_range(avctx);
790 #endif
791 #if VPX_ENCODER_ABI_VERSION >= 12
792  codecctl_int(avctx, VP9E_SET_TARGET_LEVEL, ctx->level < 0 ? 255 : lrint(ctx->level * 10));
793 #endif
794 #ifdef VPX_CTRL_VP9E_SET_ROW_MT
795  if (ctx->row_mt >= 0)
796  codecctl_int(avctx, VP9E_SET_ROW_MT, ctx->row_mt);
797 #endif
798 #ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
799  if (ctx->tune_content >= 0)
800  codecctl_int(avctx, VP9E_SET_TUNE_CONTENT, ctx->tune_content);
801 #endif
802 #ifdef VPX_CTRL_VP9E_SET_TPL
803  if (ctx->tpl_model >= 0)
804  codecctl_int(avctx, VP9E_SET_TPL, ctx->tpl_model);
805 #endif
806  }
807 #endif
808 
809  av_log(avctx, AV_LOG_DEBUG, "Using deadline: %d\n", ctx->deadline);
810 
811  //provide dummy value to initialize wrapper, values will be updated each _encode()
812  vpx_img_wrap(&ctx->rawimg, img_fmt, avctx->width, avctx->height, 1,
813  (unsigned char*)1);
814 #if CONFIG_LIBVPX_VP9_ENCODER
815  if (avctx->codec_id == AV_CODEC_ID_VP9 && (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH))
816  ctx->rawimg.bit_depth = enccfg.g_bit_depth;
817 #endif
818 
819  if (ctx->is_alpha)
820  vpx_img_wrap(&ctx->rawimg_alpha, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1,
821  (unsigned char*)1);
822 
823  cpb_props = ff_add_cpb_side_data(avctx);
824  if (!cpb_props)
825  return AVERROR(ENOMEM);
826 
827  if (enccfg.rc_end_usage == VPX_CBR ||
828  enccfg.g_pass != VPX_RC_ONE_PASS) {
829  cpb_props->max_bitrate = avctx->rc_max_rate;
830  cpb_props->min_bitrate = avctx->rc_min_rate;
831  cpb_props->avg_bitrate = avctx->bit_rate;
832  }
833  cpb_props->buffer_size = avctx->rc_buffer_size;
834 
835  return 0;
836 }
837 
838 static inline void cx_pktcpy(struct FrameListData *dst,
839  const struct vpx_codec_cx_pkt *src,
840  const struct vpx_codec_cx_pkt *src_alpha,
841  VPxContext *ctx)
842 {
843  dst->pts = src->data.frame.pts;
844  dst->duration = src->data.frame.duration;
845  dst->flags = src->data.frame.flags;
846  dst->sz = src->data.frame.sz;
847  dst->buf = src->data.frame.buf;
848  dst->have_sse = 0;
849  /* For alt-ref frame, don't store PSNR or increment frame_number */
850  if (!(dst->flags & VPX_FRAME_IS_INVISIBLE)) {
851  dst->frame_number = ++ctx->frame_number;
852  dst->have_sse = ctx->have_sse;
853  if (ctx->have_sse) {
854  /* associate last-seen SSE to the frame. */
855  /* Transfers ownership from ctx to dst. */
856  /* WARNING! This makes the assumption that PSNR_PKT comes
857  just before the frame it refers to! */
858  memcpy(dst->sse, ctx->sse, sizeof(dst->sse));
859  ctx->have_sse = 0;
860  }
861  } else {
862  dst->frame_number = -1; /* sanity marker */
863  }
864  if (src_alpha) {
865  dst->buf_alpha = src_alpha->data.frame.buf;
866  dst->sz_alpha = src_alpha->data.frame.sz;
867  } else {
868  dst->buf_alpha = NULL;
869  dst->sz_alpha = 0;
870  }
871 }
872 
873 /**
874  * Store coded frame information in format suitable for return from encode2().
875  *
876  * Write information from @a cx_frame to @a pkt
877  * @return packet data size on success
878  * @return a negative AVERROR on error
879  */
880 static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame,
881  AVPacket *pkt)
882 {
883  int ret = ff_alloc_packet2(avctx, pkt, cx_frame->sz, 0);
884  uint8_t *side_data;
885  if (ret >= 0) {
886  int pict_type;
887  memcpy(pkt->data, cx_frame->buf, pkt->size);
888  pkt->pts = pkt->dts = cx_frame->pts;
889 #if FF_API_CODED_FRAME
891  avctx->coded_frame->pts = cx_frame->pts;
892  avctx->coded_frame->key_frame = !!(cx_frame->flags & VPX_FRAME_IS_KEY);
894 #endif
895 
896  if (!!(cx_frame->flags & VPX_FRAME_IS_KEY)) {
897  pict_type = AV_PICTURE_TYPE_I;
898 #if FF_API_CODED_FRAME
900  avctx->coded_frame->pict_type = pict_type;
902 #endif
904  } else {
905  pict_type = AV_PICTURE_TYPE_P;
906 #if FF_API_CODED_FRAME
908  avctx->coded_frame->pict_type = pict_type;
910 #endif
911  }
912 
913  ff_side_data_set_encoder_stats(pkt, 0, cx_frame->sse + 1,
914  cx_frame->have_sse ? 3 : 0, pict_type);
915 
916  if (cx_frame->have_sse) {
917  int i;
918  /* Beware of the Y/U/V/all order! */
919 #if FF_API_CODED_FRAME
921  avctx->coded_frame->error[0] = cx_frame->sse[1];
922  avctx->coded_frame->error[1] = cx_frame->sse[2];
923  avctx->coded_frame->error[2] = cx_frame->sse[3];
924  avctx->coded_frame->error[3] = 0; // alpha
926 #endif
927  for (i = 0; i < 3; ++i) {
928  avctx->error[i] += cx_frame->sse[i + 1];
929  }
930  cx_frame->have_sse = 0;
931  }
932  if (cx_frame->sz_alpha > 0) {
933  side_data = av_packet_new_side_data(pkt,
935  cx_frame->sz_alpha + 8);
936  if(!side_data) {
938  return AVERROR(ENOMEM);
939  }
940  AV_WB64(side_data, 1);
941  memcpy(side_data + 8, cx_frame->buf_alpha, cx_frame->sz_alpha);
942  }
943  } else {
944  return ret;
945  }
946  return pkt->size;
947 }
948 
949 /**
950  * Queue multiple output frames from the encoder, returning the front-most.
951  * In cases where vpx_codec_get_cx_data() returns more than 1 frame append
952  * the frame queue. Return the head frame if available.
953  * @return Stored frame size
954  * @return AVERROR(EINVAL) on output size error
955  * @return AVERROR(ENOMEM) on coded frame queue data allocation error
956  */
957 static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out)
958 {
959  VPxContext *ctx = avctx->priv_data;
960  const struct vpx_codec_cx_pkt *pkt;
961  const struct vpx_codec_cx_pkt *pkt_alpha = NULL;
962  const void *iter = NULL;
963  const void *iter_alpha = NULL;
964  int size = 0;
965 
966  if (ctx->coded_frame_list) {
967  struct FrameListData *cx_frame = ctx->coded_frame_list;
968  /* return the leading frame if we've already begun queueing */
969  size = storeframe(avctx, cx_frame, pkt_out);
970  if (size < 0)
971  return size;
972  ctx->coded_frame_list = cx_frame->next;
973  free_coded_frame(cx_frame);
974  }
975 
976  /* consume all available output from the encoder before returning. buffers
977  are only good through the next vpx_codec call */
978  while ((pkt = vpx_codec_get_cx_data(&ctx->encoder, &iter)) &&
979  (!ctx->is_alpha ||
980  (pkt_alpha = vpx_codec_get_cx_data(&ctx->encoder_alpha, &iter_alpha)))) {
981  switch (pkt->kind) {
982  case VPX_CODEC_CX_FRAME_PKT:
983  if (!size) {
984  struct FrameListData cx_frame;
985 
986  /* avoid storing the frame when the list is empty and we haven't yet
987  provided a frame for output */
988  av_assert0(!ctx->coded_frame_list);
989  cx_pktcpy(&cx_frame, pkt, pkt_alpha, ctx);
990  size = storeframe(avctx, &cx_frame, pkt_out);
991  if (size < 0)
992  return size;
993  } else {
994  struct FrameListData *cx_frame =
995  av_malloc(sizeof(struct FrameListData));
996 
997  if (!cx_frame) {
998  av_log(avctx, AV_LOG_ERROR,
999  "Frame queue element alloc failed\n");
1000  return AVERROR(ENOMEM);
1001  }
1002  cx_pktcpy(cx_frame, pkt, pkt_alpha, ctx);
1003  cx_frame->buf = av_malloc(cx_frame->sz);
1004 
1005  if (!cx_frame->buf) {
1006  av_log(avctx, AV_LOG_ERROR,
1007  "Data buffer alloc (%"SIZE_SPECIFIER" bytes) failed\n",
1008  cx_frame->sz);
1009  av_freep(&cx_frame);
1010  return AVERROR(ENOMEM);
1011  }
1012  memcpy(cx_frame->buf, pkt->data.frame.buf, pkt->data.frame.sz);
1013  if (ctx->is_alpha) {
1014  cx_frame->buf_alpha = av_malloc(cx_frame->sz_alpha);
1015  if (!cx_frame->buf_alpha) {
1016  av_log(avctx, AV_LOG_ERROR,
1017  "Data buffer alloc (%"SIZE_SPECIFIER" bytes) failed\n",
1018  cx_frame->sz_alpha);
1019  av_free(cx_frame);
1020  return AVERROR(ENOMEM);
1021  }
1022  memcpy(cx_frame->buf_alpha, pkt_alpha->data.frame.buf, pkt_alpha->data.frame.sz);
1023  }
1024  coded_frame_add(&ctx->coded_frame_list, cx_frame);
1025  }
1026  break;
1027  case VPX_CODEC_STATS_PKT: {
1028  struct vpx_fixed_buf *stats = &ctx->twopass_stats;
1029  int err;
1030  if ((err = av_reallocp(&stats->buf,
1031  stats->sz +
1032  pkt->data.twopass_stats.sz)) < 0) {
1033  stats->sz = 0;
1034  av_log(avctx, AV_LOG_ERROR, "Stat buffer realloc failed\n");
1035  return err;
1036  }
1037  memcpy((uint8_t*)stats->buf + stats->sz,
1038  pkt->data.twopass_stats.buf, pkt->data.twopass_stats.sz);
1039  stats->sz += pkt->data.twopass_stats.sz;
1040  break;
1041  }
1042  case VPX_CODEC_PSNR_PKT:
1043  av_assert0(!ctx->have_sse);
1044  ctx->sse[0] = pkt->data.psnr.sse[0];
1045  ctx->sse[1] = pkt->data.psnr.sse[1];
1046  ctx->sse[2] = pkt->data.psnr.sse[2];
1047  ctx->sse[3] = pkt->data.psnr.sse[3];
1048  ctx->have_sse = 1;
1049  break;
1050  case VPX_CODEC_CUSTOM_PKT:
1051  //ignore unsupported/unrecognized packet types
1052  break;
1053  }
1054  }
1055 
1056  return size;
1057 }
1058 
1060  const AVFrame *frame, int *got_packet)
1061 {
1062  VPxContext *ctx = avctx->priv_data;
1063  struct vpx_image *rawimg = NULL;
1064  struct vpx_image *rawimg_alpha = NULL;
1065  int64_t timestamp = 0;
1066  int res, coded_size;
1067  vpx_enc_frame_flags_t flags = 0;
1068 
1069  if (frame) {
1070  rawimg = &ctx->rawimg;
1071  rawimg->planes[VPX_PLANE_Y] = frame->data[0];
1072  rawimg->planes[VPX_PLANE_U] = frame->data[1];
1073  rawimg->planes[VPX_PLANE_V] = frame->data[2];
1074  rawimg->stride[VPX_PLANE_Y] = frame->linesize[0];
1075  rawimg->stride[VPX_PLANE_U] = frame->linesize[1];
1076  rawimg->stride[VPX_PLANE_V] = frame->linesize[2];
1077  if (ctx->is_alpha) {
1078  uint8_t *u_plane, *v_plane;
1079  rawimg_alpha = &ctx->rawimg_alpha;
1080  rawimg_alpha->planes[VPX_PLANE_Y] = frame->data[3];
1081  u_plane = av_malloc(frame->linesize[1] * frame->height);
1082  v_plane = av_malloc(frame->linesize[2] * frame->height);
1083  if (!u_plane || !v_plane) {
1084  av_free(u_plane);
1085  av_free(v_plane);
1086  return AVERROR(ENOMEM);
1087  }
1088  memset(u_plane, 0x80, frame->linesize[1] * frame->height);
1089  rawimg_alpha->planes[VPX_PLANE_U] = u_plane;
1090  memset(v_plane, 0x80, frame->linesize[2] * frame->height);
1091  rawimg_alpha->planes[VPX_PLANE_V] = v_plane;
1092  rawimg_alpha->stride[VPX_PLANE_Y] = frame->linesize[0];
1093  rawimg_alpha->stride[VPX_PLANE_U] = frame->linesize[1];
1094  rawimg_alpha->stride[VPX_PLANE_V] = frame->linesize[2];
1095  }
1096  timestamp = frame->pts;
1097 #if VPX_IMAGE_ABI_VERSION >= 4
1098  switch (frame->color_range) {
1099  case AVCOL_RANGE_MPEG:
1100  rawimg->range = VPX_CR_STUDIO_RANGE;
1101  break;
1102  case AVCOL_RANGE_JPEG:
1103  rawimg->range = VPX_CR_FULL_RANGE;
1104  break;
1105  }
1106 #endif
1107  if (frame->pict_type == AV_PICTURE_TYPE_I)
1108  flags |= VPX_EFLAG_FORCE_KF;
1109  if (CONFIG_LIBVPX_VP8_ENCODER && avctx->codec_id == AV_CODEC_ID_VP8 && frame->metadata) {
1110  AVDictionaryEntry* en = av_dict_get(frame->metadata, "vp8-flags", NULL, 0);
1111  if (en) {
1112  flags |= strtoul(en->value, NULL, 10);
1113  }
1114  }
1115  }
1116 
1117  res = vpx_codec_encode(&ctx->encoder, rawimg, timestamp,
1118  avctx->ticks_per_frame, flags, ctx->deadline);
1119  if (res != VPX_CODEC_OK) {
1120  log_encoder_error(avctx, "Error encoding frame");
1121  return AVERROR_INVALIDDATA;
1122  }
1123 
1124  if (ctx->is_alpha) {
1125  res = vpx_codec_encode(&ctx->encoder_alpha, rawimg_alpha, timestamp,
1126  avctx->ticks_per_frame, flags, ctx->deadline);
1127  if (res != VPX_CODEC_OK) {
1128  log_encoder_error(avctx, "Error encoding alpha frame");
1129  return AVERROR_INVALIDDATA;
1130  }
1131  }
1132 
1133  coded_size = queue_frames(avctx, pkt);
1134 
1135  if (!frame && avctx->flags & AV_CODEC_FLAG_PASS1) {
1136  unsigned int b64_size = AV_BASE64_SIZE(ctx->twopass_stats.sz);
1137 
1138  avctx->stats_out = av_malloc(b64_size);
1139  if (!avctx->stats_out) {
1140  av_log(avctx, AV_LOG_ERROR, "Stat buffer alloc (%d bytes) failed\n",
1141  b64_size);
1142  return AVERROR(ENOMEM);
1143  }
1144  av_base64_encode(avctx->stats_out, b64_size, ctx->twopass_stats.buf,
1145  ctx->twopass_stats.sz);
1146  }
1147 
1148  if (rawimg_alpha) {
1149  av_freep(&rawimg_alpha->planes[VPX_PLANE_U]);
1150  av_freep(&rawimg_alpha->planes[VPX_PLANE_V]);
1151  }
1152 
1153  *got_packet = !!coded_size;
1154  return 0;
1155 }
1156 
1157 #define OFFSET(x) offsetof(VPxContext, x)
1158 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1159 
1160 #define COMMON_OPTIONS \
1161  { "lag-in-frames", "Number of frames to look ahead for " \
1162  "alternate reference frame selection", OFFSET(lag_in_frames), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
1163  { "arnr-maxframes", "altref noise reduction max frame count", OFFSET(arnr_max_frames), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
1164  { "arnr-strength", "altref noise reduction filter strength", OFFSET(arnr_strength), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
1165  { "arnr-type", "altref noise reduction filter type", OFFSET(arnr_type), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE, "arnr_type"}, \
1166  { "backward", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "arnr_type" }, \
1167  { "forward", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, "arnr_type" }, \
1168  { "centered", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, VE, "arnr_type" }, \
1169  { "tune", "Tune the encoding to a specific scenario", OFFSET(tune), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE, "tune"}, \
1170  { "psnr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VP8_TUNE_PSNR}, 0, 0, VE, "tune"}, \
1171  { "ssim", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VP8_TUNE_SSIM}, 0, 0, VE, "tune"}, \
1172  { "deadline", "Time to spend encoding, in microseconds.", OFFSET(deadline), AV_OPT_TYPE_INT, {.i64 = VPX_DL_GOOD_QUALITY}, INT_MIN, INT_MAX, VE, "quality"}, \
1173  { "best", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VPX_DL_BEST_QUALITY}, 0, 0, VE, "quality"}, \
1174  { "good", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VPX_DL_GOOD_QUALITY}, 0, 0, VE, "quality"}, \
1175  { "realtime", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VPX_DL_REALTIME}, 0, 0, VE, "quality"}, \
1176  { "error-resilient", "Error resilience configuration", OFFSET(error_resilient), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, VE, "er"}, \
1177  { "max-intra-rate", "Maximum I-frame bitrate (pct) 0=unlimited", OFFSET(max_intra_rate), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
1178  { "default", "Improve resiliency against losses of whole frames", 0, AV_OPT_TYPE_CONST, {.i64 = VPX_ERROR_RESILIENT_DEFAULT}, 0, 0, VE, "er"}, \
1179  { "partitions", "The frame partitions are independently decodable " \
1180  "by the bool decoder, meaning that partitions can be decoded even " \
1181  "though earlier partitions have been lost. Note that intra predicition" \
1182  " is still done over the partition boundary.", 0, AV_OPT_TYPE_CONST, {.i64 = VPX_ERROR_RESILIENT_PARTITIONS}, 0, 0, VE, "er"}, \
1183  { "crf", "Select the quality for constant quality mode", offsetof(VPxContext, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE }, \
1184  { "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 }, \
1185  { "drop-threshold", "Frame drop threshold", offsetof(VPxContext, drop_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE }, \
1186  { "noise-sensitivity", "Noise sensitivity", OFFSET(noise_sensitivity), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 4, VE}, \
1187  { "undershoot-pct", "Datarate undershoot (min) target (%)", OFFSET(rc_undershoot_pct), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 100, VE }, \
1188  { "overshoot-pct", "Datarate overshoot (max) target (%)", OFFSET(rc_overshoot_pct), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1000, VE }, \
1189 
1190 #define LEGACY_OPTIONS \
1191  {"speed", "", offsetof(VPxContext, cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, -16, 16, VE}, \
1192  {"quality", "", offsetof(VPxContext, deadline), AV_OPT_TYPE_INT, {.i64 = VPX_DL_GOOD_QUALITY}, INT_MIN, INT_MAX, VE, "quality"}, \
1193  {"vp8flags", "", offsetof(VPxContext, flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, UINT_MAX, VE, "flags"}, \
1194  {"error_resilient", "enable error resilience", 0, AV_OPT_TYPE_CONST, {.i64 = VP8F_ERROR_RESILIENT}, INT_MIN, INT_MAX, VE, "flags"}, \
1195  {"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"}, \
1196  {"arnr_max_frames", "altref noise reduction max frame count", offsetof(VPxContext, arnr_max_frames), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 15, VE}, \
1197  {"arnr_strength", "altref noise reduction filter strength", offsetof(VPxContext, arnr_strength), AV_OPT_TYPE_INT, {.i64 = 3}, 0, 6, VE}, \
1198  {"arnr_type", "altref noise reduction filter type", offsetof(VPxContext, arnr_type), AV_OPT_TYPE_INT, {.i64 = 3}, 1, 3, VE}, \
1199  {"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}, \
1200  {"sharpness", "Increase sharpness at the expense of lower PSNR", offsetof(VPxContext, sharpness), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 7, VE},
1201 
1202 #if CONFIG_LIBVPX_VP8_ENCODER
1203 static const AVOption vp8_options[] = {
1205  { "auto-alt-ref", "Enable use of alternate reference "
1206  "frames (2-pass only)", OFFSET(auto_alt_ref), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE},
1207  { "cpu-used", "Quality/Speed ratio modifier", OFFSET(cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, -16, 16, VE},
1208  { "ts-parameters", "Temporal scaling configuration using a "
1209  ":-separated list of key=value parameters", OFFSET(vp8_ts_parameters), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE},
1211  { NULL }
1212 };
1213 #endif
1214 
1215 #if CONFIG_LIBVPX_VP9_ENCODER
1216 static const AVOption vp9_options[] = {
1218  { "auto-alt-ref", "Enable use of alternate reference "
1219  "frames (2-pass only)", OFFSET(auto_alt_ref), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
1220  { "cpu-used", "Quality/Speed ratio modifier", OFFSET(cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, -8, 8, VE},
1221  { "lossless", "Lossless mode", OFFSET(lossless), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE},
1222  { "tile-columns", "Number of tile columns to use, log2", OFFSET(tile_columns), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
1223  { "tile-rows", "Number of tile rows to use, log2", OFFSET(tile_rows), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE},
1224  { "frame-parallel", "Enable frame parallel decodability features", OFFSET(frame_parallel), AV_OPT_TYPE_BOOL,{.i64 = -1}, -1, 1, VE},
1225 #if VPX_ENCODER_ABI_VERSION >= 12
1226  { "aq-mode", "adaptive quantization mode", OFFSET(aq_mode), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 4, VE, "aq_mode"},
1227 #else
1228  { "aq-mode", "adaptive quantization mode", OFFSET(aq_mode), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 3, VE, "aq_mode"},
1229 #endif
1230  { "none", "Aq not used", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, VE, "aq_mode" },
1231  { "variance", "Variance based Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "aq_mode" },
1232  { "complexity", "Complexity based Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, "aq_mode" },
1233  { "cyclic", "Cyclic Refresh Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, VE, "aq_mode" },
1234 #if VPX_ENCODER_ABI_VERSION >= 12
1235  { "equator360", "360 video Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 4}, 0, 0, VE, "aq_mode" },
1236  {"level", "Specify level", OFFSET(level), AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1, 6.2, VE},
1237 #endif
1238 #ifdef VPX_CTRL_VP9E_SET_ROW_MT
1239  {"row-mt", "Row based multi-threading", OFFSET(row_mt), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
1240 #endif
1241 #ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
1242 #if VPX_ENCODER_ABI_VERSION >= 14
1243  { "tune-content", "Tune content type", OFFSET(tune_content), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE, "tune_content" },
1244 #else
1245  { "tune-content", "Tune content type", OFFSET(tune_content), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE, "tune_content" },
1246 #endif
1247  { "default", "Regular video content", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, VE, "tune_content" },
1248  { "screen", "Screen capture content", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "tune_content" },
1249 #if VPX_ENCODER_ABI_VERSION >= 14
1250  { "film", "Film content; improves grain retention", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, "tune_content" },
1251 #endif
1252 #endif
1253 #if VPX_ENCODER_ABI_VERSION >= 14
1254  { "corpus-complexity", "corpus vbr complexity midpoint", OFFSET(corpus_complexity), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 10000, VE },
1255 #endif
1256 #ifdef VPX_CTRL_VP9E_SET_TPL
1257  { "enable-tpl", "Enable temporal dependency model", OFFSET(tpl_model), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE },
1258 #endif
1260  { NULL }
1261 };
1262 #endif
1263 
1264 #undef COMMON_OPTIONS
1265 #undef LEGACY_OPTIONS
1266 
1267 static const AVCodecDefault defaults[] = {
1268  { "qmin", "-1" },
1269  { "qmax", "-1" },
1270  { "g", "-1" },
1271  { "keyint_min", "-1" },
1272  { NULL },
1273 };
1274 
1275 #if CONFIG_LIBVPX_VP8_ENCODER
1276 static av_cold int vp8_init(AVCodecContext *avctx)
1277 {
1278  return vpx_init(avctx, vpx_codec_vp8_cx());
1279 }
1280 
1281 static const AVClass class_vp8 = {
1282  .class_name = "libvpx-vp8 encoder",
1283  .item_name = av_default_item_name,
1284  .option = vp8_options,
1285  .version = LIBAVUTIL_VERSION_INT,
1286 };
1287 
1289  .name = "libvpx",
1290  .long_name = NULL_IF_CONFIG_SMALL("libvpx VP8"),
1291  .type = AVMEDIA_TYPE_VIDEO,
1292  .id = AV_CODEC_ID_VP8,
1293  .priv_data_size = sizeof(VPxContext),
1294  .init = vp8_init,
1295  .encode2 = vpx_encode,
1296  .close = vpx_free,
1299  .priv_class = &class_vp8,
1300  .defaults = defaults,
1301  .wrapper_name = "libvpx",
1302 };
1303 #endif /* CONFIG_LIBVPX_VP8_ENCODER */
1304 
1305 #if CONFIG_LIBVPX_VP9_ENCODER
1306 static av_cold int vp9_init(AVCodecContext *avctx)
1307 {
1308  return vpx_init(avctx, vpx_codec_vp9_cx());
1309 }
1310 
1311 static const AVClass class_vp9 = {
1312  .class_name = "libvpx-vp9 encoder",
1313  .item_name = av_default_item_name,
1314  .option = vp9_options,
1315  .version = LIBAVUTIL_VERSION_INT,
1316 };
1317 
1319  .name = "libvpx-vp9",
1320  .long_name = NULL_IF_CONFIG_SMALL("libvpx VP9"),
1321  .type = AVMEDIA_TYPE_VIDEO,
1322  .id = AV_CODEC_ID_VP9,
1323  .priv_data_size = sizeof(VPxContext),
1324  .init = vp9_init,
1325  .encode2 = vpx_encode,
1326  .close = vpx_free,
1329  .priv_class = &class_vp9,
1330  .defaults = defaults,
1331  .init_static_data = ff_vp9_init_static,
1332  .wrapper_name = "libvpx",
1333 };
1334 #endif /* CONFIG_LIBVPX_VP9_ENCODER */
defaults
static const AVCodecDefault defaults[]
Definition: libvpxenc.c:1267
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:599
AVCodec
AVCodec.
Definition: avcodec.h:3481
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:85
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
level
uint8_t level
Definition: svq3.c:207
FrameListData::pts
int64_t pts
time stamp to show frame (in timebase units)
Definition: libaomenc.c:49
AVCodecContext::keyint_min
int keyint_min
minimum GOP size
Definition: avcodec.h:2146
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
vp9_init
static av_cold int vp9_init(AVFormatContext *ctx, int st_index, PayloadContext *data)
Definition: rtpdec_vp9.c:34
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
set_color_range
static void set_color_range(AVCodecContext *avctx)
Definition: libaomenc.c:330
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:2193
AVCodecContext::rc_min_rate
int64_t rc_min_rate
minimum bitrate
Definition: avcodec.h:2450
vp8_ts_parse_int_array
static void vp8_ts_parse_int_array(int *dest, char *value, size_t value_len, int max_entries)
Definition: libvpxenc.c:353
stats
static void stats(AVPacket *const *in, int n_in, unsigned *_max, unsigned *_sum)
Definition: vp9_superframe_bsf.c:33
ff_side_data_set_encoder_stats
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
Definition: avpacket.c:720
VPxEncoderContext::rawimg_alpha
struct vpx_image rawimg_alpha
Definition: libvpxenc.c:69
av_unused
#define av_unused
Definition: attributes.h:125
VPxEncoderContext
Definition: libvpxenc.c:64
VPxEncoderContext::is_alpha
uint8_t is_alpha
Definition: libvpxenc.c:70
VPxEncoderContext::rawimg
struct vpx_image rawimg
Definition: libvpxenc.c:67
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:295
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:388
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
the normal 2^n-1 "JPEG" YUV ranges
Definition: pixfmt.h:522
internal.h
AVPacket::data
uint8_t * data
Definition: avcodec.h:1477
VP8F_ERROR_RESILIENT
#define VP8F_ERROR_RESILIENT
Enable measures appropriate for streaming over lossy links.
Definition: libvpxenc.c:84
AVOption
AVOption.
Definition: opt.h:246
set_pix_fmt
static int set_pix_fmt(AVCodecContext *avctx, struct aom_image *img)
Definition: libaomdec.c:86
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:387
AV_DICT_IGNORE_SUFFIX
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
Definition: dict.h:70
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
AVCOL_SPC_RGB
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
Definition: pixfmt.h:497
VP8F_AUTO_ALT_REF
#define VP8F_AUTO_ALT_REF
Enable automatic alternate reference frame generation.
Definition: libvpxenc.c:85
dump_enc_cfg
static av_cold void dump_enc_cfg(AVCodecContext *avctx, const struct vpx_codec_enc_cfg *cfg)
Definition: libvpxenc.c:172
VPxEncoderContext::have_sse
int have_sse
true if we have pending sse[]
Definition: libvpxenc.c:74
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
mathematics.h
AVDictionary
Definition: dict.c:30
AV_CODEC_FLAG_PSNR
#define AV_CODEC_FLAG_PSNR
error[?] variables will be set during encoding.
Definition: avcodec.h:887
cx_pktcpy
static void cx_pktcpy(struct FrameListData *dst, const struct vpx_codec_cx_pkt *src, const struct vpx_codec_cx_pkt *src_alpha, VPxContext *ctx)
Definition: libvpxenc.c:838
VPxEncoderContext::level
float level
Definition: libvpxenc.c:114
ff_add_cpb_side_data
AVCPBProperties * ff_add_cpb_side_data(AVCodecContext *avctx)
Add a CPB properties side data to an encoding context.
Definition: utils.c:2013
AVCodecContext::qmax
int qmax
maximum quantizer
Definition: avcodec.h:2414
VPxEncoderContext::aq_mode
int aq_mode
Definition: libvpxenc.c:110
AVCodecContext::frame_skip_threshold
attribute_deprecated int frame_skip_threshold
Definition: avcodec.h:2494
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: avcodec.h:1509
AV_WB64
#define AV_WB64(p, v)
Definition: intreadwrite.h:433
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
VPxEncoderContext::encoder_alpha
struct vpx_codec_ctx encoder_alpha
Definition: libvpxenc.c:68
AVCOL_SPC_BT470BG
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
Definition: pixfmt.h:502
VPxEncoderContext::auto_alt_ref
int auto_alt_ref
Definition: libvpxenc.c:87
AVCOL_SPC_RESERVED
@ AVCOL_SPC_RESERVED
Definition: pixfmt.h:500
FrameListData::flags
uint32_t flags
flags for this frame
Definition: libaomenc.c:53
VPxEncoderContext::coded_frame_list
struct FrameListData * coded_frame_list
Definition: libvpxenc.c:76
VPxEncoderContext::deadline
int deadline
Definition: libvpxenc.c:72
AVCodecContext::thread_count
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
Definition: avcodec.h:2824
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:403
VPxEncoderContext::drop_threshold
int drop_threshold
Definition: libvpxenc.c:111
AVFrame::key_frame
int key_frame
1 -> keyframe, 0-> not
Definition: frame.h:373
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:1645
codecctl_int
static av_cold int codecctl_int(AVCodecContext *avctx, enum vp8e_enc_control_id id, int val)
Definition: libvpxenc.c:287
VPxEncoderContext::max_intra_rate
int max_intra_rate
Definition: libvpxenc.c:99
AVRational::num
int num
Numerator.
Definition: rational.h:59
src
#define src
Definition: vp8dsp.c:254
LEGACY_OPTIONS
#define LEGACY_OPTIONS
Definition: libvpxenc.c:1190
FrameListData::buf_alpha
void * buf_alpha
Definition: libvpxenc.c:51
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:390
vpx_encode
static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: libvpxenc.c:1059
avassert.h
lrint
#define lrint
Definition: tablegen.h:53
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
buf
void * buf
Definition: avisynth_c.h:766
av_cold
#define av_cold
Definition: attributes.h:84
AVCodecContext::rc_initial_buffer_occupancy
int rc_initial_buffer_occupancy
Number of bits which should be loaded into the rc buffer before decoding starts.
Definition: avcodec.h:2471
ff_libvpx_vp8_encoder
AVCodec ff_libvpx_vp8_encoder
av_dict_get
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:40
width
#define width
intreadwrite.h
AVCodecContext::stats_in
char * stats_in
pass2 encoding statistics input buffer Concatenated stuff from stats_out of pass1 should be placed he...
Definition: avcodec.h:2592
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
COMMON_OPTIONS
#define COMMON_OPTIONS
Definition: libvpxenc.c:1160
AVFormatContext::flags
int flags
Flags modifying the (de)muxer behaviour.
Definition: avformat.h:1473
vpx_init
static av_cold int vpx_init(AVCodecContext *avctx, const struct vpx_codec_iface *iface)
Definition: libvpxenc.c:513
AVCOL_SPC_SMPTE170M
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:503
log_encoder_error
static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
Definition: libvpxenc.c:161
AVDictionaryEntry::key
char * key
Definition: dict.h:82
AV_CODEC_ID_VP9
@ AV_CODEC_ID_VP9
Definition: avcodec.h:386
AVCodecContext::ticks_per_frame
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
Definition: avcodec.h:1697
av_strtok
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
Definition: avstring.c:184
VPxEncoderContext::row_mt
int row_mt
Definition: libvpxenc.c:115
FrameListData::sse
uint64_t sse[4]
Definition: libaomenc.c:54
VPxEncoderContext::lag_in_frames
int lag_in_frames
Definition: libvpxenc.c:95
tile_rows
int tile_rows
Definition: h265_levels.c:217
FF_PROFILE_UNKNOWN
#define FF_PROFILE_UNKNOWN
Definition: avcodec.h:2899
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:275
FrameListData::frame_number
uint64_t frame_number
Definition: libaomenc.c:56
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
VPxEncoderContext::arnr_type
int arnr_type
Definition: libvpxenc.c:91
ctx
AVFormatContext * ctx
Definition: movenc.c:48
VPxEncoderContext::static_thresh
int static_thresh
Definition: libvpxenc.c:98
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
VPxEncoderContext::rc_undershoot_pct
int rc_undershoot_pct
Definition: libvpxenc.c:100
AVCodecContext::rc_max_rate
int64_t rc_max_rate
maximum bitrate
Definition: avcodec.h:2443
AVCodecContext::error
uint64_t error[AV_NUM_DATA_POINTERS]
error
Definition: avcodec.h:2748
key
const char * key
Definition: hwcontext_opencl.c:168
AVCPBProperties
This structure describes the bitrate properties of an encoded bitstream.
Definition: avcodec.h:1128
av_packet_new_side_data
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
Definition: avpacket.c:329
AVCodecContext::codec_id
enum AVCodecID codec_id
Definition: avcodec.h:1575
AVCodecDefault
Definition: internal.h:231
AVCodecContext::rc_buffer_size
int rc_buffer_size
decoder bitstream buffer size
Definition: avcodec.h:2428
AVCPBProperties::avg_bitrate
int avg_bitrate
Average bitrate of the stream, in bits per second.
Definition: avcodec.h:1152
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
NULL
#define NULL
Definition: coverity.c:32
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:2200
VPxEncoderContext::twopass_stats
struct vpx_fixed_buf twopass_stats
Definition: libvpxenc.c:71
vpx_free
static av_cold int vpx_free(AVCodecContext *avctx)
Definition: libvpxenc.c:331
AVCodecContext::bit_rate
int64_t bit_rate
the average bitrate
Definition: avcodec.h:1615
VPxEncoderContext::frame_number
uint64_t frame_number
Definition: libvpxenc.c:75
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
profiles.h
ff_vp9_init_static
av_cold void ff_vp9_init_static(AVCodec *codec)
Definition: libvpx.c:68
vp8_ts_param_parse
static int vp8_ts_param_parse(struct vpx_codec_enc_cfg *enccfg, char *key, char *value)
Definition: libvpxenc.c:365
AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:389
list
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining list
Definition: filter_design.txt:25
VPxEncoderContext::noise_sensitivity
int noise_sensitivity
Definition: libvpxenc.c:112
FrameListData::buf
void * buf
compressed data buffer
Definition: libaomenc.c:47
AV_ROUND_NEAR_INF
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
Definition: mathematics.h:84
VPxEncoderContext::crf
int crf
Definition: libvpxenc.c:97
AVCodecContext::noise_reduction
attribute_deprecated int noise_reduction
Definition: avcodec.h:2083
VPxEncoderContext::tpl_model
int tpl_model
Definition: libvpxenc.c:118
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:388
av_base64_decode
int av_base64_decode(uint8_t *out, const char *in_str, int out_size)
Decode a base64-encoded string.
Definition: base64.c:79
VPxEncoderContext::encoder
struct vpx_codec_ctx encoder
Definition: libvpxenc.c:66
VPxEncoderContext::flags
int flags
VP8 specific flags, see VP8F_* below.
Definition: libvpxenc.c:83
base64.h
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:520
free_frame_list
static av_cold void free_frame_list(struct FrameListData *list)
Definition: libvpxenc.c:276
error
static void error(const char *err)
Definition: target_dec_fuzzer.c:61
av_cpu_count
int av_cpu_count(void)
Definition: cpu.c:267
AVCodecContext::qcompress
float qcompress
amount of qscale change between easy & hard scenes (0.0-1.0)
Definition: avcodec.h:2399
AVCodecContext::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition: avcodec.h:1688
av_rescale_rnd
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
Definition: mathematics.c:58
FrameListData::next
struct FrameListData * next
Definition: libaomenc.c:57
AVCodecContext::stats_out
char * stats_out
pass1 encoding statistics output buffer
Definition: avcodec.h:2584
AV_CODEC_CAP_AUTO_THREADS
#define AV_CODEC_CAP_AUTO_THREADS
Codec supports avctx->thread_count == 0 (auto).
Definition: avcodec.h:1049
desc
const char * desc
Definition: nvenc.c:68
VPxEncoderContext::rc_overshoot_pct
int rc_overshoot_pct
Definition: libvpxenc.c:101
AVFrame::pict_type
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:378
AVPacket::size
int size
Definition: avcodec.h:1478
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:188
AVCodecContext::gop_size
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
Definition: avcodec.h:1760
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:392
size
int size
Definition: twinvq_data.h:11134
AVFrame::error
attribute_deprecated uint64_t error[AV_NUM_DATA_POINTERS]
Definition: frame.h:430
VPxEncoderContext::lossless
int lossless
Definition: libvpxenc.c:106
av_reallocp
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
Definition: mem.c:163
storeframe
static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, AVPacket *pkt)
Store coded frame information in format suitable for return from encode2().
Definition: libvpxenc.c:880
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:394
VPxEncoderContext::tune_content
int tune_content
Definition: libvpxenc.c:116
VPxEncoderContext::corpus_complexity
int corpus_complexity
Definition: libvpxenc.c:117
VPxEncoderContext::tile_rows
int tile_rows
Definition: libvpxenc.c:108
val
const char const char void * val
Definition: avisynth_c.h:863
FrameListData
Portion of struct vpx_codec_cx_pkt from vpx_encoder.h.
Definition: libaomenc.c:46
VPxEncoderContext::sharpness
int sharpness
Definition: libvpxenc.c:79
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: avcodec.h:1476
AV_CODEC_FLAG_PASS2
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
Definition: avcodec.h:875
FFMIN
#define FFMIN(a, b)
Definition: common.h:96
AVCPBProperties::max_bitrate
int max_bitrate
Maximum bitrate of the stream, in bits per second.
Definition: avcodec.h:1134
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: avcodec.h:1483
av_dict_free
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
Definition: dict.c:203
VPxEncoderContext::tune
int tune
Definition: libvpxenc.c:93
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:226
AVCOL_SPC_SMPTE240M
@ AVCOL_SPC_SMPTE240M
functionally identical to above
Definition: pixfmt.h:504
AV_BASE64_SIZE
#define AV_BASE64_SIZE(x)
Calculate the output size needed to base64-encode x bytes to a null-terminated string.
Definition: base64.h:66
VPxEncoderContext::tile_columns
int tile_columns
Definition: libvpxenc.c:107
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1470
AVCOL_SPC_BT2020_NCL
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:507
internal.h
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:404
common.h
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
uint8_t
uint8_t
Definition: audio_convert.c:194
AVCodec::name
const char * name
Name of the codec implementation.
Definition: avcodec.h:3488
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:499
AVCPBProperties::min_bitrate
int min_bitrate
Minimum bitrate of the stream, in bits per second.
Definition: avcodec.h:1143
AVCodecContext::height
int height
Definition: avcodec.h:1738
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1775
FrameListData::duration
unsigned long duration
duration to show frame (in timebase units)
Definition: libaomenc.c:51
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
the normal 219*2^(n-8) "MPEG" YUV ranges
Definition: pixfmt.h:521
avcodec.h
ret
ret
Definition: filter_design.txt:187
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:72
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
VPxEncoderContext::cpu_used
int cpu_used
Definition: libvpxenc.c:78
AVCPBProperties::buffer_size
int buffer_size
The size of the buffer to which the ratecontrol is applied, in bits.
Definition: avcodec.h:1161
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:391
queue_frames
static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out)
Queue multiple output frames from the encoder, returning the front-most.
Definition: libvpxenc.c:957
SIZE_SPECIFIER
#define SIZE_SPECIFIER
Definition: internal.h:264
AVCodecContext::coded_frame
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
Definition: avcodec.h:2815
AVCodecContext
main external API structure.
Definition: avcodec.h:1565
pkt
static AVPacket pkt
Definition: demuxing_decoding.c:54
AVCodecContext::qmin
int qmin
minimum quantizer
Definition: avcodec.h:2407
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:2898
av_dict_parse_string
int av_dict_parse_string(AVDictionary **pm, const char *str, const char *key_val_sep, const char *pairs_sep, int flags)
Parse the key/value pairs list and add the parsed entries to a dictionary.
Definition: dict.c:180
ctlidstr
static const char *const ctlidstr[]
String mappings for enum vp8e_enc_control_id.
Definition: libvpxenc.c:122
av_base64_encode
char * av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size)
Encode data to base64 and null-terminate.
Definition: base64.c:138
profiles
static const AVProfile profiles[]
Definition: libfdk-aacenc.c:426
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: avcodec.h:1006
VPxEncoderContext::vp8_ts_parameters
char * vp8_ts_parameters
Definition: libvpxenc.c:103
VPxEncoderContext::frame_parallel
int frame_parallel
Definition: libvpxenc.c:109
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
VPxEncoderContext::error_resilient
int error_resilient
Definition: libvpxenc.c:96
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:84
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
OFFSET
#define OFFSET(x)
Definition: libvpxenc.c:1157
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:275
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
coded_frame_add
static void coded_frame_add(void *list, struct FrameListData *cx_frame)
Definition: libvpxenc.c:258
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
@ AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
Data found in BlockAdditional element of matroska container.
Definition: avcodec.h:1335
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
AVDictionaryEntry
Definition: dict.h:81
VPxEncoderContext::arnr_max_frames
int arnr_max_frames
Definition: libvpxenc.c:89
AVCodecContext::slices
int slices
Number of slices.
Definition: avcodec.h:2216
AVPacket
This structure stores compressed data.
Definition: avcodec.h:1454
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:1592
VPxEncoderContext::vpx_cs
int vpx_cs
Definition: libvpxenc.c:113
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:240
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:1738
AV_CODEC_ID_VP8
@ AV_CODEC_ID_VP8
Definition: avcodec.h:358
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:565
ff_libvpx_vp9_encoder
AVCodec ff_libvpx_vp9_encoder
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
FrameListData::sz
size_t sz
length of compressed data
Definition: libaomenc.c:48
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
libvpx.h
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:393
free_coded_frame
static av_cold void free_coded_frame(struct FrameListData *cx_frame)
Definition: libvpxenc.c:268
VPxEncoderContext::arnr_strength
int arnr_strength
Definition: libvpxenc.c:90
vp8_init
static av_cold int vp8_init(AVFormatContext *s, int st_index, PayloadContext *vp8)
Definition: rtpdec_vp8.c:263
AVDictionaryEntry::value
char * value
Definition: dict.h:83
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:227
AVCOL_SPC_BT709
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
Definition: pixfmt.h:498
VE
#define VE
Definition: libvpxenc.c:1158
ff_alloc_packet2
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
Definition: encode.c:32
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:232
snprintf
#define snprintf
Definition: snprintf.h:34
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
VPxEncoderContext::sse
uint64_t sse[4]
Definition: libvpxenc.c:73
ff_vp9_profiles
const AVProfile ff_vp9_profiles[]
Definition: profiles.c:134
AV_CODEC_FLAG_PASS1
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
Definition: avcodec.h:871
FrameListData::sz_alpha
size_t sz_alpha
Definition: libvpxenc.c:52
FrameListData::have_sse
int have_sse
true if we have pending sse[]
Definition: libaomenc.c:55