00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef VPX_ENCODER_H
00011 #define VPX_ENCODER_H
00012
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031
00032 #include "vpx_codec.h"
00033
00037 #define VPX_TS_MAX_PERIODICITY 16
00038
00040 #define VPX_TS_MAX_LAYERS 5
00041
00043 #define MAX_PERIODICITY VPX_TS_MAX_PERIODICITY
00044
00046 #define MAX_LAYERS VPX_TS_MAX_LAYERS
00047
00049 #define VPX_SS_MAX_LAYERS 5
00050
00052 #define VPX_SS_DEFAULT_LAYERS 3
00053
00062 #define VPX_ENCODER_ABI_VERSION (3 + VPX_CODEC_ABI_VERSION)
00074 #define VPX_CODEC_CAP_PSNR 0x10000
00081 #define VPX_CODEC_CAP_OUTPUT_PARTITION 0x20000
00082
00083
00091 #define VPX_CODEC_USE_PSNR 0x10000
00092 #define VPX_CODEC_USE_OUTPUT_PARTITION 0x20000
00100 typedef struct vpx_fixed_buf {
00101 void *buf;
00102 size_t sz;
00103 } vpx_fixed_buf_t;
00111 typedef int64_t vpx_codec_pts_t;
00112
00113
00121 typedef uint32_t vpx_codec_frame_flags_t;
00122 #define VPX_FRAME_IS_KEY 0x1
00123 #define VPX_FRAME_IS_DROPPABLE 0x2
00126 #define VPX_FRAME_IS_INVISIBLE 0x4
00128 #define VPX_FRAME_IS_FRAGMENT 0x8
00137 typedef uint32_t vpx_codec_er_flags_t;
00138 #define VPX_ERROR_RESILIENT_DEFAULT 0x1
00140 #define VPX_ERROR_RESILIENT_PARTITIONS 0x2
00155 enum vpx_codec_cx_pkt_kind {
00156 VPX_CODEC_CX_FRAME_PKT,
00157 VPX_CODEC_STATS_PKT,
00158 VPX_CODEC_PSNR_PKT,
00159 VPX_CODEC_CUSTOM_PKT = 256
00160 };
00161
00162
00168 typedef struct vpx_codec_cx_pkt {
00169 enum vpx_codec_cx_pkt_kind kind;
00170 union {
00171 struct {
00172 void *buf;
00173 size_t sz;
00174 vpx_codec_pts_t pts;
00176 unsigned long duration;
00178 vpx_codec_frame_flags_t flags;
00179 int partition_id;
00186 } frame;
00187 struct vpx_fixed_buf twopass_stats;
00188 struct vpx_psnr_pkt {
00189 unsigned int samples[4];
00190 uint64_t sse[4];
00191 double psnr[4];
00192 } psnr;
00193 struct vpx_fixed_buf raw;
00195
00196
00197
00198
00199
00200 char pad[128 - sizeof(enum vpx_codec_cx_pkt_kind)];
00201 } data;
00202 } vpx_codec_cx_pkt_t;
00209 typedef struct vpx_rational {
00210 int num;
00211 int den;
00212 } vpx_rational_t;
00216 enum vpx_enc_pass {
00217 VPX_RC_ONE_PASS,
00218 VPX_RC_FIRST_PASS,
00219 VPX_RC_LAST_PASS
00220 };
00221
00222
00224 enum vpx_rc_mode {
00225 VPX_VBR,
00226 VPX_CBR,
00227 VPX_CQ,
00228 VPX_Q,
00229 };
00230
00231
00240 enum vpx_kf_mode {
00241 VPX_KF_FIXED,
00242 VPX_KF_AUTO,
00243 VPX_KF_DISABLED = 0
00244 };
00245
00246
00254 typedef long vpx_enc_frame_flags_t;
00255 #define VPX_EFLAG_FORCE_KF (1<<0)
00264 typedef struct vpx_codec_enc_cfg {
00265
00266
00267
00268
00276 unsigned int g_usage;
00277
00278
00285 unsigned int g_threads;
00286
00287
00296 unsigned int g_profile;
00307 unsigned int g_w;
00308
00309
00317 unsigned int g_h;
00318
00319
00332 struct vpx_rational g_timebase;
00333
00334
00341 vpx_codec_er_flags_t g_error_resilient;
00342
00343
00349 enum vpx_enc_pass g_pass;
00350
00351
00364 unsigned int g_lag_in_frames;
00365
00366
00367
00368
00369
00370
00387 unsigned int rc_dropframe_thresh;
00388
00389
00397 unsigned int rc_resize_allowed;
00398
00399
00406 unsigned int rc_resize_up_thresh;
00407
00408
00415 unsigned int rc_resize_down_thresh;
00416
00417
00426 enum vpx_rc_mode rc_end_usage;
00427
00428
00434 struct vpx_fixed_buf rc_twopass_stats_in;
00435
00436
00441 unsigned int rc_target_bitrate;
00442
00443
00444
00445
00446
00447
00448
00457 unsigned int rc_min_quantizer;
00458
00459
00468 unsigned int rc_max_quantizer;
00469
00470
00471
00472
00473
00474
00475
00486 unsigned int rc_undershoot_pct;
00487
00488
00499 unsigned int rc_overshoot_pct;
00500
00501
00502
00503
00504
00505
00506
00516 unsigned int rc_buf_sz;
00517
00518
00526 unsigned int rc_buf_initial_sz;
00527
00528
00536 unsigned int rc_buf_optimal_sz;
00537
00538
00539
00540
00541
00542
00543
00552 unsigned int rc_2pass_vbr_bias_pct;
00560 unsigned int rc_2pass_vbr_minsection_pct;
00561
00562
00568 unsigned int rc_2pass_vbr_maxsection_pct;
00569
00570
00571
00572
00573
00574
00581 enum vpx_kf_mode kf_mode;
00582
00583
00591 unsigned int kf_min_dist;
00592
00593
00601 unsigned int kf_max_dist;
00602
00603
00604
00605
00606
00611 unsigned int ss_number_layers;
00612
00617 unsigned int ts_number_layers;
00618
00623 unsigned int ts_target_bitrate[VPX_TS_MAX_LAYERS];
00624
00630 unsigned int ts_rate_decimator[VPX_TS_MAX_LAYERS];
00631
00639 unsigned int ts_periodicity;
00640
00648 unsigned int ts_layer_id[VPX_TS_MAX_PERIODICITY];
00649 } vpx_codec_enc_cfg_t;
00678 vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx,
00679 vpx_codec_iface_t *iface,
00680 vpx_codec_enc_cfg_t *cfg,
00681 vpx_codec_flags_t flags,
00682 int ver);
00683
00684
00689 #define vpx_codec_enc_init(ctx, iface, cfg, flags) \
00690 vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION)
00691
00692
00717 vpx_codec_err_t vpx_codec_enc_init_multi_ver(vpx_codec_ctx_t *ctx,
00718 vpx_codec_iface_t *iface,
00719 vpx_codec_enc_cfg_t *cfg,
00720 int num_enc,
00721 vpx_codec_flags_t flags,
00722 vpx_rational_t *dsf,
00723 int ver);
00724
00725
00730 #define vpx_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \
00731 vpx_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \
00732 VPX_ENCODER_ABI_VERSION)
00733
00734
00754 vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface,
00755 vpx_codec_enc_cfg_t *cfg,
00756 unsigned int usage);
00757
00758
00773 vpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx,
00774 const vpx_codec_enc_cfg_t *cfg);
00775
00776
00788 vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx);
00789
00790
00791 #define VPX_DL_REALTIME (1)
00793 #define VPX_DL_GOOD_QUALITY (1000000)
00795 #define VPX_DL_BEST_QUALITY (0)
00833 vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx,
00834 const vpx_image_t *img,
00835 vpx_codec_pts_t pts,
00836 unsigned long duration,
00837 vpx_enc_frame_flags_t flags,
00838 unsigned long deadline);
00839
00883 vpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t *ctx,
00884 const vpx_fixed_buf_t *buf,
00885 unsigned int pad_before,
00886 unsigned int pad_after);
00887
00888
00912 const vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx,
00913 vpx_codec_iter_t *iter);
00914
00915
00928 const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx);
00929
00930
00932 #ifdef __cplusplus
00933 }
00934 #endif
00935 #endif
00936