Encoder Algorithm Interface

This abstraction allows applications using this encoder to easily support multiple video formats with minimal code duplication. More...

Files

file  vpx_encoder.h
 Describes the encoder algorithm interface to applications.
 
file  vpx_encoder.h
 Describes the encoder algorithm interface to applications.
 

Classes

struct  vpx_fixed_buf
 Generic fixed size buffer structure. More...
 
struct  vpx_codec_cx_pkt
 Encoder output packet. More...
 
struct  vpx_codec_enc_output_cx_cb_pair
 Callback function pointer / user data pair storage. More...
 
struct  vpx_rational
 Rational Number. More...
 
struct  vpx_codec_enc_cfg
 Encoder configuration structure. More...
 
struct  vpx_svc_parameters
 vp9 svc extra configure parameters More...
 

Typedefs

typedef struct vpx_fixed_buf vpx_fixed_buf_t
 Generic fixed size buffer structure. More...
 
typedef int64_t vpx_codec_pts_t
 Time Stamp Type. More...
 
typedef uint32_t vpx_codec_frame_flags_t
 Compressed Frame Flags. More...
 
typedef uint32_t vpx_codec_er_flags_t
 Error Resilient flags. More...
 
typedef struct vpx_codec_cx_pkt vpx_codec_cx_pkt_t
 Encoder output packet. More...
 
typedef void(* vpx_codec_enc_output_cx_pkt_cb_fn_t) (vpx_codec_cx_pkt_t *pkt, void *user_data)
 Encoder return output buffer callback. More...
 
typedef struct vpx_codec_enc_output_cx_cb_pair vpx_codec_priv_output_cx_pkt_cb_pair_t
 Callback function pointer / user data pair storage. More...
 
typedef struct vpx_rational vpx_rational_t
 Rational Number. More...
 
typedef enum vpx_enc_pass vpx_enc_pass
 Multi-pass Encoding Pass. More...
 
typedef long vpx_enc_frame_flags_t
 Encoded Frame Flags. More...
 
typedef struct vpx_codec_enc_cfg vpx_codec_enc_cfg_t
 Encoder configuration structure. More...
 
typedef struct vpx_svc_parameters vpx_svc_extra_cfg_t
 vp9 svc extra configure parameters More...
 
typedef struct vpx_fixed_buf vpx_fixed_buf_t
 Generic fixed size buffer structure. More...
 
typedef int64_t vpx_codec_pts_t
 Time Stamp Type. More...
 
typedef uint32_t vpx_codec_frame_flags_t
 Compressed Frame Flags. More...
 
typedef uint32_t vpx_codec_er_flags_t
 Error Resilient flags. More...
 
typedef struct vpx_codec_cx_pkt vpx_codec_cx_pkt_t
 Encoder output packet. More...
 
typedef void(* vpx_codec_enc_output_cx_pkt_cb_fn_t) (vpx_codec_cx_pkt_t *pkt, void *user_data)
 Encoder return output buffer callback. More...
 
typedef struct vpx_codec_enc_output_cx_cb_pair vpx_codec_priv_output_cx_pkt_cb_pair_t
 Callback function pointer / user data pair storage. More...
 
typedef struct vpx_rational vpx_rational_t
 Rational Number. More...
 
typedef long vpx_enc_frame_flags_t
 Encoded Frame Flags. More...
 
typedef struct vpx_codec_enc_cfg vpx_codec_enc_cfg_t
 Encoder configuration structure. More...
 
typedef struct vpx_svc_parameters vpx_svc_extra_cfg_t
 vp9 svc extra configure parameters More...
 

Enumerations

enum  vpx_codec_cx_pkt_kind {
  VPX_CODEC_CX_FRAME_PKT , VPX_CODEC_STATS_PKT , VPX_CODEC_FPMB_STATS_PKT , VPX_CODEC_PSNR_PKT ,
  VPX_CODEC_CUSTOM_PKT = 256 , VPX_CODEC_CX_FRAME_PKT , VPX_CODEC_STATS_PKT , VPX_CODEC_FPMB_STATS_PKT ,
  VPX_CODEC_PSNR_PKT , VPX_CODEC_SPATIAL_SVC_LAYER_SIZES , VPX_CODEC_SPATIAL_SVC_LAYER_PSNR , VPX_CODEC_CUSTOM_PKT = 256
}
 Encoder output packet variants. More...
 
