• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

vpx/vpx_encoder.h

Go to the documentation of this file.
00001 /*
00002  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
00003  *
00004  *  Use of this source code is governed by a BSD-style license
00005  *  that can be found in the LICENSE file in the root of the source
00006  *  tree. An additional intellectual property rights grant can be found
00007  *  in the file PATENTS.  All contributing project authors may
00008  *  be found in the AUTHORS file in the root of the source tree.
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             /* This packet size is fixed to allow codecs to extend this
00149              * interface without having to manage storage for raw packets,
00150              * ie if it's smaller than 128 bytes, you can store in the
00151              * packet list directly.
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     };
00184 
00185 
00194     enum vpx_kf_mode
00195     {
00196         VPX_KF_FIXED, 
00197         VPX_KF_AUTO,  
00198         VPX_KF_DISABLED = 0 
00199     };
00200 
00201 
00209     typedef long vpx_enc_frame_flags_t;
00210 #define VPX_EFLAG_FORCE_KF (1<<0)  
00219     typedef struct vpx_codec_enc_cfg
00220     {
00221         /*
00222          * generic settings (g)
00223          */
00224 
00232         unsigned int           g_usage;
00233 
00234 
00241         unsigned int           g_threads;
00242 
00243 
00252         unsigned int           g_profile;  
00263         unsigned int           g_w;
00264 
00265 
00273         unsigned int           g_h;
00274 
00275 
00288         struct vpx_rational    g_timebase;
00289 
00290 
00297         unsigned int           g_error_resilient;
00298 
00299 
00305         enum vpx_enc_pass      g_pass;
00306 
00307 
00320         unsigned int           g_lag_in_frames;
00321 
00322 
00323         /*
00324          * rate control settings (rc)
00325          */
00326 
00343         unsigned int           rc_dropframe_thresh;
00344 
00345 
00353         unsigned int           rc_resize_allowed;
00354 
00355 
00362         unsigned int           rc_resize_up_thresh;
00363 
00364 
00371         unsigned int           rc_resize_down_thresh;
00372 
00373 
00382         enum vpx_rc_mode       rc_end_usage;
00383 
00384 
00390         struct vpx_fixed_buf   rc_twopass_stats_in;
00391 
00392 
00397         unsigned int           rc_target_bitrate;
00398 
00399 
00400         /*
00401          * quantizer settings
00402          */
00403 
00404 
00413         unsigned int           rc_min_quantizer;
00414 
00415 
00424         unsigned int           rc_max_quantizer;
00425 
00426 
00427         /*
00428          * bitrate tolerance
00429          */
00430 
00431 
00438         unsigned int           rc_undershoot_pct;
00439 
00440 
00447         unsigned int           rc_overshoot_pct;
00448 
00449 
00450         /*
00451          * decoder buffer model parameters
00452          */
00453 
00454 
00464         unsigned int           rc_buf_sz;
00465 
00466 
00474         unsigned int           rc_buf_initial_sz;
00475 
00476 
00484         unsigned int           rc_buf_optimal_sz;
00485 
00486 
00487         /*
00488          * 2 pass rate control parameters
00489          */
00490 
00491 
00500         unsigned int           rc_2pass_vbr_bias_pct;       
00508         unsigned int           rc_2pass_vbr_minsection_pct;
00509 
00510 
00516         unsigned int           rc_2pass_vbr_maxsection_pct;
00517 
00518 
00519         /*
00520          * keyframing settings (kf)
00521          */
00522 
00529         enum vpx_kf_mode       kf_mode;
00530 
00531 
00539         unsigned int           kf_min_dist;
00540 
00541 
00549         unsigned int           kf_max_dist;
00550 
00551     } vpx_codec_enc_cfg_t; 
00576     vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t      *ctx,
00577                                            vpx_codec_iface_t    *iface,
00578                                            vpx_codec_enc_cfg_t  *cfg,
00579                                            vpx_codec_flags_t     flags,
00580                                            int                   ver);
00581 
00582 
00587 #define vpx_codec_enc_init(ctx, iface, cfg, flags) \
00588     vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION)
00589 
00590 
00610     vpx_codec_err_t  vpx_codec_enc_config_default(vpx_codec_iface_t    *iface,
00611             vpx_codec_enc_cfg_t  *cfg,
00612             unsigned int          usage);
00613 
00614 
00629     vpx_codec_err_t  vpx_codec_enc_config_set(vpx_codec_ctx_t            *ctx,
00630             const vpx_codec_enc_cfg_t  *cfg);
00631 
00632 
00644     vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t   *ctx);
00645 
00646 
00647 #define VPX_DL_REALTIME     (1)        
00649 #define VPX_DL_GOOD_QUALITY (1000000)  
00651 #define VPX_DL_BEST_QUALITY (0)        
00689     vpx_codec_err_t  vpx_codec_encode(vpx_codec_ctx_t            *ctx,
00690                                       const vpx_image_t          *img,
00691                                       vpx_codec_pts_t             pts,
00692                                       unsigned long               duration,
00693                                       vpx_enc_frame_flags_t       flags,
00694                                       unsigned long               deadline);
00695 
00696 
00740     vpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t       *ctx,
00741             const vpx_fixed_buf_t *buf,
00742             unsigned int           pad_before,
00743             unsigned int           pad_after);
00744 
00745 
00769     const vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t   *ctx,
00770             vpx_codec_iter_t  *iter);
00771 
00772 
00785     const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t   *ctx);
00786 
00787 
00790 #endif
00791 #ifdef __cplusplus
00792 }
00793 #endif

Generated on Mon Feb 21 2011 02:44:05 for WebM VP8 Codec SDK by  doxygen 1.7.1