WebM VP8 Codec SDK: vpx/vpx_encoder.h Source File

WebM VP8 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_ENCODER_H
11 #define 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 3
53
62 #define VPX_ENCODER_ABI_VERSION (3 + VPX_CODEC_ABI_VERSION)
74 #define VPX_CODEC_CAP_PSNR 0x10000
81 #define VPX_CODEC_CAP_OUTPUT_PARTITION 0x20000
82
83
91 #define VPX_CODEC_USE_PSNR 0x10000
92 #define VPX_CODEC_USE_OUTPUT_PARTITION 0x20000
100 typedef struct vpx_fixed_buf {
101 void *buf;
102 size_t sz;
103 } vpx_fixed_buf_t;
111 typedef int64_t vpx_codec_pts_t;
112
113
121 typedef uint32_t vpx_codec_frame_flags_t;
122 #define VPX_FRAME_IS_KEY 0x1
123 #define VPX_FRAME_IS_DROPPABLE 0x2
126 #define VPX_FRAME_IS_INVISIBLE 0x4
128 #define VPX_FRAME_IS_FRAGMENT 0x8
137 typedef uint32_t vpx_codec_er_flags_t;
138 #define VPX_ERROR_RESILIENT_DEFAULT 0x1
140 #define VPX_ERROR_RESILIENT_PARTITIONS 0x2
155 enum vpx_codec_cx_pkt_kind {
156 VPX_CODEC_CX_FRAME_PKT,
157 VPX_CODEC_STATS_PKT,
158 VPX_CODEC_PSNR_PKT,
159 VPX_CODEC_CUSTOM_PKT = 256
160 };
161
162
168 typedef struct vpx_codec_cx_pkt {
169 enum vpx_codec_cx_pkt_kind kind;
170 union {
171 struct {
172 void *buf;
173 size_t sz;
174 vpx_codec_pts_t pts;
176 unsigned long duration;
178 vpx_codec_frame_flags_t flags;
179 int partition_id;
186 } frame;
187 struct vpx_fixed_buf twopass_stats;
188 struct vpx_psnr_pkt {
189 unsigned int samples[4];
190 uint64_t sse[4];
191 double psnr[4];
192 } psnr;
193 struct vpx_fixed_buf raw;
195 /* This packet size is fixed to allow codecs to extend this
196 * interface without having to manage storage for raw packets,
197 * i.e., if it's smaller than 128 bytes, you can store in the
198 * packet list directly.
199 */
200 char pad[128 - sizeof(enum vpx_codec_cx_pkt_kind)];
201 } data;
202 } vpx_codec_cx_pkt_t;
209 typedef struct vpx_rational {
210 int num;
211 int den;
212 } vpx_rational_t;
216 enum vpx_enc_pass {
217 VPX_RC_ONE_PASS,
218 VPX_RC_FIRST_PASS,
219 VPX_RC_LAST_PASS
220 };
221
222
224 enum vpx_rc_mode {
225 VPX_VBR,
226 VPX_CBR,
227 VPX_CQ,
228 VPX_Q,
229 };
230
231
240 enum vpx_kf_mode {
241 VPX_KF_FIXED,
242 VPX_KF_AUTO,
243 VPX_KF_DISABLED = 0
244 };
245
246
254 typedef long vpx_enc_frame_flags_t;
255 #define VPX_EFLAG_FORCE_KF (1<<0)
264 typedef struct vpx_codec_enc_cfg {
265 /*
266 * generic settings (g)
267 */
268
276 unsigned int g_usage;
277
278
285 unsigned int g_threads;
286
287
296 unsigned int g_profile;
307 unsigned int g_w;
308
309
317 unsigned int g_h;
318
319
332 struct vpx_rational g_timebase;
333
334
341 vpx_codec_er_flags_t g_error_resilient;
342
343
349 enum vpx_enc_pass g_pass;
350
351
364 unsigned int g_lag_in_frames;
365
366
367 /*
368 * rate control settings (rc)
369 */
370
387 unsigned int rc_dropframe_thresh;
388
389
397 unsigned int rc_resize_allowed;
398
399
406 unsigned int rc_resize_up_thresh;
407
408
415 unsigned int rc_resize_down_thresh;
416
417
426 enum vpx_rc_mode rc_end_usage;
427
428
434 struct vpx_fixed_buf rc_twopass_stats_in;
435
436
441 unsigned int rc_target_bitrate;
442
443
444 /*
445 * quantizer settings
446 */
447
448
457 unsigned int rc_min_quantizer;
458
459
468 unsigned int rc_max_quantizer;
469
470
471 /*
472 * bitrate tolerance
473 */
474
475
486 unsigned int rc_undershoot_pct;
487
488
499 unsigned int rc_overshoot_pct;
500
501
502 /*
503 * decoder buffer model parameters
504 */
505
506
516 unsigned int rc_buf_sz;
517
518
526 unsigned int rc_buf_initial_sz;
527
528
536 unsigned int rc_buf_optimal_sz;
537
538
539 /*
540 * 2 pass rate control parameters
541 */
542
543
552 unsigned int rc_2pass_vbr_bias_pct;
560 unsigned int rc_2pass_vbr_minsection_pct;
561
562
568 unsigned int rc_2pass_vbr_maxsection_pct;
569
570
571 /*
572 * keyframing settings (kf)
573 */
574
581 enum vpx_kf_mode kf_mode;
582
583
591 unsigned int kf_min_dist;
592
593
601 unsigned int kf_max_dist;
602
603 /*
604 * Spatial scalability settings (ss)
605 */
606
611 unsigned int ss_number_layers;
612
617 unsigned int ts_number_layers;
618
623 unsigned int ts_target_bitrate[VPX_TS_MAX_LAYERS];
624
630 unsigned int ts_rate_decimator[VPX_TS_MAX_LAYERS];
631
639 unsigned int ts_periodicity;
640
648 unsigned int ts_layer_id[VPX_TS_MAX_PERIODICITY];
649 } vpx_codec_enc_cfg_t;
678 vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx,
679 vpx_codec_iface_t *iface,
680 vpx_codec_enc_cfg_t *cfg,
681 vpx_codec_flags_t flags,
682 int ver);
683
684
689 #define vpx_codec_enc_init(ctx, iface, cfg, flags) \
690 vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION)
691
692
717 vpx_codec_err_t vpx_codec_enc_init_multi_ver(vpx_codec_ctx_t *ctx,
718 vpx_codec_iface_t *iface,
719 vpx_codec_enc_cfg_t *cfg,
720 int num_enc,
721 vpx_codec_flags_t flags,
722 vpx_rational_t *dsf,
723 int ver);
724
725
730 #define vpx_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \
731 vpx_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \
732 VPX_ENCODER_ABI_VERSION)
733
734
754 vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface,
755 vpx_codec_enc_cfg_t *cfg,
756 unsigned int usage);
757
758
773 vpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx,
774 const vpx_codec_enc_cfg_t *cfg);
775
776
788 vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx);
789
790
791 #define VPX_DL_REALTIME (1)
793 #define VPX_DL_GOOD_QUALITY (1000000)
795 #define VPX_DL_BEST_QUALITY (0)
833 vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx,
834 const vpx_image_t *img,
835 vpx_codec_pts_t pts,
836 unsigned long duration,
837 vpx_enc_frame_flags_t flags,
838 unsigned long deadline);
839
883 vpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t *ctx,
884 const vpx_fixed_buf_t *buf,
885 unsigned int pad_before,
886 unsigned int pad_after);
887
888
912 const vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx,
913 vpx_codec_iter_t *iter);
914
915
928 const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx);
929
930
932 #ifdef __cplusplus
933 }
934 #endif
935 #endif
936
vpx_rational
Rational Number.
Definition: vpx_encoder.h:222
vpx_codec_cx_pkt::twopass_stats
struct vpx_fixed_buf twopass_stats
Definition: vpx_encoder.h:200
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:241
vpx_image
Image Descriptor.
Definition: vpx_image.h:99
vpx_codec_cx_pkt::pts
vpx_codec_pts_t pts
Definition: vpx_encoder.h:187
vpx_kf_mode
vpx_kf_mode
Keyframe placement mode.
Definition: vpx_encoder.h:253
VPX_TS_MAX_LAYERS
#define VPX_TS_MAX_LAYERS
Definition: vpx_encoder.h:40
VPX_CBR
Definition: vpx_encoder.h:239
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_codec_cx_pkt::raw
struct vpx_fixed_buf raw
Definition: vpx_encoder.h:206
vpx_rational::den
int den
Definition: vpx_encoder.h:224
VPX_CODEC_STATS_PKT
Definition: vpx_encoder.h:170
vpx_codec_cx_pkt::partition_id
int partition_id
Definition: vpx_encoder.h:192
vpx_enc_pass
vpx_enc_pass
Multi-pass Encoding Pass.
Definition: vpx_encoder.h:229
vpx_codec_enc_cfg
Encoder configuration structure.
Definition: vpx_encoder.h:277
VPX_CODEC_CUSTOM_PKT
Definition: vpx_encoder.h:172
VPX_CODEC_PSNR_PKT
Definition: vpx_encoder.h:171
VPX_KF_AUTO
Definition: vpx_encoder.h:255
vpx_codec_cx_pkt
Encoder output packet.
Definition: vpx_encoder.h:181
vpx_fixed_buf::buf
void * buf
Definition: vpx_encoder.h:102
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:101
vpx_codec_frame_flags_t
uint32_t vpx_codec_frame_flags_t
Compressed Frame Flags.
Definition: vpx_encoder.h:122
VPX_RC_FIRST_PASS
Definition: vpx_encoder.h:231
VPX_RC_LAST_PASS
Definition: vpx_encoder.h:232
vpx_codec_cx_pkt::frame
struct vpx_codec_cx_pkt::@1::@2 frame
vpx_codec_cx_pkt::sse
uint64_t sse[4]
Definition: vpx_encoder.h:203
vpx_codec_cx_pkt::sz
size_t sz
Definition: vpx_encoder.h:186
vpx_codec_cx_pkt::kind
enum vpx_codec_cx_pkt_kind kind
Definition: vpx_encoder.h:182
vpx_enc_frame_flags_t
long vpx_enc_frame_flags_t
Encoded Frame Flags.
Definition: vpx_encoder.h:267
vpx_rational::num
int num
Definition: vpx_encoder.h:223
vpx_codec_iface_t
const struct vpx_codec_iface vpx_codec_iface_t
Codec interface structure.
Definition: vpx_codec.h:175
vpx_codec_cx_pkt::pad
char pad[128-sizeof(enum vpx_codec_cx_pkt_kind)]
Definition: vpx_encoder.h:213
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 usage)
Get a default configuration.
vpx_codec_flags_t
long vpx_codec_flags_t
Initialization-time Feature Enabling.
Definition: vpx_codec.h:166
vpx_codec_cx_pkt_kind
vpx_codec_cx_pkt_kind
Encoder output packet variants.
Definition: vpx_encoder.h:168
VPX_VBR
Definition: vpx_encoder.h:238
vpx_codec_cx_pkt::psnr
double psnr[4]
Definition: vpx_encoder.h:204
VPX_KF_FIXED
Definition: vpx_encoder.h:254
vpx_codec_cx_pkt::samples
unsigned int samples[4]
Definition: vpx_encoder.h:202
vpx_rc_mode
vpx_rc_mode
Rate control mode.
Definition: vpx_encoder.h:237
vpx_codec_enc_init_ver
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.
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:189
vpx_codec_er_flags_t
uint32_t vpx_codec_er_flags_t
Error Resilient flags.
Definition: vpx_encoder.h:142
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_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_KF_DISABLED
Definition: vpx_encoder.h:256
vpx_codec_pts_t
int64_t vpx_codec_pts_t
Time Stamp Type.
Definition: vpx_encoder.h:112
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:240
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_iter_t
const void * vpx_codec_iter_t
Iterator.
Definition: vpx_codec.h:190
VPX_CODEC_CX_FRAME_PKT
Definition: vpx_encoder.h:169
vpx_codec_cx_pkt::flags
vpx_codec_frame_flags_t flags
Definition: vpx_encoder.h:191
vpx_codec_cx_pkt::buf
void * buf
Definition: vpx_encoder.h:185
VPX_RC_ONE_PASS
Definition: vpx_encoder.h:230
vpx_codec_ctx
Codec context structure.
Definition: vpx_codec.h:201