enum  vpx_enc_pass {
  VPX_RC_ONE_PASS , VPX_RC_FIRST_PASS , VPX_RC_LAST_PASS , VPX_RC_ONE_PASS ,
  VPX_RC_FIRST_PASS , VPX_RC_LAST_PASS
}
 Multi-pass Encoding Pass. More...
 
enum  vpx_rc_mode {
  VPX_VBR , VPX_CBR , VPX_CQ , VPX_Q ,
  VPX_VBR , VPX_CBR , VPX_CQ , VPX_Q
}
 Rate control mode. More...
 
enum  vpx_kf_mode {
  VPX_KF_FIXED , VPX_KF_AUTO , VPX_KF_DISABLED = 0 , VPX_KF_FIXED ,
  VPX_KF_AUTO , VPX_KF_DISABLED = 0
}
 Keyframe placement mode. More...
 
enum  vpx_codec_cx_pkt_kind {
  VPX_CODEC_CX_FRAME_PKT , VPX_CODEC_STATS_PKT , VPX_CODEC_FPMB_STATS_PKT , VPX_CODEC_PSNR_PKT ,
  VPX_CODEC_CUSTOM_PKT = 256 , VPX_CODEC_CX_FRAME_PKT , VPX_CODEC_STATS_PKT , VPX_CODEC_FPMB_STATS_PKT ,
  VPX_CODEC_PSNR_PKT , VPX_CODEC_SPATIAL_SVC_LAYER_SIZES , VPX_CODEC_SPATIAL_SVC_LAYER_PSNR , VPX_CODEC_CUSTOM_PKT = 256
}
 Encoder output packet variants. More...
 
enum  vpx_enc_pass {
  VPX_RC_ONE_PASS , VPX_RC_FIRST_PASS , VPX_RC_LAST_PASS , VPX_RC_ONE_PASS ,
  VPX_RC_FIRST_PASS , VPX_RC_LAST_PASS
}
 Multi-pass Encoding Pass. More...
 
enum  vpx_rc_mode {
  VPX_VBR , VPX_CBR , VPX_CQ , VPX_Q ,
  VPX_VBR , VPX_CBR , VPX_CQ , VPX_Q
}
 Rate control mode. More...
 
enum  vpx_kf_mode {
  VPX_KF_FIXED , VPX_KF_AUTO , VPX_KF_DISABLED = 0 , VPX_KF_FIXED ,
  VPX_KF_AUTO , VPX_KF_DISABLED = 0
}
 Keyframe placement mode. More...
 

Functions

vpx_codec_err_t vpx_codec_enc_init_ver (vpx_codec_ctx_t *ctx, vpx_codec_iface_t *iface, const vpx_codec_enc_cfg_t *cfg, vpx_codec_flags_t flags, int ver)
 Initialize an encoder instance. More...
 
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. More...
 
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. More...
 
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. More...
 
vpx_fixed_buf_tvpx_codec_get_global_headers (vpx_codec_ctx_t *ctx)
 Get global stream headers. More...
 
vpx_codec_err_t vpx_codec_encode (vpx_codec_ctx_t *ctx, const vpx_image_t *img, vpx_codec_pts_t pts, unsigned long duration, vpx_enc_frame_flags_t flags, unsigned long deadline)
 Encode a frame. More...
 
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. More...
 
const vpx_codec_cx_pkt_tvpx_codec_get_cx_data (vpx_codec_ctx_t *ctx, vpx_codec_iter_t *iter)
 Encoded data iterator. More...
 
const vpx_image_tvpx_codec_get_preview_frame (vpx_codec_ctx_t *ctx)
 Get Preview Frame. More...
 

Detailed Description

This abstraction allows applications using this encoder to easily support multiple video formats with minimal code duplication.

This section describes the interface common to all encoders.

Typedef Documentation

◆ vpx_codec_cx_pkt_t [1/2]

Encoder output packet.

This structure contains the different kinds of output data the encoder may produce while compressing a frame. alias for struct vpx_codec_cx_pkt

◆ vpx_codec_cx_pkt_t [2/2]

Encoder output packet.

This structure contains the different kinds of output data the encoder may produce while compressing a frame. alias for struct vpx_codec_cx_pkt

◆ vpx_codec_enc_cfg_t [1/2]

