AOMedia Codec SDK
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 "av1/common/enums.h"
41 
42 #include "common/tools_common.h"
43 #include "common/video_writer.h"
44 
45 #define MAX_EXTERNAL_REFERENCES 128
46 #define AOM_BORDER_IN_PIXELS 288
47 
48 static const char *exec_name;
49 
50 void usage_exit(void) {
51  fprintf(stderr,
52  "Usage: %s <img_width> <img_height> <infile> <outfile> "
53  "<lf_width> <lf_height> <lf_blocksize>\n",
54  exec_name);
55  exit(EXIT_FAILURE);
56 }
57 
58 static int aom_img_size_bytes(aom_image_t *img) {
59  int image_size_bytes = 0;
60  int plane;
61  for (plane = 0; plane < 3; ++plane) {
62  const int w = aom_img_plane_width(img, plane) *
63  ((img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 2 : 1);
64  const int h = aom_img_plane_height(img, plane);
65  image_size_bytes += w * h;
66  }
67  return image_size_bytes;
68 }
69 
70 static int get_frame_stats(aom_codec_ctx_t *ctx, const aom_image_t *img,
71  aom_codec_pts_t pts, unsigned int duration,
73  aom_fixed_buf_t *stats) {
74  int got_pkts = 0;
75  aom_codec_iter_t iter = NULL;
76  const aom_codec_cx_pkt_t *pkt = NULL;
77  const aom_codec_err_t res = aom_codec_encode(ctx, img, pts, duration, flags);
78  if (res != AOM_CODEC_OK) die_codec(ctx, "Failed to get frame stats.");
79 
80  while ((pkt = aom_codec_get_cx_data(ctx, &iter)) != NULL) {
81  got_pkts = 1;
82 
83  if (pkt->kind == AOM_CODEC_STATS_PKT) {
84  const uint8_t *const pkt_buf = pkt->data.twopass_stats.buf;
85  const size_t pkt_size = pkt->data.twopass_stats.sz;
86  stats->buf = realloc(stats->buf, stats->sz + pkt_size);
87  memcpy((uint8_t *)stats->buf + stats->sz, pkt_buf, pkt_size);
88  stats->sz += pkt_size;
89  }
90  }
91 
92  return got_pkts;
93 }
94 
95 static int encode_frame(aom_codec_ctx_t *ctx, const aom_image_t *img,
96  aom_codec_pts_t pts, unsigned int duration,
97  aom_enc_frame_flags_t flags, AvxVideoWriter *writer) {
98  int got_pkts = 0;
99  aom_codec_iter_t iter = NULL;
100  const aom_codec_cx_pkt_t *pkt = NULL;
101  const aom_codec_err_t res = aom_codec_encode(ctx, img, pts, duration, flags);
102  if (res != AOM_CODEC_OK) die_codec(ctx, "Failed to encode frame.");
103 
104  while ((pkt = aom_codec_get_cx_data(ctx, &iter)) != NULL) {
105  got_pkts = 1;
106  if (pkt->kind == AOM_CODEC_CX_FRAME_PKT) {
107  const int keyframe = (pkt->data.frame.flags & AOM_FRAME_IS_KEY) != 0;
108 
109  if (!aom_video_writer_write_frame(writer, pkt->data.frame.buf,
110  pkt->data.frame.sz,
111  pkt->data.frame.pts))
112  die_codec(ctx, "Failed to write compressed frame.");
113  printf(keyframe ? "K" : ".");
114  fflush(stdout);
115  }
116  }
117 
118  return got_pkts;
119 }
120 
121 static void get_raw_image(aom_image_t **frame_to_encode, aom_image_t *raw,
122  aom_image_t *raw_shift) {
123  if (!CONFIG_LOWBITDEPTH) {
124  // Need to allocate larger buffer to use hbd internal.
125  int input_shift = 0;
126  aom_img_upshift(raw_shift, raw, input_shift);
127  *frame_to_encode = raw_shift;
128  } else {
129  *frame_to_encode = raw;
130  }
131 }
132 
133 static aom_fixed_buf_t pass0(aom_image_t *raw, FILE *infile,
134  const AvxInterface *encoder,
135  const aom_codec_enc_cfg_t *cfg, int lf_width,
136  int lf_height, int lf_blocksize, int flags,
137  aom_image_t *raw_shift) {
138  aom_codec_ctx_t codec;
139  int frame_count = 0;
140  int image_size_bytes = aom_img_size_bytes(raw);
141  int u_blocks, v_blocks;
142  int bu, bv;
143  aom_fixed_buf_t stats = { NULL, 0 };
144  aom_image_t *frame_to_encode;
145 
146  if (aom_codec_enc_init(&codec, encoder->codec_interface(), cfg, flags))
147  die_codec(&codec, "Failed to initialize encoder");
149  die_codec(&codec, "Failed to turn off auto altref");
151  die_codec(&codec, "Failed to set frame parallel decoding");
152 
153  // How many reference images we need to encode.
154  u_blocks = (lf_width + lf_blocksize - 1) / lf_blocksize;
155  v_blocks = (lf_height + lf_blocksize - 1) / lf_blocksize;
156 
157  printf("\n First pass: ");
158 
159  for (bv = 0; bv < v_blocks; ++bv) {
160  for (bu = 0; bu < u_blocks; ++bu) {
161  const int block_u_min = bu * lf_blocksize;
162  const int block_v_min = bv * lf_blocksize;
163  int block_u_end = (bu + 1) * lf_blocksize;
164  int block_v_end = (bv + 1) * lf_blocksize;
165  int u_block_size, v_block_size;
166  int block_ref_u, block_ref_v;
167 
168  block_u_end = block_u_end < lf_width ? block_u_end : lf_width;
169  block_v_end = block_v_end < lf_height ? block_v_end : lf_height;
170  u_block_size = block_u_end - block_u_min;
171  v_block_size = block_v_end - block_v_min;
172  block_ref_u = block_u_min + u_block_size / 2;
173  block_ref_v = block_v_min + v_block_size / 2;
174 
175  printf("A%d, ", (block_ref_u + block_ref_v * lf_width));
176  fseek(infile, (block_ref_u + block_ref_v * lf_width) * image_size_bytes,
177  SEEK_SET);
178  aom_img_read(raw, infile);
179  get_raw_image(&frame_to_encode, raw, raw_shift);
180 
181  // Reference frames can be encoded encoded without tiles.
182  ++frame_count;
183  get_frame_stats(&codec, frame_to_encode, frame_count, 1,
189  &stats);
190  }
191  }
192 
194  die_codec(&codec, "Failed to set frame parallel decoding");
195 
196  for (bv = 0; bv < v_blocks; ++bv) {
197  for (bu = 0; bu < u_blocks; ++bu) {
198  const int block_u_min = bu * lf_blocksize;
199  const int block_v_min = bv * lf_blocksize;
200  int block_u_end = (bu + 1) * lf_blocksize;
201  int block_v_end = (bv + 1) * lf_blocksize;
202  int u, v;
203  block_u_end = block_u_end < lf_width ? block_u_end : lf_width;
204  block_v_end = block_v_end < lf_height ? block_v_end : lf_height;
205  for (v = block_v_min; v < block_v_end; ++v) {
206  for (u = block_u_min; u < block_u_end; ++u) {
207  printf("C%d, ", (u + v * lf_width));
208  fseek(infile, (u + v * lf_width) * image_size_bytes, SEEK_SET);
209  aom_img_read(raw, infile);
210  get_raw_image(&frame_to_encode, raw, raw_shift);
211 
212  ++frame_count;
213  get_frame_stats(&codec, frame_to_encode, frame_count, 1,
219  &stats);
220  }
221  }
222  }
223  }
224  // Flush encoder.
225  // No ARF, this should not be needed.
226  while (get_frame_stats(&codec, NULL, frame_count, 1, 0, &stats)) {
227  }
228 
229  if (aom_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec.");
230 
231  printf("\nFirst pass complete. Processed %d frames.\n", frame_count);
232 
233  return stats;
234 }
235 
236 static void pass1(aom_image_t *raw, FILE *infile, const char *outfile_name,
237  const AvxInterface *encoder, aom_codec_enc_cfg_t *cfg,
238  int lf_width, int lf_height, int lf_blocksize, int flags,
239  aom_image_t *raw_shift) {
240  AvxVideoInfo info = { encoder->fourcc,
241  cfg->g_w,
242  cfg->g_h,
243  { cfg->g_timebase.num, cfg->g_timebase.den },
244  0 };
245  AvxVideoWriter *writer = NULL;
246  aom_codec_ctx_t codec;
247  int frame_count = 0;
248  int image_size_bytes = aom_img_size_bytes(raw);
249  int bu, bv;
250  int u_blocks, v_blocks;
251  aom_image_t *frame_to_encode;
252  aom_image_t reference_images[MAX_EXTERNAL_REFERENCES];
253  int reference_image_num = 0;
254  int i;
255 
256  writer = aom_video_writer_open(outfile_name, kContainerIVF, &info);
257  if (!writer) die("Failed to open %s for writing", outfile_name);
258 
259  if (aom_codec_enc_init(&codec, encoder->codec_interface(), cfg, flags))
260  die_codec(&codec, "Failed to initialize encoder");
262  die_codec(&codec, "Failed to turn off auto altref");
264  die_codec(&codec, "Failed to set frame parallel decoding");
265  // Note: The superblock is a sequence parameter and has to be the same for 1
266  // sequence. In lightfield application, must choose the superblock size(either
267  // 64x64 or 128x128) before the encoding starts. Otherwise, the default is
268  // AOM_SUPERBLOCK_SIZE_DYNAMIC, and the superblock size will be set to 64x64
269  // internally.
272  die_codec(&codec, "Failed to set SB size");
273 
274  u_blocks = (lf_width + lf_blocksize - 1) / lf_blocksize;
275  v_blocks = (lf_height + lf_blocksize - 1) / lf_blocksize;
276 
277  reference_image_num = u_blocks * v_blocks;
279  if (!CONFIG_LOWBITDEPTH) ref_fmt |= AOM_IMG_FMT_HIGHBITDEPTH;
280  // Allocate memory with the border so that it can be used as a reference.
281  for (i = 0; i < reference_image_num; i++) {
282  if (!aom_img_alloc_with_border(&reference_images[i], ref_fmt, cfg->g_w,
283  cfg->g_h, 32, 8, AOM_BORDER_IN_PIXELS)) {
284  die("Failed to allocate image.");
285  }
286  }
287 
288  printf("\n Second pass: ");
289 
290  // Encode reference images first.
291  printf("Encoding Reference Images\n");
292  for (bv = 0; bv < v_blocks; ++bv) {
293  for (bu = 0; bu < u_blocks; ++bu) {
294  const int block_u_min = bu * lf_blocksize;
295  const int block_v_min = bv * lf_blocksize;
296  int block_u_end = (bu + 1) * lf_blocksize;
297  int block_v_end = (bv + 1) * lf_blocksize;
298  int u_block_size, v_block_size;
299  int block_ref_u, block_ref_v;
300 
301  block_u_end = block_u_end < lf_width ? block_u_end : lf_width;
302  block_v_end = block_v_end < lf_height ? block_v_end : lf_height;
303  u_block_size = block_u_end - block_u_min;
304  v_block_size = block_v_end - block_v_min;
305  block_ref_u = block_u_min + u_block_size / 2;
306  block_ref_v = block_v_min + v_block_size / 2;
307 
308  printf("A%d, ", (block_ref_u + block_ref_v * lf_width));
309  fseek(infile, (block_ref_u + block_ref_v * lf_width) * image_size_bytes,
310  SEEK_SET);
311  aom_img_read(raw, infile);
312 
313  get_raw_image(&frame_to_encode, raw, raw_shift);
314 
315  // Reference frames may be encoded without tiles.
316  ++frame_count;
317  printf("Encoding reference image %d of %d\n", bv * u_blocks + bu,
318  u_blocks * v_blocks);
319  encode_frame(&codec, frame_to_encode, frame_count, 1,
325  writer);
326 
328  &reference_images[frame_count - 1]))
329  die_codec(&codec, "Failed to copy decoder reference frame");
330  }
331  }
332 
333  cfg->large_scale_tile = 1;
334  // Fixed q encoding for camera frames.
335  cfg->rc_end_usage = AOM_Q;
336  if (aom_codec_enc_config_set(&codec, cfg))
337  die_codec(&codec, "Failed to configure encoder");
338 
339  // The fixed q value used in encoding.
340  if (aom_codec_control(&codec, AOME_SET_CQ_LEVEL, 36))
341  die_codec(&codec, "Failed to set cq level");
343  die_codec(&codec, "Failed to set frame parallel decoding");
345  die_codec(&codec, "Failed to turn on single tile decoding");
346  // Set tile_columns and tile_rows to MAX values, which guarantees the tile
347  // size of 64 x 64 pixels(i.e. 1 SB) for <= 4k resolution.
349  die_codec(&codec, "Failed to set tile width");
350  if (aom_codec_control(&codec, AV1E_SET_TILE_ROWS, 6))
351  die_codec(&codec, "Failed to set tile height");
352 
353  for (bv = 0; bv < v_blocks; ++bv) {
354  for (bu = 0; bu < u_blocks; ++bu) {
355  const int block_u_min = bu * lf_blocksize;
356  const int block_v_min = bv * lf_blocksize;
357  int block_u_end = (bu + 1) * lf_blocksize;
358  int block_v_end = (bv + 1) * lf_blocksize;
359  int u, v;
360  block_u_end = block_u_end < lf_width ? block_u_end : lf_width;
361  block_v_end = block_v_end < lf_height ? block_v_end : lf_height;
362  for (v = block_v_min; v < block_v_end; ++v) {
363  for (u = block_u_min; u < block_u_end; ++u) {
364  av1_ref_frame_t ref;
365  ref.idx = 0;
366  ref.use_external_ref = 1;
367  ref.img = reference_images[bv * u_blocks + bu];
368  if (aom_codec_control(&codec, AV1_SET_REFERENCE, &ref))
369  die_codec(&codec, "Failed to set reference frame");
370 
371  printf("C%d, ", (u + v * lf_width));
372  fseek(infile, (u + v * lf_width) * image_size_bytes, SEEK_SET);
373  aom_img_read(raw, infile);
374  get_raw_image(&frame_to_encode, raw, raw_shift);
375 
376  ++frame_count;
377  printf("Encoding image %d of %d\n",
378  frame_count - (u_blocks * v_blocks), lf_width * lf_height);
379  encode_frame(&codec, frame_to_encode, frame_count, 1,
385  writer);
386  }
387  }
388  }
389  }
390 
391  // Flush encoder.
392  // No ARF, this should not be needed.
393  while (encode_frame(&codec, NULL, -1, 1, 0, writer)) {
394  }
395 
396  for (i = 0; i < reference_image_num; i++) aom_img_free(&reference_images[i]);
397 
398  if (aom_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec.");
399  aom_video_writer_close(writer);
400 
401  printf("\nSecond pass complete. Processed %d frames.\n", frame_count);
402 }
403 
404 int main(int argc, char **argv) {
405  FILE *infile = NULL;
406  int w, h;
407  // The number of lightfield images in the u and v dimensions.
408  int lf_width, lf_height;
409  // Defines how many images refer to the same reference image for MCP.
410  // lf_blocksize X lf_blocksize images will all use the reference image
411  // in the middle of the block of images.
412  int lf_blocksize;
413  aom_codec_ctx_t codec;
415  aom_image_t raw;
416  aom_image_t raw_shift;
417  aom_codec_err_t res;
418  aom_fixed_buf_t stats;
419  int flags = 0;
420 
421  const AvxInterface *encoder = NULL;
422  const int fps = 30;
423  const int bitrate = 200; // kbit/s
424  const char *const width_arg = argv[1];
425  const char *const height_arg = argv[2];
426  const char *const infile_arg = argv[3];
427  const char *const outfile_arg = argv[4];
428  const char *const lf_width_arg = argv[5];
429  const char *const lf_height_arg = argv[6];
430  const char *lf_blocksize_arg = argv[7];
431  exec_name = argv[0];
432 
433  if (argc < 8) die("Invalid number of arguments");
434 
435  encoder = get_aom_encoder_by_name("av1");
436  if (!encoder) die("Unsupported codec.");
437 
438  w = (int)strtol(width_arg, NULL, 0);
439  h = (int)strtol(height_arg, NULL, 0);
440  lf_width = (int)strtol(lf_width_arg, NULL, 0);
441  lf_height = (int)strtol(lf_height_arg, NULL, 0);
442  lf_blocksize = (int)strtol(lf_blocksize_arg, NULL, 0);
443  lf_blocksize = lf_blocksize < lf_width ? lf_blocksize : lf_width;
444  lf_blocksize = lf_blocksize < lf_height ? lf_blocksize : lf_height;
445 
446  if (w <= 0 || h <= 0 || (w % 2) != 0 || (h % 2) != 0)
447  die("Invalid frame size: %dx%d", w, h);
448  if (lf_width <= 0 || lf_height <= 0)
449  die("Invalid lf_width and/or lf_height: %dx%d", lf_width, lf_height);
450  if (lf_blocksize <= 0) die("Invalid lf_blocksize: %d", lf_blocksize);
451 
452  if (!aom_img_alloc(&raw, AOM_IMG_FMT_I420, w, h, 32)) {
453  die("Failed to allocate image.");
454  }
455  if (!CONFIG_LOWBITDEPTH) {
456  // Need to allocate larger buffer to use hbd internal.
458  32);
459  }
460 
461  printf("Using %s\n", aom_codec_iface_name(encoder->codec_interface()));
462 
463  // Configuration
464  res = aom_codec_enc_config_default(encoder->codec_interface(), &cfg, 0);
465  if (res) die_codec(&codec, "Failed to get default codec config.");
466 
467  cfg.g_w = w;
468  cfg.g_h = h;
469  cfg.g_timebase.num = 1;
470  cfg.g_timebase.den = fps;
471  cfg.rc_target_bitrate = bitrate;
472  cfg.g_error_resilient = 0; // This is required.
473  cfg.g_lag_in_frames = 0; // need to set this since default is 19.
474  cfg.kf_mode = AOM_KF_DISABLED;
475  cfg.large_scale_tile = 0; // Only set it to 1 for camera frame encoding.
476  cfg.g_bit_depth = AOM_BITS_8;
477  flags |= (cfg.g_bit_depth > AOM_BITS_8 || !CONFIG_LOWBITDEPTH)
479  : 0;
480 
481  if (!(infile = fopen(infile_arg, "rb")))
482  die("Failed to open %s for reading", infile_arg);
483 
484  // Pass 0
486  stats = pass0(&raw, infile, encoder, &cfg, lf_width, lf_height, lf_blocksize,
487  flags, &raw_shift);
488 
489  // Pass 1
490  rewind(infile);
491  cfg.g_pass = AOM_RC_LAST_PASS;
492  cfg.rc_twopass_stats_in = stats;
493  pass1(&raw, infile, outfile_arg, encoder, &cfg, lf_width, lf_height,
494  lf_blocksize, flags, &raw_shift);
495  free(stats.buf);
496 
497  if (!CONFIG_LOWBITDEPTH) aom_img_free(&raw_shift);
498  aom_img_free(&raw);
499  fclose(infile);
500 
501  return EXIT_SUCCESS;
502 }
AOM_IMG_FMT_I420
@ AOM_IMG_FMT_I420
Definition: aom_image.h:45
aom_image::fmt
aom_img_fmt_t fmt
Definition: aom_image.h:142
AOM_EFLAG_NO_UPD_ENTROPY
#define AOM_EFLAG_NO_UPD_ENTROPY
Disable entropy update.
Definition: aomcx.h:120
aom_codec_enc_cfg
Encoder configuration structure.
Definition: aom_encoder.h:237
AOM_EFLAG_NO_REF_BWD
#define AOM_EFLAG_NO_REF_BWD
Don't reference the bwd reference frame.
Definition: aomcx.h:86
aom_img_fmt_t
enum aom_img_fmt aom_img_fmt_t
List of supported image formats.
aom_fixed_buf
Generic fixed size buffer structure.
Definition: aom_encoder.h:84
aom_codec_enc_cfg::g_lag_in_frames
unsigned int g_lag_in_frames
Allow lagged encoding.
Definition: aom_encoder.h:363
AOM_BITS_8
@ AOM_BITS_8
Definition: aom_codec.h:225
av1_ref_frame::use_external_ref
int use_external_ref
Definition: aom.h:110
AOM_EFLAG_NO_REF_LAST3
#define AOM_EFLAG_NO_REF_LAST3
Don't reference the last3 frame.
Definition: aomcx.h:64
aom_codec_ctx
Codec context structure.
Definition: aom_codec.h:204
av1_ref_frame
AV1 specific reference frame data struct.
Definition: aom.h:108
aom_codec_iter_t
const typedef void * aom_codec_iter_t
Iterator.
Definition: aom_codec.h:194
aomcx.h
Provides definitions for using AOM or AV1 encoder algorithm within the aom Codec Interface.
AOM_CODEC_OK
@ AOM_CODEC_OK
Operation completed without error.
Definition: aom_codec.h:103
AOM_CODEC_USE_HIGHBITDEPTH
#define AOM_CODEC_USE_HIGHBITDEPTH
Definition: aom_encoder.h:78
aom_codec_enc_cfg::rc_target_bitrate
unsigned int rc_target_bitrate
Target data rate.
Definition: aom_encoder.h:491
AOM_RC_FIRST_PASS
@ AOM_RC_FIRST_PASS
Definition: aom_encoder.h:195
aom_img_free
void aom_img_free(aom_image_t *img)
Close an image descriptor.
aom_codec_enc_config_set
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.
AOME_SET_ENABLEAUTOALTREF
@ AOME_SET_ENABLEAUTOALTREF
Codec control function to enable automatic set and use alf frames.
Definition: aomcx.h:190
av1_ref_frame::img
aom_image_t img
Definition: aom.h:111
aom_codec_iface_name
const char * aom_codec_iface_name(aom_codec_iface_t *iface)
Return the name for a given interface.
aom_rational::den
int den
Definition: aom_encoder.h:189
aom_codec_destroy
aom_codec_err_t aom_codec_destroy(aom_codec_ctx_t *ctx)
Destroy a codec instance.
AV1E_SET_SINGLE_TILE_DECODING
@ AV1E_SET_SINGLE_TILE_DECODING
Codec control function to set the single tile decoding mode to 0 or 1.
Definition: aomcx.h:832
AV1_COPY_NEW_FRAME_IMAGE
@ AV1_COPY_NEW_FRAME_IMAGE
Definition: aom.h:66
aom_img_alloc_with_border
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.
AOM_RC_LAST_PASS
@ AOM_RC_LAST_PASS
Definition: aom_encoder.h:196
aom_img_alloc
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.
aom_codec_control
#define aom_codec_control(ctx, id, data)
aom_codec_control wrapper macro
Definition: aom_codec.h:423
aom_img_plane_width
int aom_img_plane_width(const aom_image_t *img, int plane)
Get the width of a plane.
aom_codec_cx_pkt::twopass_stats
aom_fixed_buf_t twopass_stats
Definition: aom_encoder.h:165
AV1E_SET_TILE_ROWS
@ AV1E_SET_TILE_ROWS
Codec control function to set number of tile rows.
Definition: aomcx.h:326
aom_codec_enc_cfg::kf_mode
enum aom_kf_mode kf_mode
Keyframe placement mode.
Definition: aom_encoder.h:621
AOM_SUPERBLOCK_SIZE_64X64
@ AOM_SUPERBLOCK_SIZE_64X64
Definition: aom_codec.h:237
AOM_EFLAG_NO_UPD_LAST
#define AOM_EFLAG_NO_UPD_LAST
Don't update the last frame.
Definition: aomcx.h:100
AV1E_SET_FRAME_PARALLEL_DECODING
@ AV1E_SET_FRAME_PARALLEL_DECODING
Codec control function to enable frame parallel decoding feature.
Definition: aomcx.h:338
aom_codec_enc_cfg::rc_end_usage
enum aom_rc_mode rc_end_usage
Rate control algorithm to use.
Definition: aom_encoder.h:471
aom_codec_enc_cfg::g_pass
enum aom_enc_pass g_pass
Multi-pass Encoding Mode.
Definition: aom_encoder.h:349
aom_codec_pts_t
int64_t aom_codec_pts_t
Time Stamp Type.
Definition: aom_encoder.h:94
aom_enc_frame_flags_t
long aom_enc_frame_flags_t
Encoded Frame Flags.
Definition: aom_encoder.h:228
aom_codec_enc_cfg::g_w
unsigned int g_w
Width of the frame.
Definition: aom_encoder.h:276
aom_codec_enc_cfg::g_error_resilient
aom_codec_er_flags_t g_error_resilient
Enable error resilient modes.
Definition: aom_encoder.h:342
AOM_EFLAG_NO_UPD_GF
#define AOM_EFLAG_NO_UPD_GF
Don't update the golden frame.
Definition: aomcx.h:107
AV1E_SET_SUPERBLOCK_SIZE
@ AV1E_SET_SUPERBLOCK_SIZE
Codec control function to set intended superblock size.
Definition: aomcx.h:530
aom_codec_enc_cfg::rc_twopass_stats_in
aom_fixed_buf_t rc_twopass_stats_in
Two-pass stats buffer.
Definition: aom_encoder.h:478
aom_codec_err_t
aom_codec_err_t
Algorithm return codes.
Definition: aom_codec.h:101
AOM_EFLAG_NO_REF_GF
#define AOM_EFLAG_NO_REF_GF
Don't reference the golden frame.
Definition: aomcx.h:71
aom_encoder.h
Describes the encoder algorithm interface to applications.
aom_codec_get_cx_data
const aom_codec_cx_pkt_t * aom_codec_get_cx_data(aom_codec_ctx_t *ctx, aom_codec_iter_t *iter)
Encoded data iterator.
av1_ref_frame::idx
int idx
Definition: aom.h:109
aom_codec_encode
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_Q
@ AOM_Q
Definition: aom_encoder.h:204
aom_codec_cx_pkt::data
union aom_codec_cx_pkt::@1 data
AOM_KF_DISABLED
@ AOM_KF_DISABLED
Definition: aom_encoder.h:218
aom_codec_cx_pkt::frame
struct aom_codec_cx_pkt::@1::@2 frame
aom_codec_cx_pkt
Encoder output packet.
Definition: aom_encoder.h:147
AOM_EFLAG_NO_UPD_ARF
#define AOM_EFLAG_NO_UPD_ARF
Don't update the alternate reference frame.
Definition: aomcx.h:114
AV1E_SET_TILE_COLUMNS
@ AV1E_SET_TILE_COLUMNS
Codec control function to set number of tile columns.
Definition: aomcx.h:308
AOM_EFLAG_NO_REF_LAST2
#define AOM_EFLAG_NO_REF_LAST2
Don't reference the last2 frame.
Definition: aomcx.h:57
AOM_CODEC_STATS_PKT
@ AOM_CODEC_STATS_PKT
Definition: aom_encoder.h:136
aom_codec_enc_cfg::g_h
unsigned int g_h
Height of the frame.
Definition: aom_encoder.h:285
AOM_CODEC_CX_FRAME_PKT
@ AOM_CODEC_CX_FRAME_PKT
Definition: aom_encoder.h:135
AOM_EFLAG_NO_REF_ARF2
#define AOM_EFLAG_NO_REF_ARF2
Don't reference the alt2 reference frame.
Definition: aomcx.h:93
aom_codec_enc_init
#define aom_codec_enc_init(ctx, iface, cfg, flags)
Convenience macro for aom_codec_enc_init_ver()
Definition: aom_encoder.h:774
AOME_SET_CQ_LEVEL
@ AOME_SET_CQ_LEVEL
Codec control function to set constrained quality level.
Definition: aomcx.h:231
aom_image
Image Descriptor.
Definition: aom_image.h:141
aom_fixed_buf::sz
size_t sz
Definition: aom_encoder.h:86
aom_codec_cx_pkt::kind
enum aom_codec_cx_pkt_kind kind
Definition: aom_encoder.h:148
aom_codec_enc_cfg::g_timebase
struct aom_rational g_timebase
Stream timebase units.
Definition: aom_encoder.h:334
aom_img_plane_height
int aom_img_plane_height(const aom_image_t *img, int plane)
Get the height of a plane.
aom_codec_enc_cfg::g_bit_depth
aom_bit_depth_t g_bit_depth
Bit-depth of the codec.
Definition: aom_encoder.h:312
AOM_FRAME_IS_KEY
#define AOM_FRAME_IS_KEY
Definition: aom_encoder.h:104
aom_codec_enc_cfg::large_scale_tile
unsigned int large_scale_tile
Tile coding mode.
Definition: aom_encoder.h:669
AOM_IMG_FMT_HIGHBITDEPTH
#define AOM_IMG_FMT_HIGHBITDEPTH
Definition: aom_image.h:38
aom_fixed_buf::buf
void * buf
Definition: aom_encoder.h:85
AOM_EFLAG_NO_REF_ARF
#define AOM_EFLAG_NO_REF_ARF
Don't reference the alternate reference frame.
Definition: aomcx.h:79
aom_codec_enc_config_default
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.
AV1_SET_REFERENCE
@ AV1_SET_REFERENCE
Definition: aom.h:60
aom_rational::num
int num
Definition: aom_encoder.h:188