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 (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
76typedef struct aom_fixed_buf {
77 void *buf;
78 size_t sz;
86typedef int64_t aom_codec_pts_t;
87
95typedef uint32_t aom_codec_frame_flags_t;
96#define AOM_FRAME_IS_KEY 0x1
99#define AOM_FRAME_IS_DROPPABLE 0x2
101#define AOM_FRAME_IS_INTRAONLY 0x10
103#define AOM_FRAME_IS_SWITCH 0x20
105#define AOM_FRAME_IS_ERROR_RESILIENT 0x40
107#define AOM_FRAME_IS_DELAYED_RANDOM_ACCESS_POINT 0x80
108
115typedef uint32_t aom_codec_er_flags_t;
117#define AOM_ERROR_RESILIENT_DEFAULT 0x1
118
132
138typedef struct aom_codec_cx_pkt {
140 union {
141 struct {
142 void *buf;
143 size_t sz;
147 unsigned long duration;
158 struct aom_psnr_pkt {
159 unsigned int samples[4];
160 uint64_t sse[4];
161 double psnr[4];
165 /* This packet size is fixed to allow codecs to extend this
166 * interface without having to manage storage for raw packets,
167 * i.e., if it's smaller than 128 bytes, you can store in the
168 * packet list directly.
169 */
170 char pad[128 - sizeof(enum aom_codec_cx_pkt_kind)];
178typedef struct aom_rational {
179 int num;
180 int den;
189
196};
197
209 AOM_KF_DISABLED = 0
211
220#define AOM_EFLAG_FORCE_KF (1 << 0)
228typedef struct aom_codec_enc_cfg {
229 /*
230 * generic settings (g)
231 */
232
240 unsigned int g_usage;
241
248 unsigned int g_threads;
249
258 unsigned int g_profile;
267 unsigned int g_w;
268
276 unsigned int g_h;
277
281 unsigned int g_limit;
282
289
296
304
311 unsigned int g_input_bit_depth;
312
326
334
341
354 unsigned int g_lag_in_frames;
355
356 /*
357 * rate control settings (rc)
358 */
359
377
385 unsigned int rc_resize_mode;
386
394
402
411 unsigned int rc_superres_mode;
412
424
434
443
452
462
469
476
481 unsigned int rc_target_bitrate;
482
483 /*
484 * quantizer settings
485 */
486
495 unsigned int rc_min_quantizer;
496
505 unsigned int rc_max_quantizer;
506
507 /*
508 * bitrate tolerance
509 */
510
521 unsigned int rc_undershoot_pct;
522
533 unsigned int rc_overshoot_pct;
534
535 /*
536 * decoder buffer model parameters
537 */
538
548 unsigned int rc_buf_sz;
549
557 unsigned int rc_buf_initial_sz;
558
566 unsigned int rc_buf_optimal_sz;
567
568 /*
569 * 2 pass rate control parameters
570 */
571
581
588
595
596 /*
597 * keyframing settings (kf)
598 */
599
604
612
620 unsigned int kf_min_dist;
621
629 unsigned int kf_max_dist;
630
636 unsigned int sframe_dist;
637
651 unsigned int sframe_mode;
652
659 unsigned int large_scale_tile;
660
666 unsigned int monochrome;
667
676
683 unsigned int save_as_annexb;
684
692
700
705#define MAX_TILE_WIDTHS 64 // maximum tile width array length
706
713
718#define MAX_TILE_HEIGHTS 64 // maximum tile height array length
719
726
756 aom_codec_iface_t *iface,
757 const aom_codec_enc_cfg_t *cfg,
758 aom_codec_flags_t flags, int ver);
759
764#define aom_codec_enc_init(ctx, iface, cfg, flags) \
765 aom_codec_enc_init_ver(ctx, iface, cfg, flags, AOM_ENCODER_ABI_VERSION)
766
789 int num_enc, aom_codec_flags_t flags, aom_rational_t *dsf, int ver);
790
795#define aom_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \
796 aom_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \
797 AOM_ENCODER_ABI_VERSION)
798
820 unsigned int reserved);
821
837 const aom_codec_enc_cfg_t *cfg);
838
863
865#define AOM_USAGE_GOOD_QUALITY (0)
867#define AOM_USAGE_REALTIME (1)
868
894 aom_codec_pts_t pts, unsigned long duration,
896
941 const aom_fixed_buf_t *buf,
942 unsigned int pad_before,
943 unsigned int pad_after);
944
969 aom_codec_iter_t *iter);
970
984
986#ifdef __cplusplus
987}
988#endif
989#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:705
#define MAX_TILE_HEIGHTS
Maximum number of tile heights in tile heights array.
Definition: aom_encoder.h:718
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:181
aom_codec_err_t
Algorithm return codes.
Definition: aom_codec.h:101
const void * aom_codec_iter_t
Iterator.
Definition: aom_codec.h:194
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:115
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:191
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:184
int64_t aom_codec_pts_t
Time Stamp Type.
Definition: aom_encoder.h:86
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 reserved)
Get a default configuration.
aom_kf_mode
Keyframe placement mode.
Definition: aom_encoder.h:206
long aom_enc_frame_flags_t
Encoded Frame Flags.
Definition: aom_encoder.h:219
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:95
aom_codec_cx_pkt_kind
Encoder output packet variants.
Definition: aom_encoder.h:125
@ AOM_CBR
Definition: aom_encoder.h:193
@ AOM_CQ
Definition: aom_encoder.h:194
@ AOM_VBR
Definition: aom_encoder.h:192
@ AOM_Q
Definition: aom_encoder.h:195
@ AOM_RC_ONE_PASS
Definition: aom_encoder.h:185
@ AOM_RC_LAST_PASS
Definition: aom_encoder.h:187
@ AOM_RC_FIRST_PASS
Definition: aom_encoder.h:186
@ AOM_KF_FIXED
Definition: aom_encoder.h:207
@ AOM_KF_AUTO
Definition: aom_encoder.h:208
@ AOM_KF_DISABLED
Definition: aom_encoder.h:209
@ AOM_CODEC_PSNR_PKT
Definition: aom_encoder.h:129
@ AOM_CODEC_CUSTOM_PKT
Definition: aom_encoder.h:130
@ AOM_CODEC_CX_FRAME_PKT
Definition: aom_encoder.h:126
@ AOM_CODEC_STATS_PKT
Definition: aom_encoder.h:127
@ AOM_CODEC_FPMB_STATS_PKT
Definition: aom_encoder.h:128
Codec context structure.
Definition: aom_codec.h:204
Encoder output packet.
Definition: aom_encoder.h:138
unsigned long duration
duration to show frame (in timebase units)
Definition: aom_encoder.h:147
size_t sz
Definition: aom_encoder.h:143
enum aom_codec_cx_pkt_kind kind
Definition: aom_encoder.h:139
double psnr[4]
Definition: aom_encoder.h:161
aom_fixed_buf_t twopass_stats
Definition: aom_encoder.h:156
aom_fixed_buf_t raw
Definition: aom_encoder.h:163
union aom_codec_cx_pkt::@1 data
aom_codec_pts_t pts
time stamp to show frame (in timebase units)
Definition: aom_encoder.h:145
struct aom_codec_cx_pkt::@1::@2 frame
aom_fixed_buf_t firstpass_mb_stats
Definition: aom_encoder.h:157
size_t vis_frame_size
size of the visible frame in this packet
Definition: aom_encoder.h:154
char pad[128 - sizeof(enum aom_codec_cx_pkt_kind)]
Definition: aom_encoder.h:170
aom_codec_frame_flags_t flags
Definition: aom_encoder.h:148
int partition_id
the partition id defines the decoding order of the partitions. Only applicable when "output partition...
Definition: aom_encoder.h:152
unsigned int samples[4]
Definition: aom_encoder.h:159
void * buf
Definition: aom_encoder.h:142
uint64_t sse[4]
Definition: aom_encoder.h:160
Encoder configuration structure.
Definition: aom_encoder.h:228
unsigned int g_input_bit_depth
Bit-depth of the input frames.
Definition: aom_encoder.h:311
unsigned int g_forced_max_frame_height
Forced maximum height of the frame.
Definition: aom_encoder.h:295
unsigned int rc_dropframe_thresh
Temporal resampling configuration, if supported by the codec.
Definition: aom_encoder.h:376
unsigned int rc_resize_denominator
Frame resize denominator.
Definition: aom_encoder.h:393
struct aom_rational g_timebase
Stream timebase units.
Definition: aom_encoder.h:325
int tile_width_count
Number of explicit tile widths specified.
Definition: aom_encoder.h:691
unsigned int g_usage
Algorithm specific "usage" value.
Definition: aom_encoder.h:240
unsigned int rc_buf_sz
Decoder Buffer Size.
Definition: aom_encoder.h:548
unsigned int full_still_picture_hdr
full_still_picture_hdr
Definition: aom_encoder.h:675
unsigned int g_h
Height of the frame.
Definition: aom_encoder.h:276
enum aom_kf_mode kf_mode
Keyframe placement mode.
Definition: aom_encoder.h:611
aom_fixed_buf_t rc_firstpass_mb_stats_in
first pass mb stats buffer.
Definition: aom_encoder.h:475
enum aom_rc_mode rc_end_usage
Rate control algorithm to use.
Definition: aom_encoder.h:461
unsigned int rc_superres_kf_denominator
Keyframe super-resolution denominator.
Definition: aom_encoder.h:433
unsigned int g_threads
Maximum number of threads to use.
Definition: aom_encoder.h:248
unsigned int rc_2pass_vbr_maxsection_pct
Two-pass mode per-GOP maximum bitrate.
Definition: aom_encoder.h:594
unsigned int rc_resize_kf_denominator
Keyframe resize denominator.
Definition: aom_encoder.h:401
unsigned int kf_min_dist
Keyframe minimum interval.
Definition: aom_encoder.h:620
unsigned int g_lag_in_frames
Allow lagged encoding.
Definition: aom_encoder.h:354
unsigned int rc_2pass_vbr_minsection_pct
Two-pass mode per-GOP minimum bitrate.
Definition: aom_encoder.h:587
unsigned int rc_2pass_vbr_bias_pct
Two-pass mode CBR/VBR bias.
Definition: aom_encoder.h:580
unsigned int rc_superres_qthresh
Frame super-resolution q threshold.
Definition: aom_encoder.h:442
unsigned int rc_buf_initial_sz
Decoder Buffer Initial Size.
Definition: aom_encoder.h:557
unsigned int rc_superres_mode
Frame super-resolution scaling mode.
Definition: aom_encoder.h:411
unsigned int g_profile
Bitstream profile to use.
Definition: aom_encoder.h:258
unsigned int g_limit
Max number of frames to encode.
Definition: aom_encoder.h:281
unsigned int monochrome
Monochrome mode.
Definition: aom_encoder.h:666
aom_bit_depth_t g_bit_depth
Bit-depth of the codec.
Definition: aom_encoder.h:303
int tile_heights[64]
Array of specified tile heights.
Definition: aom_encoder.h:725
unsigned int g_w
Width of the frame.
Definition: aom_encoder.h:267
unsigned int g_forced_max_frame_width
Forced maximum width of the frame.
Definition: aom_encoder.h:288
unsigned int rc_undershoot_pct
Rate control adaptation undershoot control.
Definition: aom_encoder.h:521
unsigned int kf_max_dist
Keyframe maximum interval.
Definition: aom_encoder.h:629
aom_codec_er_flags_t g_error_resilient
Enable error resilient modes.
Definition: aom_encoder.h:333
unsigned int rc_max_quantizer
Maximum (Worst Quality) Quantizer.
Definition: aom_encoder.h:505
cfg_options_t cfg
Options defined per config file.
Definition: aom_encoder.h:730
unsigned int rc_superres_denominator
Frame super-resolution denominator.
Definition: aom_encoder.h:423
unsigned int rc_buf_optimal_sz
Decoder Buffer Optimal Size.
Definition: aom_encoder.h:566
unsigned int rc_min_quantizer
Minimum (Best Quality) Quantizer.
Definition: aom_encoder.h:495
unsigned int sframe_dist
sframe interval
Definition: aom_encoder.h:636
unsigned int sframe_mode
sframe insertion mode
Definition: aom_encoder.h:651
enum aom_enc_pass g_pass
Multi-pass Encoding Mode.
Definition: aom_encoder.h:340
int fwd_kf_enabled
Option to enable forward reference key frame.
Definition: aom_encoder.h:603
int tile_widths[64]
Array of specified tile widths.
Definition: aom_encoder.h:712
unsigned int rc_target_bitrate
Target data rate.
Definition: aom_encoder.h:481
unsigned int rc_resize_mode
Mode for spatial resampling, if supported by the codec.
Definition: aom_encoder.h:385
unsigned int rc_overshoot_pct
Rate control adaptation overshoot control.
Definition: aom_encoder.h:533
aom_fixed_buf_t rc_twopass_stats_in
Two-pass stats buffer.
Definition: aom_encoder.h:468
unsigned int save_as_annexb
Bitstream syntax mode.
Definition: aom_encoder.h:683
unsigned int rc_superres_kf_qthresh
Keyframe super-resolution q threshold.
Definition: aom_encoder.h:451
int tile_height_count
Number of explicit tile heights specified.
Definition: aom_encoder.h:699
unsigned int large_scale_tile
Tile coding mode.
Definition: aom_encoder.h:659
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:141
Rational Number.
Definition: aom_encoder.h:178
int num
Definition: aom_encoder.h:179
int den
Definition: aom_encoder.h:180
Config Options.
Definition: aom_codec.h:533