Encoder configuration structure.

This structure contains the encoder settings that have common representations across all codecs. This doesn't imply that all codecs support all features, however. alias for struct vpx_codec_enc_cfg

◆ vpx_codec_enc_cfg_t [2/2]

Encoder configuration structure.

This structure contains the encoder settings that have common representations across all codecs. This doesn't imply that all codecs support all features, however. alias for struct vpx_codec_enc_cfg

◆ vpx_codec_enc_output_cx_pkt_cb_fn_t [1/2]

typedef void(* vpx_codec_enc_output_cx_pkt_cb_fn_t) (vpx_codec_cx_pkt_t *pkt, void *user_data)

Encoder return output buffer callback.

This callback function, when registered, returns with packets when each spatial layer is encoded.

◆ vpx_codec_enc_output_cx_pkt_cb_fn_t [2/2]

typedef void(* vpx_codec_enc_output_cx_pkt_cb_fn_t) (vpx_codec_cx_pkt_t *pkt, void *user_data)

Encoder return output buffer callback.

This callback function, when registered, returns with packets when each spatial layer is encoded.

◆ vpx_codec_er_flags_t [1/2]

typedef uint32_t vpx_codec_er_flags_t

Error Resilient flags.

These flags define which error resilient features to enable in the encoder. The flags are specified through the vpx_codec_enc_cfg::g_error_resilient variable.

◆ vpx_codec_er_flags_t [2/2]

typedef uint32_t vpx_codec_er_flags_t

Error Resilient flags.

These flags define which error resilient features to enable in the encoder. The flags are specified through the vpx_codec_enc_cfg::g_error_resilient variable.

◆ vpx_codec_frame_flags_t [1/2]

typedef uint32_t vpx_codec_frame_flags_t

Compressed Frame Flags.

This type represents a bitfield containing information about a compressed frame that may be useful to an application. The most significant 16 bits can be used by an algorithm to provide additional detail, for example to support frame types that are codec specific (MPEG-1 D-frames for example)

◆ vpx_codec_frame_flags_t [2/2]

typedef uint32_t vpx_codec_frame_flags_t

Compressed Frame Flags.

This type represents a bitfield containing information about a compressed frame that may be useful to an application. The most significant 16 bits can be used by an algorithm to provide additional detail, for example to support frame types that are codec specific (MPEG-1 D-frames for example)

◆ vpx_codec_priv_output_cx_pkt_cb_pair_t [1/2]

Callback function pointer / user data pair storage.

◆ vpx_codec_priv_output_cx_pkt_cb_pair_t [2/2]

Callback function pointer / user data pair storage.

◆ vpx_codec_pts_t [1/2]

typedef int64_t vpx_codec_pts_t

Time Stamp Type.

An integer, which when multiplied by the stream's time base, provides the absolute time of a sample.

◆ vpx_codec_pts_t [2/2]

typedef int64_t vpx_codec_pts_t

Time Stamp Type.

An integer, which when multiplied by the stream's time base, provides the absolute time of a sample.

◆ vpx_enc_frame_flags_t [1/2]

typedef long vpx_enc_frame_flags_t

Encoded Frame Flags.

This type indicates a bitfield to be passed to vpx_codec_encode(), defining per-frame boolean values. By convention, bits common to all codecs will be named VPX_EFLAG_*, and bits specific to an algorithm will be named /algo/_eflag_*. The lower order 16 bits are reserved for common use.

◆ vpx_enc_frame_flags_t [2/2]

typedef long vpx_enc_frame_flags_t

Encoded Frame Flags.

This type indicates a bitfield to be passed to vpx_codec_encode(), defining per-frame boolean values. By convention, bits common to all codecs will be named VPX_EFLAG_*, and bits specific to an algorithm will be named /algo/_eflag_*. The lower order 16 bits are reserved for common use.

◆ vpx_enc_pass

typedef enum vpx_enc_pass vpx_enc_pass

Multi-pass Encoding Pass.

◆ vpx_fixed_buf_t [1/2]

Generic fixed size buffer structure.

This structure is able to hold a reference to any fixed size buffer. alias for struct vpx_fixed_buf

◆ vpx_fixed_buf_t [2/2]

Generic fixed size buffer structure.

This structure is able to hold a reference to any fixed size buffer. alias for struct vpx_fixed_buf

