Update aom to commit id e87fb2378f01103d5d6e477a4ef6892dc714e614

This commit is contained in:
trav90 2018-10-18 21:53:44 -05:00 • committed by Roy Tam
commit 992c6637e3
429 changed files with 76047 additions and 40937 deletions

View file

@ -15,8 +15,6 @@
#include "./aom_config.h"
#if CONFIG_AV1_ENCODER && CONFIG_AV1_DECODER
#include "aom_ports/mem.h" // ROUND_POWER_OF_TWO
#include "aom/aomcx.h"
#include "aom/aomdx.h"
@ -26,9 +24,9 @@
using libaom_test::ACMRandom;
namespace {
struct CompressedSource {
explicit CompressedSource(int seed) : rnd_(seed) {
frame_count_ = 0;
class CompressedSource {
public:
explicit CompressedSource(int seed) : rnd_(seed), frame_count_(0) {
aom_codec_iface_t *algo = &aom_codec_av1_cx_algo;
aom_codec_enc_cfg_t cfg;
@ -39,8 +37,15 @@ struct CompressedSource {
cfg.rc_end_usage = AOM_CQ;
cfg.rc_max_quantizer = max_q;
cfg.rc_min_quantizer = max_q;
cfg.g_w = WIDTH;
cfg.g_h = HEIGHT;
// choose the picture size
{
width_ = rnd_.PseudoUniform(kWidth - 8) + 8;
height_ = rnd_.PseudoUniform(kHeight - 8) + 8;
}
cfg.g_w = width_;
cfg.g_h = height_;
cfg.g_lag_in_frames = 0;
aom_codec_enc_init(&enc_, algo, &cfg, 0);
@ -48,8 +53,8 @@ struct CompressedSource {
~CompressedSource() { aom_codec_destroy(&enc_); }
const aom_codec_cx_pkt_t *readFrame() {
uint8_t buf[WIDTH * HEIGHT * 3 / 2] = { 0 };
const aom_codec_cx_pkt_t *ReadFrame() {
uint8_t buf[kWidth * kHeight * 3 / 2] = { 0 };
// render regular pattern
const int period = rnd_.Rand8() % 32 + 1;
@ -57,52 +62,63 @@ struct CompressedSource {
const int val_a = rnd_.Rand8();
const int val_b = rnd_.Rand8();
for (int i = 0; i < (int)sizeof buf; ++i)
buf[i] = (i + phase) % period < period / 2 ? val_a : val_b;
aom_image_t img;
aom_img_wrap(&img, AOM_IMG_FMT_I420, WIDTH, HEIGHT, 0, buf);
aom_img_wrap(&img, AOM_IMG_FMT_I420, width_, height_, 0, buf);
aom_codec_encode(&enc_, &img, frame_count_++, 1, 0, 0);
aom_codec_iter_t iter = NULL;
return aom_codec_get_cx_data(&enc_, &iter);
const aom_codec_cx_pkt_t *pkt = NULL;
do {
pkt = aom_codec_get_cx_data(&enc_, &iter);
} while (pkt && pkt->kind != AOM_CODEC_CX_FRAME_PKT);
return pkt;
}
private:
static const int kWidth = 128;
static const int kHeight = 128;
ACMRandom rnd_;
aom_codec_ctx_t enc_;
int frame_count_;
static const int WIDTH = 32;
static const int HEIGHT = 32;
int width_, height_;
};
// lowers an aom_image_t to a easily comparable/printable form
std::vector<int16_t> serialize(const aom_image_t *img) {
const int w_uv = ROUND_POWER_OF_TWO(img->d_w, img->x_chroma_shift);
const int h_uv = ROUND_POWER_OF_TWO(img->d_h, img->y_chroma_shift);
const int w[] = { (int)img->d_w, w_uv, w_uv };
const int h[] = { (int)img->d_h, h_uv, h_uv };
std::vector<int16_t> Serialize(const aom_image_t *img) {
std::vector<int16_t> bytes;
bytes.reserve(img->d_w * img->d_h * 3);
for (int plane = 0; plane < 3; ++plane)
for (int r = 0; r < h[plane]; ++r)
for (int c = 0; c < w[plane]; ++c) {
const int offset = r * img->stride[plane] + c;
for (int plane = 0; plane < 3; ++plane) {
const int w = aom_img_plane_width(img, plane);
const int h = aom_img_plane_height(img, plane);
for (int r = 0; r < h; ++r) {
for (int c = 0; c < w; ++c) {
unsigned char *row = img->planes[plane] + r * img->stride[plane];
if (img->fmt & AOM_IMG_FMT_HIGHBITDEPTH)
bytes.push_back(img->planes[plane][offset * 2]);
bytes.push_back(row[c * 2]);
else
bytes.push_back(img->planes[plane][offset]);
bytes.push_back(row[c]);
}
}
}
return bytes;
}
struct Decoder {
class Decoder {
public:
explicit Decoder(int allowLowbitdepth) {
aom_codec_iface_t *algo = &aom_codec_av1_dx_algo;
aom_codec_dec_cfg cfg = { 0 };
aom_codec_dec_cfg_t cfg = aom_codec_dec_cfg_t();
cfg.allow_lowbitdepth = allowLowbitdepth;
aom_codec_dec_init(&dec_, algo, &cfg, 0);
@ -111,11 +127,11 @@ struct Decoder {
~Decoder() { aom_codec_destroy(&dec_); }
std::vector<int16_t> decode(const aom_codec_cx_pkt_t *pkt) {
aom_codec_decode(&dec_, (uint8_t *)pkt->data.frame.buf, pkt->data.frame.sz,
NULL, 0);
aom_codec_decode(&dec_, static_cast<uint8_t *>(pkt->data.frame.buf),
static_cast<unsigned int>(pkt->data.frame.sz), NULL, 0);
aom_codec_iter_t iter = NULL;
return serialize(aom_codec_get_frame(&dec_, &iter));
return Serialize(aom_codec_get_frame(&dec_, &iter));
}
private:
@ -124,22 +140,19 @@ struct Decoder {
// Try to reveal a mismatch between LBD and HBD coding paths.
TEST(CodingPathSync, SearchForHbdLbdMismatch) {
// disable test. Re-enable it locally to help diagnosing LBD/HBD mismatches.
// And re-enable it once both coding paths match
// so they don't diverge anymore.
return;
const int count_tests = 100;
for (int i = 0; i < count_tests; ++i) {
Decoder dec_HBD(0);
Decoder dec_LBD(1);
Decoder dec_hbd(0);
Decoder dec_lbd(1);
CompressedSource enc(i);
const aom_codec_cx_pkt_t *frame = enc.readFrame();
ASSERT_EQ(dec_LBD.decode(frame), dec_HBD.decode(frame));
const aom_codec_cx_pkt_t *frame = enc.ReadFrame();
std::vector<int16_t> lbd_yuv = dec_lbd.decode(frame);
std::vector<int16_t> hbd_yuv = dec_hbd.decode(frame);
ASSERT_EQ(lbd_yuv, hbd_yuv);
}
}
} // namespace
#endif