AOMedia AV1 Codec
lightfield_encoder
1 /*
2  * Copyright (c) 2017, 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 
12 // Lightfield Encoder
13 // ==================
14 //
15 // This is an example of a simple lightfield encoder. It builds upon the
16 // twopass_encoder.c example. It takes an input file in YV12 format,
17 // treating it as a planar lightfield instead of a video. The img_width
18 // and img_height arguments are the dimensions of the lightfield images,
19 // while the lf_width and lf_height arguments are the number of
20 // lightfield images in each dimension. The lf_blocksize determines the
21 // number of reference images used for MCP. For example, 5 means that there
22 // is a reference image for every 5x5 lightfield image block. All images
23 // within a block will use the center image in that block as the reference
24 // image for MCP.
25 // Run "make test" to download lightfield test data: vase10x10.yuv.
26 // Run lightfield encoder to encode whole lightfield:
27 // examples/lightfield_encoder 1024 1024 vase10x10.yuv vase10x10.ivf 10 10 5
28 
29 // Note: In bitstream.c and encoder.c, define EXT_TILE_DEBUG as 1 will print
30 // out the uncompressed header and the frame contexts, which can be used to
31 // test the bit exactness of the headers and the frame contexts for large scale
32 // tile coded frames.
33 
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <string.h>
37 
38 #include "aom/aom_encoder.h"
39 #include "aom/aomcx.h"
40 #include "aom_scale/yv12config.h"
41 #include "av1/common/enums.h"
42 #include "common/tools_common.h"
43 #include "common/video_writer.h"
44 
45 static const char *exec_name;
46 
47 void usage_exit(void) {
48  fprintf(stderr,
49  "Usage: %s <img_width> <img_height> <infile> <outfile> "
50  "<lf_width> <lf_height> <lf_blocksize>\n",
51  exec_name);
52  exit(EXIT_FAILURE);
53 }
54 
55 static int img_size_bytes(aom_image_t *img) {
56  int image_size_bytes = 0;
57  int plane;
58  for (plane = 0; plane < 3; ++plane) {
59  const int w = aom_img_plane_width(img, plane) *
60  ((img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 2 : 1);
61  const int h = aom_img_plane_height(img, plane);
62  image_size_bytes += w * h;
63  }
64  return image_size_bytes;
65 }
66 
67 static int get_frame_stats(aom_codec_ctx_t *ctx, const aom_image_t *img,
68  aom_codec_pts_t pts, unsigned int duration,
70  aom_fixed_buf_t *stats) {
71  int got_pkts = 0;
72  aom_codec_iter_t iter = NULL;
73  const aom_codec_cx_pkt_t *pkt = NULL;
74  const aom_codec_err_t res = aom_codec_encode(ctx, img, pts, duration, flags);
75  if (res != AOM_CODEC_OK) die_codec(ctx, "Failed to get frame stats.");
76 
77  while ((pkt = aom_codec_get_cx_data(ctx, &iter)) != NULL) {
78  got_pkts = 1;
79 
80  if (pkt->kind == AOM_CODEC_STATS_PKT) {
81  const uint8_t *const pkt_buf = pkt->data.twopass_stats.buf;
82  const size_t pkt_size = pkt->data.twopass_stats.sz;
83  stats->buf = realloc(stats->buf, stats->sz + pkt_size);
84  if (!stats->buf) die("Failed to allocate frame stats buffer.");
85  memcpy((uint8_t *)stats->buf + stats->sz, pkt_buf, pkt_size);
86  stats->sz += pkt_size;
87  }
88  }
89 
90  return got_pkts;
91 }
92 
93 static int encode_frame(aom_codec_ctx_t *ctx, const aom_image_t *img,
94  aom_codec_pts_t pts, unsigned int duration,
95  aom_enc_frame_flags_t flags, AvxVideoWriter *writer) {
96  int got_pkts = 0;
97  aom_codec_iter_t iter = NULL;
98  const aom_codec_cx_pkt_t *pkt = NULL;
99  const aom_codec_err_t res = aom_codec_encode(ctx, img, pts, duration, flags);
100  if (res != AOM_CODEC_OK) die_codec(ctx, "Failed to encode frame.");
101 
102  while ((pkt = aom_codec_get_cx_data(ctx, &iter)) != NULL) {
103  got_pkts = 1;
104  if (pkt->kind == AOM_CODEC_CX_FRAME_PKT) {
105  const int keyframe = (pkt->data.frame.flags & AOM_FRAME_IS_KEY) != 0;
106 
107  if (!aom_video_writer_write_frame(writer, pkt->data.frame.buf,
108  pkt->data.frame.sz,
109  pkt->data.frame.pts))
110  die_codec(ctx, "Failed to write compressed frame.");
111  printf(keyframe ? "K" : ".");
112  fflush(stdout);
113  }
114  }
115 
116  return got_pkts;
117 }
118 
119 static void get_raw_image(aom_image_t **frame_to_encode, aom_image_t *raw,
120  aom_image_t *raw_shift) {
121  if (FORCE_HIGHBITDEPTH_DECODING) {
122  // Need to allocate larger buffer to use hbd internal.
123  int input_shift = 0;
124  aom_img_upshift(raw_shift, raw, input_shift);
125  *frame_to_encode = raw_shift;
126  } else {
127  *frame_to_encode = raw;
128  }
129 }
130 
131 static aom_fixed_buf_t pass0(aom_image_t *raw, FILE *infile,
132  aom_codec_iface_t *encoder,
133  const aom_codec_enc_cfg_t *cfg, int lf_width,
134  int lf_height, int lf_blocksize, int flags,
135  aom_image_t *raw_shift) {
136  aom_codec_ctx_t codec;
137  int frame_count = 0;
138  int image_size_bytes = img_size_bytes(raw);
139  int u_blocks, v_blocks;
140  int bu, bv;
141  aom_fixed_buf_t stats = { NULL, 0 };
142  aom_image_t *frame_to_encode;
143 
144  if (aom_codec_enc_init(&codec, encoder, cfg, flags))
145  die("Failed to initialize encoder");
147  die_codec(&codec, "Failed to turn off auto altref");
149  die_codec(&codec, "Failed to set frame parallel decoding");
150 
151  // How many reference images we need to encode.
152  u_blocks = (lf_width + lf_blocksize - 1) / lf_blocksize;
153  v_blocks = (lf_height + lf_blocksize - 1) / lf_blocksize;
154 
155  printf("\n First pass: ");
156 
157  for (bv = 0; bv < v_blocks; ++bv) {
158  for (bu = 0; bu < u_blocks; ++bu) {
159  const int block_u_min = bu * lf_blocksize;
160  const int block_v_min = bv * lf_blocksize;
161  int block_u_end = (bu + 1) * lf_blocksize;
162  int block_v_end = (bv + 1) * lf_blocksize;
163  int u_block_size, v_block_size;
164  int block_ref_u, block_ref_v;
165 
166  block_u_end = block_u_end < lf_width ? block_u_end : lf_width;
167  block_v_end = block_v_end < lf_height ? block_v_end : lf_height;
168  u_block_size = block_u_end - block_u_min;
169  v_block_size = block_v_end - block_v_min;
170  block_ref_u = block_u_min + u_block_size / 2;
171  block_ref_v = block_v_min + v_block_size / 2;
172 
173  printf("A%d, ", (block_ref_u + block_ref_v * lf_width));
174  fseek(infile, (block_ref_u + block_ref_v * lf_width) * image_size_bytes,
175  SEEK_SET);
176  aom_img_read(raw, infile);
177  get_raw_image(&frame_to_encode, raw, raw_shift);
178 
179  // Reference frames can be encoded encoded without tiles.
180  ++frame_count;
181  get_frame_stats(&codec, frame_to_encode, frame_count, 1,
187  &stats);
188  }
189  }
190 
192  die_codec(&codec, "Failed to set frame parallel decoding");
193 
194  for (bv = 0; bv < v_blocks; ++bv) {
195  for (bu = 0; bu < u_blocks; ++bu) {
196  const int block_u_min = bu * lf_blocksize;
197  const int block_v_min = bv * lf_blocksize;
198  int block_u_end = (bu + 1) * lf_blocksize;
199  int block_v_end = (bv + 1) * lf_blocksize;
200  int u, v;
201  block_u_end = block_u_end < lf_width ? block_u_end : lf_width;
202  block_v_end = block_v_end < lf_height ? block_v_end : lf_height;
203  for (v = block_v_min; v < block_v_end; ++v) {
204  for (u = block_u_min; u < block_u_end; ++u) {
205  printf("C%d, ", (u + v * lf_width));
206  fseek(infile, (u + v * lf_width) * image_size_bytes, SEEK_SET);
207  aom_img_read(raw, infile);
208  get_raw_image(&frame_to_encode, raw, raw_shift);
209 
210  ++frame_count;
211  get_frame_stats(&codec, frame_to_encode, frame_count, 1,
217  &stats);
218  }
219  }
220  }
221  }
222  // Flush encoder.
223  // No ARF, this should not be needed.
224  while (get_frame_stats(&codec, NULL, frame_count, 1, 0, &stats)) {
225  }
226 
227  if (aom_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec.");
228 
229  printf("\nFirst pass complete. Processed %d frames.\n", frame_count);
230 
231  return stats;
232 }
233 
234 static void pass1(aom_image_t *raw, FILE *infile, const char *outfile_name,
235  aom_codec_iface_t *encoder, aom_codec_enc_cfg_t *cfg,
236  int lf_width, int lf_height, int lf_blocksize, int flags,
237  aom_image_t *raw_shift) {
238  AvxVideoInfo info = { get_fourcc_by_aom_encoder(encoder),
239  cfg->g_w,
240  cfg->g_h,
241  { cfg->g_timebase.num, cfg->g_timebase.den },
242  0 };
243  AvxVideoWriter *writer = NULL;
244  aom_codec_ctx_t codec;
245  int frame_count = 0;
246  int image_size_bytes = img_size_bytes(raw);
247  int bu, bv;
248  int u_blocks, v_blocks;
249  aom_image_t *frame_to_encode;
250  aom_image_t reference_images[MAX_EXTERNAL_REFERENCES];
251  int reference_image_num = 0;
252  int i;
253 
254  writer = aom_video_writer_open(outfile_name, kContainerIVF, &info);
255  if (!writer) die("Failed to open %s for writing", outfile_name);
256 
257  if (aom_codec_enc_init(&codec, encoder, cfg, flags))
258  die("Failed to initialize encoder");
260  die_codec(&codec, "Failed to turn off auto altref");
262  die_codec(&codec, "Failed to set frame parallel decoding");
264  die_codec(&codec, "Failed to enable encoder ext_tile debug");
265  if (aom_codec_control(&codec, AOME_SET_CPUUSED, 3))
266  die_codec(&codec, "Failed to set cpu-used");
267 
268  // Note: The superblock is a sequence parameter and has to be the same for 1
269  // sequence. In lightfield application, must choose the superblock size(either
270  // 64x64 or 128x128) before the encoding starts. Otherwise, the default is
271  // AOM_SUPERBLOCK_SIZE_DYNAMIC, and the superblock size will be set to 64x64
272  // internally.
275  die_codec(&codec, "Failed to set SB size");
276 
277  u_blocks = (lf_width + lf_blocksize - 1) / lf_blocksize;
278  v_blocks = (lf_height + lf_blocksize - 1) / lf_blocksize;
279 
280  reference_image_num = u_blocks * v_blocks;
281  // Set the max gf group length so the references are guaranteed to be in
282  // a different gf group than any of the regular frames. This avoids using
283  // both vbr and constant quality mode in a single group. The number of
284  // references now cannot surpass 17 because of the enforced MAX_GF_INTERVAL of
285  // 16. If it is necessary to exceed this reference frame limit, one will have
286  // to do some additional handling to ensure references are in separate gf
287  // groups from the regular frames.
289  reference_image_num - 1))
290  die_codec(&codec, "Failed to set max gf interval");
292  if (FORCE_HIGHBITDEPTH_DECODING) ref_fmt |= AOM_IMG_FMT_HIGHBITDEPTH;
293  // Allocate memory with the border so that it can be used as a reference.
294  int border_in_pixels =
295  (codec.config.enc->rc_resize_mode || codec.config.enc->rc_superres_mode)
296  ? AOM_BORDER_IN_PIXELS
297  : AOM_ENC_NO_SCALE_BORDER;
298  for (i = 0; i < reference_image_num; i++) {
299  if (!aom_img_alloc_with_border(&reference_images[i], ref_fmt, cfg->g_w,
300  cfg->g_h, 32, 8, border_in_pixels)) {
301  die("Failed to allocate image.");
302  }
303  }
304 
305  printf("\n Second pass: ");
306 
307  // Encode reference images first.
308  printf("Encoding Reference Images\n");
309  for (bv = 0; bv < v_blocks; ++bv) {
310  for (bu = 0; bu < u_blocks; ++bu) {
311  const int block_u_min = bu * lf_blocksize;
312  const int block_v_min = bv * lf_blocksize;
313  int block_u_end = (bu + 1) * lf_blocksize;
314  int block_v_end = (bv + 1) * lf_blocksize;
315  int u_block_size, v_block_size;
316  int block_ref_u, block_ref_v;
317 
318  block_u_end = block_u_end < lf_width ? block_u_end : lf_width;
319  block_v_end = block_v_end < lf_height ? block_v_end : lf_height;
320  u_block_size = block_u_end - block_u_min;
321  v_block_size = block_v_end - block_v_min;
322  block_ref_u = block_u_min + u_block_size / 2;
323  block_ref_v = block_v_min + v_block_size / 2;
324 
325  printf("A%d, ", (block_ref_u + block_ref_v * lf_width));
326  fseek(infile, (block_ref_u + block_ref_v * lf_width) * image_size_bytes,
327  SEEK_SET);
328  aom_img_read(raw, infile);
329 
330  get_raw_image(&frame_to_encode, raw, raw_shift);
331 
332  // Reference frames may be encoded without tiles.
333  ++frame_count;
334  printf("Encoding reference image %d of %d\n", bv * u_blocks + bu,
335  u_blocks * v_blocks);
336  encode_frame(&codec, frame_to_encode, frame_count, 1,
342  writer);
343 
345  &reference_images[frame_count - 1]))
346  die_codec(&codec, "Failed to copy decoder reference frame");
347  }
348  }
349 
350  cfg->large_scale_tile = 1;
351  // Fixed q encoding for camera frames.
352  cfg->rc_end_usage = AOM_Q;
353  if (aom_codec_enc_config_set(&codec, cfg))
354  die_codec(&codec, "Failed to configure encoder");
355 
356  // The fixed q value used in encoding.
357  if (aom_codec_control(&codec, AOME_SET_CQ_LEVEL, 36))
358  die_codec(&codec, "Failed to set cq level");
360  die_codec(&codec, "Failed to set frame parallel decoding");
362  die_codec(&codec, "Failed to turn on single tile decoding");
363  // Set tile_columns and tile_rows to MAX values, which guarantees the tile
364  // size of 64 x 64 pixels(i.e. 1 SB) for <= 4k resolution.
366  die_codec(&codec, "Failed to set tile width");
367  if (aom_codec_control(&codec, AV1E_SET_TILE_ROWS, 6))
368  die_codec(&codec, "Failed to set tile height");
369 
370  for (bv = 0; bv < v_blocks; ++bv) {
371  for (bu = 0; bu < u_blocks; ++bu) {
372  const int block_u_min = bu * lf_blocksize;
373  const int block_v_min = bv * lf_blocksize;
374  int block_u_end = (bu + 1) * lf_blocksize;
375  int block_v_end = (bv + 1) * lf_blocksize;
376  int u, v;
377  block_u_end = block_u_end < lf_width ? block_u_end : lf_width;
378  block_v_end = block_v_end < lf_height ? block_v_end : lf_height;
379  for (v = block_v_min; v < block_v_end; ++v) {
380  for (u = block_u_min; u < block_u_end; ++u) {
381  av1_ref_frame_t ref;
382  ref.idx = 0;
383  ref.use_external_ref = 1;
384  ref.img = reference_images[bv * u_blocks + bu];
385  if (aom_codec_control(&codec, AV1_SET_REFERENCE, &ref))
386  die_codec(&codec, "Failed to set reference frame");
387 
388  printf("C%d, ", (u + v * lf_width));
389  fseek(infile, (u + v * lf_width) * image_size_bytes, SEEK_SET);
390  aom_img_read(raw, infile);
391  get_raw_image(&frame_to_encode, raw, raw_shift);
392 
393  ++frame_count;
394  printf("Encoding image %d of %d\n",
395  frame_count - (u_blocks * v_blocks), lf_width * lf_height);
396  encode_frame(&codec, frame_to_encode, frame_count, 1,
402  writer);
403  }
404  }
405  }
406  }
407 
408  // Flush encoder.
409  // No ARF, this should not be needed.
410  while (encode_frame(&codec, NULL, -1, 1, 0, writer)) {
411  }
412 
413  for (i = 0; i < reference_image_num; i++) aom_img_free(&reference_images[i]);
414 
415  if (aom_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec.");
416 
417  // Modify large_scale_file fourcc.
418  if (cfg->large_scale_tile == 1)
419  aom_video_writer_set_fourcc(writer, LST_FOURCC);
420  aom_video_writer_close(writer);
421 
422  printf("\nSecond pass complete. Processed %d frames.\n", frame_count);
423 }
424 
425 int main(int argc, char **argv) {
426  FILE *infile = NULL;
427  int w, h;
428  // The number of lightfield images in the u and v dimensions.
429  int lf_width, lf_height;
430  // Defines how many images refer to the same reference image for MCP.
431  // lf_blocksize X lf_blocksize images will all use the reference image
432  // in the middle of the block of images.
433  int lf_blocksize;
434  aom_codec_ctx_t codec;
436  aom_image_t raw;
437  aom_image_t raw_shift;
438  aom_codec_err_t res;
439  aom_fixed_buf_t stats;
440  int flags = 0;
441 
442  const int fps = 30;
443  const int bitrate = 200; // kbit/s
444  const char *const width_arg = argv[1];
445  const char *const height_arg = argv[2];
446  const char *const infile_arg = argv[3];
447  const char *const outfile_arg = argv[4];
448  const char *const lf_width_arg = argv[5];
449  const char *const lf_height_arg = argv[6];
450  const char *lf_blocksize_arg = argv[7];
451  exec_name = argv[0];
452 
453  if (argc < 8) die("Invalid number of arguments");
454 
455  aom_codec_iface_t *encoder = get_aom_encoder_by_short_name("av1");
456  if (!encoder) die("Unsupported codec.");
457 
458  w = (int)strtol(width_arg, NULL, 0);
459  h = (int)strtol(height_arg, NULL, 0);
460  lf_width = (int)strtol(lf_width_arg, NULL, 0);
461  lf_height = (int)strtol(lf_height_arg, NULL, 0);
462  lf_blocksize = (int)strtol(lf_blocksize_arg, NULL, 0);
463  lf_blocksize = lf_blocksize < lf_width ? lf_blocksize : lf_width;
464  lf_blocksize = lf_blocksize < lf_height ? lf_blocksize : lf_height;
465 
466  if (w <= 0 || h <= 0 || (w % 2) != 0 || (h % 2) != 0)
467  die("Invalid frame size: %dx%d", w, h);
468  if (lf_width <= 0 || lf_height <= 0)
469  die("Invalid lf_width and/or lf_height: %dx%d", lf_width, lf_height);
470  if (lf_blocksize <= 0) die("Invalid lf_blocksize: %d", lf_blocksize);
471 
472  if (!aom_img_alloc(&raw, AOM_IMG_FMT_I420, w, h, 32)) {
473  die("Failed to allocate image.");
474  }
475  if (FORCE_HIGHBITDEPTH_DECODING) {
476  // Need to allocate larger buffer to use hbd internal.
478  32);
479  }
480 
481  printf("Using %s\n", aom_codec_iface_name(encoder));
482 
483  // Configuration
484  res = aom_codec_enc_config_default(encoder, &cfg, 0);
485  if (res) die_codec(&codec, "Failed to get default codec config.");
486 
487  cfg.g_w = w;
488  cfg.g_h = h;
489  cfg.g_timebase.num = 1;
490  cfg.g_timebase.den = fps;
491  cfg.rc_target_bitrate = bitrate;
492  cfg.g_error_resilient = 0; // This is required.
493  cfg.g_lag_in_frames = 0; // need to set this since default is 19.
494  cfg.kf_mode = AOM_KF_DISABLED;
495  cfg.large_scale_tile = 0; // Only set it to 1 for camera frame encoding.
496  cfg.g_bit_depth = AOM_BITS_8;
497  flags |= (cfg.g_bit_depth > AOM_BITS_8 || FORCE_HIGHBITDEPTH_DECODING)
499  : 0;
500 
501  if (!(infile = fopen(infile_arg, "rb")))
502  die("Failed to open %s for reading", infile_arg);
503 
504  // Pass 0
506  stats = pass0(&raw, infile, encoder, &cfg, lf_width, lf_height, lf_blocksize,
507  flags, &raw_shift);
508 
509  // Pass 1
510  rewind(infile);
511  cfg.g_pass = AOM_RC_LAST_PASS;
512  cfg.rc_twopass_stats_in = stats;
513  pass1(&raw, infile, outfile_arg, encoder, &cfg, lf_width, lf_height,
514  lf_blocksize, flags, &raw_shift);
515  free(stats.buf);
516 
517  if (FORCE_HIGHBITDEPTH_DECODING) aom_img_free(&raw_shift);
518  aom_img_free(&raw);
519  fclose(infile);
520 
521  return EXIT_SUCCESS;
522 }
Describes the encoder algorithm interface to applications.
aom_image_t * aom_img_alloc(aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w, unsigned int d_h, unsigned int align)
Open a descriptor, allocating storage for the underlying image.
#define AOM_IMG_FMT_HIGHBITDEPTH
Definition: aom_image.h:38
@ AOM_IMG_FMT_I420
Definition: aom_image.h:45
enum aom_img_fmt aom_img_fmt_t
List of supported image formats.
int aom_img_plane_height(const aom_image_t *img, int plane)
Get the height of a plane.
int aom_img_plane_width(const aom_image_t *img, int plane)
Get the width of a plane.
aom_image_t * aom_img_alloc_with_border(aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w, unsigned int d_h, unsigned int align, unsigned int size_align, unsigned int border)
Open a descriptor, allocating storage for the underlying image with a border.
void aom_img_free(aom_image_t *img)
Close an image descriptor.
Provides definitions for using AOM or AV1 encoder algorithm within the aom Codec Interface.
#define AOM_EFLAG_NO_UPD_ARF
Don't update the alternate reference frame.
Definition: aomcx.h:135
#define AOM_EFLAG_NO_REF_LAST2
Don't reference the last2 frame.
Definition: aomcx.h:78
#define AOM_EFLAG_NO_REF_BWD
Don't reference the bwd reference frame.
Definition: aomcx.h:107
#define AOM_EFLAG_NO_UPD_LAST
Don't update the last frame.
Definition: aomcx.h:121
#define AOM_EFLAG_NO_REF_ARF
Don't reference the alternate reference frame.
Definition: aomcx.h:100
#define AOM_EFLAG_NO_REF_LAST3
Don't reference the last3 frame.
Definition: aomcx.h:85
#define AOM_EFLAG_NO_UPD_GF
Don't update the golden frame.
Definition: aomcx.h:128
#define AOM_EFLAG_NO_REF_GF
Don't reference the golden frame.
Definition: aomcx.h:92
#define AOM_EFLAG_NO_UPD_ENTROPY
Disable entropy update.
Definition: aomcx.h:141
#define AOM_EFLAG_NO_REF_ARF2
Don't reference the alt2 reference frame.
Definition: aomcx.h:114
@ AV1E_SET_MAX_GF_INTERVAL
Codec control function to set minimum interval between GF/ARF frames, unsigned int parameter.
Definition: aomcx.h:593
@ AV1E_SET_FRAME_PARALLEL_DECODING
Codec control function to enable frame parallel decoding feature, unsigned int parameter.
Definition: aomcx.h:430
@ AV1E_SET_TILE_ROWS
Codec control function to set number of tile rows, unsigned int parameter.
Definition: aomcx.h:397
@ AV1E_SET_SUPERBLOCK_SIZE
Codec control function to set intended superblock size, unsigned int parameter.
Definition: aomcx.h:646
@ AOME_SET_ENABLEAUTOALTREF
Codec control function to enable automatic set and use alf frames, unsigned int parameter.
Definition: aomcx.h:227
@ AV1E_SET_TILE_COLUMNS
Codec control function to set number of tile columns. unsigned int parameter.
Definition: aomcx.h:379
@ AOME_SET_CPUUSED
Codec control function to set encoder internal speed settings, int parameter.
Definition: aomcx.h:219
@ AV1E_SET_SINGLE_TILE_DECODING
Codec control function to set the single tile decoding mode, unsigned int parameter.
Definition: aomcx.h:1144
@ AOME_SET_CQ_LEVEL
Codec control function to set constrained / constant quality level, unsigned int parameter.
Definition: aomcx.h:291
@ AV1E_ENABLE_EXT_TILE_DEBUG
Codec control function to enable EXT_TILE_DEBUG in AV1 encoder, unsigned int parameter.
Definition: aomcx.h:1297
@ AV1_SET_REFERENCE
Codec control function to write a frame into a reference buffer.
Definition: aom.h:57
@ AV1_COPY_NEW_FRAME_IMAGE
Codec control function to copy the new frame to an external buffer.
Definition: aom.h:76
const char * aom_codec_iface_name(aom_codec_iface_t *iface)
Return the name for a given interface.
aom_codec_err_t aom_codec_control(aom_codec_ctx_t *ctx, int ctrl_id,...)
Algorithm Control.
const struct aom_codec_iface aom_codec_iface_t
Codec interface structure.
Definition: aom_codec.h:254
int64_t aom_codec_pts_t
Time Stamp Type.
Definition: aom_codec.h:235
aom_codec_err_t aom_codec_destroy(aom_codec_ctx_t *ctx)
Destroy a codec instance.
aom_codec_err_t
Algorithm return codes.
Definition: aom_codec.h:155
const void * aom_codec_iter_t
Iterator.
Definition: aom_codec.h:288
#define AOM_FRAME_IS_KEY
Definition: aom_codec.h:271
@ AOM_BITS_8
Definition: aom_codec.h:319
@ AOM_CODEC_OK
Operation completed without error.
Definition: aom_codec.h:157
@ AOM_SUPERBLOCK_SIZE_64X64
Definition: aom_codec.h:331
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.
#define aom_codec_enc_init(ctx, iface, cfg, flags)
Convenience macro for aom_codec_enc_init_ver()
Definition: aom_encoder.h:934
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.
long aom_enc_frame_flags_t
Encoded Frame Flags.
Definition: aom_encoder.h:376
#define AOM_CODEC_USE_HIGHBITDEPTH
Make the encoder output one partition at a time.
Definition: aom_encoder.h:81
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_enc_config_set(aom_codec_ctx_t *ctx, const aom_codec_enc_cfg_t *cfg)
Set or change configuration.
@ AOM_Q
Definition: aom_encoder.h:188
@ AOM_RC_LAST_PASS
Definition: aom_encoder.h:180
@ AOM_RC_FIRST_PASS
Definition: aom_encoder.h:177
@ AOM_KF_DISABLED
Definition: aom_encoder.h:202
@ AOM_CODEC_CX_FRAME_PKT
Definition: aom_encoder.h:109
@ AOM_CODEC_STATS_PKT
Definition: aom_encoder.h:110
Codec context structure.
Definition: aom_codec.h:298
union aom_codec_ctx::@0 config
Encoder output packet.
Definition: aom_encoder.h:121
enum aom_codec_cx_pkt_kind kind
Definition: aom_encoder.h:122
aom_fixed_buf_t twopass_stats
Definition: aom_encoder.h:139
union aom_codec_cx_pkt::@1 data
struct aom_codec_cx_pkt::@1::@2 frame
Encoder configuration structure.
Definition: aom_encoder.h:386
struct aom_rational g_timebase
Stream timebase units.
Definition: aom_encoder.h:483
unsigned int g_h
Height of the frame.
Definition: aom_encoder.h:434
aom_superres_mode rc_superres_mode
Frame super-resolution scaling mode.
Definition: aom_encoder.h:567
enum aom_kf_mode kf_mode
Keyframe placement mode.
Definition: aom_encoder.h:761
enum aom_rc_mode rc_end_usage
Rate control algorithm to use.
Definition: aom_encoder.h:617
unsigned int g_lag_in_frames
Allow lagged encoding.
Definition: aom_encoder.h:512
aom_bit_depth_t g_bit_depth
Bit-depth of the codec.
Definition: aom_encoder.h:461
unsigned int g_w
Width of the frame.
Definition: aom_encoder.h:425
aom_codec_er_flags_t g_error_resilient
Enable error resilient modes.
Definition: aom_encoder.h:491
enum aom_enc_pass g_pass
Multi-pass Encoding Mode.
Definition: aom_encoder.h:498
unsigned int rc_target_bitrate
Target data rate.
Definition: aom_encoder.h:637
unsigned int rc_resize_mode
Mode for spatial resampling, if supported by the codec.
Definition: aom_encoder.h:543
aom_fixed_buf_t rc_twopass_stats_in
Two-pass stats buffer.
Definition: aom_encoder.h:624
unsigned int large_scale_tile
Tile coding mode.
Definition: aom_encoder.h:809
Generic fixed size buffer structure.
Definition: aom_encoder.h:87
size_t sz
Definition: aom_encoder.h:89
void * buf
Definition: aom_encoder.h:88
Image Descriptor.
Definition: aom_image.h:180
aom_img_fmt_t fmt
Definition: aom_image.h:181
int num
Definition: aom_encoder.h:164
int den
Definition: aom_encoder.h:165
AV1 specific reference frame data struct.
Definition: aom.h:89
int use_external_ref
Definition: aom.h:91
aom_image_t img
Definition: aom.h:92
int idx
Definition: aom.h:90