◆ vpx_rational_t [1/2]

typedef struct vpx_rational vpx_rational_t

Rational Number.

This structure holds a fractional value. alias for struct vpx_rational

◆ vpx_rational_t [2/2]

typedef struct vpx_rational vpx_rational_t

Rational Number.

This structure holds a fractional value. alias for struct vpx_rational

◆ vpx_svc_extra_cfg_t [1/2]

vp9 svc extra configure parameters

This defines max/min quantizers and scale factors for each layer

◆ vpx_svc_extra_cfg_t [2/2]

vp9 svc extra configure parameters

This defines max/min quantizers and scale factors for each layer

Enumeration Type Documentation

◆ vpx_codec_cx_pkt_kind [1/2]

Encoder output packet variants.

This enumeration lists the different kinds of data packets that can be returned by calls to vpx_codec_get_cx_data(). Algorithms MAY extend this list to provide additional functionality.

Enumerator
VPX_CODEC_CX_FRAME_PKT 

Compressed video frame.

VPX_CODEC_STATS_PKT 

Two-pass statistics for this frame.

VPX_CODEC_FPMB_STATS_PKT 

first pass mb statistics for this frame

VPX_CODEC_PSNR_PKT 

PSNR statistics for this frame.

VPX_CODEC_CUSTOM_PKT 

Algorithm extensions

VPX_CODEC_CX_FRAME_PKT 

Compressed video frame.

VPX_CODEC_STATS_PKT 

Two-pass statistics for this frame.

VPX_CODEC_FPMB_STATS_PKT 

first pass mb statistics for this frame

VPX_CODEC_PSNR_PKT 

PSNR statistics for this frame.

VPX_CODEC_SPATIAL_SVC_LAYER_SIZES 

Sizes for each layer in this frame.

VPX_CODEC_SPATIAL_SVC_LAYER_PSNR 

PSNR for each layer in this frame.

VPX_CODEC_CUSTOM_PKT 

Algorithm extensions

◆ vpx_codec_cx_pkt_kind [2/2]

Encoder output packet variants.

This enumeration lists the different kinds of data packets that can be returned by calls to vpx_codec_get_cx_data(). Algorithms MAY extend this list to provide additional functionality.

Enumerator
VPX_CODEC_CX_FRAME_PKT 

Compressed video frame.

VPX_CODEC_STATS_PKT 

Two-pass statistics for this frame.

VPX_CODEC_FPMB_STATS_PKT 

first pass mb statistics for this frame

VPX_CODEC_PSNR_PKT 

PSNR statistics for this frame.

VPX_CODEC_CUSTOM_PKT 

Algorithm extensions

VPX_CODEC_CX_FRAME_PKT 

Compressed video frame.

VPX_CODEC_STATS_PKT 

Two-pass statistics for this frame.

VPX_CODEC_FPMB_STATS_PKT 

first pass mb statistics for this frame

VPX_CODEC_PSNR_PKT 

PSNR statistics for this frame.

VPX_CODEC_SPATIAL_SVC_LAYER_SIZES 

Sizes for each layer in this frame.

VPX_CODEC_SPATIAL_SVC_LAYER_PSNR 

PSNR for each layer in this frame.

VPX_CODEC_CUSTOM_PKT 

Algorithm extensions

◆ vpx_enc_pass [1/2]

Multi-pass Encoding Pass.

Enumerator
VPX_RC_ONE_PASS 

Single pass mode.

VPX_RC_FIRST_PASS 

First pass of multi-pass mode.

VPX_RC_LAST_PASS 

Final pass of multi-pass mode.

VPX_RC_ONE_PASS 

Single pass mode.

VPX_RC_FIRST_PASS 

First pass of multi-pass mode.

VPX_RC_LAST_PASS 

Final pass of multi-pass mode.

◆ vpx_enc_pass [2/2]

Multi-pass Encoding Pass.

Enumerator
VPX_RC_ONE_PASS 

Single pass mode.

VPX_RC_FIRST_PASS 

First pass of multi-pass mode.

VPX_RC_LAST_PASS 

Final pass of multi-pass mode.

VPX_RC_ONE_PASS 

Single pass mode.

VPX_RC_FIRST_PASS 

First pass of multi-pass mode.

VPX_RC_LAST_PASS 

Final pass of multi-pass mode.

