WebM Codec SDK

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

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 #ifndef VPX_VPX_ENCODER_H_
11 #define VPX_VPX_ENCODER_H_
12
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #include "./vpx_codec.h"
33
37 #define VPX_TS_MAX_PERIODICITY 16
38
40 #define VPX_TS_MAX_LAYERS 5
41
43 #define MAX_PERIODICITY VPX_TS_MAX_PERIODICITY
44
46 #define MAX_LAYERS VPX_TS_MAX_LAYERS
47
49 #define VPX_SS_MAX_LAYERS 5
50
52 #define VPX_SS_DEFAULT_LAYERS 1
53
62 #define VPX_ENCODER_ABI_VERSION (4 + VPX_CODEC_ABI_VERSION)
74 #define VPX_CODEC_CAP_PSNR 0x10000
81 #define VPX_CODEC_CAP_OUTPUT_PARTITION 0x20000
82
85 #define VPX_CODEC_CAP_HIGHBITDEPTH 0x40000
86
94 #define VPX_CODEC_USE_PSNR 0x10000
95 #define VPX_CODEC_USE_OUTPUT_PARTITION 0x20000
97 #define VPX_CODEC_USE_HIGHBITDEPTH 0x40000
104 typedef struct vpx_fixed_buf {
105 void *buf;
106 size_t sz;
107 } vpx_fixed_buf_t;
115 typedef int64_t vpx_codec_pts_t;
116
117
125 typedef uint32_t vpx_codec_frame_flags_t;
126 #define VPX_FRAME_IS_KEY 0x1
127 #define VPX_FRAME_IS_DROPPABLE 0x2
130 #define VPX_FRAME_IS_INVISIBLE 0x4
132 #define VPX_FRAME_IS_FRAGMENT 0x8
141 typedef uint32_t vpx_codec_er_flags_t;
142 #define VPX_ERROR_RESILIENT_DEFAULT 0x1
144 #define VPX_ERROR_RESILIENT_PARTITIONS 0x2
159 enum vpx_codec_cx_pkt_kind {
160 VPX_CODEC_CX_FRAME_PKT,
161 VPX_CODEC_STATS_PKT,
162 VPX_CODEC_FPMB_STATS_PKT,
163 VPX_CODEC_PSNR_PKT,
164 // Spatial SVC is still experimental and may be removed before the next ABI
165 // bump.
166 #if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
167 VPX_CODEC_SPATIAL_SVC_LAYER_SIZES,
168 VPX_CODEC_SPATIAL_SVC_LAYER_PSNR,
169 #endif
170 VPX_CODEC_CUSTOM_PKT = 256
171 };
172
173
179 typedef struct vpx_codec_cx_pkt {
180 enum vpx_codec_cx_pkt_kind kind;
181 union {
182 struct {
183 void *buf;
184 size_t sz;
185 vpx_codec_pts_t pts;
187 unsigned long duration;
189 vpx_codec_frame_flags_t flags;
190 int partition_id;
197 } frame;
198 vpx_fixed_buf_t twopass_stats;
199 vpx_fixed_buf_t firstpass_mb_stats;
200 struct vpx_psnr_pkt {
201 unsigned int samples[4];
202 uint64_t sse[4];
203 double psnr[4];
204 } psnr;
205 vpx_fixed_buf_t raw;
206 // Spatial SVC is still experimental and may be removed before the next
207 // ABI bump.
208 #if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
209 size_t layer_sizes[VPX_SS_MAX_LAYERS];
210 struct vpx_psnr_pkt layer_psnr[VPX_SS_MAX_LAYERS];
211 #endif
212
213 /* This packet size is fixed to allow codecs to extend this
214 * interface without having to manage storage for raw packets,
215 * i.e., if it's smaller than 128 bytes, you can store in the
216 * packet list directly.
217 */
218 char pad[128 - sizeof(enum vpx_codec_cx_pkt_kind)];
219 } data;
220 } vpx_codec_cx_pkt_t;
228 // putting the definitions here for now. (agrange: find if there
229 // is a better place for this)
230 typedef void (* vpx_codec_enc_output_cx_pkt_cb_fn_t)(vpx_codec_cx_pkt_t *pkt,
231 void *user_data);
232
234 typedef struct vpx_codec_enc_output_cx_cb_pair {
235 vpx_codec_enc_output_cx_pkt_cb_fn_t output_cx_pkt;
236 void *user_priv;
237 } vpx_codec_priv_output_cx_pkt_cb_pair_t;
238
243 typedef struct vpx_rational {
244 int num;
245 int den;
246 } vpx_rational_t;
250 enum vpx_enc_pass {
251 VPX_RC_ONE_PASS,
252 VPX_RC_FIRST_PASS,
253 VPX_RC_LAST_PASS
254 };
255
256
258 enum vpx_rc_mode {
259 VPX_VBR,
260 VPX_CBR,
261 VPX_CQ,
262 VPX_Q,
263 };
264
265
274 enum vpx_kf_mode {
275 VPX_KF_FIXED,
276 VPX_KF_AUTO,
277 VPX_KF_DISABLED = 0
278 };
279
280
288 typedef long vpx_enc_frame_flags_t;
289 #define VPX_EFLAG_FORCE_KF (1<<0)
298 typedef struct vpx_codec_enc_cfg {
299 /*
300 * generic settings (g)
301 */
302
310 unsigned int g_usage;
311
312
319 unsigned int g_threads;
320
321
330 unsigned int g_profile;
341 unsigned int g_w;
342
343
351 unsigned int g_h;
352
359 vpx_bit_depth_t g_bit_depth;
360
367 unsigned int g_input_bit_depth;
368
381 struct vpx_rational g_timebase;
382
383
390 vpx_codec_er_flags_t g_error_resilient;
391
392
398 enum vpx_enc_pass g_pass;
399
400
413 unsigned int g_lag_in_frames;
414
415
416 /*
417 * rate control settings (rc)
418 */
419
436 unsigned int rc_dropframe_thresh;
437
438
446 unsigned int rc_resize_allowed;
447
453 unsigned int rc_scaled_width;
454
460 unsigned int rc_scaled_height;
461
468 unsigned int rc_resize_up_thresh;
469
470
477 unsigned int rc_resize_down_thresh;
478
479
488 enum vpx_rc_mode rc_end_usage;
489
490
496 vpx_fixed_buf_t rc_twopass_stats_in;
497
503 vpx_fixed_buf_t rc_firstpass_mb_stats_in;
504
509 unsigned int rc_target_bitrate;
510
511
512 /*
513 * quantizer settings
514 */
515
516
525 unsigned int rc_min_quantizer;
526
527
536 unsigned int rc_max_quantizer;
537
538
539 /*
540 * bitrate tolerance
541 */
542
543
554 unsigned int rc_undershoot_pct;
555
556
567 unsigned int rc_overshoot_pct;
568
569
570 /*
571 * decoder buffer model parameters
572 */
573
574
584 unsigned int rc_buf_sz;
585
586
594 unsigned int rc_buf_initial_sz;
595
596
604 unsigned int rc_buf_optimal_sz;
605
606
607 /*
608 * 2 pass rate control parameters
609 */
610
611
620 unsigned int rc_2pass_vbr_bias_pct;
628 unsigned int rc_2pass_vbr_minsection_pct;
629
630
636 unsigned int rc_2pass_vbr_maxsection_pct;
637
638
639 /*
640 * keyframing settings (kf)
641 */
642
649 enum vpx_kf_mode kf_mode;
650
651
659 unsigned int kf_min_dist;
660
661
669 unsigned int kf_max_dist;
670
671 /*
672 * Spatial scalability settings (ss)
673 */
674
679 unsigned int ss_number_layers;
680
686 int ss_enable_auto_alt_ref[VPX_SS_MAX_LAYERS];
687
693 unsigned int ss_target_bitrate[VPX_SS_MAX_LAYERS];
694
699 unsigned int ts_number_layers;
700
706 unsigned int ts_target_bitrate[VPX_TS_MAX_LAYERS];
707
713 unsigned int ts_rate_decimator[VPX_TS_MAX_LAYERS];
714
722 unsigned int ts_periodicity;
723
731 unsigned int ts_layer_id[VPX_TS_MAX_PERIODICITY];
732 } vpx_codec_enc_cfg_t;
739 typedef struct vpx_svc_parameters {
740 int max_quantizers[VPX_SS_MAX_LAYERS];
741 int min_quantizers[VPX_SS_MAX_LAYERS];
742 int scaling_factor_num[VPX_SS_MAX_LAYERS];
743 int scaling_factor_den[VPX_SS_MAX_LAYERS];
744 } vpx_svc_extra_cfg_t;
745
746
769 vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx,
770 vpx_codec_iface_t *iface,
771 const vpx_codec_enc_cfg_t *cfg,
772 vpx_codec_flags_t flags,
773 int ver);
774
775
780 #define vpx_codec_enc_init(ctx, iface, cfg, flags) \
781 vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION)
782
783
804 vpx_codec_err_t vpx_codec_enc_init_multi_ver(vpx_codec_ctx_t *ctx,
805 vpx_codec_iface_t *iface,
806 vpx_codec_enc_cfg_t *cfg,
807 int num_enc,
808 vpx_codec_flags_t flags,
809 vpx_rational_t *dsf,
810 int ver);
811
812
817 #define vpx_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \
818 vpx_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \
819 VPX_ENCODER_ABI_VERSION)
820
821
841 vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface,
842 vpx_codec_enc_cfg_t *cfg,
843 unsigned int reserved);
844
845
860 vpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx,
861 const vpx_codec_enc_cfg_t *cfg);
862
863
875 vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx);
876
877
878 #define VPX_DL_REALTIME (1)
880 #define VPX_DL_GOOD_QUALITY (1000000)
882 #define VPX_DL_BEST_QUALITY (0)
920 vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx,
921 const vpx_image_t *img,
922 vpx_codec_pts_t pts,
923 unsigned long duration,
924 vpx_enc_frame_flags_t flags,
925 unsigned long deadline);
926
970 vpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t *ctx,
971 const vpx_fixed_buf_t *buf,
972 unsigned int pad_before,
973 unsigned int pad_after);
974
975
999 const vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx,
1000 vpx_codec_iter_t *iter);
1001
1002
1015 const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx);
1016
1017
1019 #ifdef __cplusplus
1020 }
1021 #endif
1022 #endif // VPX_VPX_ENCODER_H_
1023
vpx_rational
Rational Number.
Definition: vpx_encoder.h:256
vpx_codec_cx_pkt::twopass_stats
vpx_fixed_buf_t twopass_stats
Definition: vpx_encoder.h:211
vpx_codec_set_cx_data_buf
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.
VPX_Q
Definition: vpx_encoder.h:275
vpx_image
Image Descriptor.
Definition: vpx_image.h:82
vpx_codec_cx_pkt::pts
vpx_codec_pts_t pts
Definition: vpx_encoder.h:198
vpx_kf_mode
vpx_kf_mode
Keyframe placement mode.
Definition: vpx_encoder.h:287
VPX_TS_MAX_LAYERS
#define VPX_TS_MAX_LAYERS
Definition: vpx_encoder.h:40
VPX_CBR
Definition: vpx_encoder.h:273
vpx_codec_enc_cfg_t
struct vpx_codec_enc_cfg vpx_codec_enc_cfg_t
Encoder configuration structure.
vpx_fixed_buf_t
struct vpx_fixed_buf vpx_fixed_buf_t
Generic fixed size buffer structure.
vpx_svc_parameters::min_quantizers
int min_quantizers[5]
Definition: vpx_encoder.h:754
vpx_codec_enc_output_cx_cb_pair::output_cx_pkt
vpx_codec_enc_output_cx_pkt_cb_fn_t output_cx_pkt
Definition: vpx_encoder.h:248
vpx_rational::den
int den
Definition: vpx_encoder.h:258
vpx_svc_extra_cfg_t
struct vpx_svc_parameters vpx_svc_extra_cfg_t
vp9 svc extra configure parameters
VPX_CODEC_STATS_PKT
Definition: vpx_encoder.h:174
vpx_codec_cx_pkt::partition_id
int partition_id
Definition: vpx_encoder.h:203
vpx_enc_pass
vpx_enc_pass
Multi-pass Encoding Pass.
Definition: vpx_encoder.h:263
vpx_codec_enc_cfg
Encoder configuration structure.
Definition: vpx_encoder.h:311
VPX_CODEC_CUSTOM_PKT
Definition: vpx_encoder.h:183
VPX_CODEC_PSNR_PKT
Definition: vpx_encoder.h:176
VPX_KF_AUTO
Definition: vpx_encoder.h:289
vpx_codec_enc_output_cx_cb_pair::user_priv
void * user_priv
Definition: vpx_encoder.h:249
vpx_codec_cx_pkt
Encoder output packet.
Definition: vpx_encoder.h:192
vpx_codec_enc_config_set
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.
vpx_fixed_buf
Generic fixed size buffer structure.
Definition: vpx_encoder.h:105
vpx_codec_frame_flags_t
uint32_t vpx_codec_frame_flags_t
Compressed Frame Flags.
Definition: vpx_encoder.h:126
VPX_RC_FIRST_PASS
Definition: vpx_encoder.h:265
VPX_RC_LAST_PASS
Definition: vpx_encoder.h:266
vpx_codec_cx_pkt::frame
struct vpx_codec_cx_pkt::@1::@2 frame
VPX_SS_MAX_LAYERS
#define VPX_SS_MAX_LAYERS
Definition: vpx_encoder.h:49
vpx_svc_parameters::max_quantizers
int max_quantizers[5]
Definition: vpx_encoder.h:753
vpx_bit_depth_t
enum vpx_bit_depth vpx_bit_depth_t
Bit depth for codecThis enumeration determines the bit depth of the codec.
vpx_codec_cx_pkt::sse
uint64_t sse[4]
Definition: vpx_encoder.h:215
vpx_svc_parameters::scaling_factor_den
int scaling_factor_den[5]
Definition: vpx_encoder.h:756
vpx_codec_cx_pkt::sz
size_t sz
Definition: vpx_encoder.h:197
vpx_codec_cx_pkt::kind
enum vpx_codec_cx_pkt_kind kind
Definition: vpx_encoder.h:193
vpx_codec_cx_pkt::raw
vpx_fixed_buf_t raw
Definition: vpx_encoder.h:218
vpx_codec_enc_output_cx_cb_pair
Callback function pointer / user data pair storage.
Definition: vpx_encoder.h:247
vpx_enc_frame_flags_t
long vpx_enc_frame_flags_t
Encoded Frame Flags.
Definition: vpx_encoder.h:301
vpx_rational::num
int num
Definition: vpx_encoder.h:257
vpx_codec_iface_t
const struct vpx_codec_iface vpx_codec_iface_t
Codec interface structure.
Definition: vpx_codec.h:173
vpx_codec_cx_pkt::pad
char pad[128-sizeof(enum vpx_codec_cx_pkt_kind)]
Definition: vpx_encoder.h:231
vpx_svc_parameters::scaling_factor_num
int scaling_factor_num[5]
Definition: vpx_encoder.h:755
vpx_codec_flags_t
long vpx_codec_flags_t
Initialization-time Feature Enabling.
Definition: vpx_codec.h:165
vpx_codec_cx_pkt_kind
vpx_codec_cx_pkt_kind
Encoder output packet variants.
Definition: vpx_encoder.h:172
VPX_VBR
Definition: vpx_encoder.h:272
vpx_codec_cx_pkt::psnr
double psnr[4]
Definition: vpx_encoder.h:216
VPX_KF_FIXED
Definition: vpx_encoder.h:288
vpx_codec_cx_pkt::samples
unsigned int samples[4]
Definition: vpx_encoder.h:214
vpx_codec_cx_pkt::firstpass_mb_stats
vpx_fixed_buf_t firstpass_mb_stats
Definition: vpx_encoder.h:212
vpx_rc_mode
vpx_rc_mode
Rate control mode.
Definition: vpx_encoder.h:271
vpx_codec_get_preview_frame
const vpx_image_t * vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx)
Get Preview Frame.
vpx_codec_cx_pkt::duration
unsigned long duration
Definition: vpx_encoder.h:200
vpx_codec_er_flags_t
uint32_t vpx_codec_er_flags_t
Error Resilient flags.
Definition: vpx_encoder.h:146
vpx_codec_err_t
vpx_codec_err_t
Algorithm return codes.
Definition: vpx_codec.h:89
vpx_codec_get_cx_data
const vpx_codec_cx_pkt_t * vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx, vpx_codec_iter_t *iter)
Encoded data iterator.
vpx_codec_cx_pkt::data
union vpx_codec_cx_pkt::@1 data
vpx_codec_enc_output_cx_pkt_cb_fn_t
void(* vpx_codec_enc_output_cx_pkt_cb_fn_t)(vpx_codec_cx_pkt_t *pkt, void *user_data)
Encoder return output buffer callback.
Definition: vpx_encoder.h:243
vpx_codec_cx_pkt_t
struct vpx_codec_cx_pkt vpx_codec_cx_pkt_t
Encoder output packet.
vpx_rational_t
struct vpx_rational vpx_rational_t
Rational Number.
vpx_codec_priv_output_cx_pkt_cb_pair_t
struct vpx_codec_enc_output_cx_cb_pair vpx_codec_priv_output_cx_pkt_cb_pair_t
Callback function pointer / user data pair storage.
VPX_KF_DISABLED
Definition: vpx_encoder.h:290
VPX_CODEC_FPMB_STATS_PKT
Definition: vpx_encoder.h:175
vpx_codec_pts_t
int64_t vpx_codec_pts_t
Time Stamp Type.
Definition: vpx_encoder.h:116
vpx_codec_enc_config_default
vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface, vpx_codec_enc_cfg_t *cfg, unsigned int reserved)
Get a default configuration.
VPX_TS_MAX_PERIODICITY
#define VPX_TS_MAX_PERIODICITY
Definition: vpx_encoder.h:37
vpx_codec_get_global_headers
vpx_fixed_buf_t * vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx)
Get global stream headers.
VPX_CQ
Definition: vpx_encoder.h:274
vpx_codec.h
Describes the codec algorithm interface to applications.
vpx_codec_enc_init_multi_ver
vpx_codec_err_t vpx_codec_enc_init_multi_ver(vpx_codec_ctx_t *ctx, vpx_codec_iface_t *iface, vpx_codec_enc_cfg_t *cfg, int num_enc, vpx_codec_flags_t flags, vpx_rational_t *dsf, int ver)
Initialize multi-encoder instance.
vpx_codec_enc_init_ver
vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx, vpx_codec_iface_t *iface, const vpx_codec_enc_cfg_t *cfg, vpx_codec_flags_t flags, int ver)
Initialize an encoder instance.
vpx_codec_iter_t
const void * vpx_codec_iter_t
Iterator.
Definition: vpx_codec.h:188
VPX_CODEC_CX_FRAME_PKT
Definition: vpx_encoder.h:173
vpx_codec_cx_pkt::flags
vpx_codec_frame_flags_t flags
Definition: vpx_encoder.h:202
vpx_codec_cx_pkt::buf
void * buf
Definition: vpx_encoder.h:196
vpx_svc_parameters
vp9 svc extra configure parameters
Definition: vpx_encoder.h:752
VPX_RC_ONE_PASS
Definition: vpx_encoder.h:264
vpx_codec_ctx
Codec context structure.
Definition: vpx_codec.h:199