summaryrefslogtreecommitdiffstats
path: root/third_party/aom/examples
diff options
context:
space:
mode:
authortrav90 <travawine@palemoon.org>2018-10-19 23:00:02 -0500
committertrav90 <travawine@palemoon.org>2018-10-19 23:00:02 -0500
commitb8df135c97a854c2ff9b4394b016649c601177fa (patch)
tree802b7de5ad245f1a12adbcef835ab0d0687c1bf8 /third_party/aom/examples
parenta4d3c59dcac642f6b9557dc09b60eda40b517630 (diff)
downloadUXP-b8df135c97a854c2ff9b4394b016649c601177fa.tar
UXP-b8df135c97a854c2ff9b4394b016649c601177fa.tar.gz
UXP-b8df135c97a854c2ff9b4394b016649c601177fa.tar.lz
UXP-b8df135c97a854c2ff9b4394b016649c601177fa.tar.xz
UXP-b8df135c97a854c2ff9b4394b016649c601177fa.zip
Update libaom to rev b25610052a1398032320008d69b51d2da94f5928
Diffstat (limited to 'third_party/aom/examples')
-rw-r--r--third_party/aom/examples/aom_cx_set_ref.c2
-rw-r--r--third_party/aom/examples/inspect.c4
-rw-r--r--third_party/aom/examples/lightfield_bitstream_parsing.c78
-rw-r--r--third_party/aom/examples/lightfield_decoder.c78
-rw-r--r--third_party/aom/examples/lightfield_encoder.c3
-rw-r--r--third_party/aom/examples/lightfield_tile_list_decoder.c76
-rw-r--r--third_party/aom/examples/twopass_encoder.c3
7 files changed, 112 insertions, 132 deletions
diff --git a/third_party/aom/examples/aom_cx_set_ref.c b/third_party/aom/examples/aom_cx_set_ref.c
index e02e94c07..fc037d484 100644
--- a/third_party/aom/examples/aom_cx_set_ref.c
+++ b/third_party/aom/examples/aom_cx_set_ref.c
@@ -163,7 +163,7 @@ static int encode_frame(aom_codec_ctx_t *ecodec, aom_image_t *img,
// Copy out first decoded frame, and use it as reference later.
if (*frame_out == 1 && ext_ref != NULL)
- if (aom_codec_control(dcodec, AV1_GET_NEW_FRAME_IMAGE, ext_ref))
+ if (aom_codec_control(dcodec, AV1_COPY_NEW_FRAME_IMAGE, ext_ref))
die_codec(dcodec, "Failed to get decoder new frame");
}
}
diff --git a/third_party/aom/examples/inspect.c b/third_party/aom/examples/inspect.c
index 4887fc4a3..9d5f0dcfc 100644
--- a/third_party/aom/examples/inspect.c
+++ b/third_party/aom/examples/inspect.c
@@ -630,7 +630,9 @@ int read_frame() {
die_codec(&codec, "Failed to decode frame.");
}
int got_any_frames = 0;
- while ((img = aom_codec_get_frame(&codec, &iter))) {
+ aom_image_t *frame_img;
+ while ((frame_img = aom_codec_get_frame(&codec, &iter))) {
+ img = frame_img;
++frame_count;
got_any_frames = 1;
}
diff --git a/third_party/aom/examples/lightfield_bitstream_parsing.c b/third_party/aom/examples/lightfield_bitstream_parsing.c
index d13f3f172..71d4dec77 100644
--- a/third_party/aom/examples/lightfield_bitstream_parsing.c
+++ b/third_party/aom/examples/lightfield_bitstream_parsing.c
@@ -12,15 +12,14 @@
// Lightfield Bitstream Parsing
// ============================
//
-// This is an lightfield bitstream parsing example. It takes an input file
+// This is a lightfield bitstream parsing example. It takes an input file
// containing the whole compressed lightfield bitstream(ivf file), and parses it
// and constructs and outputs a new bitstream that can be decoded by an AV1
-// decoder. The output bitstream contains tile list OBUs. 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.
+// decoder. The output bitstream contains reference frames(i.e. anchor frames),
+// camera frame header, and tile list OBUs. num_references is the number of
+// anchor frames coded at the beginning of the light field file.
// After running the lightfield encoder, run lightfield bitstream parsing:
-// examples/lightfield_bitstream_parsing vase10x10.ivf vase_tile_list.ivf 10 10
-// 5
+// examples/lightfield_bitstream_parsing vase10x10.ivf vase_tile_list.ivf 4
#include <stdio.h>
#include <stdlib.h>
@@ -35,13 +34,13 @@
#include "common/video_reader.h"
#include "common/video_writer.h"
+#define MAX_TILES 512
+
static const char *exec_name;
void usage_exit(void) {
- fprintf(
- stderr,
- "Usage: %s <infile> <outfile> <lf_width> <lf_height> <lf_blocksize> \n",
- exec_name);
+ fprintf(stderr, "Usage: %s <infile> <outfile> <num_references> \n",
+ exec_name);
exit(EXIT_FAILURE);
}
@@ -95,39 +94,36 @@ const TILE_LIST_INFO tile_list[2][9] = {
{ 50, 2, 5, 4 } },
};
+static int get_image_bps(aom_img_fmt_t fmt) {
+ switch (fmt) {
+ case AOM_IMG_FMT_I420: return 12;
+ case AOM_IMG_FMT_I422: return 16;
+ case AOM_IMG_FMT_I444: return 24;
+ case AOM_IMG_FMT_I42016: return 24;
+ case AOM_IMG_FMT_I42216: return 32;
+ case AOM_IMG_FMT_I44416: return 48;
+ default: die("Invalid image format");
+ }
+}
+
int main(int argc, char **argv) {
aom_codec_ctx_t codec;
AvxVideoReader *reader = NULL;
AvxVideoWriter *writer = NULL;
const AvxInterface *decoder = NULL;
const AvxVideoInfo *info = NULL;
- const char *lf_width_arg;
- const char *lf_height_arg;
- const char *lf_blocksize_arg;
- int width, height;
- int lf_width, lf_height;
- int lf_blocksize;
- int u_blocks, v_blocks;
+ int num_references;
int n, i;
aom_codec_pts_t pts;
exec_name = argv[0];
- if (argc != 6) die("Invalid number of arguments.");
+ if (argc != 4) die("Invalid number of arguments.");
reader = aom_video_reader_open(argv[1]);
if (!reader) die("Failed to open %s for reading.", argv[1]);
- lf_width_arg = argv[3];
- lf_height_arg = argv[4];
- lf_blocksize_arg = argv[5];
-
- 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);
-
+ num_references = (int)strtol(argv[3], NULL, 0);
info = aom_video_reader_get_info(reader);
- width = info->frame_width;
- height = info->frame_height;
// The writer to write out ivf file in tile list OBU, which can be decoded by
// AV1 decoder.
@@ -144,11 +140,6 @@ int main(int argc, char **argv) {
// Decode anchor frames.
aom_codec_control_(&codec, AV1_SET_TILE_MODE, 0);
- // How many anchor frames we have.
- u_blocks = (lf_width + lf_blocksize - 1) / lf_blocksize;
- v_blocks = (lf_height + lf_blocksize - 1) / lf_blocksize;
-
- int num_references = v_blocks * u_blocks;
for (i = 0; i < num_references; ++i) {
aom_video_reader_read_frame(reader);
@@ -223,10 +214,20 @@ int main(int argc, char **argv) {
die_codec(&codec, "Failed to copy compressed camera frame header.");
}
- // Allocate a buffer to store tile list bitstream. Image format
- // AOM_IMG_FMT_I420.
- size_t data_sz =
- ALIGN_POWER_OF_TWO(width, 5) * ALIGN_POWER_OF_TWO(height, 5) * 12 / 8;
+ // Read out the image format.
+ aom_img_fmt_t ref_fmt = 0;
+ if (aom_codec_control(&codec, AV1D_GET_IMG_FORMAT, &ref_fmt))
+ die_codec(&codec, "Failed to get the image format");
+ const int bps = get_image_bps(ref_fmt);
+ // read out the tile size.
+ unsigned int tile_size = 0;
+ if (aom_codec_control(&codec, AV1D_GET_TILE_SIZE, &tile_size))
+ die_codec(&codec, "Failed to get the tile size");
+ const unsigned int tile_width = tile_size >> 16;
+ const unsigned int tile_height = tile_size & 65535;
+ // Allocate a buffer to store tile list bitstream.
+ const size_t data_sz = MAX_TILES * ALIGN_POWER_OF_TWO(tile_width, 5) *
+ ALIGN_POWER_OF_TWO(tile_height, 5) * bps / 8;
unsigned char *tl_buf = (unsigned char *)malloc(data_sz);
if (tl_buf == NULL) die_codec(&codec, "Failed to allocate tile list buffer.");
@@ -251,7 +252,8 @@ int main(int argc, char **argv) {
// Write the OBU size using a fixed length_field_size of 4 bytes.
saved_obu_size_loc = tl;
- aom_wb_write_literal(&wb, 0, 32);
+ // aom_wb_write_unsigned_literal(&wb, data, bits) requires that bits <= 32.
+ aom_wb_write_unsigned_literal(&wb, 0, 32);
tl += 4;
tile_list_obu_header_size += 4;
diff --git a/third_party/aom/examples/lightfield_decoder.c b/third_party/aom/examples/lightfield_decoder.c
index 625cddcac..5da468413 100644
--- a/third_party/aom/examples/lightfield_decoder.c
+++ b/third_party/aom/examples/lightfield_decoder.c
@@ -14,14 +14,10 @@
//
// This is an example of a simple lightfield decoder. It builds upon the
// simple_decoder.c example. It takes an input file containing the compressed
-// data (in ivf format), treating it as a lightfield instead of a video and
-// will decode a single lightfield tile. The lf_width and lf_height arguments
-// are the number of lightfield images in each dimension. The tile to decode
-// is specified by the tile_u, tile_v, tile_s, tile_t arguments. The tile_u,
-// tile_v specify the image and tile_s, tile_t specify the tile in the image.
+// data (in ivf format), treating it as a lightfield instead of a video.
// After running the lightfield encoder, run lightfield decoder to decode a
-// single tile:
-// examples/lightfield_decoder vase10x10.ivf vase_reference.yuv 10 10 5
+// batch of tiles:
+// examples/lightfield_decoder vase10x10.ivf vase_reference.yuv 4
#include <stdio.h>
#include <stdlib.h>
@@ -38,10 +34,7 @@
static const char *exec_name;
void usage_exit(void) {
- fprintf(
- stderr,
- "Usage: %s <infile> <outfile> <lf_width> <lf_height> <lf_blocksize>\n",
- exec_name);
+ fprintf(stderr, "Usage: %s <infile> <outfile> <num_references>\n", exec_name);
exit(EXIT_FAILURE);
}
@@ -85,22 +78,14 @@ int main(int argc, char **argv) {
AvxVideoReader *reader = NULL;
const AvxInterface *decoder = NULL;
const AvxVideoInfo *info = NULL;
- const char *lf_width_arg;
- const char *lf_height_arg;
- const char *lf_blocksize_arg;
- int width, height;
- int lf_width, lf_height;
- int lf_blocksize;
- int u_blocks;
- int v_blocks;
+ int num_references;
aom_image_t reference_images[MAX_EXTERNAL_REFERENCES];
size_t frame_size = 0;
const unsigned char *frame = NULL;
- int n, i;
-
+ int n, i, j;
exec_name = argv[0];
- if (argc != 6) die("Invalid number of arguments.");
+ if (argc != 4) die("Invalid number of arguments.");
reader = aom_video_reader_open(argv[1]);
if (!reader) die("Failed to open %s for reading.", argv[1]);
@@ -108,16 +93,9 @@ int main(int argc, char **argv) {
if (!(outfile = fopen(argv[2], "wb")))
die("Failed to open %s for writing.", argv[2]);
- lf_width_arg = argv[3];
- lf_height_arg = argv[4];
- lf_blocksize_arg = argv[5];
- 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);
+ num_references = (int)strtol(argv[3], NULL, 0);
info = aom_video_reader_get_info(reader);
- width = info->frame_width;
- height = info->frame_height;
decoder = get_aom_decoder_by_fourcc(info->codec_fourcc);
if (!decoder) die("Unknown input codec.");
@@ -126,33 +104,39 @@ int main(int argc, char **argv) {
if (aom_codec_dec_init(&codec, decoder->codec_interface(), NULL, 0))
die_codec(&codec, "Failed to initialize decoder.");
- // How many anchor frames we have.
- u_blocks = (lf_width + lf_blocksize - 1) / lf_blocksize;
- v_blocks = (lf_height + lf_blocksize - 1) / lf_blocksize;
-
- int num_references = v_blocks * u_blocks;
-
- // Allocate memory to store decoded references.
- aom_img_fmt_t ref_fmt = AOM_IMG_FMT_I420;
- if (!CONFIG_LOWBITDEPTH) ref_fmt |= AOM_IMG_FMT_HIGHBITDEPTH;
- // Allocate memory with the border so that it can be used as a reference.
- for (i = 0; i < num_references; i++) {
- unsigned int border = AOM_BORDER_IN_PIXELS;
- if (!aom_img_alloc_with_border(&reference_images[i], ref_fmt, width, height,
- 32, 8, border)) {
- die("Failed to allocate references.");
- }
+ if (aom_codec_control(&codec, AV1D_SET_IS_ANNEXB, info->is_annexb)) {
+ die("Failed to set annex b status");
}
// Decode anchor frames.
aom_codec_control_(&codec, AV1_SET_TILE_MODE, 0);
-
for (i = 0; i < num_references; ++i) {
aom_video_reader_read_frame(reader);
frame = aom_video_reader_get_frame(reader, &frame_size);
if (aom_codec_decode(&codec, frame, frame_size, NULL))
die_codec(&codec, "Failed to decode frame.");
+ if (i == 0) {
+ aom_img_fmt_t ref_fmt = 0;
+ if (aom_codec_control(&codec, AV1D_GET_IMG_FORMAT, &ref_fmt))
+ die_codec(&codec, "Failed to get the image format");
+
+ int frame_res[2];
+ if (aom_codec_control(&codec, AV1D_GET_FRAME_SIZE, frame_res))
+ die_codec(&codec, "Failed to get the image frame size");
+
+ // Allocate memory to store decoded references. Allocate memory with the
+ // border so that it can be used as a reference.
+ for (j = 0; j < num_references; j++) {
+ unsigned int border = AOM_BORDER_IN_PIXELS;
+ if (!aom_img_alloc_with_border(&reference_images[j], ref_fmt,
+ frame_res[0], frame_res[1], 32, 8,
+ border)) {
+ die("Failed to allocate references.");
+ }
+ }
+ }
+
if (aom_codec_control(&codec, AV1_COPY_NEW_FRAME_IMAGE,
&reference_images[i]))
die_codec(&codec, "Failed to copy decoded reference frame");
diff --git a/third_party/aom/examples/lightfield_encoder.c b/third_party/aom/examples/lightfield_encoder.c
index 22daf622c..f8c37fbb0 100644
--- a/third_party/aom/examples/lightfield_encoder.c
+++ b/third_party/aom/examples/lightfield_encoder.c
@@ -240,7 +240,8 @@ static void pass1(aom_image_t *raw, FILE *infile, const char *outfile_name,
AvxVideoInfo info = { encoder->fourcc,
cfg->g_w,
cfg->g_h,
- { cfg->g_timebase.num, cfg->g_timebase.den } };
+ { cfg->g_timebase.num, cfg->g_timebase.den },
+ 0 };
AvxVideoWriter *writer = NULL;
aom_codec_ctx_t codec;
int frame_count = 0;
diff --git a/third_party/aom/examples/lightfield_tile_list_decoder.c b/third_party/aom/examples/lightfield_tile_list_decoder.c
index cec6baa2c..2e4f3898d 100644
--- a/third_party/aom/examples/lightfield_tile_list_decoder.c
+++ b/third_party/aom/examples/lightfield_tile_list_decoder.c
@@ -16,12 +16,12 @@
// contains the anchor frames that are references of the coded tiles, the camera
// frame header, and tile list OBUs that include the tile information and the
// compressed tile data. This input file is reconstructed from the encoded
-// lightfield ivf file, and is decodable by AV1 decoder. 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.
+// lightfield ivf file, and is decodable by AV1 decoder. num_references is
+// the number of anchor frames coded at the beginning of the light field file.
+// num_tile_lists is the number of tile lists need to be decoded.
// Run lightfield tile list decoder to decode an AV1 tile list file:
// examples/lightfield_tile_list_decoder vase_tile_list.ivf vase_tile_list.yuv
-// 10 10 5 2
+// 4 2
#include <stdio.h>
#include <stdlib.h>
@@ -40,8 +40,7 @@ static const char *exec_name;
void usage_exit(void) {
fprintf(stderr,
- "Usage: %s <infile> <outfile> <lf_width> <lf_height> <lf_blocksize> "
- "<num_tile_lists>\n",
+ "Usage: %s <infile> <outfile> <num_references> <num_tile_lists>\n",
exec_name);
exit(EXIT_FAILURE);
}
@@ -52,21 +51,16 @@ int main(int argc, char **argv) {
AvxVideoReader *reader = NULL;
const AvxInterface *decoder = NULL;
const AvxVideoInfo *info = NULL;
- const char *lf_width_arg;
- const char *lf_height_arg;
- const char *lf_blocksize_arg;
- int width, height;
- int lf_width, lf_height, lf_blocksize;
- int u_blocks, v_blocks;
+ int num_references;
int num_tile_lists;
aom_image_t reference_images[MAX_EXTERNAL_REFERENCES];
size_t frame_size = 0;
const unsigned char *frame = NULL;
- int i, n;
+ int i, j, n;
exec_name = argv[0];
- if (argc != 7) die("Invalid number of arguments.");
+ if (argc != 5) die("Invalid number of arguments.");
reader = aom_video_reader_open(argv[1]);
if (!reader) die("Failed to open %s for reading.", argv[1]);
@@ -74,17 +68,10 @@ int main(int argc, char **argv) {
if (!(outfile = fopen(argv[2], "wb")))
die("Failed to open %s for writing.", argv[2]);
- lf_width_arg = argv[3];
- lf_height_arg = argv[4];
- lf_blocksize_arg = argv[5];
- 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);
- num_tile_lists = (int)strtol(argv[6], NULL, 0);
+ num_references = (int)strtol(argv[3], NULL, 0);
+ num_tile_lists = (int)strtol(argv[4], NULL, 0);
info = aom_video_reader_get_info(reader);
- width = info->frame_width;
- height = info->frame_height;
decoder = get_aom_decoder_by_fourcc(info->codec_fourcc);
if (!decoder) die("Unknown input codec.");
@@ -93,33 +80,39 @@ int main(int argc, char **argv) {
if (aom_codec_dec_init(&codec, decoder->codec_interface(), NULL, 0))
die_codec(&codec, "Failed to initialize decoder.");
- // How many anchor frames we have.
- u_blocks = (lf_width + lf_blocksize - 1) / lf_blocksize;
- v_blocks = (lf_height + lf_blocksize - 1) / lf_blocksize;
-
- int num_references = v_blocks * u_blocks;
-
- // Allocate memory to store decoded references.
- aom_img_fmt_t ref_fmt = AOM_IMG_FMT_I420;
- if (!CONFIG_LOWBITDEPTH) ref_fmt |= AOM_IMG_FMT_HIGHBITDEPTH;
- // Allocate memory with the border so that it can be used as a reference.
- for (i = 0; i < num_references; i++) {
- unsigned int border = AOM_BORDER_IN_PIXELS;
- if (!aom_img_alloc_with_border(&reference_images[i], ref_fmt, width, height,
- 32, 8, border)) {
- die("Failed to allocate references.");
- }
+ if (aom_codec_control(&codec, AV1D_SET_IS_ANNEXB, info->is_annexb)) {
+ die("Failed to set annex b status");
}
// Decode anchor frames.
aom_codec_control_(&codec, AV1_SET_TILE_MODE, 0);
-
for (i = 0; i < num_references; ++i) {
aom_video_reader_read_frame(reader);
frame = aom_video_reader_get_frame(reader, &frame_size);
if (aom_codec_decode(&codec, frame, frame_size, NULL))
die_codec(&codec, "Failed to decode frame.");
+ if (i == 0) {
+ aom_img_fmt_t ref_fmt = 0;
+ if (aom_codec_control(&codec, AV1D_GET_IMG_FORMAT, &ref_fmt))
+ die_codec(&codec, "Failed to get the image format");
+
+ int frame_res[2];
+ if (aom_codec_control(&codec, AV1D_GET_FRAME_SIZE, frame_res))
+ die_codec(&codec, "Failed to get the image frame size");
+
+ // Allocate memory to store decoded references. Allocate memory with the
+ // border so that it can be used as a reference.
+ for (j = 0; j < num_references; j++) {
+ unsigned int border = AOM_BORDER_IN_PIXELS;
+ if (!aom_img_alloc_with_border(&reference_images[j], ref_fmt,
+ frame_res[0], frame_res[1], 32, 8,
+ border)) {
+ die("Failed to allocate references.");
+ }
+ }
+ }
+
if (aom_codec_control(&codec, AV1_COPY_NEW_FRAME_IMAGE,
&reference_images[i]))
die_codec(&codec, "Failed to copy decoded reference frame");
@@ -142,13 +135,11 @@ int main(int argc, char **argv) {
// Set external references.
av1_ext_ref_frame_t set_ext_ref = { &reference_images[0], num_references };
aom_codec_control_(&codec, AV1D_SET_EXT_REF_PTR, &set_ext_ref);
-
// Must decode the camera frame header first.
aom_video_reader_read_frame(reader);
frame = aom_video_reader_get_frame(reader, &frame_size);
if (aom_codec_decode(&codec, frame, frame_size, NULL))
die_codec(&codec, "Failed to decode the frame.");
-
// Decode tile lists one by one.
for (n = 0; n < num_tile_lists; n++) {
aom_video_reader_read_frame(reader);
@@ -156,7 +147,6 @@ int main(int argc, char **argv) {
if (aom_codec_decode(&codec, frame, frame_size, NULL))
die_codec(&codec, "Failed to decode the tile list.");
-
aom_codec_iter_t iter = NULL;
aom_image_t *img;
while ((img = aom_codec_get_frame(&codec, &iter)))
diff --git a/third_party/aom/examples/twopass_encoder.c b/third_party/aom/examples/twopass_encoder.c
index 1b134cce0..a03bc6cc2 100644
--- a/third_party/aom/examples/twopass_encoder.c
+++ b/third_party/aom/examples/twopass_encoder.c
@@ -148,7 +148,8 @@ static void pass1(aom_image_t *raw, FILE *infile, const char *outfile_name,
AvxVideoInfo info = { encoder->fourcc,
cfg->g_w,
cfg->g_h,
- { cfg->g_timebase.num, cfg->g_timebase.den } };
+ { cfg->g_timebase.num, cfg->g_timebase.den },
+ 0 };
AvxVideoWriter *writer = NULL;
aom_codec_ctx_t codec;
int frame_count = 0;