◆ vpx_kf_mode [1/2]

Keyframe placement mode.

This enumeration determines whether keyframes are placed automatically by the encoder or whether this behavior is disabled. Older releases of this SDK were implemented such that VPX_KF_FIXED meant keyframes were disabled. This name is confusing for this behavior, so the new symbols to be used are VPX_KF_AUTO and VPX_KF_DISABLED.

Enumerator
VPX_KF_FIXED 

deprecated, implies VPX_KF_DISABLED

VPX_KF_AUTO 

Encoder determines optimal placement automatically.

VPX_KF_DISABLED 

Encoder does not place keyframes.

VPX_KF_FIXED 

deprecated, implies VPX_KF_DISABLED

VPX_KF_AUTO 

Encoder determines optimal placement automatically.

VPX_KF_DISABLED 

Encoder does not place keyframes.

◆ vpx_kf_mode [2/2]

Keyframe placement mode.

This enumeration determines whether keyframes are placed automatically by the encoder or whether this behavior is disabled. Older releases of this SDK were implemented such that VPX_KF_FIXED meant keyframes were disabled. This name is confusing for this behavior, so the new symbols to be used are VPX_KF_AUTO and VPX_KF_DISABLED.

Enumerator
VPX_KF_FIXED 

deprecated, implies VPX_KF_DISABLED

VPX_KF_AUTO 

Encoder determines optimal placement automatically.

VPX_KF_DISABLED 

Encoder does not place keyframes.

VPX_KF_FIXED 

deprecated, implies VPX_KF_DISABLED

VPX_KF_AUTO 

Encoder determines optimal placement automatically.

VPX_KF_DISABLED 

Encoder does not place keyframes.

◆ vpx_rc_mode [1/2]

Rate control mode.

Enumerator
VPX_VBR 

Variable Bit Rate (VBR) mode.

VPX_CBR 

Constant Bit Rate (CBR) mode.

VPX_CQ 

Constrained Quality (CQ) mode.

VPX_Q 

Constant Quality (Q) mode.

VPX_VBR 

Variable Bit Rate (VBR) mode.

VPX_CBR 

Constant Bit Rate (CBR) mode.

VPX_CQ 

Constrained Quality (CQ) mode.

VPX_Q 

Constant Quality (Q) mode.

◆ vpx_rc_mode [2/2]

Rate control mode.

Enumerator
VPX_VBR 

Variable Bit Rate (VBR) mode.

VPX_CBR 

Constant Bit Rate (CBR) mode.

VPX_CQ 

Constrained Quality (CQ) mode.

VPX_Q 

Constant Quality (Q) mode.

VPX_VBR 

Variable Bit Rate (VBR) mode.

VPX_CBR 

Constant Bit Rate (CBR) mode.

VPX_CQ 

Constrained Quality (CQ) mode.

VPX_Q 

Constant Quality (Q) mode.

Function Documentation

◆ 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.

Initializes a encoder configuration structure with default values. Supports the notion of "usages" so that an algorithm may offer different default settings depending on the user's intended goal. This function SHOULD be called by all applications to initialize the configuration structure before specializing the configuration with application specific values.

Parameters
[in]ifacePointer to the algorithm interface to use.
[out]cfgConfiguration buffer to populate.
[in]usageMust be set to 0.
Return values
VPX_CODEC_OKThe configuration was populated.
VPX_CODEC_INCAPABLEInterface is not an encoder interface.
VPX_CODEC_INVALID_PARAMA parameter was NULL, or the usage value was not recognized.

Initializes a encoder configuration structure with default values. Supports the notion of "usages" so that an algorithm may offer different default settings depending on the user's intended goal. This function SHOULD be called by all applications to initialize the configuration structure before specializing the configuration with application specific values.

Parameters
[in]ifacePointer to the algorithm interface to use.
[out]cfgConfiguration buffer to populate.
[in]reservedMust set to 0 for VP8 and VP9.
Return values
VPX_CODEC_OKThe configuration was populated.
VPX_CODEC_INCAPABLEInterface is not an encoder interface.
VPX_CODEC_INVALID_PARAMA parameter was NULL, or the usage value was not recognized.

◆ 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.

Reconfigures an encoder instance according to the given configuration.

