Simplify aomenc API - remove AvxInterface
AvxInterface adds extra indirection between user code and
aom_codec_iface_t, the interface data structure. Instead of
exposing it, hide it from the interface and return
aom_codec_iface_t directly.
Also explicitly differentiate "codec short name" (e.g., "av1") from
"codec name" (e.g., "AOMedia Project AV1 Encoder
1.0.0-errata1-avif-714-g15e1944a5")
BUG=aomedia:2651
Change-Id: Iba114972d954a2457055e97f174520a0119ace41
diff --git a/examples/twopass_encoder.c b/examples/twopass_encoder.c
index a03bc6c..e4524ac 100644
--- a/examples/twopass_encoder.c
+++ b/examples/twopass_encoder.c
@@ -117,13 +117,13 @@
}
static aom_fixed_buf_t pass0(aom_image_t *raw, FILE *infile,
- const AvxInterface *encoder,
+ const aom_codec_iface_t *encoder,
const aom_codec_enc_cfg_t *cfg, int limit) {
aom_codec_ctx_t codec;
int frame_count = 0;
aom_fixed_buf_t stats = { NULL, 0 };
- if (aom_codec_enc_init(&codec, encoder->codec_interface(), cfg, 0))
+ if (aom_codec_enc_init(&codec, encoder, cfg, 0))
die_codec(&codec, "Failed to initialize encoder");
// Calculate frame statistics.
@@ -143,9 +143,9 @@
}
static void pass1(aom_image_t *raw, FILE *infile, const char *outfile_name,
- const AvxInterface *encoder, const aom_codec_enc_cfg_t *cfg,
- int limit) {
- AvxVideoInfo info = { encoder->fourcc,
+ const aom_codec_iface_t *encoder,
+ const aom_codec_enc_cfg_t *cfg, int limit) {
+ AvxVideoInfo info = { get_fourcc_by_aom_encoder(encoder),
cfg->g_w,
cfg->g_h,
{ cfg->g_timebase.num, cfg->g_timebase.den },
@@ -157,7 +157,7 @@
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->codec_interface(), cfg, 0))
+ if (aom_codec_enc_init(&codec, encoder, cfg, 0))
die_codec(&codec, "Failed to initialize encoder");
// Encode frames.
@@ -188,7 +188,6 @@
aom_codec_err_t res;
aom_fixed_buf_t stats;
- const AvxInterface *encoder = NULL;
const int fps = 30; // TODO(dkovalev) add command line argument
const int bitrate = 200; // kbit/s TODO(dkovalev) add command line argument
const char *const codec_arg = argv[1];
@@ -205,7 +204,7 @@
if (limit == 0) limit = 100;
- encoder = get_aom_encoder_by_name(codec_arg);
+ aom_codec_iface_t *encoder = get_aom_encoder_by_short_name(codec_arg);
if (!encoder) die("Unsupported codec.");
w = (int)strtol(width_arg, NULL, 0);
@@ -217,10 +216,10 @@
if (!aom_img_alloc(&raw, AOM_IMG_FMT_I420, w, h, 1))
die("Failed to allocate image", w, h);
- printf("Using %s\n", aom_codec_iface_name(encoder->codec_interface()));
+ printf("Using %s\n", aom_codec_iface_name(encoder));
// Configuration
- res = aom_codec_enc_config_default(encoder->codec_interface(), &cfg, 0);
+ res = aom_codec_enc_config_default(encoder, &cfg, 0);
if (res) die_codec(&codec, "Failed to get default codec config.");
cfg.g_w = w;