AOMedia Codec SDK
aom_encoder.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
11#ifndef AOM_AOM_AOM_ENCODER_H_
12#define AOM_AOM_AOM_ENCODER_H_
13
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include "aom/aom_codec.h"
34
43#define AOM_ENCODER_ABI_VERSION \
44 (7 + AOM_CODEC_ABI_VERSION)
55#define AOM_CODEC_CAP_PSNR 0x10000
59#define AOM_CODEC_CAP_HIGHBITDEPTH 0x40000
60
68#define AOM_CODEC_USE_PSNR 0x10000
70#define AOM_CODEC_USE_HIGHBITDEPTH 0x40000
76typedef struct aom_fixed_buf {
77 void *buf;
78 size_t sz;
88typedef uint32_t aom_codec_frame_flags_t;
89#define AOM_FRAME_IS_KEY 0x1
92#define AOM_FRAME_IS_DROPPABLE 0x2
94#define AOM_FRAME_IS_INTRAONLY 0x10
96#define AOM_FRAME_IS_SWITCH 0x20
98#define AOM_FRAME_IS_ERROR_RESILIENT 0x40
100#define AOM_FRAME_IS_DELAYED_RANDOM_ACCESS_POINT 0x80
101
108typedef uint32_t aom_codec_er_flags_t;
110#define AOM_ERROR_RESILIENT_DEFAULT 0x1
111
125
131typedef struct aom_codec_cx_pkt {
133 union {
134 struct {
135 void *buf;
136 size_t sz;
140 unsigned long duration;
151 struct aom_psnr_pkt {
152 unsigned int samples[4];
153 uint64_t sse[4];
154 double psnr[4];
158 /* This packet size is fixed to allow codecs to extend this
159 * interface without having to manage storage for raw packets,
160 * i.e., if it's smaller than 128 bytes, you can store in the
161 * packet list directly.
162 */
163 char pad[128 - sizeof(enum aom_codec_cx_pkt_kind)];
171typedef struct aom_rational {
172 int num;
173 int den;
182
189};
190
202 AOM_KF_DISABLED = 0
204
206typedef enum {
218 AOM_SUPERRES_AUTO,
220
226typedef struct cfg_options {
230 unsigned int init_by_cfg_file;
234 unsigned int super_block_size;
238 unsigned int max_partition_size;
242 unsigned int min_partition_size;
258 unsigned int disable_flip_idtx;
262 unsigned int disable_cdef;
266 unsigned int disable_lr;
270 unsigned int disable_obmc;
302 unsigned int disable_palette;
306 unsigned int disable_intrabc;
310 unsigned int disable_cfl;
334 unsigned int disable_tx_64x64;
368
377#define AOM_EFLAG_FORCE_KF (1 << 0)
385typedef struct aom_codec_enc_cfg {
386 /*
387 * generic settings (g)
388 */
389
397 unsigned int g_usage;
398
405 unsigned int g_threads;
406
415 unsigned int g_profile;
424 unsigned int g_w;
425
433 unsigned int g_h;
434
438 unsigned int g_limit;
439
446
453
461
468 unsigned int g_input_bit_depth;
469
483
491
498
511 unsigned int g_lag_in_frames;
512
513 /*
514 * rate control settings (rc)
515 */
516
534
542 unsigned int rc_resize_mode;
543
551
559
567
579
589
598
607
617
624
631
636 unsigned int rc_target_bitrate;
637
638 /*
639 * quantizer settings
640 */
641
650 unsigned int rc_min_quantizer;
651
660 unsigned int rc_max_quantizer;
661
662 /*
663 * bitrate tolerance
664 */
665
676 unsigned int rc_undershoot_pct;
677
688 unsigned int rc_overshoot_pct;
689
690 /*
691 * decoder buffer model parameters
692 */
693
703 unsigned int rc_buf_sz;
704
712 unsigned int rc_buf_initial_sz;
713
721 unsigned int rc_buf_optimal_sz;
722
723 /*
724 * 2 pass rate control parameters
725 */
726
736
743
750
751 /*
752 * keyframing settings (kf)
753 */
754
759
767
775 unsigned int kf_min_dist;
776
784 unsigned int kf_max_dist;
785
791 unsigned int sframe_dist;
792
806 unsigned int sframe_mode;
807
814 unsigned int large_scale_tile;
815
821 unsigned int monochrome;
822
831
838 unsigned int save_as_annexb;
839
847
855
860#define MAX_TILE_WIDTHS 64 // maximum tile width array length
861
868
873#define MAX_TILE_HEIGHTS 64 // maximum tile height array length
874
881
895
900#define FIXED_QP_OFFSET_COUNT 5
901
917
947 aom_codec_iface_t *iface,
948 const aom_codec_enc_cfg_t *cfg,
949 aom_codec_flags_t flags, int ver);
950
955#define aom_codec_enc_init(ctx, iface, cfg, flags) \
956 aom_codec_enc_init_ver(ctx, iface, cfg, flags, AOM_ENCODER_ABI_VERSION)
957
980 int num_enc, aom_codec_flags_t flags, aom_rational_t *dsf, int ver);
981
986#define aom_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \
987 aom_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \
988 AOM_ENCODER_ABI_VERSION)
989
1013 unsigned int usage);
1014
1030 const aom_codec_enc_cfg_t *cfg);
1031
1056
1058#define AOM_USAGE_GOOD_QUALITY (0)
1060#define AOM_USAGE_REALTIME (1)
1061
1087 aom_codec_pts_t pts, unsigned long duration,
1088 aom_enc_frame_flags_t flags);
1089
1134 const aom_fixed_buf_t *buf,
1135 unsigned int pad_before,
1136 unsigned int pad_after);
1137
1162 aom_codec_iter_t *iter);
1163
1177
1179#ifdef __cplusplus
1180}
1181#endif
1182#endif // AOM_AOM_AOM_ENCODER_H_
Describes the codec algorithm interface to applications.
#define MAX_TILE_WIDTHS
Maximum number of tile widths in tile widths array.
Definition: aom_encoder.h:860
#define MAX_TILE_HEIGHTS
Maximum number of tile heights in tile heights array.
Definition: aom_encoder.h:873
#define FIXED_QP_OFFSET_COUNT
Number of fixed QP offsets.
Definition: aom_encoder.h:900
enum aom_bit_depth aom_bit_depth_t
Bit depth for codecThis enumeration determines the bit depth of the codec.
long aom_codec_flags_t
Initialization-time Feature Enabling.
Definition: aom_codec.h:174
const struct aom_codec_iface aom_codec_iface_t
Codec interface structure.
Definition: aom_codec.h:196
int64_t aom_codec_pts_t
Time Stamp Type.
Definition: aom_codec.h:181
aom_codec_err_t
Algorithm return codes.
Definition: aom_codec.h:101
const void * aom_codec_iter_t
Iterator.
Definition: aom_codec.h:209
aom_superres_mode
Frame super-resolution mode.
Definition: aom_encoder.h:206
aom_codec_err_t aom_codec_enc_init_ver(aom_codec_ctx_t *ctx, aom_codec_iface_t *iface, const aom_codec_enc_cfg_t *cfg, aom_codec_flags_t flags, int ver)
Initialize an encoder instance.
const aom_codec_cx_pkt_t * aom_codec_get_cx_data(aom_codec_ctx_t *ctx, aom_codec_iter_t *iter)
Encoded data iterator.
struct aom_codec_cx_pkt aom_codec_cx_pkt_t
Encoder output packet.
uint32_t aom_codec_er_flags_t
Error Resilient flags.
Definition: aom_encoder.h:108
aom_codec_err_t aom_codec_set_cx_data_buf(aom_codec_ctx_t *ctx, const aom_fixed_buf_t *buf, unsigned int pad_before, unsigned int pad_after)
Set compressed data output buffer.
aom_codec_err_t aom_codec_encode(aom_codec_ctx_t *ctx, const aom_image_t *img, aom_codec_pts_t pts, unsigned long duration, aom_enc_frame_flags_t flags)
Encode a frame.
aom_rc_mode
Rate control mode.
Definition: aom_encoder.h:184
const aom_image_t * aom_codec_get_preview_frame(aom_codec_ctx_t *ctx)
Get Preview Frame.
aom_enc_pass
Multi-pass Encoding Pass.
Definition: aom_encoder.h:177
struct aom_rational aom_rational_t
Rational Number.
struct aom_fixed_buf aom_fixed_buf_t
Generic fixed size buffer structure.
aom_codec_err_t aom_codec_enc_config_default(aom_codec_iface_t *iface, aom_codec_enc_cfg_t *cfg, unsigned int usage)
Get the default configuration for a usage.
struct cfg_options cfg_options_t
Encoder Config Options.
aom_kf_mode
Keyframe placement mode.
Definition: aom_encoder.h:199
long aom_enc_frame_flags_t
Encoded Frame Flags.
Definition: aom_encoder.h:376
aom_fixed_buf_t * aom_codec_get_global_headers(aom_codec_ctx_t *ctx)
Get global stream headers.
aom_codec_err_t aom_codec_enc_init_multi_ver(aom_codec_ctx_t *ctx, aom_codec_iface_t *iface, aom_codec_enc_cfg_t *cfg, int num_enc, aom_codec_flags_t flags, aom_rational_t *dsf, int ver)
Initialize multi-encoder instance.
struct aom_codec_enc_cfg aom_codec_enc_cfg_t
Encoder configuration structure.
aom_codec_err_t aom_codec_enc_config_set(aom_codec_ctx_t *ctx, const aom_codec_enc_cfg_t *cfg)
Set or change configuration.
uint32_t aom_codec_frame_flags_t
Compressed Frame Flags.
Definition: aom_encoder.h:88
aom_codec_cx_pkt_kind
Encoder output packet variants.
Definition: aom_encoder.h:118
@ AOM_SUPERRES_RANDOM
Definition: aom_encoder.h:212
@ AOM_SUPERRES_QTHRESH
Definition: aom_encoder.h:215
@ AOM_SUPERRES_NONE
Definition: aom_encoder.h:208
@ AOM_SUPERRES_FIXED
Definition: aom_encoder.h:210
@ AOM_CBR
Definition: aom_encoder.h:186
@ AOM_CQ
Definition: aom_encoder.h:187
@ AOM_VBR
Definition: aom_encoder.h:185
@ AOM_Q
Definition: aom_encoder.h:188
@ AOM_RC_ONE_PASS
Definition: aom_encoder.h:178
@ AOM_RC_LAST_PASS
Definition: aom_encoder.h:180
@ AOM_RC_FIRST_PASS
Definition: aom_encoder.h:179
@ AOM_KF_FIXED
Definition: aom_encoder.h:200
@ AOM_KF_AUTO
Definition: aom_encoder.h:201
@ AOM_KF_DISABLED
Definition: aom_encoder.h:202
@ AOM_CODEC_PSNR_PKT
Definition: aom_encoder.h:122
@ AOM_CODEC_CUSTOM_PKT
Definition: aom_encoder.h:123
@ AOM_CODEC_CX_FRAME_PKT
Definition: aom_encoder.h:119
@ AOM_CODEC_STATS_PKT
Definition: aom_encoder.h:120
@ AOM_CODEC_FPMB_STATS_PKT
Definition: aom_encoder.h:121
Codec context structure.
Definition: aom_codec.h:219
Encoder output packet.
Definition: aom_encoder.h:131
unsigned long duration
duration to show frame (in timebase units)
Definition: aom_encoder.h:140
size_t sz
Definition: aom_encoder.h:136
enum aom_codec_cx_pkt_kind kind
Definition: aom_encoder.h:132
double psnr[4]
Definition: aom_encoder.h:154
aom_fixed_buf_t twopass_stats
Definition: aom_encoder.h:149
aom_fixed_buf_t raw
Definition: aom_encoder.h:156
union aom_codec_cx_pkt::@1 data
aom_codec_pts_t pts
time stamp to show frame (in timebase units)
Definition: aom_encoder.h:138
struct aom_codec_cx_pkt::@1::@2 frame
aom_fixed_buf_t firstpass_mb_stats
Definition: aom_encoder.h:150
size_t vis_frame_size
size of the visible frame in this packet
Definition: aom_encoder.h:147
char pad[128 - sizeof(enum aom_codec_cx_pkt_kind)]
Definition: aom_encoder.h:163
aom_codec_frame_flags_t flags
Definition: aom_encoder.h:141
int partition_id
the partition id defines the decoding order of the partitions. Only applicable when "output partition...
Definition: aom_encoder.h:145
unsigned int samples[4]
Definition: aom_encoder.h:152
void * buf
Definition: aom_encoder.h:135
uint64_t sse[4]
Definition: aom_encoder.h:153
Encoder configuration structure.
Definition: aom_encoder.h:385
unsigned int g_input_bit_depth
Bit-depth of the input frames.
Definition: aom_encoder.h:468
unsigned int g_forced_max_frame_height
Forced maximum height of the frame.
Definition: aom_encoder.h:452
unsigned int rc_dropframe_thresh
Temporal resampling configuration, if supported by the codec.
Definition: aom_encoder.h:533
unsigned int rc_resize_denominator
Frame resize denominator.
Definition: aom_encoder.h:550
struct aom_rational g_timebase
Stream timebase units.
Definition: aom_encoder.h:482
int tile_width_count
Number of explicit tile widths specified.
Definition: aom_encoder.h:846
unsigned int g_usage
Algorithm specific "usage" value.
Definition: aom_encoder.h:397
unsigned int rc_buf_sz
Decoder Buffer Size.
Definition: aom_encoder.h:703
unsigned int full_still_picture_hdr
full_still_picture_hdr
Definition: aom_encoder.h:830
unsigned int g_h
Height of the frame.
Definition: aom_encoder.h:433
aom_superres_mode rc_superres_mode
Frame super-resolution scaling mode.
Definition: aom_encoder.h:566
int fixed_qp_offsets[5]
Array of fixed QP offsets.
Definition: aom_encoder.h:916
enum aom_kf_mode kf_mode
Keyframe placement mode.
Definition: aom_encoder.h:766
aom_fixed_buf_t rc_firstpass_mb_stats_in
first pass mb stats buffer.
Definition: aom_encoder.h:630
enum aom_rc_mode rc_end_usage
Rate control algorithm to use.
Definition: aom_encoder.h:616
unsigned int rc_superres_kf_denominator
Keyframe super-resolution denominator.
Definition: aom_encoder.h:588
unsigned int g_threads
Maximum number of threads to use.
Definition: aom_encoder.h:405
unsigned int rc_2pass_vbr_maxsection_pct
Two-pass mode per-GOP maximum bitrate.
Definition: aom_encoder.h:749
unsigned int rc_resize_kf_denominator
Keyframe resize denominator.
Definition: aom_encoder.h:558
unsigned int kf_min_dist
Keyframe minimum interval.
Definition: aom_encoder.h:775
unsigned int g_lag_in_frames
Allow lagged encoding.
Definition: aom_encoder.h:511
unsigned int use_fixed_qp_offsets
Whether encoder should use fixed QP offsets.
Definition: aom_encoder.h:894
unsigned int rc_2pass_vbr_minsection_pct
Two-pass mode per-GOP minimum bitrate.
Definition: aom_encoder.h:742
unsigned int rc_2pass_vbr_bias_pct
Two-pass mode CBR/VBR bias.
Definition: aom_encoder.h:735
unsigned int rc_superres_qthresh
Frame super-resolution q threshold.
Definition: aom_encoder.h:597
unsigned int rc_buf_initial_sz
Decoder Buffer Initial Size.
Definition: aom_encoder.h:712
unsigned int g_profile
Bitstream profile to use.
Definition: aom_encoder.h:415
unsigned int g_limit
Max number of frames to encode.
Definition: aom_encoder.h:438
unsigned int monochrome
Monochrome mode.
Definition: aom_encoder.h:821
aom_bit_depth_t g_bit_depth
Bit-depth of the codec.
Definition: aom_encoder.h:460
int tile_heights[64]
Array of specified tile heights.
Definition: aom_encoder.h:880
unsigned int g_w
Width of the frame.
Definition: aom_encoder.h:424
unsigned int g_forced_max_frame_width
Forced maximum width of the frame.
Definition: aom_encoder.h:445
unsigned int rc_undershoot_pct
Rate control adaptation undershoot control.
Definition: aom_encoder.h:676
unsigned int kf_max_dist
Keyframe maximum interval.
Definition: aom_encoder.h:784
aom_codec_er_flags_t g_error_resilient
Enable error resilient modes.
Definition: aom_encoder.h:490
unsigned int rc_max_quantizer
Maximum (Worst Quality) Quantizer.
Definition: aom_encoder.h:660
unsigned int rc_superres_denominator
Frame super-resolution denominator.
Definition: aom_encoder.h:578
unsigned int rc_buf_optimal_sz
Decoder Buffer Optimal Size.
Definition: aom_encoder.h:721
unsigned int rc_min_quantizer
Minimum (Best Quality) Quantizer.
Definition: aom_encoder.h:650
unsigned int sframe_dist
sframe interval
Definition: aom_encoder.h:791
unsigned int sframe_mode
sframe insertion mode
Definition: aom_encoder.h:806
enum aom_enc_pass g_pass
Multi-pass Encoding Mode.
Definition: aom_encoder.h:497
int fwd_kf_enabled
Option to enable forward reference key frame.
Definition: aom_encoder.h:758
int tile_widths[64]
Array of specified tile widths.
Definition: aom_encoder.h:867
unsigned int rc_target_bitrate
Target data rate.
Definition: aom_encoder.h:636
unsigned int rc_resize_mode
Mode for spatial resampling, if supported by the codec.
Definition: aom_encoder.h:542
unsigned int rc_overshoot_pct
Rate control adaptation overshoot control.
Definition: aom_encoder.h:688
aom_fixed_buf_t rc_twopass_stats_in
Two-pass stats buffer.
Definition: aom_encoder.h:623
unsigned int save_as_annexb
Bitstream syntax mode.
Definition: aom_encoder.h:838
unsigned int rc_superres_kf_qthresh
Keyframe super-resolution q threshold.
Definition: aom_encoder.h:606
cfg_options_t encoder_cfg
Options defined per config file.
Definition: aom_encoder.h:921
int tile_height_count
Number of explicit tile heights specified.
Definition: aom_encoder.h:854
unsigned int large_scale_tile
Tile coding mode.
Definition: aom_encoder.h:814
Generic fixed size buffer structure.
Definition: aom_encoder.h:76
size_t sz
Definition: aom_encoder.h:78
void * buf
Definition: aom_encoder.h:77
Image Descriptor.
Definition: aom_image.h:171
Rational Number.
Definition: aom_encoder.h:171
int num
Definition: aom_encoder.h:172
int den
Definition: aom_encoder.h:173
Encoder Config Options.
Definition: aom_encoder.h:226
unsigned int disable_tx_64x64
disable 64x64 transform
Definition: aom_encoder.h:334
unsigned int reduced_reference_set
use reduced reference frame set
Definition: aom_encoder.h:362
unsigned int disable_palette
disable Palette
Definition: aom_encoder.h:302
unsigned int disable_inter_intra_comp
disable inter/intra compound
Definition: aom_encoder.h:290
unsigned int disable_ab_partition_type
disable AB Shape partition type
Definition: aom_encoder.h:246
unsigned int disable_warp_motion
disable Warped Motion
Definition: aom_encoder.h:274
unsigned int disable_lr
disable Loop Restoration Filter
Definition: aom_encoder.h:266
unsigned int disable_1to4_partition_type
disable 1:4/4:1 partition type
Definition: aom_encoder.h:254
unsigned int disable_intra_angle_delta
disable intra angle delta
Definition: aom_encoder.h:326
unsigned int min_partition_size
min partition size 8, 16, 32, 64, 128
Definition: aom_encoder.h:242
unsigned int disable_smooth_intra
disable intra smooth mode
Definition: aom_encoder.h:314
unsigned int disable_ref_frame_mv
disable ref frame MV
Definition: aom_encoder.h:358
unsigned int reduced_tx_type_set
use reduced transform type set
Definition: aom_encoder.h:366
unsigned int disable_one_sided_comp
disable one sided compound
Definition: aom_encoder.h:298
unsigned int max_partition_size
max partition size 8, 16, 32, 64, 128
Definition: aom_encoder.h:238
unsigned int disable_trellis_quant
disable trellis quantization
Definition: aom_encoder.h:354
unsigned int disable_inter_intra_wedge
disable inter/intra wedge comp
Definition: aom_encoder.h:346
unsigned int disable_rect_partition_type
disable rectangular partition type
Definition: aom_encoder.h:250
unsigned int disable_smooth_inter_intra
disable smooth inter/intra
Definition: aom_encoder.h:338
unsigned int disable_intrabc
disable Intra Block Copy
Definition: aom_encoder.h:306
unsigned int disable_obmc
disable OBMC
Definition: aom_encoder.h:270
unsigned int init_by_cfg_file
Indicate init by cfg file 0 or 1.
Definition: aom_encoder.h:230
unsigned int disable_flip_idtx
disable flip and identity transform type
Definition: aom_encoder.h:258
unsigned int disable_intra_edge_filter
disable intra edge filter
Definition: aom_encoder.h:330
unsigned int disable_dual_filter
disable dual filter
Definition: aom_encoder.h:322
unsigned int disable_global_motion
disable global motion
Definition: aom_encoder.h:278
unsigned int disable_cfl
disable chroma from luma
Definition: aom_encoder.h:310
unsigned int disable_diff_wtd_comp
disable diff weighted compound
Definition: aom_encoder.h:286
unsigned int disable_inter_inter_wedge
disable inter/inter wedge comp
Definition: aom_encoder.h:342
unsigned int super_block_size
Superblock size 0, 64 or 128.
Definition: aom_encoder.h:234
unsigned int disable_filter_intra
disable filter intra
Definition: aom_encoder.h:318
unsigned int disable_masked_comp
disable masked compound
Definition: aom_encoder.h:294
unsigned int disable_cdef
disable CDEF filter
Definition: aom_encoder.h:262
unsigned int disable_paeth_intra
disable paeth intra
Definition: aom_encoder.h:350
unsigned int disable_dist_wtd_comp
disable dist weighted compound
Definition: aom_encoder.h:282