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
30 extern "C" {
31 #endif
32 
33 #include "aom/aom_codec.h"
34 
43 #define AOM_ENCODER_ABI_VERSION \
44  (5 + 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;
86 typedef int64_t aom_codec_pts_t;
87 
95 typedef uint32_t aom_codec_frame_flags_t;
96 #define AOM_FRAME_IS_KEY 0x1
99 #define AOM_FRAME_IS_DROPPABLE 0x2
100 
101 #define AOM_FRAME_IS_INVISIBLE 0x4
102 
103 #define AOM_FRAME_IS_FRAGMENT 0x8
104 
105 #define AOM_FRAME_IS_INTRAONLY 0x10
106 
107 #define AOM_FRAME_IS_SWITCH 0x20
108 
109 #define AOM_FRAME_IS_ERROR_RESILIENT 0x40
110 
117 typedef uint32_t aom_codec_er_flags_t;
119 #define AOM_ERROR_RESILIENT_DEFAULT 0x1
120 
133 };
134 
140 typedef struct aom_codec_cx_pkt {
142  union {
143  struct {
144  void *buf;
145  size_t sz;
149  unsigned long duration;
157  } frame;
160  struct aom_psnr_pkt {
161  unsigned int samples[4];
162  uint64_t sse[4];
163  double psnr[4];
164  } psnr;
167  /* This packet size is fixed to allow codecs to extend this
168  * interface without having to manage storage for raw packets,
169  * i.e., if it's smaller than 128 bytes, you can store in the
170  * packet list directly.
171  */
172  char pad[128 - sizeof(enum aom_codec_cx_pkt_kind)];
173  } data;
180 typedef struct aom_rational {
181  int num;
182  int den;
183 } aom_rational_t;
190 };
191 
198 };
199 
212 };
213 
222 #define AOM_EFLAG_FORCE_KF (1 << 0)
230 typedef struct aom_codec_enc_cfg {
231  /*
232  * generic settings (g)
233  */
234 
242  unsigned int g_usage;
243 
250  unsigned int g_threads;
251 
260  unsigned int g_profile;
269  unsigned int g_w;
270 
278  unsigned int g_h;
279 
283  unsigned int g_limit;
284 
291 
298 
306 
313  unsigned int g_input_bit_depth;
314 
327  struct aom_rational g_timebase;
328 
336 
342  enum aom_enc_pass g_pass;
343 
356  unsigned int g_lag_in_frames;
357 
358  /*
359  * rate control settings (rc)
360  */
361 
378  unsigned int rc_dropframe_thresh;
379 
387  unsigned int rc_resize_mode;
388 
395  unsigned int rc_resize_denominator;
396 
404 
414  unsigned int rc_superres_mode;
415 
427 
437 
445  unsigned int rc_superres_qthresh;
446 
455 
464  enum aom_rc_mode rc_end_usage;
465 
472 
479 
484  unsigned int rc_target_bitrate;
485 
486  /*
487  * quantizer settings
488  */
489 
498  unsigned int rc_min_quantizer;
499 
508  unsigned int rc_max_quantizer;
509 
510  /*
511  * bitrate tolerance
512  */
513 
524  unsigned int rc_undershoot_pct;
525 
536  unsigned int rc_overshoot_pct;
537 
538  /*
539  * decoder buffer model parameters
540  */
541 
551  unsigned int rc_buf_sz;
552 
560  unsigned int rc_buf_initial_sz;
561 
569  unsigned int rc_buf_optimal_sz;
570 
571  /*
572  * 2 pass rate control parameters
573  */
574 
583  unsigned int rc_2pass_vbr_bias_pct;
584 
591 
598 
599  /*
600  * keyframing settings (kf)
601  */
602 
607 
614  enum aom_kf_mode kf_mode;
615 
623  unsigned int kf_min_dist;
624 
632  unsigned int kf_max_dist;
633 
639  unsigned int sframe_dist;
640 
654  unsigned int sframe_mode;
655 
662  unsigned int large_scale_tile;
663 
669  unsigned int monochrome;
670 
679 
686  unsigned int save_as_annexb;
687 
695 
703 
708 #define MAX_TILE_WIDTHS 64 // maximum tile width array length
709 
715  int tile_widths[MAX_TILE_WIDTHS];
716 
721 #define MAX_TILE_HEIGHTS 64 // maximum tile height array length
722 
728  int tile_heights[MAX_TILE_HEIGHTS];
729 
759  aom_codec_iface_t *iface,
760  const aom_codec_enc_cfg_t *cfg,
761  aom_codec_flags_t flags, int ver);
762 
767 #define aom_codec_enc_init(ctx, iface, cfg, flags) \
768  aom_codec_enc_init_ver(ctx, iface, cfg, flags, AOM_ENCODER_ABI_VERSION)
769 
792  int num_enc, aom_codec_flags_t flags, aom_rational_t *dsf, int ver);
793 
798 #define aom_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \
799  aom_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \
800  AOM_ENCODER_ABI_VERSION)
801 
822  aom_codec_enc_cfg_t *cfg,
823  unsigned int reserved);
824 
840  const aom_codec_enc_cfg_t *cfg);
841 
866 
892  aom_codec_pts_t pts, unsigned long duration,
893  aom_enc_frame_flags_t flags);
894 
939  const aom_fixed_buf_t *buf,
940  unsigned int pad_before,
941  unsigned int pad_after);
942 
967  aom_codec_iter_t *iter);
968 
982 
984 #ifdef __cplusplus
985 }
986 #endif
987 #endif // AOM_AOM_AOM_ENCODER_H_
Definition: aom_encoder.h:210
unsigned int rc_superres_mode
Frame super-resolution scaling mode.
Definition: aom_encoder.h:414
void * buf
Definition: aom_encoder.h:77
unsigned int kf_max_dist
Keyframe maximum interval.
Definition: aom_encoder.h:632
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 rc_superres_qthresh
Frame super-resolution q threshold.
Definition: aom_encoder.h:445
Definition: aom_encoder.h:189
unsigned int g_w
Width of the frame.
Definition: aom_encoder.h:269
uint64_t sse[4]
Definition: aom_encoder.h:162
unsigned int rc_target_bitrate
Target data rate.
Definition: aom_encoder.h:484
uint32_t aom_codec_er_flags_t
Error Resilient flags.
Definition: aom_encoder.h:117
unsigned int rc_superres_denominator
Frame super-resolution denominator.
Definition: aom_encoder.h:426
unsigned int rc_buf_optimal_sz
Decoder Buffer Optimal Size.
Definition: aom_encoder.h:569
Encoder configuration structure.
Definition: aom_encoder.h:230
unsigned int samples[4]
Definition: aom_encoder.h:161
aom_fixed_buf_t rc_twopass_stats_in
Two-pass stats buffer.
Definition: aom_encoder.h:471
aom_rc_mode
Rate control mode.
Definition: aom_encoder.h:193
struct aom_codec_cx_pkt aom_codec_cx_pkt_t
Encoder output packet.
int64_t aom_codec_pts_t
Time Stamp Type.
Definition: aom_encoder.h:86
aom_fixed_buf_t rc_firstpass_mb_stats_in
first pass mb stats buffer.
Definition: aom_encoder.h:478
Definition: aom_encoder.h:195
uint32_t aom_codec_frame_flags_t
Compressed Frame Flags.
Definition: aom_encoder.h:95
aom_codec_er_flags_t g_error_resilient
Enable error resilient modes.
Definition: aom_encoder.h:335
Rational Number.
Definition: aom_encoder.h:180
Codec context structure.
Definition: aom_codec.h:204
unsigned int rc_2pass_vbr_minsection_pct
Two-pass mode per-GOP minimum bitrate.
Definition: aom_encoder.h:590
aom_codec_err_t aom_codec_enc_config_default(aom_codec_iface_t *iface, aom_codec_enc_cfg_t *cfg, unsigned int reserved)
Get a default configuration.
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:147
Image Descriptor.
Definition: aom_image.h:141
double psnr[4]
Definition: aom_encoder.h:163
unsigned int rc_undershoot_pct
Rate control adaptation undershoot control.
Definition: aom_encoder.h:524
aom_fixed_buf_t raw
Definition: aom_encoder.h:165
aom_kf_mode
Keyframe placement mode.
Definition: aom_encoder.h:208
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.
Generic fixed size buffer structure.
Definition: aom_encoder.h:76
unsigned int g_profile
Bitstream profile to use.
Definition: aom_encoder.h:260
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.
const struct aom_codec_iface aom_codec_iface_t
Codec interface structure.
Definition: aom_codec.h:181
unsigned int rc_buf_initial_sz
Decoder Buffer Initial Size.
Definition: aom_encoder.h:560
aom_codec_cx_pkt_kind
Encoder output packet variants.
Definition: aom_encoder.h:127
unsigned int g_limit
Max number of frames to encode.
Definition: aom_encoder.h:283
Definition: aom_encoder.h:131
Definition: aom_encoder.h:129
Config Options.
Definition: aom_codec.h:533
size_t sz
Definition: aom_encoder.h:145
enum aom_codec_cx_pkt_kind kind
Definition: aom_encoder.h:141
Describes the codec algorithm interface to applications.
unsigned int rc_2pass_vbr_maxsection_pct
Two-pass mode per-GOP maximum bitrate.
Definition: aom_encoder.h:597
unsigned int g_forced_max_frame_width
Forced maximum width of the frame.
Definition: aom_encoder.h:290
int fwd_kf_enabled
Option to enable forward reference key frame.
Definition: aom_encoder.h:606
unsigned long duration
duration to show frame (in timebase units)
Definition: aom_encoder.h:149
unsigned int sframe_mode
sframe insertion mode
Definition: aom_encoder.h:654
unsigned int g_forced_max_frame_height
Forced maximum height of the frame.
Definition: aom_encoder.h:297
Definition: aom_encoder.h:187
struct aom_codec_cx_pkt::@1::@2 frame
Definition: aom_encoder.h:128
unsigned int rc_2pass_vbr_bias_pct
Two-pass mode CBR/VBR bias.
Definition: aom_encoder.h:583
unsigned int rc_resize_mode
Mode for spatial resampling, if supported by the codec.
Definition: aom_encoder.h:387
struct aom_fixed_buf aom_fixed_buf_t
Generic fixed size buffer structure.
void * buf
Definition: aom_encoder.h:144
#define MAX_TILE_WIDTHS
Maximum number of tile widths in tile widths array.
Definition: aom_encoder.h:708
unsigned int rc_max_quantizer
Maximum (Worst Quality) Quantizer.
Definition: aom_encoder.h:508
#define MAX_TILE_HEIGHTS
Maximum number of tile heights in tile heights array.
Definition: aom_encoder.h:721
unsigned int rc_buf_sz
Decoder Buffer Size.
Definition: aom_encoder.h:551
Definition: aom_encoder.h:130
Definition: aom_encoder.h:196
unsigned int rc_overshoot_pct
Rate control adaptation overshoot control.
Definition: aom_encoder.h:536
Definition: aom_encoder.h:194
unsigned int large_scale_tile
Tile coding mode.
Definition: aom_encoder.h:662
aom_enc_pass
Multi-pass Encoding Pass.
Definition: aom_encoder.h:186
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:156
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:403
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.
unsigned int kf_min_dist
Keyframe minimum interval.
Definition: aom_encoder.h:623
unsigned int full_still_picture_hdr
full_still_picture_hdr
Definition: aom_encoder.h:678
unsigned int monochrome
Monochrome mode.
Definition: aom_encoder.h:669
const void * aom_codec_iter_t
Iterator.
Definition: aom_codec.h:194
unsigned int rc_resize_denominator
Frame resize denominator.
Definition: aom_encoder.h:395
struct aom_rational aom_rational_t
Rational Number.
struct aom_codec_enc_cfg aom_codec_enc_cfg_t
Encoder configuration structure.
long aom_codec_flags_t
Initialization-time Feature Enabling.
Definition: aom_codec.h:174
cfg_options_t cfg
Options defined per config file.
Definition: aom_encoder.h:733
int partition_id
the partition id defines the decoding order of the partitions. Only applicable when "output partition...
Definition: aom_encoder.h:154
Definition: aom_encoder.h:132
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:242
unsigned int g_input_bit_depth
Bit-depth of the input frames.
Definition: aom_encoder.h:313
aom_codec_err_t
Algorithm return codes.
Definition: aom_codec.h:101
aom_fixed_buf_t twopass_stats
Definition: aom_encoder.h:158
Definition: aom_encoder.h:209
Definition: aom_encoder.h:197
int den
Definition: aom_encoder.h:182
char pad[128 - sizeof(enum aom_codec_cx_pkt_kind)]
Definition: aom_encoder.h:172
unsigned int sframe_dist
sframe interval
Definition: aom_encoder.h:639
aom_fixed_buf_t firstpass_mb_stats
Definition: aom_encoder.h:159
Encoder output packet.
Definition: aom_encoder.h:140
int tile_width_count
Number of explicit tile widths specified.
Definition: aom_encoder.h:694
unsigned int rc_min_quantizer
Minimum (Best Quality) Quantizer.
Definition: aom_encoder.h:498
int num
Definition: aom_encoder.h:181
aom_codec_frame_flags_t flags
Definition: aom_encoder.h:150
unsigned int g_lag_in_frames
Allow lagged encoding.
Definition: aom_encoder.h:356
unsigned int rc_superres_kf_denominator
Keyframe super-resolution denominator.
Definition: aom_encoder.h:436
long aom_enc_frame_flags_t
Encoded Frame Flags.
Definition: aom_encoder.h:221
unsigned int g_threads
Maximum number of threads to use.
Definition: aom_encoder.h:250
union aom_codec_cx_pkt::@1 data
int tile_height_count
Number of explicit tile heights specified.
Definition: aom_encoder.h:702
aom_bit_depth_t g_bit_depth
Bit-depth of the codec.
Definition: aom_encoder.h:305
unsigned int rc_superres_kf_qthresh
Keyframe super-resolution q threshold.
Definition: aom_encoder.h:454
size_t sz
Definition: aom_encoder.h:78
Definition: aom_encoder.h:188
unsigned int save_as_annexb
Bitstream syntax mode.
Definition: aom_encoder.h:686
Definition: aom_encoder.h:211
unsigned int g_h
Height of the frame.
Definition: aom_encoder.h:278
unsigned int rc_dropframe_thresh
Temporal resampling configuration, if supported by the codec.
Definition: aom_encoder.h:378