Parameters
[in]ctxPointer to this instance's context
[in]cfgConfiguration buffer to use
Return values
VPX_CODEC_OKThe configuration was populated.
VPX_CODEC_INCAPABLEInterface is not an encoder interface.
VPX_CODEC_INVALID_PARAMA parameter was NULL, or the usage value was not recognized.

◆ 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.

Initializes multi-encoder context using the given interface. Applications should call the vpx_codec_enc_init_multi convenience macro instead of this function directly, to ensure that the ABI version number parameter is properly initialized.

Parameters
[in]ctxPointer to this instance's context.
[in]ifacePointer to the algorithm interface to use.
[in]cfgConfiguration to use, if known. May be NULL.
[in]num_encTotal number of encoders.
[in]flagsBitfield of VPX_CODEC_USE_* flags
[in]dsfPointer to down-sampling factors.
[in]verABI version number. Must be set to VPX_ENCODER_ABI_VERSION
Return values
VPX_CODEC_OKThe decoder algorithm initialized.
VPX_CODEC_MEM_ERRORMemory allocation failed.

◆ vpx_codec_enc_init_ver()

vpx_codec_err_t vpx_codec_enc_init_ver ( vpx_codec_ctx_t ctx,
vpx_codec_iface_t iface,
const vpx_codec_enc_cfg_t cfg,
vpx_codec_flags_t  flags,
int  ver 
)

Initialize an encoder instance.

Initializes a encoder context using the given interface. Applications should call the vpx_codec_enc_init convenience macro instead of this function directly, to ensure that the ABI version number parameter is properly initialized.

If the library was configured with –disable-multithread, this call is not thread safe and should be guarded with a lock if being used in a multithreaded context.

Parameters
[in]ctxPointer to this instance's context.
[in]ifacePointer to the algorithm interface to use.
[in]cfgConfiguration to use, if known. May be NULL.
[in]flagsBitfield of VPX_CODEC_USE_* flags
[in]verABI version number. Must be set to VPX_ENCODER_ABI_VERSION
Return values
VPX_CODEC_OKThe decoder algorithm initialized.
VPX_CODEC_MEM_ERRORMemory allocation failed.

◆ vpx_codec_encode()

vpx_codec_err_t vpx_codec_encode ( vpx_codec_ctx_t ctx,
const vpx_image_t img,
vpx_codec_pts_t  pts,
unsigned long  duration,
vpx_enc_frame_flags_t  flags,
unsigned long  deadline 
)

Encode a frame.

Encodes a video frame at the given "presentation time." The presentation time stamp (PTS) MUST be strictly increasing.

The encoder supports the notion of a soft real-time deadline. Given a non-zero value to the deadline parameter, the encoder will make a "best effort" guarantee to return before the given time slice expires. It is implicit that limiting the available time to encode will degrade the output quality. The encoder can be given an unlimited time to produce the best possible frame by specifying a deadline of '0'. This deadline supersedes the VPx notion of "best quality, good quality, realtime". Applications that wish to map these former settings to the new deadline based system can use the symbols #VPX_DL_REALTIME, #VPX_DL_GOOD_QUALITY, and #VPX_DL_BEST_QUALITY.

When the last frame has been passed to the encoder, this function should continue to be called, with the img parameter set to NULL. This will signal the end-of-stream condition to the encoder and allow it to encode any held buffers. Encoding is complete when vpx_codec_encode() is called and vpx_codec_get_cx_data() returns no data.

Parameters
[in]ctxPointer to this instance's context
[in]imgImage data to encode, NULL to flush.
[in]ptsPresentation time stamp, in timebase units.
[in]durationDuration to show frame, in timebase units.
[in]flagsFlags to use for encoding this frame.
[in]deadlineTime to spend encoding, in microseconds. (0=infinite)
Return values
VPX_CODEC_OKThe configuration was populated.
VPX_CODEC_INCAPABLEInterface is not an encoder interface.
VPX_CODEC_INVALID_PARAMA parameter was NULL, the image format is unsupported, etc.

Encodes a video frame at the given "presentation time." The presentation time stamp (PTS) MUST be strictly increasing.

