WebM VP8 Codec SDK
vpx_encoder.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3  *
4  * Use of this source code is governed by a BSD-style license
5  * that can be found in the LICENSE file in the root of the source
6  * tree. An additional intellectual property rights grant can be found
7  * in the file PATENTS. All contributing project authors may
8  * be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #ifndef VPX_ENCODER_H
32 #define VPX_ENCODER_H
33 #include "vpx_codec.h"
34 
35 
44 #define VPX_ENCODER_ABI_VERSION (2 + VPX_CODEC_ABI_VERSION)
56 #define VPX_CODEC_CAP_PSNR 0x10000
63 #define VPX_CODEC_CAP_OUTPUT_PARTITION 0x20000
64 
65 
73 #define VPX_CODEC_USE_PSNR 0x10000
74 #define VPX_CODEC_USE_OUTPUT_PARTITION 0x20000
82  typedef struct vpx_fixed_buf
83  {
84  void *buf;
85  size_t sz;
94  typedef int64_t vpx_codec_pts_t;
95 
96 
104  typedef uint32_t vpx_codec_frame_flags_t;
105 #define VPX_FRAME_IS_KEY 0x1
106 #define VPX_FRAME_IS_DROPPABLE 0x2
109 #define VPX_FRAME_IS_INVISIBLE 0x4
111 #define VPX_FRAME_IS_FRAGMENT 0x8
120  typedef uint32_t vpx_codec_er_flags_t;
121 #define VPX_ERROR_RESILIENT_DEFAULT 0x1
123 #define VPX_ERROR_RESILIENT_PARTITIONS 0x2
138  enum vpx_codec_cx_pkt_kind
139  {
143  VPX_CODEC_CUSTOM_PKT = 256
144  };
145 
146 
152  typedef struct vpx_codec_cx_pkt
153  {
155  union
156  {
157  struct
158  {
159  void *buf;
160  size_t sz;
161  vpx_codec_pts_t pts;
163  unsigned long duration;
165  vpx_codec_frame_flags_t flags;
166  int partition_id;
173  } frame;
175  struct vpx_psnr_pkt
176  {
177  unsigned int samples[4];
178  uint64_t sse[4];
179  double psnr[4];
180  } psnr;
181  struct vpx_fixed_buf raw;
183  /* This packet size is fixed to allow codecs to extend this
184  * interface without having to manage storage for raw packets,
185  * i.e., if it's smaller than 128 bytes, you can store in the
186  * packet list directly.
187  */
188  char pad[128 - sizeof(enum vpx_codec_cx_pkt_kind)];
189  } data;
197  typedef struct vpx_rational
198  {
199  int num;
200  int den;
205  enum vpx_enc_pass
206  {
210  };
211 
214  enum vpx_rc_mode
215  {
216  VPX_VBR,
217  VPX_CBR,
219  };
231  {
232  VPX_KF_FIXED,
233  VPX_KF_AUTO,
234  VPX_KF_DISABLED = 0
235  };
236 
237 
245  typedef long vpx_enc_frame_flags_t;
246 #define VPX_EFLAG_FORCE_KF (1<<0)
255  typedef struct vpx_codec_enc_cfg
256  {
257  /*
258  * generic settings (g)
259  */
260 
268  unsigned int g_usage;
269 
270 
277  unsigned int g_threads;
278 
279 
288  unsigned int g_profile;
299  unsigned int g_w;
300 
309  unsigned int g_h;
310 
311 
324  struct vpx_rational g_timebase;
325 
326 
333  vpx_codec_er_flags_t g_error_resilient;
334 
335 
341  enum vpx_enc_pass g_pass;
342 
343 
356  unsigned int g_lag_in_frames;
357 
358 
359  /*
360  * rate control settings (rc)
361  */
362 
379  unsigned int rc_dropframe_thresh;
380 
381 
389  unsigned int rc_resize_allowed;
390 
391 
398  unsigned int rc_resize_up_thresh;
399 
400 
407  unsigned int rc_resize_down_thresh;
408 
409 
418  enum vpx_rc_mode rc_end_usage;
419 
426  struct vpx_fixed_buf rc_twopass_stats_in;
427 
428 
433  unsigned int rc_target_bitrate;
434 
435 
436  /*
437  * quantizer settings
438  */
440 
449  unsigned int rc_min_quantizer;
450 
451 
460  unsigned int rc_max_quantizer;
461 
463  /*
464  * bitrate tolerance
465  */
466 
467 
478  unsigned int rc_undershoot_pct;
479 
480 
491  unsigned int rc_overshoot_pct;
492 
493 
494  /*
495  * decoder buffer model parameters
496  */
497 
498 
508  unsigned int rc_buf_sz;
509 
510 
518  unsigned int rc_buf_initial_sz;
519 
520 
528  unsigned int rc_buf_optimal_sz;
529 
530 
531  /*
532  * 2 pass rate control parameters
533  */
534 
535 
544  unsigned int rc_2pass_vbr_bias_pct;
552  unsigned int rc_2pass_vbr_minsection_pct;
553 
554 
560  unsigned int rc_2pass_vbr_maxsection_pct;
561 
562 
563  /*
564  * keyframing settings (kf)
565  */
566 
573  enum vpx_kf_mode kf_mode;
574 
575 
583  unsigned int kf_min_dist;
584 
585 
593  unsigned int kf_max_dist;
594 
621  vpx_codec_iface_t *iface,
622  vpx_codec_enc_cfg_t *cfg,
623  vpx_codec_flags_t flags,
624  int ver);
625 
626 
631 #define vpx_codec_enc_init(ctx, iface, cfg, flags) \
632  vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION)
633 
634 
655  vpx_codec_enc_cfg_t *cfg,
656  unsigned int usage);
657 
658 
674  const vpx_codec_enc_cfg_t *cfg);
675 
676 
689 
690 
691 #define VPX_DL_REALTIME (1)
693 #define VPX_DL_GOOD_QUALITY (1000000)
695 #define VPX_DL_BEST_QUALITY (0)
733  vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx,
734  const vpx_image_t *img,
735  vpx_codec_pts_t pts,
736  unsigned long duration,
737  vpx_enc_frame_flags_t flags,
738  unsigned long deadline);
739 
740 
785  const vpx_fixed_buf_t *buf,
786  unsigned int pad_before,
787  unsigned int pad_after);
788 
789 
814  vpx_codec_iter_t *iter);
815 
816 
830 
831 
834 #endif
835 #ifdef __cplusplus
836 }
837 #endif
Rational Number.
Definition: vpx_encoder.h:210
struct vpx_fixed_buf twopass_stats
Definition: vpx_encoder.h:187
struct vpx_codec_iface vpx_codec_iface_t
Codec interface structure.
Definition: vpx_codec.h:167
vpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t *ctx, const vpx_fixed_buf_t *buf, unsigned int pad_before, unsigned int pad_after)
Set compressed data output buffer.
Image Descriptor.
Definition: vpx_image.h:97
vpx_codec_pts_t pts
Definition: vpx_encoder.h:174
vpx_kf_mode
Keyframe placement mode.
Definition: vpx_encoder.h:243
Definition: vpx_encoder.h:230
struct vpx_codec_enc_cfg vpx_codec_enc_cfg_t
Encoder configuration structure.
struct vpx_fixed_buf vpx_fixed_buf_t
Generic fixed size buffer structure.
struct vpx_fixed_buf raw
Definition: vpx_encoder.h:194
int den
Definition: vpx_encoder.h:213
Definition: vpx_encoder.h:154
int partition_id
Definition: vpx_encoder.h:179
vpx_enc_pass
Multi-pass Encoding Pass.
Definition: vpx_encoder.h:218
Encoder configuration structure.
Definition: vpx_encoder.h:268
Definition: vpx_encoder.h:156
Definition: vpx_encoder.h:155
Definition: vpx_encoder.h:246
Encoder output packet.
Definition: vpx_encoder.h:165
void * buf
Definition: vpx_encoder.h:85
vpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx, const vpx_codec_enc_cfg_t *cfg)
Set or change configuration.
Generic fixed size buffer structure.
Definition: vpx_encoder.h:83
uint32_t vpx_codec_frame_flags_t
Compressed Frame Flags.
Definition: vpx_encoder.h:105
Definition: vpx_encoder.h:221
Definition: vpx_encoder.h:222
struct vpx_codec_cx_pkt::@1::@2 frame
uint64_t sse[4]
Definition: vpx_encoder.h:191
size_t sz
Definition: vpx_encoder.h:173
enum vpx_codec_cx_pkt_kind kind
Definition: vpx_encoder.h:167
long vpx_enc_frame_flags_t
Encoded Frame Flags.
Definition: vpx_encoder.h:258
int num
Definition: vpx_encoder.h:212
char pad[128-sizeof(enum vpx_codec_cx_pkt_kind)]
Definition: vpx_encoder.h:201
vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface, vpx_codec_enc_cfg_t *cfg, unsigned int usage)
Get a default configuration.
long vpx_codec_flags_t
Initialization-time Feature Enabling.
Definition: vpx_codec.h:158
vpx_codec_cx_pkt_kind
Encoder output packet variants.
Definition: vpx_encoder.h:151
Definition: vpx_encoder.h:229
double psnr[4]
Definition: vpx_encoder.h:192
Definition: vpx_encoder.h:245
unsigned int samples[4]
Definition: vpx_encoder.h:190
vpx_rc_mode
Rate control mode.
Definition: vpx_encoder.h:227
vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx, vpx_codec_iface_t *iface, vpx_codec_enc_cfg_t *cfg, vpx_codec_flags_t flags, int ver)
Initialize an encoder instance.
const vpx_image_t * vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx)
Get Preview Frame.
unsigned long duration
Definition: vpx_encoder.h:176
uint32_t vpx_codec_er_flags_t
Error Resilient flags.
Definition: vpx_encoder.h:125
vpx_codec_err_t
Algorithm return codes.
Definition: vpx_codec.h:81
const vpx_codec_cx_pkt_t * vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx, vpx_codec_iter_t *iter)
Encoded data iterator.
union vpx_codec_cx_pkt::@1 data
struct vpx_codec_cx_pkt vpx_codec_cx_pkt_t
Encoder output packet.
struct vpx_rational vpx_rational_t
Rational Number.
Definition: vpx_encoder.h:247
int64_t vpx_codec_pts_t
Time Stamp Type.
Definition: vpx_encoder.h:95
vpx_fixed_buf_t * vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx)
Get global stream headers.
Definition: vpx_encoder.h:231
Describes the codec algorithm interface to applications.
const void * vpx_codec_iter_t
Iterator.
Definition: vpx_codec.h:182
Definition: vpx_encoder.h:153
vpx_codec_frame_flags_t flags
Definition: vpx_encoder.h:178
void * buf
Definition: vpx_encoder.h:172
Definition: vpx_encoder.h:220
Codec context structure.
Definition: vpx_codec.h:193