lightfield_encoder
/*
* Copyright (c) 2017, Alliance for Open Media. All rights reserved.
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
// Lightfield Encoder
// ==================
//
// This is an example of a simple lightfield encoder. It builds upon the
// twopass_encoder.c example. It takes an input file in YV12 format,
// treating it as a planar lightfield instead of a video. The img_width
// and img_height arguments are the dimensions of the lightfield images,
// while the lf_width and lf_height arguments are the number of
// lightfield images in each dimension. The lf_blocksize determines the
// number of reference images used for MCP. For example, 5 means that there
// is a reference image for every 5x5 lightfield image block. All images
// within a block will use the center image in that block as the reference
// image for MCP.
// Run "make test" to download lightfield test data: vase10x10.yuv.
// Run lightfield encoder to encode whole lightfield:
// examples/lightfield_encoder 1024 1024 vase10x10.yuv vase10x10.ivf 10 10 5
// Note: In bitstream.c and encoder.c, define EXT_TILE_DEBUG as 1 will print
// out the uncompressed header and the frame contexts, which can be used to
// test the bit exactness of the headers and the frame contexts for large scale
// tile coded frames.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "aom/aom_encoder.h"
#include "aom/aomcx.h"
#include "aom_scale/yv12config.h"
#include "av1/common/enums.h"
#include "av1/encoder/encoder_utils.h"
#include "common/tools_common.h"
#include "common/video_writer.h"
static const char *exec_name;
void usage_exit(void) {
fprintf(stderr,
"Usage: %s <img_width> <img_height> <infile> <outfile> "
"<lf_width> <lf_height> <lf_blocksize>\n",
exec_name);
exit(EXIT_FAILURE);
}
static int img_size_bytes(aom_image_t *img) {
int image_size_bytes = 0;
int plane;
for (plane = 0; plane < 3; ++plane) {
const int w = aom_img_plane_width(img, plane) *
((img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 2 : 1);
const int h = aom_img_plane_height(img, plane);
image_size_bytes += w * h;
}
return image_size_bytes;
}
static int get_frame_stats(aom_codec_ctx_t *ctx, const aom_image_t *img,
aom_codec_pts_t pts, unsigned int duration,
aom_enc_frame_flags_t flags,
aom_fixed_buf_t *stats) {
int got_pkts = 0;
aom_codec_iter_t iter = NULL;
const aom_codec_cx_pkt_t *pkt = NULL;
const aom_codec_err_t res = aom_codec_encode(ctx, img, pts, duration, flags);
if (res != AOM_CODEC_OK) die_codec(ctx, "Failed to get frame stats.");
while ((pkt = aom_codec_get_cx_data(ctx, &iter)) != NULL) {
got_pkts = 1;
if (pkt->kind == AOM_CODEC_STATS_PKT) {
const uint8_t *const pkt_buf = pkt->data.twopass_stats.buf;
const size_t pkt_size = pkt->data.twopass_stats.sz;
stats->buf = realloc(stats->buf, stats->sz + pkt_size);
if (!stats->buf) die("Failed to allocate frame stats buffer.");
memcpy((uint8_t *)stats->buf + stats->sz, pkt_buf, pkt_size);
stats->sz += pkt_size;
}
}
return got_pkts;
}
static int encode_frame(aom_codec_ctx_t *ctx, const aom_image_t *img,
aom_codec_pts_t pts, unsigned int duration,
aom_enc_frame_flags_t flags, AvxVideoWriter *writer) {
int got_pkts = 0;
aom_codec_iter_t iter = NULL;
const aom_codec_cx_pkt_t *pkt = NULL;
const aom_codec_err_t res = aom_codec_encode(ctx, img, pts, duration, flags);
if (res != AOM_CODEC_OK) die_codec(ctx, "Failed to encode frame.");
while ((pkt = aom_codec_get_cx_data(ctx, &iter)) != NULL) {
got_pkts = 1;
if (pkt->kind == AOM_CODEC_CX_FRAME_PKT) {
const int keyframe = (pkt->data.frame.flags & AOM_FRAME_IS_KEY) != 0;
if (!aom_video_writer_write_frame(writer, pkt->data.frame.buf,
pkt->data.frame.sz,
pkt->data.frame.pts))
die_codec(ctx, "Failed to write compressed frame.");
printf(keyframe ? "K" : ".");
fflush(stdout);
}
}
return got_pkts;
}
static void get_raw_image(aom_image_t **frame_to_encode, aom_image_t *raw,
aom_image_t *raw_shift) {
if (FORCE_HIGHBITDEPTH_DECODING) {
// Need to allocate larger buffer to use hbd internal.
int input_shift = 0;
aom_img_upshift(raw_shift, raw, input_shift);
*frame_to_encode = raw_shift;
} else {
*frame_to_encode = raw;
}
}
static aom_fixed_buf_t pass0(aom_image_t *raw, FILE *infile,
aom_codec_iface_t *encoder,
const aom_codec_enc_cfg_t *cfg, int lf_width,
int lf_height, int lf_blocksize, int flags,
aom_image_t *raw_shift) {
aom_codec_ctx_t codec;
int frame_count = 0;
int image_size_bytes = img_size_bytes(raw);
int u_blocks, v_blocks;
int bu, bv;
aom_fixed_buf_t stats = { NULL, 0 };
aom_image_t *frame_to_encode;
if (aom_codec_enc_init(&codec, encoder, cfg, flags))
die("Failed to initialize encoder");
if (aom_codec_control(&codec, AOME_SET_ENABLEAUTOALTREF, 0))
die_codec(&codec, "Failed to turn off auto altref");
if (aom_codec_control(&codec, AV1E_SET_FRAME_PARALLEL_DECODING, 0))
die_codec(&codec, "Failed to set frame parallel decoding");
// How many reference images we need to encode.
u_blocks = (lf_width + lf_blocksize - 1) / lf_blocksize;
v_blocks = (lf_height + lf_blocksize - 1) / lf_blocksize;
printf("\n First pass: ");
for (bv = 0; bv < v_blocks; ++bv) {
for (bu = 0; bu < u_blocks; ++bu) {
const int block_u_min = bu * lf_blocksize;
const int block_v_min = bv * lf_blocksize;
int block_u_end = (bu + 1) * lf_blocksize;
int block_v_end = (bv + 1) * lf_blocksize;
int u_block_size, v_block_size;
int block_ref_u, block_ref_v;
block_u_end = block_u_end < lf_width ? block_u_end : lf_width;
block_v_end = block_v_end < lf_height ? block_v_end : lf_height;
u_block_size = block_u_end - block_u_min;
v_block_size = block_v_end - block_v_min;
block_ref_u = block_u_min + u_block_size / 2;
block_ref_v = block_v_min + v_block_size / 2;
printf("A%d, ", (block_ref_u + block_ref_v * lf_width));
fseek(infile, (block_ref_u + block_ref_v * lf_width) * image_size_bytes,
SEEK_SET);
aom_img_read(raw, infile);
get_raw_image(&frame_to_encode, raw, raw_shift);
// Reference frames can be encoded encoded without tiles.
++frame_count;
get_frame_stats(&codec, frame_to_encode, frame_count, 1,
AOM_EFLAG_NO_REF_LAST2 | AOM_EFLAG_NO_REF_LAST3 |
AOM_EFLAG_NO_REF_GF | AOM_EFLAG_NO_REF_ARF |
AOM_EFLAG_NO_REF_BWD | AOM_EFLAG_NO_REF_ARF2 |
AOM_EFLAG_NO_UPD_LAST | AOM_EFLAG_NO_UPD_GF |
AOM_EFLAG_NO_UPD_ARF,
&stats);
}
}
if (aom_codec_control(&codec, AV1E_SET_FRAME_PARALLEL_DECODING, 1))
die_codec(&codec, "Failed to set frame parallel decoding");
for (bv = 0; bv < v_blocks; ++bv) {
for (bu = 0; bu < u_blocks; ++bu) {
const int block_u_min = bu * lf_blocksize;
const int block_v_min = bv * lf_blocksize;
int block_u_end = (bu + 1) * lf_blocksize;
int block_v_end = (bv + 1) * lf_blocksize;
int u, v;
block_u_end = block_u_end < lf_width ? block_u_end : lf_width;
block_v_end = block_v_end < lf_height ? block_v_end : lf_height;
for (v = block_v_min; v < block_v_end; ++v) {
for (u = block_u_min; u < block_u_end; ++u) {
printf("C%d, ", (u + v * lf_width));
fseek(infile, (u + v * lf_width) * image_size_bytes, SEEK_SET);
aom_img_read(raw, infile);
get_raw_image(&frame_to_encode, raw, raw_shift);
++frame_count;
get_frame_stats(&codec, frame_to_encode, frame_count, 1,
AOM_EFLAG_NO_REF_LAST2 | AOM_EFLAG_NO_REF_LAST3 |
AOM_EFLAG_NO_REF_GF | AOM_EFLAG_NO_REF_ARF |
AOM_EFLAG_NO_REF_BWD | AOM_EFLAG_NO_REF_ARF2 |
AOM_EFLAG_NO_UPD_LAST | AOM_EFLAG_NO_UPD_GF |
AOM_EFLAG_NO_UPD_ARF | AOM_EFLAG_NO_UPD_ENTROPY,
&stats);
}
}
}
}
// Flush encoder.
// No ARF, this should not be needed.
while (get_frame_stats(&codec, NULL, frame_count, 1, 0, &stats)) {
}
if (aom_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec.");
printf("\nFirst pass complete. Processed %d frames.\n", frame_count);
return stats;
}
static void pass1(aom_image_t *raw, FILE *infile, const char *outfile_name,
aom_codec_iface_t *encoder, aom_codec_enc_cfg_t *cfg,
int lf_width, int lf_height, int lf_blocksize, int flags,
aom_image_t *raw_shift) {
AvxVideoInfo info = { get_fourcc_by_aom_encoder(encoder),
cfg->g_w,
cfg->g_h,
{ cfg->g_timebase.num, cfg->g_timebase.den },
0 };
AvxVideoWriter *writer = NULL;
aom_codec_ctx_t codec;
int frame_count = 0;
int image_size_bytes = img_size_bytes(raw);
int bu, bv;
int u_blocks, v_blocks;
aom_image_t *frame_to_encode;
aom_image_t reference_images[MAX_EXTERNAL_REFERENCES];
int reference_image_num = 0;
int i;
writer = aom_video_writer_open(outfile_name, kContainerIVF, &info);
if (!writer) die("Failed to open %s for writing", outfile_name);
if (aom_codec_enc_init(&codec, encoder, cfg, flags))
die("Failed to initialize encoder");
if (aom_codec_control(&codec, AOME_SET_ENABLEAUTOALTREF, 0))
die_codec(&codec, "Failed to turn off auto altref");
if (aom_codec_control(&codec, AV1E_SET_FRAME_PARALLEL_DECODING, 0))
die_codec(&codec, "Failed to set frame parallel decoding");
if (aom_codec_control(&codec, AV1E_ENABLE_EXT_TILE_DEBUG, 1))
die_codec(&codec, "Failed to enable encoder ext_tile debug");
if (aom_codec_control(&codec, AOME_SET_CPUUSED, 3))
die_codec(&codec, "Failed to set cpu-used");
// Note: The superblock is a sequence parameter and has to be the same for 1
// sequence. In lightfield application, must choose the superblock size(either
// 64x64 or 128x128) before the encoding starts. Otherwise, the default is
// AOM_SUPERBLOCK_SIZE_DYNAMIC, and the superblock size will be set to 64x64
// internally.
if (aom_codec_control(&codec, AV1E_SET_SUPERBLOCK_SIZE,
AOM_SUPERBLOCK_SIZE_64X64))
die_codec(&codec, "Failed to set SB size");
u_blocks = (lf_width + lf_blocksize - 1) / lf_blocksize;
v_blocks = (lf_height + lf_blocksize - 1) / lf_blocksize;
reference_image_num = u_blocks * v_blocks;
// Set the max gf group length so the references are guaranteed to be in
// a different gf group than any of the regular frames. This avoids using
// both vbr and constant quality mode in a single group. The number of
// references now cannot surpass 17 because of the enforced MAX_GF_INTERVAL of
// 16. If it is necessary to exceed this reference frame limit, one will have
// to do some additional handling to ensure references are in separate gf
// groups from the regular frames.
if (aom_codec_control(&codec, AV1E_SET_MAX_GF_INTERVAL,
reference_image_num - 1))
die_codec(&codec, "Failed to set max gf interval");
aom_img_fmt_t ref_fmt = AOM_IMG_FMT_I420;
if (FORCE_HIGHBITDEPTH_DECODING) ref_fmt |= AOM_IMG_FMT_HIGHBITDEPTH;
// Allocate memory with the border so that it can be used as a reference.
const bool resize =
codec.config.enc->rc_resize_mode || codec.config.enc->rc_superres_mode;
const bool all_intra = reference_image_num - 1 == 0;
int border_in_pixels =
av1_get_enc_border_size(resize, all_intra, BLOCK_64X64);
for (i = 0; i < reference_image_num; i++) {
if (!aom_img_alloc_with_border(&reference_images[i], ref_fmt, cfg->g_w,
cfg->g_h, 32, 8, border_in_pixels)) {
die("Failed to allocate image.");
}
}
printf("\n Second pass: ");
// Encode reference images first.
printf("Encoding Reference Images\n");
for (bv = 0; bv < v_blocks; ++bv) {
for (bu = 0; bu < u_blocks; ++bu) {
const int block_u_min = bu * lf_blocksize;
const int block_v_min = bv * lf_blocksize;
int block_u_end = (bu + 1) * lf_blocksize;
int block_v_end = (bv + 1) * lf_blocksize;
int u_block_size, v_block_size;
int block_ref_u, block_ref_v;
block_u_end = block_u_end < lf_width ? block_u_end : lf_width;
block_v_end = block_v_end < lf_height ? block_v_end : lf_height;
u_block_size = block_u_end - block_u_min;
v_block_size = block_v_end - block_v_min;
block_ref_u = block_u_min + u_block_size / 2;
block_ref_v = block_v_min + v_block_size / 2;
printf("A%d, ", (block_ref_u + block_ref_v * lf_width));
fseek(infile, (block_ref_u + block_ref_v * lf_width) * image_size_bytes,
SEEK_SET);
aom_img_read(raw, infile);
get_raw_image(&frame_to_encode, raw, raw_shift);
// Reference frames may be encoded without tiles.
++frame_count;
printf("Encoding reference image %d of %d\n", bv * u_blocks + bu,
u_blocks * v_blocks);
encode_frame(&codec, frame_to_encode, frame_count, 1,
AOM_EFLAG_NO_REF_LAST2 | AOM_EFLAG_NO_REF_LAST3 |
AOM_EFLAG_NO_REF_GF | AOM_EFLAG_NO_REF_ARF |
AOM_EFLAG_NO_REF_BWD | AOM_EFLAG_NO_REF_ARF2 |
AOM_EFLAG_NO_UPD_LAST | AOM_EFLAG_NO_UPD_GF |
AOM_EFLAG_NO_UPD_ARF | AOM_EFLAG_NO_UPD_ENTROPY,
writer);
if (aom_codec_control(&codec, AV1_COPY_NEW_FRAME_IMAGE,
&reference_images[frame_count - 1]))
die_codec(&codec, "Failed to copy decoder reference frame");
}
}
cfg->large_scale_tile = 1;
// Fixed q encoding for camera frames.
cfg->rc_end_usage = AOM_Q;
if (aom_codec_enc_config_set(&codec, cfg))
die_codec(&codec, "Failed to configure encoder");
// The fixed q value used in encoding.
if (aom_codec_control(&codec, AOME_SET_CQ_LEVEL, 36))
die_codec(&codec, "Failed to set cq level");
if (aom_codec_control(&codec, AV1E_SET_FRAME_PARALLEL_DECODING, 1))
die_codec(&codec, "Failed to set frame parallel decoding");
if (aom_codec_control(&codec, AV1E_SET_SINGLE_TILE_DECODING, 1))
die_codec(&codec, "Failed to turn on single tile decoding");
// Set tile_columns and tile_rows to MAX values, which guarantees the tile
// size of 64 x 64 pixels(i.e. 1 SB) for <= 4k resolution.
if (aom_codec_control(&codec, AV1E_SET_TILE_COLUMNS, 6))
die_codec(&codec, "Failed to set tile width");
if (aom_codec_control(&codec, AV1E_SET_TILE_ROWS, 6))
die_codec(&codec, "Failed to set tile height");
for (bv = 0; bv < v_blocks; ++bv) {
for (bu = 0; bu < u_blocks; ++bu) {
const int block_u_min = bu * lf_blocksize;
const int block_v_min = bv * lf_blocksize;
int block_u_end = (bu + 1) * lf_blocksize;
int block_v_end = (bv + 1) * lf_blocksize;
int u, v;
block_u_end = block_u_end < lf_width ? block_u_end : lf_width;
block_v_end = block_v_end < lf_height ? block_v_end : lf_height;
for (v = block_v_min; v < block_v_end; ++v) {
for (u = block_u_min; u < block_u_end; ++u) {
av1_ref_frame_t ref;
ref.idx = 0;
ref.use_external_ref = 1;
ref.img = reference_images[bv * u_blocks + bu];
if (aom_codec_control(&codec, AV1_SET_REFERENCE, &ref))
die_codec(&codec, "Failed to set reference frame");
printf("C%d, ", (u + v * lf_width));
fseek(infile, (u + v * lf_width) * image_size_bytes, SEEK_SET);
aom_img_read(raw, infile);
get_raw_image(&frame_to_encode, raw, raw_shift);
++frame_count;
printf("Encoding image %d of %d\n",
frame_count - (u_blocks * v_blocks), lf_width * lf_height);
encode_frame(&codec, frame_to_encode, frame_count, 1,
AOM_EFLAG_NO_REF_LAST2 | AOM_EFLAG_NO_REF_LAST3 |
AOM_EFLAG_NO_REF_GF | AOM_EFLAG_NO_REF_ARF |
AOM_EFLAG_NO_REF_BWD | AOM_EFLAG_NO_REF_ARF2 |
AOM_EFLAG_NO_UPD_LAST | AOM_EFLAG_NO_UPD_GF |
AOM_EFLAG_NO_UPD_ARF | AOM_EFLAG_NO_UPD_ENTROPY,
writer);
}
}
}
}
// Flush encoder.
// No ARF, this should not be needed.
while (encode_frame(&codec, NULL, -1, 1, 0, writer)) {
}
for (i = 0; i < reference_image_num; i++) aom_img_free(&reference_images[i]);
if (aom_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec.");
// Modify large_scale_file fourcc.
if (cfg->large_scale_tile == 1)
aom_video_writer_set_fourcc(writer, LST_FOURCC);
aom_video_writer_close(writer);
printf("\nSecond pass complete. Processed %d frames.\n", frame_count);
}
int main(int argc, char **argv) {
FILE *infile = NULL;
int w, h;
// The number of lightfield images in the u and v dimensions.
int lf_width, lf_height;
// Defines how many images refer to the same reference image for MCP.
// lf_blocksize X lf_blocksize images will all use the reference image
// in the middle of the block of images.
int lf_blocksize;
aom_codec_enc_cfg_t cfg;
aom_image_t raw;
aom_image_t raw_shift;
aom_codec_err_t res;
aom_fixed_buf_t stats;
int flags = 0;
const int fps = 30;
const int bitrate = 200; // kbit/s
const char *const width_arg = argv[1];
const char *const height_arg = argv[2];
const char *const infile_arg = argv[3];
const char *const outfile_arg = argv[4];
const char *const lf_width_arg = argv[5];
const char *const lf_height_arg = argv[6];
const char *lf_blocksize_arg = argv[7];
exec_name = argv[0];
if (argc < 8) die("Invalid number of arguments");
aom_codec_iface_t *encoder = get_aom_encoder_by_short_name("av1");
if (!encoder) die("Unsupported codec.");
w = (int)strtol(width_arg, NULL, 0);
h = (int)strtol(height_arg, NULL, 0);
lf_width = (int)strtol(lf_width_arg, NULL, 0);
lf_height = (int)strtol(lf_height_arg, NULL, 0);
lf_blocksize = (int)strtol(lf_blocksize_arg, NULL, 0);
lf_blocksize = lf_blocksize < lf_width ? lf_blocksize : lf_width;
lf_blocksize = lf_blocksize < lf_height ? lf_blocksize : lf_height;
if (w <= 0 || h <= 0 || (w % 2) != 0 || (h % 2) != 0)
die("Invalid frame size: %dx%d", w, h);
if (lf_width <= 0 || lf_height <= 0)
die("Invalid lf_width and/or lf_height: %dx%d", lf_width, lf_height);
if (lf_blocksize <= 0) die("Invalid lf_blocksize: %d", lf_blocksize);
if (!aom_img_alloc(&raw, AOM_IMG_FMT_I420, w, h, 32)) {
die("Failed to allocate image.");
}
if (FORCE_HIGHBITDEPTH_DECODING) {
// Need to allocate larger buffer to use hbd internal.
aom_img_alloc(&raw_shift, AOM_IMG_FMT_I420 | AOM_IMG_FMT_HIGHBITDEPTH, w, h,
32);
}
printf("Using %s\n", aom_codec_iface_name(encoder));
// Configuration
res = aom_codec_enc_config_default(encoder, &cfg, 0);
if (res)
die("Failed to get default codec config: %s", aom_codec_err_to_string(res));
cfg.g_w = w;
cfg.g_h = h;
cfg.g_timebase.num = 1;
cfg.g_timebase.den = fps;
cfg.rc_target_bitrate = bitrate;
cfg.g_error_resilient = 0; // This is required.
cfg.g_lag_in_frames = 0; // need to set this since default is 19.
cfg.kf_mode = AOM_KF_DISABLED;
cfg.large_scale_tile = 0; // Only set it to 1 for camera frame encoding.
cfg.g_bit_depth = AOM_BITS_8;
flags |= (cfg.g_bit_depth > AOM_BITS_8 || FORCE_HIGHBITDEPTH_DECODING)
? AOM_CODEC_USE_HIGHBITDEPTH
: 0;
if (!(infile = fopen(infile_arg, "rb")))
die("Failed to open %s for reading", infile_arg);
// Pass 0
cfg.g_pass = AOM_RC_FIRST_PASS;
stats = pass0(&raw, infile, encoder, &cfg, lf_width, lf_height, lf_blocksize,
flags, &raw_shift);
// Pass 1
rewind(infile);
cfg.g_pass = AOM_RC_LAST_PASS;
cfg.rc_twopass_stats_in = stats;
pass1(&raw, infile, outfile_arg, encoder, &cfg, lf_width, lf_height,
lf_blocksize, flags, &raw_shift);
free(stats.buf);
if (FORCE_HIGHBITDEPTH_DECODING) aom_img_free(&raw_shift);
aom_img_free(&raw);
fclose(infile);
return EXIT_SUCCESS;
}
aom_encoder.h
Describes the encoder algorithm interface to applications.
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_IMG_FMT_HIGHBITDEPTH
#define AOM_IMG_FMT_HIGHBITDEPTH
Definition aom_image.h:38
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_IMG_FMT_I420
@ AOM_IMG_FMT_I420
Definition aom_image.h:45
aom_img_fmt_t
enum aom_img_fmt aom_img_fmt_t
List of supported image formats.
aom_img_plane_height
int aom_img_plane_height(const aom_image_t *img, int plane)
Get the height of a plane.
aom_img_plane_width
int aom_img_plane_width(const aom_image_t *img, int plane)
Get the width of a plane.
aom_image_t
struct aom_image aom_image_t
Image Descriptor.
aom_img_free
void aom_img_free(aom_image_t *img)
Close an image descriptor.
aomcx.h
Provides definitions for using AOM or AV1 encoder algorithm within the aom Codec Interface.
enums.h
AOM_EFLAG_NO_UPD_ARF
#define AOM_EFLAG_NO_UPD_ARF
Don't update the alternate reference frame.
Definition aomcx.h:137
AOM_EFLAG_NO_REF_LAST2
#define AOM_EFLAG_NO_REF_LAST2
Don't reference the last2 frame.
Definition aomcx.h:80
AOM_EFLAG_NO_REF_BWD
#define AOM_EFLAG_NO_REF_BWD
Don't reference the bwd reference frame.
Definition aomcx.h:109
AOM_EFLAG_NO_UPD_LAST
#define AOM_EFLAG_NO_UPD_LAST
Don't update the last frame.
Definition aomcx.h:123
AOM_EFLAG_NO_REF_ARF
#define AOM_EFLAG_NO_REF_ARF
Don't reference the alternate reference frame.
Definition aomcx.h:102
AOM_EFLAG_NO_REF_LAST3
#define AOM_EFLAG_NO_REF_LAST3
Don't reference the last3 frame.
Definition aomcx.h:87
AOM_EFLAG_NO_UPD_GF
#define AOM_EFLAG_NO_UPD_GF
Don't update the golden frame.
Definition aomcx.h:130
AOM_EFLAG_NO_REF_GF
#define AOM_EFLAG_NO_REF_GF
Don't reference the golden frame.
Definition aomcx.h:94
AOM_EFLAG_NO_UPD_ENTROPY
#define AOM_EFLAG_NO_UPD_ENTROPY
Disable entropy update.
Definition aomcx.h:143
AOM_EFLAG_NO_REF_ARF2
#define AOM_EFLAG_NO_REF_ARF2
Don't reference the alt2 reference frame.
Definition aomcx.h:116
AV1E_SET_MAX_GF_INTERVAL
@ AV1E_SET_MAX_GF_INTERVAL
Codec control function to set minimum interval between GF/ARF frames, unsigned int parameter.
Definition aomcx.h:607
AV1E_SET_FRAME_PARALLEL_DECODING
@ AV1E_SET_FRAME_PARALLEL_DECODING
Codec control function to enable frame parallel decoding feature, unsigned int parameter.
Definition aomcx.h:444
AV1E_SET_TILE_ROWS
@ AV1E_SET_TILE_ROWS
Codec control function to set number of tile rows, unsigned int parameter.
Definition aomcx.h:411
AV1E_SET_SUPERBLOCK_SIZE
@ AV1E_SET_SUPERBLOCK_SIZE
Codec control function to set intended superblock size, unsigned int parameter.
Definition aomcx.h:664
AOME_SET_ENABLEAUTOALTREF
@ AOME_SET_ENABLEAUTOALTREF
Codec control function to enable automatic set and use arf frames, unsigned int parameter.
Definition aomcx.h:231
AV1E_SET_TILE_COLUMNS
@ AV1E_SET_TILE_COLUMNS
Codec control function to set number of tile columns. unsigned int parameter.
Definition aomcx.h:393
AOME_SET_CPUUSED
@ AOME_SET_CPUUSED
Codec control function to set encoder internal speed settings, int parameter.
Definition aomcx.h:223
AV1E_SET_SINGLE_TILE_DECODING
@ AV1E_SET_SINGLE_TILE_DECODING
Codec control function to set the single tile decoding mode, unsigned int parameter.
Definition aomcx.h:1169
AOME_SET_CQ_LEVEL
@ AOME_SET_CQ_LEVEL
Codec control function to set constrained / constant quality level, unsigned int parameter.
Definition aomcx.h:301
AV1E_ENABLE_EXT_TILE_DEBUG
@ AV1E_ENABLE_EXT_TILE_DEBUG
Codec control function to enable EXT_TILE_DEBUG in AV1 encoder, unsigned int parameter.
Definition aomcx.h:1323
av1_ref_frame_t
struct av1_ref_frame av1_ref_frame_t
AV1 specific reference frame data struct.
AV1_SET_REFERENCE
@ AV1_SET_REFERENCE
Codec control function to write a frame into a reference buffer.
Definition aom.h:57
AV1_COPY_NEW_FRAME_IMAGE
@ AV1_COPY_NEW_FRAME_IMAGE
Codec control function to copy the new frame to an external buffer.
Definition aom.h:76
aom_codec_iface_name
const char * aom_codec_iface_name(aom_codec_iface_t *iface)
Return the name for a given interface.
aom_codec_control
aom_codec_err_t aom_codec_control(aom_codec_ctx_t *ctx, int ctrl_id,...)
Algorithm Control.
aom_codec_ctx_t
struct aom_codec_ctx aom_codec_ctx_t
Codec context structure.
aom_codec_iface_t
const struct aom_codec_iface aom_codec_iface_t
Codec interface structure.
Definition aom_codec.h:271
aom_codec_pts_t
int64_t aom_codec_pts_t
Time Stamp Type.
Definition aom_codec.h:252
aom_codec_destroy
aom_codec_err_t aom_codec_destroy(aom_codec_ctx_t *ctx)
Destroy a codec instance.
aom_codec_err_to_string
const char * aom_codec_err_to_string(aom_codec_err_t err)
Convert error number to printable string.
aom_codec_err_t
aom_codec_err_t
Algorithm return codes.
Definition aom_codec.h:155
aom_codec_iter_t
const void * aom_codec_iter_t
Iterator.
Definition aom_codec.h:305
AOM_FRAME_IS_KEY
#define AOM_FRAME_IS_KEY
Definition aom_codec.h:288
AOM_BITS_8
@ AOM_BITS_8
Definition aom_codec.h:336
AOM_CODEC_OK
@ AOM_CODEC_OK
Operation completed without error.
Definition aom_codec.h:157
AOM_SUPERBLOCK_SIZE_64X64
@ AOM_SUPERBLOCK_SIZE_64X64
Definition aom_codec.h:348
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.
aom_codec_cx_pkt_t
struct aom_codec_cx_pkt aom_codec_cx_pkt_t
Encoder output packet.
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_fixed_buf_t
struct aom_fixed_buf aom_fixed_buf_t
Generic fixed size buffer structure.
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:956
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 usage)
Get the default configuration for a usage.
aom_enc_frame_flags_t
long aom_enc_frame_flags_t
Encoded Frame Flags.
Definition aom_encoder.h:377
aom_codec_enc_cfg_t
struct aom_codec_enc_cfg aom_codec_enc_cfg_t
Encoder configuration structure.
AOM_CODEC_USE_HIGHBITDEPTH
#define AOM_CODEC_USE_HIGHBITDEPTH
Definition aom_encoder.h:80
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.
AOM_Q
@ AOM_Q
Definition aom_encoder.h:189
AOM_RC_LAST_PASS
@ AOM_RC_LAST_PASS
Definition aom_encoder.h:181
AOM_RC_FIRST_PASS
@ AOM_RC_FIRST_PASS
Definition aom_encoder.h:178
AOM_KF_DISABLED
@ AOM_KF_DISABLED
Definition aom_encoder.h:203
AOM_CODEC_CX_FRAME_PKT
@ AOM_CODEC_CX_FRAME_PKT
Definition aom_encoder.h:110
AOM_CODEC_STATS_PKT
@ AOM_CODEC_STATS_PKT
Definition aom_encoder.h:111
aom_codec_ctx::config
union aom_codec_ctx::@246156302066230216302177003006212014055260000154 config
aom_codec_cx_pkt::sz
size_t sz
Definition aom_encoder.h:127
aom_codec_cx_pkt::kind
enum aom_codec_cx_pkt_kind kind
Definition aom_encoder.h:123
aom_codec_cx_pkt::twopass_stats
aom_fixed_buf_t twopass_stats
Definition aom_encoder.h:140
aom_codec_cx_pkt::data
union aom_codec_cx_pkt::@202210014045072156205127107315337341215221351166 data
aom_codec_cx_pkt::pts
aom_codec_pts_t pts
time stamp to show frame (in timebase units)
Definition aom_encoder.h:129
aom_codec_cx_pkt::flags
aom_codec_frame_flags_t flags
Definition aom_encoder.h:132
aom_codec_cx_pkt::frame
struct aom_codec_cx_pkt::@202210014045072156205127107315337341215221351166::@052232317104146204273007241322037340334334344046 frame
aom_codec_cx_pkt::buf
void * buf
Definition aom_encoder.h:126
aom_codec_enc_cfg::g_timebase
struct aom_rational g_timebase
Stream timebase units.
Definition aom_encoder.h:498
aom_codec_enc_cfg::g_h
unsigned int g_h
Height of the frame.
Definition aom_encoder.h:440
aom_codec_enc_cfg::rc_superres_mode
aom_superres_mode rc_superres_mode
Frame super-resolution scaling mode.
Definition aom_encoder.h:582
aom_codec_enc_cfg::kf_mode
enum aom_kf_mode kf_mode
Keyframe placement mode.
Definition aom_encoder.h:777
aom_codec_enc_cfg::rc_end_usage
enum aom_rc_mode rc_end_usage
Rate control algorithm to use.
Definition aom_encoder.h:632
aom_codec_enc_cfg::g_lag_in_frames
unsigned int g_lag_in_frames
Allow lagged encoding.
Definition aom_encoder.h:527
aom_codec_enc_cfg::g_bit_depth
aom_bit_depth_t g_bit_depth
Bit-depth of the codec.
Definition aom_encoder.h:472
aom_codec_enc_cfg::g_w
unsigned int g_w
Width of the frame.
Definition aom_encoder.h:431
aom_codec_enc_cfg::g_error_resilient
aom_codec_er_flags_t g_error_resilient
Enable error resilient modes.
Definition aom_encoder.h:506
aom_codec_enc_cfg::g_pass
enum aom_enc_pass g_pass
Multi-pass Encoding Mode.
Definition aom_encoder.h:513
aom_codec_enc_cfg::rc_target_bitrate
unsigned int rc_target_bitrate
Target data rate.
Definition aom_encoder.h:653
aom_codec_enc_cfg::rc_resize_mode
unsigned int rc_resize_mode
Mode for spatial resampling, if supported by the codec.
Definition aom_encoder.h:558
aom_codec_enc_cfg::rc_twopass_stats_in
aom_fixed_buf_t rc_twopass_stats_in
Two-pass stats buffer.
Definition aom_encoder.h:639
aom_codec_enc_cfg::large_scale_tile
unsigned int large_scale_tile
Tile coding mode.
Definition aom_encoder.h:827
aom_fixed_buf::sz
size_t sz
Definition aom_encoder.h:90
aom_fixed_buf::buf
void * buf
Definition aom_encoder.h:89
aom_image::fmt
aom_img_fmt_t fmt
Definition aom_image.h:212
aom_rational::num
int num
Definition aom_encoder.h:165
aom_rational::den
int den
Definition aom_encoder.h:166
av1_ref_frame::use_external_ref
int use_external_ref
Definition aom.h:91
av1_ref_frame::img
aom_image_t img
Definition aom.h:92
av1_ref_frame::idx
int idx
Definition aom.h:90