00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030
00031 #ifndef VPX_ENCODER_H
00032 #define VPX_ENCODER_H
00033 #include "vpx_codec.h"
00034
00035
00044 #define VPX_ENCODER_ABI_VERSION (2 + VPX_CODEC_ABI_VERSION)
00056 #define VPX_CODEC_CAP_PSNR 0x10000
00066 #define VPX_CODEC_USE_PSNR 0x10000
00073 typedef struct vpx_fixed_buf
00074 {
00075 void *buf;
00076 size_t sz;
00077 } vpx_fixed_buf_t;
00085 typedef int64_t vpx_codec_pts_t;
00086
00087
00095 typedef uint32_t vpx_codec_frame_flags_t;
00096 #define VPX_FRAME_IS_KEY 0x1
00097 #define VPX_FRAME_IS_DROPPABLE 0x2
00100 #define VPX_FRAME_IS_INVISIBLE 0x4
00110 enum vpx_codec_cx_pkt_kind
00111 {
00112 VPX_CODEC_CX_FRAME_PKT,
00113 VPX_CODEC_STATS_PKT,
00114 VPX_CODEC_PSNR_PKT,
00115 VPX_CODEC_CUSTOM_PKT = 256
00116 };
00117
00118
00124 typedef struct vpx_codec_cx_pkt
00125 {
00126 enum vpx_codec_cx_pkt_kind kind;
00127 union
00128 {
00129 struct
00130 {
00131 void *buf;
00132 size_t sz;
00133 vpx_codec_pts_t pts;
00135 unsigned long duration;
00137 vpx_codec_frame_flags_t flags;
00138 } frame;
00139 struct vpx_fixed_buf twopass_stats;
00140 struct vpx_psnr_pkt
00141 {
00142 unsigned int samples[4];
00143 uint64_t sse[4];
00144 double psnr[4];
00145 } psnr;
00146 struct vpx_fixed_buf raw;
00148
00149
00150
00151
00152
00153 char pad[128 - sizeof(enum vpx_codec_cx_pkt_kind)];
00154 } data;
00155 } vpx_codec_cx_pkt_t;
00162 typedef struct vpx_rational
00163 {
00164 int num;
00165 int den;
00166 } vpx_rational_t;
00170 enum vpx_enc_pass
00171 {
00172 VPX_RC_ONE_PASS,
00173 VPX_RC_FIRST_PASS,
00174 VPX_RC_LAST_PASS
00175 };
00176
00177
00179 enum vpx_rc_mode
00180 {
00181 VPX_VBR,
00182 VPX_CBR,
00183 VPX_CQ
00184 };
00185
00186
00195 enum vpx_kf_mode
00196 {
00197 VPX_KF_FIXED,
00198 VPX_KF_AUTO,
00199 VPX_KF_DISABLED = 0
00200 };
00201
00202
00210 typedef long vpx_enc_frame_flags_t;
00211 #define VPX_EFLAG_FORCE_KF (1<<0)
00220 typedef struct vpx_codec_enc_cfg
00221 {
00222
00223
00224
00225
00233 unsigned int g_usage;
00234
00235
00242 unsigned int g_threads;
00243
00244
00253 unsigned int g_profile;
00264 unsigned int g_w;
00265
00266
00274 unsigned int g_h;
00275
00276
00289 struct vpx_rational g_timebase;
00290
00291
00298 unsigned int g_error_resilient;
00299
00300
00306 enum vpx_enc_pass g_pass;
00307
00308
00321 unsigned int g_lag_in_frames;
00322
00323
00324
00325
00326
00327
00344 unsigned int rc_dropframe_thresh;
00345
00346
00354 unsigned int rc_resize_allowed;
00355
00356
00363 unsigned int rc_resize_up_thresh;
00364
00365
00372 unsigned int rc_resize_down_thresh;
00373
00374
00383 enum vpx_rc_mode rc_end_usage;
00384
00385
00391 struct vpx_fixed_buf rc_twopass_stats_in;
00392
00393
00398 unsigned int rc_target_bitrate;
00399
00400
00401
00402
00403
00404
00405
00414 unsigned int rc_min_quantizer;
00415
00416
00425 unsigned int rc_max_quantizer;
00426
00427
00428
00429
00430
00431
00432
00439 unsigned int rc_undershoot_pct;
00440
00441
00448 unsigned int rc_overshoot_pct;
00449
00450
00451
00452
00453
00454
00455
00465 unsigned int rc_buf_sz;
00466
00467
00475 unsigned int rc_buf_initial_sz;
00476
00477
00485 unsigned int rc_buf_optimal_sz;
00486
00487
00488
00489
00490
00491
00492
00501 unsigned int rc_2pass_vbr_bias_pct;
00509 unsigned int rc_2pass_vbr_minsection_pct;
00510
00511
00517 unsigned int rc_2pass_vbr_maxsection_pct;
00518
00519
00520
00521
00522
00523
00530 enum vpx_kf_mode kf_mode;
00531
00532
00540 unsigned int kf_min_dist;
00541
00542
00550 unsigned int kf_max_dist;
00551
00552 } vpx_codec_enc_cfg_t;
00577 vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx,
00578 vpx_codec_iface_t *iface,
00579 vpx_codec_enc_cfg_t *cfg,
00580 vpx_codec_flags_t flags,
00581 int ver);
00582
00583
00588 #define vpx_codec_enc_init(ctx, iface, cfg, flags) \
00589 vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION)
00590
00591
00611 vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface,
00612 vpx_codec_enc_cfg_t *cfg,
00613 unsigned int usage);
00614
00615
00630 vpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx,
00631 const vpx_codec_enc_cfg_t *cfg);
00632
00633
00645 vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx);
00646
00647
00648 #define VPX_DL_REALTIME (1)
00650 #define VPX_DL_GOOD_QUALITY (1000000)
00652 #define VPX_DL_BEST_QUALITY (0)
00690 vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx,
00691 const vpx_image_t *img,
00692 vpx_codec_pts_t pts,
00693 unsigned long duration,
00694 vpx_enc_frame_flags_t flags,
00695 unsigned long deadline);
00696
00697
00741 vpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t *ctx,
00742 const vpx_fixed_buf_t *buf,
00743 unsigned int pad_before,
00744 unsigned int pad_after);
00745
00746
00770 const vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx,
00771 vpx_codec_iter_t *iter);
00772
00773
00786 const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx);
00787
00788
00791 #endif
00792 #ifdef __cplusplus
00793 }
00794 #endif