00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029
00030 #ifndef VPX_ENCODER_H
00031 #define VPX_ENCODER_H
00032 #include "vpx_codec.h"
00033
00034
00043 #define VPX_ENCODER_ABI_VERSION (2 + VPX_CODEC_ABI_VERSION)
00055 #define VPX_CODEC_CAP_PSNR 0x10000
00065 #define VPX_CODEC_USE_PSNR 0x10000
00072 typedef struct vpx_fixed_buf
00073 {
00074 void *buf;
00075 size_t sz;
00076 } vpx_fixed_buf_t;
00084 typedef int64_t vpx_codec_pts_t;
00085
00086
00094 typedef uint32_t vpx_codec_frame_flags_t;
00095 #define VPX_FRAME_IS_KEY 0x1
00096 #define VPX_FRAME_IS_DROPPABLE 0x2
00099 #define VPX_FRAME_IS_INVISIBLE 0x4
00109 enum vpx_codec_cx_pkt_kind
00110 {
00111 VPX_CODEC_CX_FRAME_PKT,
00112 VPX_CODEC_STATS_PKT,
00113 VPX_CODEC_PSNR_PKT,
00114 VPX_CODEC_CUSTOM_PKT = 256
00115 };
00116
00117
00123 typedef struct vpx_codec_cx_pkt
00124 {
00125 enum vpx_codec_cx_pkt_kind kind;
00126 union
00127 {
00128 struct
00129 {
00130 void *buf;
00131 size_t sz;
00132 vpx_codec_pts_t pts;
00134 unsigned long duration;
00136 vpx_codec_frame_flags_t flags;
00137 } frame;
00138 struct vpx_fixed_buf twopass_stats;
00139 struct vpx_psnr_pkt
00140 {
00141 unsigned int samples[4];
00142 uint64_t sse[4];
00143 double psnr[4];
00144 } psnr;
00145 struct vpx_fixed_buf raw;
00147
00148
00149
00150
00151
00152 char pad[128 - sizeof(enum vpx_codec_cx_pkt_kind)];
00153 } data;
00154 } vpx_codec_cx_pkt_t;
00161 typedef struct vpx_rational
00162 {
00163 int num;
00164 int den;
00165 } vpx_rational_t;
00169 enum vpx_enc_pass
00170 {
00171 VPX_RC_ONE_PASS,
00172 VPX_RC_FIRST_PASS,
00173 VPX_RC_LAST_PASS,
00174 };
00175
00176
00178 enum vpx_rc_mode
00179 {
00180 VPX_VBR,
00181 VPX_CBR
00182 };
00183
00184
00193 enum vpx_kf_mode
00194 {
00195 VPX_KF_FIXED,
00196 VPX_KF_AUTO,
00197 VPX_KF_DISABLED = 0
00198 };
00199
00200
00208 typedef long vpx_enc_frame_flags_t;
00209 #define VPX_EFLAG_FORCE_KF (1<<0)
00218 typedef struct vpx_codec_enc_cfg
00219 {
00220
00221
00222
00223
00231 unsigned int g_usage;
00232
00233
00240 unsigned int g_threads;
00241
00242
00251 unsigned int g_profile;
00262 unsigned int g_w;
00263
00264
00272 unsigned int g_h;
00273
00274
00287 struct vpx_rational g_timebase;
00288
00289
00296 unsigned int g_error_resilient;
00297
00298
00304 enum vpx_enc_pass g_pass;
00305
00306
00319 unsigned int g_lag_in_frames;
00320
00321
00322
00323
00324
00325
00342 unsigned int rc_dropframe_thresh;
00343
00344
00352 unsigned int rc_resize_allowed;
00353
00354
00361 unsigned int rc_resize_up_thresh;
00362
00363
00370 unsigned int rc_resize_down_thresh;
00371
00372
00381 enum vpx_rc_mode rc_end_usage;
00382
00383
00389 struct vpx_fixed_buf rc_twopass_stats_in;
00390
00391
00396 unsigned int rc_target_bitrate;
00397
00398
00399
00400
00401
00402
00403
00412 unsigned int rc_min_quantizer;
00413
00414
00423 unsigned int rc_max_quantizer;
00424
00425
00426
00427
00428
00429
00430
00437 unsigned int rc_undershoot_pct;
00438
00439
00446 unsigned int rc_overshoot_pct;
00447
00448
00449
00450
00451
00452
00453
00463 unsigned int rc_buf_sz;
00464
00465
00473 unsigned int rc_buf_initial_sz;
00474
00475
00483 unsigned int rc_buf_optimal_sz;
00484
00485
00486
00487
00488
00489
00490
00499 unsigned int rc_2pass_vbr_bias_pct;
00507 unsigned int rc_2pass_vbr_minsection_pct;
00508
00509
00515 unsigned int rc_2pass_vbr_maxsection_pct;
00516
00517
00518
00519
00520
00521
00528 enum vpx_kf_mode kf_mode;
00529
00530
00538 unsigned int kf_min_dist;
00539
00540
00548 unsigned int kf_max_dist;
00549
00550 } vpx_codec_enc_cfg_t;
00575 vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx,
00576 vpx_codec_iface_t *iface,
00577 vpx_codec_enc_cfg_t *cfg,
00578 vpx_codec_flags_t flags,
00579 int ver);
00580
00581
00586 #define vpx_codec_enc_init(ctx, iface, cfg, flags) \
00587 vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION)
00588
00589
00609 vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface,
00610 vpx_codec_enc_cfg_t *cfg,
00611 unsigned int usage);
00612
00613
00628 vpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx,
00629 const vpx_codec_enc_cfg_t *cfg);
00630
00631
00643 vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx);
00644
00645
00646 #define VPX_DL_REALTIME (1)
00648 #define VPX_DL_GOOD_QUALITY (1000000)
00650 #define VPX_DL_BEST_QUALITY (0)
00688 vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx,
00689 const vpx_image_t *img,
00690 vpx_codec_pts_t pts,
00691 unsigned long duration,
00692 vpx_enc_frame_flags_t flags,
00693 unsigned long deadline);
00694
00695
00739 vpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t *ctx,
00740 const vpx_fixed_buf_t *buf,
00741 unsigned int pad_before,
00742 unsigned int pad_after);
00743
00744
00768 const vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx,
00769 vpx_codec_iter_t *iter);
00770
00771
00784 const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx);
00785
00786
00789 #endif
00790 #ifdef __cplusplus
00791 }
00792 #endif