AOMedia AV1 Codec
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
30 extern "C" {
31 #endif
32 
33 #include "aom/aom_codec.h"
34 
43 #define AOM_ENCODER_ABI_VERSION \
44  (9 + 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
76 typedef struct aom_fixed_buf {
77  void *buf;
78  size_t sz;
87 typedef uint32_t aom_codec_er_flags_t;
89 #define AOM_ERROR_RESILIENT_DEFAULT 0x1
90 
103 };
104 
110 typedef struct aom_codec_cx_pkt {
112  union {
113  struct {
114  void *buf;
115  size_t sz;
119  unsigned long duration;
127  } frame;
130  struct aom_psnr_pkt {
131  unsigned int samples[4];
132  uint64_t sse[4];
133  double psnr[4];
136  unsigned int samples_hbd[4];
139  uint64_t sse_hbd[4];
142  double psnr_hbd[4];
143  } psnr;
145  } data;
152 typedef struct aom_rational {
153  int num;
154  int den;
155 } aom_rational_t;
162 };
163 
170 };
171 
184 };
185 
187 typedef enum {
199  AOM_SUPERRES_AUTO,
201 
207 typedef struct cfg_options {
211  unsigned int init_by_cfg_file;
215  unsigned int super_block_size;
219  unsigned int max_partition_size;
223  unsigned int min_partition_size;
239  unsigned int disable_flip_idtx;
243  unsigned int disable_cdef;
247  unsigned int disable_lr;
251  unsigned int disable_obmc;
255  unsigned int disable_warp_motion;
259  unsigned int disable_global_motion;
263  unsigned int disable_dist_wtd_comp;
267  unsigned int disable_diff_wtd_comp;
275  unsigned int disable_masked_comp;
283  unsigned int disable_palette;
287  unsigned int disable_intrabc;
291  unsigned int disable_cfl;
295  unsigned int disable_smooth_intra;
299  unsigned int disable_filter_intra;
303  unsigned int disable_dual_filter;
315  unsigned int disable_tx_64x64;
331  unsigned int disable_paeth_intra;
335  unsigned int disable_trellis_quant;
339  unsigned int disable_ref_frame_mv;
343  unsigned int reduced_reference_set;
347  unsigned int reduced_tx_type_set;
348 } cfg_options_t;
349 
359 #define AOM_EFLAG_FORCE_KF (1 << 0)
360 
367 typedef struct aom_codec_enc_cfg {
368  /*
369  * generic settings (g)
370  */
371 
379  unsigned int g_usage;
380 
387  unsigned int g_threads;
388 
397  unsigned int g_profile;
406  unsigned int g_w;
407 
415  unsigned int g_h;
416 
420  unsigned int g_limit;
421 
428 
435 
443 
450  unsigned int g_input_bit_depth;
451 
465 
473 
480 
493  unsigned int g_lag_in_frames;
494 
495  /*
496  * rate control settings (rc)
497  */
498 
515  unsigned int rc_dropframe_thresh;
516 
524  unsigned int rc_resize_mode;
525 
532  unsigned int rc_resize_denominator;
533 
541 
549 
561 
571 
579  unsigned int rc_superres_qthresh;
580 
589 
599 
606 
613 
618  unsigned int rc_target_bitrate;
619 
620  /*
621  * quantizer settings
622  */
623 
632  unsigned int rc_min_quantizer;
633 
642  unsigned int rc_max_quantizer;
643 
644  /*
645  * bitrate tolerance
646  */
647 
655  unsigned int rc_undershoot_pct;
656 
664  unsigned int rc_overshoot_pct;
665 
666  /*
667  * decoder buffer model parameters
668  */
669 
679  unsigned int rc_buf_sz;
680 
688  unsigned int rc_buf_initial_sz;
689 
697  unsigned int rc_buf_optimal_sz;
698 
699  /*
700  * 2 pass rate control parameters
701  */
702 
711  unsigned int rc_2pass_vbr_bias_pct;
712 
719 
726 
727  /*
728  * keyframing settings (kf)
729  */
730 
735 
743 
751  unsigned int kf_min_dist;
752 
760  unsigned int kf_max_dist;
761 
767  unsigned int sframe_dist;
768 
782  unsigned int sframe_mode;
783 
790  unsigned int large_scale_tile;
791 
797  unsigned int monochrome;
798 
807 
814  unsigned int save_as_annexb;
815 
823 
831 
836 #define MAX_TILE_WIDTHS 64 // maximum tile width array length
837 
844 
849 #define MAX_TILE_HEIGHTS 64 // maximum tile height array length
850 
857 
870  unsigned int use_fixed_qp_offsets;
871 
876 #define FIXED_QP_OFFSET_COUNT 5
877 
893 
923  aom_codec_iface_t *iface,
924  const aom_codec_enc_cfg_t *cfg,
925  aom_codec_flags_t flags, int ver);
926 
931 #define aom_codec_enc_init(ctx, iface, cfg, flags) \
932  aom_codec_enc_init_ver(ctx, iface, cfg, flags, AOM_ENCODER_ABI_VERSION)
933 
956  aom_codec_enc_cfg_t *cfg,
957  unsigned int usage);
958 
974  const aom_codec_enc_cfg_t *cfg);
975 
1000 
1002 #define AOM_USAGE_GOOD_QUALITY (0)
1003 
1004 #define AOM_USAGE_REALTIME (1)
1005 
1006 #define AOM_USAGE_ALL_INTRA (2)
1007 
1036  aom_codec_pts_t pts, unsigned long duration,
1037  aom_enc_frame_flags_t flags);
1038 
1083  const aom_fixed_buf_t *buf,
1084  unsigned int pad_before,
1085  unsigned int pad_after);
1086 
1111  aom_codec_iter_t *iter);
1112 
1126 
1128 #ifdef __cplusplus
1129 }
1130 #endif
1131 #endif // AOM_AOM_AOM_ENCODER_H_
Definition: aom_encoder.h:182
void * buf
Definition: aom_encoder.h:77
unsigned int kf_max_dist
Keyframe maximum interval.
Definition: aom_encoder.h:760
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.
unsigned int min_partition_size
min partition size 8, 16, 32, 64, 128
Definition: aom_encoder.h:223
unsigned int rc_superres_qthresh
Frame super-resolution q threshold.
Definition: aom_encoder.h:579
Definition: aom_encoder.h:161
unsigned int g_w
Width of the frame.
Definition: aom_encoder.h:406
aom_superres_mode rc_superres_mode
Frame super-resolution scaling mode.
Definition: aom_encoder.h:548
unsigned int init_by_cfg_file
Indicate init by cfg file 0 or 1.
Definition: aom_encoder.h:211
uint64_t sse[4]
Definition: aom_encoder.h:132
unsigned int disable_smooth_inter_intra
disable smooth inter/intra
Definition: aom_encoder.h:319
unsigned int rc_target_bitrate
Target data rate.
Definition: aom_encoder.h:618
uint32_t aom_codec_er_flags_t
Error Resilient flags.
Definition: aom_encoder.h:87
int64_t aom_codec_pts_t
Time Stamp Type.
Definition: aom_codec.h:235
Definition: aom_encoder.h:189
unsigned int disable_paeth_intra
disable paeth intra
Definition: aom_encoder.h:331
unsigned int disable_cfl
disable chroma from luma
Definition: aom_encoder.h:291
unsigned int rc_superres_denominator
Frame super-resolution denominator.
Definition: aom_encoder.h:560
unsigned int rc_buf_optimal_sz
Decoder Buffer Optimal Size.
Definition: aom_encoder.h:697
Encoder configuration structure.
Definition: aom_encoder.h:367
unsigned int samples[4]
Definition: aom_encoder.h:131
enum aom_kf_mode kf_mode
Keyframe placement mode.
Definition: aom_encoder.h:742
unsigned int disable_intra_angle_delta
disable intra angle delta
Definition: aom_encoder.h:307
aom_fixed_buf_t rc_twopass_stats_in
Two-pass stats buffer.
Definition: aom_encoder.h:605
aom_rc_mode
Rate control mode.
Definition: aom_encoder.h:165
struct aom_codec_cx_pkt aom_codec_cx_pkt_t
Encoder output packet.
unsigned int disable_tx_64x64
disable 64x64 transform
Definition: aom_encoder.h:315
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.
aom_fixed_buf_t rc_firstpass_mb_stats_in
first pass mb stats buffer.
Definition: aom_encoder.h:612
Definition: aom_encoder.h:167
aom_codec_er_flags_t g_error_resilient
Enable error resilient modes.
Definition: aom_encoder.h:472
unsigned int disable_masked_comp
disable masked compound
Definition: aom_encoder.h:275
Rational Number.
Definition: aom_encoder.h:152
unsigned int super_block_size
Superblock size 0, 64 or 128.
Definition: aom_encoder.h:215
Codec context structure.
Definition: aom_codec.h:298
unsigned int rc_2pass_vbr_minsection_pct
Two-pass mode per-GOP minimum bitrate.
Definition: aom_encoder.h:718
unsigned int disable_1to4_partition_type
disable 1:4/4:1 partition type
Definition: aom_encoder.h:235
Definition: aom_encoder.h:193
const aom_image_t * aom_codec_get_preview_frame(aom_codec_ctx_t *ctx)
Get Preview Frame.
aom_codec_pts_t pts
time stamp to show frame (in timebase units)
Definition: aom_encoder.h:117
Image Descriptor.
Definition: aom_image.h:171
double psnr[4]
Definition: aom_encoder.h:133
unsigned int rc_undershoot_pct
Rate control adaptation undershoot control.
Definition: aom_encoder.h:655
aom_fixed_buf_t raw
Definition: aom_encoder.h:144
aom_kf_mode
Keyframe placement mode.
Definition: aom_encoder.h:180
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.
enum aom_rc_mode rc_end_usage
Rate control algorithm to use.
Definition: aom_encoder.h:598
Generic fixed size buffer structure.
Definition: aom_encoder.h:76
unsigned int g_profile
Bitstream profile to use.
Definition: aom_encoder.h:397
const aom_codec_cx_pkt_t * aom_codec_get_cx_data(aom_codec_ctx_t *ctx, aom_codec_iter_t *iter)
Encoded data iterator.
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.
unsigned int max_partition_size
max partition size 8, 16, 32, 64, 128
Definition: aom_encoder.h:219
unsigned int disable_diff_wtd_comp
disable diff weighted compound
Definition: aom_encoder.h:267
const struct aom_codec_iface aom_codec_iface_t
Codec interface structure.
Definition: aom_codec.h:254
unsigned int rc_buf_initial_sz
Decoder Buffer Initial Size.
Definition: aom_encoder.h:688
aom_codec_cx_pkt_kind
Encoder output packet variants.
Definition: aom_encoder.h:97
unsigned int samples_hbd[4]
Number of samples, total/y/u/v when input bit-depth < stream bit-depth.
Definition: aom_encoder.h:136
struct aom_rational g_timebase
Stream timebase units.
Definition: aom_encoder.h:464
unsigned int g_limit
Max number of frames to encode.
Definition: aom_encoder.h:420
Definition: aom_encoder.h:101
Definition: aom_encoder.h:99
Encoder Config Options.
Definition: aom_encoder.h:207
size_t sz
Definition: aom_encoder.h:115
unsigned int disable_ref_frame_mv
disable ref frame MV
Definition: aom_encoder.h:339
enum aom_codec_cx_pkt_kind kind
Definition: aom_encoder.h:111
Describes the codec algorithm interface to applications.
unsigned int disable_global_motion
disable global motion
Definition: aom_encoder.h:259
unsigned int rc_2pass_vbr_maxsection_pct
Two-pass mode per-GOP maximum bitrate.
Definition: aom_encoder.h:725
#define FIXED_QP_OFFSET_COUNT
Number of fixed QP offsets.
Definition: aom_encoder.h:876
unsigned int disable_inter_intra_wedge
disable inter/intra wedge comp
Definition: aom_encoder.h:327
unsigned int g_forced_max_frame_width
Forced maximum width of the frame.
Definition: aom_encoder.h:427
double psnr_hbd[4]
PSNR, total/y/u/v when input bit-depth < stream bit-depth.
Definition: aom_encoder.h:142
int fwd_kf_enabled
Option to enable forward reference key frame.
Definition: aom_encoder.h:734
unsigned long duration
duration to show frame (in timebase units)
Definition: aom_encoder.h:119
unsigned int disable_trellis_quant
disable trellis quantization
Definition: aom_encoder.h:335
unsigned int sframe_mode
sframe insertion mode
Definition: aom_encoder.h:782
unsigned int g_forced_max_frame_height
Forced maximum height of the frame.
Definition: aom_encoder.h:434
Definition: aom_encoder.h:159
struct aom_codec_cx_pkt::@1::@2 frame
unsigned int disable_rect_partition_type
disable rectangular partition type
Definition: aom_encoder.h:231
unsigned int disable_obmc
disable OBMC
Definition: aom_encoder.h:251
Definition: aom_encoder.h:98
unsigned int rc_2pass_vbr_bias_pct
Two-pass mode CBR/VBR bias.
Definition: aom_encoder.h:711
unsigned int rc_resize_mode
Mode for spatial resampling, if supported by the codec.
Definition: aom_encoder.h:524
unsigned int use_fixed_qp_offsets
Whether encoder should use fixed QP offsets.
Definition: aom_encoder.h:870
struct aom_fixed_buf aom_fixed_buf_t
Generic fixed size buffer structure.
unsigned int disable_warp_motion
disable Warped Motion
Definition: aom_encoder.h:255
void * buf
Definition: aom_encoder.h:114
#define MAX_TILE_WIDTHS
Maximum number of tile widths in tile widths array.
Definition: aom_encoder.h:836
unsigned int rc_max_quantizer
Maximum (Worst Quality) Quantizer.
Definition: aom_encoder.h:642
unsigned int disable_intra_edge_filter
disable intra edge filter
Definition: aom_encoder.h:311
#define MAX_TILE_HEIGHTS
Maximum number of tile heights in tile heights array.
Definition: aom_encoder.h:849
unsigned int rc_buf_sz
Decoder Buffer Size.
Definition: aom_encoder.h:679
Definition: aom_encoder.h:100
Definition: aom_encoder.h:168
unsigned int rc_overshoot_pct
Rate control adaptation overshoot control.
Definition: aom_encoder.h:664
uint64_t sse_hbd[4]
sum squared error, total/y/u/v when input bit-depth < stream bit-depth.
Definition: aom_encoder.h:139
Definition: aom_encoder.h:166
unsigned int large_scale_tile
Tile coding mode.
Definition: aom_encoder.h:790
aom_enc_pass
Multi-pass Encoding Pass.
Definition: aom_encoder.h:158
uint32_t aom_codec_frame_flags_t
Compressed Frame Flags.
Definition: aom_codec.h:270
unsigned int disable_filter_intra
disable filter intra
Definition: aom_encoder.h:299
unsigned int disable_dual_filter
disable dual filter
Definition: aom_encoder.h:303
aom_fixed_buf_t * aom_codec_get_global_headers(aom_codec_ctx_t *ctx)
Get global stream headers.
size_t vis_frame_size
size of the visible frame in this packet
Definition: aom_encoder.h:126
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.
unsigned int rc_resize_kf_denominator
Keyframe resize denominator.
Definition: aom_encoder.h:540
int tile_widths[64]
Array of specified tile widths.
Definition: aom_encoder.h:843
unsigned int kf_min_dist
Keyframe minimum interval.
Definition: aom_encoder.h:751
unsigned int full_still_picture_hdr
full_still_picture_hdr
Definition: aom_encoder.h:806
unsigned int monochrome
Monochrome mode.
Definition: aom_encoder.h:797
unsigned int disable_inter_inter_wedge
disable inter/inter wedge comp
Definition: aom_encoder.h:323
unsigned int disable_lr
disable Loop Restoration Filter
Definition: aom_encoder.h:247
const void * aom_codec_iter_t
Iterator.
Definition: aom_codec.h:288
unsigned int disable_palette
disable Palette
Definition: aom_encoder.h:283
unsigned int rc_resize_denominator
Frame resize denominator.
Definition: aom_encoder.h:532
Definition: aom_encoder.h:196
struct aom_rational aom_rational_t
Rational Number.
struct aom_codec_enc_cfg aom_codec_enc_cfg_t
Encoder configuration structure.
int fixed_qp_offsets[5]
Array of fixed QP offsets.
Definition: aom_encoder.h:892
long aom_codec_flags_t
Initialization-time Feature Enabling.
Definition: aom_codec.h:228
int partition_id
the partition id defines the decoding order of the partitions. Only applicable when "output partition...
Definition: aom_encoder.h:124
Definition: aom_encoder.h:102
enum aom_bit_depth aom_bit_depth_t
Bit depth for codecThis enumeration determines the bit depth of the codec.
unsigned int g_usage
Algorithm specific "usage" value.
Definition: aom_encoder.h:379
unsigned int g_input_bit_depth
Bit-depth of the input frames.
Definition: aom_encoder.h:450
cfg_options_t encoder_cfg
Options defined per config file.
Definition: aom_encoder.h:897
aom_codec_err_t
Algorithm return codes.
Definition: aom_codec.h:155
unsigned int reduced_reference_set
use reduced reference frame set
Definition: aom_encoder.h:343
aom_fixed_buf_t twopass_stats
Definition: aom_encoder.h:128
Definition: aom_encoder.h:181
unsigned int disable_flip_idtx
disable flip and identity transform type
Definition: aom_encoder.h:239
Definition: aom_encoder.h:169
int den
Definition: aom_encoder.h:154
unsigned int sframe_dist
sframe interval
Definition: aom_encoder.h:767
unsigned int disable_dist_wtd_comp
disable dist weighted compound
Definition: aom_encoder.h:263
aom_fixed_buf_t firstpass_mb_stats
Definition: aom_encoder.h:129
Encoder output packet.
Definition: aom_encoder.h:110
int tile_width_count
Number of explicit tile widths specified.
Definition: aom_encoder.h:822
unsigned int rc_min_quantizer
Minimum (Best Quality) Quantizer.
Definition: aom_encoder.h:632
unsigned int disable_cdef
disable CDEF filter
Definition: aom_encoder.h:243
unsigned int disable_intrabc
disable Intra Block Copy
Definition: aom_encoder.h:287
int num
Definition: aom_encoder.h:153
unsigned int disable_smooth_intra
disable intra smooth mode
Definition: aom_encoder.h:295
aom_superres_mode
Frame super-resolution mode.
Definition: aom_encoder.h:187
aom_codec_frame_flags_t flags
Definition: aom_encoder.h:120
unsigned int g_lag_in_frames
Allow lagged encoding.
Definition: aom_encoder.h:493
unsigned int disable_inter_intra_comp
disable inter/intra compound
Definition: aom_encoder.h:271
unsigned int rc_superres_kf_denominator
Keyframe super-resolution denominator.
Definition: aom_encoder.h:570
long aom_enc_frame_flags_t
Encoded Frame Flags.
Definition: aom_encoder.h:357
unsigned int g_threads
Maximum number of threads to use.
Definition: aom_encoder.h:387
Definition: aom_encoder.h:191
union aom_codec_cx_pkt::@1 data
int tile_height_count
Number of explicit tile heights specified.
Definition: aom_encoder.h:830
aom_bit_depth_t g_bit_depth
Bit-depth of the codec.
Definition: aom_encoder.h:442
unsigned int rc_superres_kf_qthresh
Keyframe super-resolution q threshold.
Definition: aom_encoder.h:588
struct cfg_options cfg_options_t
Encoder Config Options.
size_t sz
Definition: aom_encoder.h:78
unsigned int reduced_tx_type_set
use reduced transform type set
Definition: aom_encoder.h:347
unsigned int disable_one_sided_comp
disable one sided compound
Definition: aom_encoder.h:279
int tile_heights[64]
Array of specified tile heights.
Definition: aom_encoder.h:856
Definition: aom_encoder.h:160
unsigned int save_as_annexb
Bitstream syntax mode.
Definition: aom_encoder.h:814
unsigned int disable_ab_partition_type
disable AB Shape partition type
Definition: aom_encoder.h:227
Definition: aom_encoder.h:183
enum aom_enc_pass g_pass
Multi-pass Encoding Mode.
Definition: aom_encoder.h:479
unsigned int g_h
Height of the frame.
Definition: aom_encoder.h:415
unsigned int rc_dropframe_thresh
Temporal resampling configuration, if supported by the codec.
Definition: aom_encoder.h:515