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_ENCODER_H_
12 #define 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
62 #define AOM_CODEC_CAP_OUTPUT_PARTITION 0x20000
63 
66 #define AOM_CODEC_CAP_HIGHBITDEPTH 0x40000
67 
75 #define AOM_CODEC_USE_PSNR 0x10000
77 #define AOM_CODEC_USE_OUTPUT_PARTITION 0x20000
78 #define AOM_CODEC_USE_HIGHBITDEPTH 0x40000
84 typedef struct aom_fixed_buf {
85  void *buf;
86  size_t sz;
94 typedef int64_t aom_codec_pts_t;
95 
103 typedef uint32_t aom_codec_frame_flags_t;
104 #define AOM_FRAME_IS_KEY 0x1
107 #define AOM_FRAME_IS_DROPPABLE 0x2
108 
109 #define AOM_FRAME_IS_INVISIBLE 0x4
110 
111 #define AOM_FRAME_IS_FRAGMENT 0x8
112 
119 typedef uint32_t aom_codec_er_flags_t;
121 #define AOM_ERROR_RESILIENT_DEFAULT 0x1
122 
126 #define AOM_ERROR_RESILIENT_PARTITIONS 0x2
127 
140 };
141 
147 typedef struct aom_codec_cx_pkt {
149  union {
150  struct {
151  void *buf;
152  size_t sz;
156  unsigned long duration;
164  } frame;
167  struct aom_psnr_pkt {
168  unsigned int samples[4];
169  uint64_t sse[4];
170  double psnr[4];
171  } psnr;
174  /* This packet size is fixed to allow codecs to extend this
175  * interface without having to manage storage for raw packets,
176  * i.e., if it's smaller than 128 bytes, you can store in the
177  * packet list directly.
178  */
179  char pad[128 - sizeof(enum aom_codec_cx_pkt_kind)];
180  } data;
187 typedef struct aom_rational {
188  int num;
189  int den;
190 } aom_rational_t;
197 };
198 
205 };
206 
219 };
220 
229 #define AOM_EFLAG_FORCE_KF (1 << 0)
237 typedef struct aom_codec_enc_cfg {
238  /*
239  * generic settings (g)
240  */
241 
249  unsigned int g_usage;
250 
257  unsigned int g_threads;
258 
267  unsigned int g_profile;
276  unsigned int g_w;
277 
285  unsigned int g_h;
286 
290  unsigned int g_limit;
291 
298 
305 
313 
320  unsigned int g_input_bit_depth;
321 
334  struct aom_rational g_timebase;
335 
343 
350 
363  unsigned int g_lag_in_frames;
364 
365  /*
366  * rate control settings (rc)
367  */
368 
385  unsigned int rc_dropframe_thresh;
386 
394  unsigned int rc_resize_mode;
395 
402  unsigned int rc_resize_denominator;
403 
411 
421  unsigned int rc_superres_mode;
422 
434 
444 
452  unsigned int rc_superres_qthresh;
453 
462 
472 
479 
486 
491  unsigned int rc_target_bitrate;
492 
493  /*
494  * quantizer settings
495  */
496 
505  unsigned int rc_min_quantizer;
506 
515  unsigned int rc_max_quantizer;
516 
517  /*
518  * bitrate tolerance
519  */
520 
531  unsigned int rc_undershoot_pct;
532 
543  unsigned int rc_overshoot_pct;
544 
545  /*
546  * decoder buffer model parameters
547  */
548 
558  unsigned int rc_buf_sz;
559 
567  unsigned int rc_buf_initial_sz;
568 
576  unsigned int rc_buf_optimal_sz;
577 
578  /*
579  * 2 pass rate control parameters
580  */
581 
590  unsigned int rc_2pass_vbr_bias_pct;
591 
598 
605 
606  /*
607  * keyframing settings (kf)
608  */
609 
614 
622 
630  unsigned int kf_min_dist;
631 
639  unsigned int kf_max_dist;
640 
646  unsigned int sframe_dist;
647 
661  unsigned int sframe_mode;
662 
669  unsigned int large_scale_tile;
670 
676  unsigned int monochrome;
677 
686 
693  unsigned int save_as_annexb;
694 
702 
710 
715 #define MAX_TILE_WIDTHS 64 // maximum tile width array length
716 
722  int tile_widths[MAX_TILE_WIDTHS];
723 
728 #define MAX_TILE_HEIGHTS 64 // maximum tile height array length
729 
735  int tile_heights[MAX_TILE_HEIGHTS];
736 
766  aom_codec_iface_t *iface,
767  const aom_codec_enc_cfg_t *cfg,
768  aom_codec_flags_t flags, int ver);
769 
774 #define aom_codec_enc_init(ctx, iface, cfg, flags) \
775  aom_codec_enc_init_ver(ctx, iface, cfg, flags, AOM_ENCODER_ABI_VERSION)
776 
799  int num_enc, aom_codec_flags_t flags, aom_rational_t *dsf, int ver);
800 
805 #define aom_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \
806  aom_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \
807  AOM_ENCODER_ABI_VERSION)
808 
829  aom_codec_enc_cfg_t *cfg,
830  unsigned int reserved);
831 
847  const aom_codec_enc_cfg_t *cfg);
848 
861 
887  aom_codec_pts_t pts, unsigned long duration,
888  aom_enc_frame_flags_t flags);
889 
934  const aom_fixed_buf_t *buf,
935  unsigned int pad_before,
936  unsigned int pad_after);
937 
962  aom_codec_iter_t *iter);
963 
977 
979 #ifdef __cplusplus
980 }
981 #endif
982 #endif // AOM_AOM_ENCODER_H_