The encoder supports the notion of a soft real-time deadline. Given a non-zero value to the deadline parameter, the encoder will make a "best effort" guarantee to return before the given time slice expires. It is implicit that limiting the available time to encode will degrade the output quality. The encoder can be given an unlimited time to produce the best possible frame by specifying a deadline of '0'. This deadline supercedes the VPx notion of "best quality, good quality, realtime". Applications that wish to map these former settings to the new deadline based system can use the symbols #VPX_DL_REALTIME, #VPX_DL_GOOD_QUALITY, and #VPX_DL_BEST_QUALITY.

When the last frame has been passed to the encoder, this function should continue to be called, with the img parameter set to NULL. This will signal the end-of-stream condition to the encoder and allow it to encode any held buffers. Encoding is complete when vpx_codec_encode() is called and vpx_codec_get_cx_data() returns no data.

Parameters
[in]ctxPointer to this instance's context
[in]imgImage data to encode, NULL to flush.
[in]ptsPresentation time stamp, in timebase units.
[in]durationDuration to show frame, in timebase units.
[in]flagsFlags to use for encoding this frame.
[in]deadlineTime to spend encoding, in microseconds. (0=infinite)
Return values
VPX_CODEC_OKThe configuration was populated.
VPX_CODEC_INCAPABLEInterface is not an encoder interface.
VPX_CODEC_INVALID_PARAMA parameter was NULL, the image format is unsupported, etc.

◆ 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.

Iterates over a list of data packets to be passed from the encoder to the application. The different kinds of packets available are enumerated in vpx_codec_cx_pkt_kind.

VPX_CODEC_CX_FRAME_PKT packets should be passed to the application's muxer. Multiple compressed frames may be in the list. VPX_CODEC_STATS_PKT packets should be appended to a global buffer.

The application MUST silently ignore any packet kinds that it does not recognize or support.

The data buffers returned from this function are only guaranteed to be valid until the application makes another call to any vpx_codec_* function.

Parameters
[in]ctxPointer to this instance's context
[in,out]iterIterator storage, initialized to NULL
Returns
Returns a pointer to an output data packet (compressed frame data, two-pass statistics, etc.) or NULL to signal end-of-list.

◆ vpx_codec_get_global_headers()

vpx_fixed_buf_t * vpx_codec_get_global_headers ( vpx_codec_ctx_t ctx)

Get global stream headers.

Retrieves a stream level global header packet, if supported by the codec.

Parameters
[in]ctxPointer to this instance's context
Return values
NULLEncoder does not support global header
Non-NULLPointer to buffer containing global header packet

◆ vpx_codec_get_preview_frame()

const vpx_image_t * vpx_codec_get_preview_frame ( vpx_codec_ctx_t ctx)

Get Preview Frame.

Returns an image that can be used as a preview. Shows the image as it would exist at the decompressor. The application MUST NOT write into this image buffer.

Parameters
[in]ctxPointer to this instance's context
Returns
Returns a pointer to a preview image, or NULL if no image is available.

◆ 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.

Sets the buffer that the codec should output the compressed data into. This call effectively sets the buffer pointer returned in the next VPX_CODEC_CX_FRAME_PKT packet. Subsequent packets will be appended into this buffer. The buffer is preserved across frames, so applications must periodically call this function after flushing the accumulated compressed data to disk or to the network to reset the pointer to the buffer's head.

pad_before bytes will be skipped before writing the compressed data, and pad_after bytes will be appended to the packet. The size of the packet will be the sum of the size of the actual compressed data, pad_before, and pad_after. The padding bytes will be preserved (not overwritten).

Note that calling this function does not guarantee that the returned compressed data will be placed into the specified buffer. In the event that the encoded data will not fit into the buffer provided, the returned packet MAY point to an internal buffer, as it would if this call were never used. In this event, the output packet will NOT have any padding, and the application must free space and copy it to the proper place. This is of particular note in configurations that may output multiple packets for a single encoded frame (e.g., lagged encoding) or if the application does not reset the buffer periodically.

Applications may restore the default behavior of the codec providing the compressed data buffer by calling this function with a NULL buffer.

Applications MUSTNOT call this function during iteration of vpx_codec_get_cx_data().

Parameters
[in]ctxPointer to this instance's context
[in]bufBuffer to store compressed data into
[in]pad_beforeBytes to skip before writing compressed data
[in]pad_afterBytes to skip after writing compressed data
Return values
VPX_CODEC_OKThe buffer was set successfully.
VPX_CODEC_INVALID_PARAMA parameter was NULL, the image format is unsupported, etc.