summaryrefslogtreecommitdiffstats
path: root/third_party/aom/aom_util
diff options
context:
space:
mode:
authortrav90 <travawine@palemoon.org>2018-10-19 21:52:15 -0500
committertrav90 <travawine@palemoon.org>2018-10-19 21:52:20 -0500
commitbbcc64772580c8a979288791afa02d30bc476d2e (patch)
tree437ce94c3fdd7497508e5b55de06c6d011678597 /third_party/aom/aom_util
parent14805f6ddbfb173c327768fff9f81f40ce5e81b0 (diff)
downloadUXP-bbcc64772580c8a979288791afa02d30bc476d2e.tar
UXP-bbcc64772580c8a979288791afa02d30bc476d2e.tar.gz
UXP-bbcc64772580c8a979288791afa02d30bc476d2e.tar.lz
UXP-bbcc64772580c8a979288791afa02d30bc476d2e.tar.xz
UXP-bbcc64772580c8a979288791afa02d30bc476d2e.zip
Update aom to v1.0.0
Update aom to commit id d14c5bb4f336ef1842046089849dee4a301fbbf0.
Diffstat (limited to 'third_party/aom/aom_util')
-rw-r--r--third_party/aom/aom_util/aom_thread.c3
-rw-r--r--third_party/aom/aom_util/aom_thread.h19
-rw-r--r--third_party/aom/aom_util/aom_util.cmake46
-rw-r--r--third_party/aom/aom_util/aom_util.mk18
-rw-r--r--third_party/aom/aom_util/debug_util.c221
-rw-r--r--third_party/aom/aom_util/debug_util.h32
-rw-r--r--third_party/aom/aom_util/endian_inl.h4
7 files changed, 280 insertions, 63 deletions
diff --git a/third_party/aom/aom_util/aom_thread.c b/third_party/aom/aom_util/aom_thread.c
index 954b8f99c..cae9f5e25 100644
--- a/third_party/aom/aom_util/aom_thread.c
+++ b/third_party/aom/aom_util/aom_thread.c
@@ -16,8 +16,9 @@
#include <assert.h>
#include <string.h> // for memset()
-#include "./aom_thread.h"
+
#include "aom_mem/aom_mem.h"
+#include "aom_util/aom_thread.h"
#if CONFIG_MULTITHREAD
diff --git a/third_party/aom/aom_util/aom_thread.h b/third_party/aom/aom_util/aom_thread.h
index 0ae8f2f49..3b22ac70c 100644
--- a/third_party/aom/aom_util/aom_thread.h
+++ b/third_party/aom/aom_util/aom_thread.h
@@ -17,7 +17,7 @@
#ifndef AOM_THREAD_H_
#define AOM_THREAD_H_
-#include "./aom_config.h"
+#include "config/aom_config.h"
#ifdef __cplusplus
extern "C" {
@@ -173,6 +173,23 @@ static INLINE int pthread_cond_signal(pthread_cond_t *const condition) {
return !ok;
}
+static INLINE int pthread_cond_broadcast(pthread_cond_t *const condition) {
+ int ok = 1;
+#ifdef USE_WINDOWS_CONDITION_VARIABLE
+ WakeAllConditionVariable(condition);
+#else
+ while (WaitForSingleObject(condition->waiting_sem_, 0) == WAIT_OBJECT_0) {
+ // a thread is waiting in pthread_cond_wait: allow it to be notified
+ ok &= SetEvent(condition->signal_event_);
+ // wait until the event is consumed so the signaler cannot consume
+ // the event via its own pthread_cond_wait.
+ ok &= (WaitForSingleObject(condition->received_sem_, INFINITE) !=
+ WAIT_OBJECT_0);
+ }
+#endif
+ return !ok;
+}
+
static INLINE int pthread_cond_wait(pthread_cond_t *const condition,
pthread_mutex_t *const mutex) {
int ok;
diff --git a/third_party/aom/aom_util/aom_util.cmake b/third_party/aom/aom_util/aom_util.cmake
index 144d773e3..d4f3bce74 100644
--- a/third_party/aom/aom_util/aom_util.cmake
+++ b/third_party/aom/aom_util/aom_util.cmake
@@ -1,34 +1,28 @@
-##
-## 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.
-##
-if (NOT AOM_AOM_UTIL_AOM_UTIL_CMAKE_)
+#
+# 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.
+#
+if(AOM_AOM_UTIL_AOM_UTIL_CMAKE_)
+ return()
+endif() # AOM_AOM_UTIL_AOM_UTIL_CMAKE_
set(AOM_AOM_UTIL_AOM_UTIL_CMAKE_ 1)
-set(AOM_UTIL_SOURCES
- "${AOM_ROOT}/aom_util/aom_thread.c"
- "${AOM_ROOT}/aom_util/aom_thread.h"
- "${AOM_ROOT}/aom_util/endian_inl.h")
-
-if (CONFIG_BITSTREAM_DEBUG)
- set(AOM_UTIL_SOURCES
- ${AOM_UTIL_SOURCES}
- "${AOM_ROOT}/aom_util/debug_util.c"
- "${AOM_ROOT}/aom_util/debug_util.h")
-endif ()
+list(APPEND AOM_UTIL_SOURCES "${AOM_ROOT}/aom_util/aom_thread.c"
+ "${AOM_ROOT}/aom_util/aom_thread.h"
+ "${AOM_ROOT}/aom_util/endian_inl.h"
+ "${AOM_ROOT}/aom_util/debug_util.c"
+ "${AOM_ROOT}/aom_util/debug_util.h")
# Creates the aom_util build target and makes libaom depend on it. The libaom
# target must exist before this function is called.
-function (setup_aom_util_targets)
+function(setup_aom_util_targets)
add_library(aom_util OBJECT ${AOM_UTIL_SOURCES})
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_util PARENT_SCOPE)
target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_util>)
-endfunction ()
-
-endif () # AOM_AOM_UTIL_AOM_UTIL_CMAKE_
+endfunction()
diff --git a/third_party/aom/aom_util/aom_util.mk b/third_party/aom/aom_util/aom_util.mk
deleted file mode 100644
index 14b484a15..000000000
--- a/third_party/aom/aom_util/aom_util.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-##
-## Copyright (c) 2016, 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.
-##
-
-
-UTIL_SRCS-yes += aom_util.mk
-UTIL_SRCS-yes += aom_thread.c
-UTIL_SRCS-yes += aom_thread.h
-UTIL_SRCS-$(CONFIG_BITSTREAM_DEBUG) += debug_util.c
-UTIL_SRCS-$(CONFIG_BITSTREAM_DEBUG) += debug_util.h
-UTIL_SRCS-yes += endian_inl.h
diff --git a/third_party/aom/aom_util/debug_util.c b/third_party/aom/aom_util/debug_util.c
index ea73df8da..468c47ed1 100644
--- a/third_party/aom/aom_util/debug_util.c
+++ b/third_party/aom/aom_util/debug_util.c
@@ -14,17 +14,6 @@
#include <string.h>
#include "aom_util/debug_util.h"
-#define QUEUE_MAX_SIZE 2000000
-static int result_queue[QUEUE_MAX_SIZE];
-static int nsymbs_queue[QUEUE_MAX_SIZE];
-static aom_cdf_prob cdf_queue[QUEUE_MAX_SIZE][16];
-
-static int queue_r = 0;
-static int queue_w = 0;
-static int queue_prev_w = -1;
-static int skip_r = 0;
-static int skip_w = 0;
-
static int frame_idx_w = 0;
static int frame_idx_r = 0;
@@ -37,6 +26,18 @@ void bitstream_queue_set_frame_read(int frame_idx) { frame_idx_r = frame_idx; }
int bitstream_queue_get_frame_read(void) { return frame_idx_r; }
+#if CONFIG_BITSTREAM_DEBUG
+#define QUEUE_MAX_SIZE 2000000
+static int result_queue[QUEUE_MAX_SIZE];
+static int nsymbs_queue[QUEUE_MAX_SIZE];
+static aom_cdf_prob cdf_queue[QUEUE_MAX_SIZE][16];
+
+static int queue_r = 0;
+static int queue_w = 0;
+static int queue_prev_w = -1;
+static int skip_r = 0;
+static int skip_w = 0;
+
void bitstream_queue_set_skip_write(int skip) { skip_w = skip; }
void bitstream_queue_set_skip_read(int skip) { skip_r = skip; }
@@ -74,3 +75,201 @@ void bitstream_queue_push(int result, const aom_cdf_prob *cdf, int nsymbs) {
}
}
}
+#endif // CONFIG_BITSTREAM_DEBUG
+
+#if CONFIG_MISMATCH_DEBUG
+static int frame_buf_idx_r = 0;
+static int frame_buf_idx_w = 0;
+static int max_frame_buf_num = 5;
+#define MAX_FRAME_STRIDE 1280
+#define MAX_FRAME_HEIGHT 720
+static uint16_t
+ frame_pre[5][3][MAX_FRAME_STRIDE * MAX_FRAME_HEIGHT]; // prediction only
+static uint16_t
+ frame_tx[5][3][MAX_FRAME_STRIDE * MAX_FRAME_HEIGHT]; // prediction + txfm
+static int frame_stride = MAX_FRAME_STRIDE;
+static int frame_height = MAX_FRAME_HEIGHT;
+static int frame_size = MAX_FRAME_STRIDE * MAX_FRAME_HEIGHT;
+void mismatch_move_frame_idx_w() {
+ frame_buf_idx_w = (frame_buf_idx_w + 1) % max_frame_buf_num;
+ if (frame_buf_idx_w == frame_buf_idx_r) {
+ printf("frame_buf overflow\n");
+ assert(0);
+ }
+}
+
+void mismatch_reset_frame(int num_planes) {
+ for (int plane = 0; plane < num_planes; ++plane) {
+ memset(frame_pre[frame_buf_idx_w][plane], 0,
+ sizeof(frame_pre[frame_buf_idx_w][plane][0]) * frame_size);
+ memset(frame_tx[frame_buf_idx_w][plane], 0,
+ sizeof(frame_tx[frame_buf_idx_w][plane][0]) * frame_size);
+ }
+}
+
+void mismatch_move_frame_idx_r() {
+ if (frame_buf_idx_w == frame_buf_idx_r) {
+ printf("frame_buf underflow\n");
+ assert(0);
+ }
+ frame_buf_idx_r = (frame_buf_idx_r + 1) % max_frame_buf_num;
+}
+
+void mismatch_record_block_pre(const uint8_t *src, int src_stride,
+ int frame_offset, int plane, int pixel_c,
+ int pixel_r, int blk_w, int blk_h, int highbd) {
+ if (pixel_c + blk_w >= frame_stride || pixel_r + blk_h >= frame_height) {
+ printf("frame_buf undersized\n");
+ assert(0);
+ }
+
+ const uint16_t *src16 = highbd ? CONVERT_TO_SHORTPTR(src) : NULL;
+ for (int r = 0; r < blk_h; ++r) {
+ for (int c = 0; c < blk_w; ++c) {
+ frame_pre[frame_buf_idx_w][plane]
+ [(r + pixel_r) * frame_stride + c + pixel_c] =
+ src16 ? src16[r * src_stride + c] : src[r * src_stride + c];
+ }
+ }
+#if 0
+ int ref_frame_idx = 3;
+ int ref_frame_offset = 4;
+ int ref_plane = 1;
+ int ref_pixel_c = 162;
+ int ref_pixel_r = 16;
+ if (frame_idx_w == ref_frame_idx && plane == ref_plane &&
+ frame_offset == ref_frame_offset && ref_pixel_c >= pixel_c &&
+ ref_pixel_c < pixel_c + blk_w && ref_pixel_r >= pixel_r &&
+ ref_pixel_r < pixel_r + blk_h) {
+ printf(
+ "\nrecord_block_pre frame_idx %d frame_offset %d plane %d pixel_c %d pixel_r %d blk_w "
+ "%d blk_h %d\n",
+ frame_idx_w, frame_offset, plane, pixel_c, pixel_r, blk_w, blk_h);
+ }
+#endif
+}
+void mismatch_record_block_tx(const uint8_t *src, int src_stride,
+ int frame_offset, int plane, int pixel_c,
+ int pixel_r, int blk_w, int blk_h, int highbd) {
+ if (pixel_c + blk_w >= frame_stride || pixel_r + blk_h >= frame_height) {
+ printf("frame_buf undersized\n");
+ assert(0);
+ }
+
+ const uint16_t *src16 = highbd ? CONVERT_TO_SHORTPTR(src) : NULL;
+ for (int r = 0; r < blk_h; ++r) {
+ for (int c = 0; c < blk_w; ++c) {
+ frame_tx[frame_buf_idx_w][plane]
+ [(r + pixel_r) * frame_stride + c + pixel_c] =
+ src16 ? src16[r * src_stride + c] : src[r * src_stride + c];
+ }
+ }
+#if 0
+ int ref_frame_idx = 3;
+ int ref_frame_offset = 4;
+ int ref_plane = 1;
+ int ref_pixel_c = 162;
+ int ref_pixel_r = 16;
+ if (frame_idx_w == ref_frame_idx && plane == ref_plane && frame_offset == ref_frame_offset &&
+ ref_pixel_c >= pixel_c && ref_pixel_c < pixel_c + blk_w &&
+ ref_pixel_r >= pixel_r && ref_pixel_r < pixel_r + blk_h) {
+ printf(
+ "\nrecord_block_tx frame_idx %d frame_offset %d plane %d pixel_c %d pixel_r %d blk_w "
+ "%d blk_h %d\n",
+ frame_idx_w, frame_offset, plane, pixel_c, pixel_r, blk_w, blk_h);
+ }
+#endif
+}
+void mismatch_check_block_pre(const uint8_t *src, int src_stride,
+ int frame_offset, int plane, int pixel_c,
+ int pixel_r, int blk_w, int blk_h, int highbd) {
+ if (pixel_c + blk_w >= frame_stride || pixel_r + blk_h >= frame_height) {
+ printf("frame_buf undersized\n");
+ assert(0);
+ }
+
+ const uint16_t *src16 = highbd ? CONVERT_TO_SHORTPTR(src) : NULL;
+ int mismatch = 0;
+ for (int r = 0; r < blk_h; ++r) {
+ for (int c = 0; c < blk_w; ++c) {
+ if (frame_pre[frame_buf_idx_r][plane]
+ [(r + pixel_r) * frame_stride + c + pixel_c] !=
+ (uint16_t)(src16 ? src16[r * src_stride + c]
+ : src[r * src_stride + c])) {
+ mismatch = 1;
+ }
+ }
+ }
+ if (mismatch) {
+ printf(
+ "\ncheck_block_pre failed frame_idx %d frame_offset %d plane %d "
+ "pixel_c %d pixel_r "
+ "%d blk_w %d blk_h %d\n",
+ frame_idx_r, frame_offset, plane, pixel_c, pixel_r, blk_w, blk_h);
+ printf("enc\n");
+ for (int rr = 0; rr < blk_h; ++rr) {
+ for (int cc = 0; cc < blk_w; ++cc) {
+ printf("%d ", frame_pre[frame_buf_idx_r][plane]
+ [(rr + pixel_r) * frame_stride + cc + pixel_c]);
+ }
+ printf("\n");
+ }
+
+ printf("dec\n");
+ for (int rr = 0; rr < blk_h; ++rr) {
+ for (int cc = 0; cc < blk_w; ++cc) {
+ printf("%d ",
+ src16 ? src16[rr * src_stride + cc] : src[rr * src_stride + cc]);
+ }
+ printf("\n");
+ }
+ assert(0);
+ }
+}
+void mismatch_check_block_tx(const uint8_t *src, int src_stride,
+ int frame_offset, int plane, int pixel_c,
+ int pixel_r, int blk_w, int blk_h, int highbd) {
+ if (pixel_c + blk_w >= frame_stride || pixel_r + blk_h >= frame_height) {
+ printf("frame_buf undersized\n");
+ assert(0);
+ }
+
+ const uint16_t *src16 = highbd ? CONVERT_TO_SHORTPTR(src) : NULL;
+ int mismatch = 0;
+ for (int r = 0; r < blk_h; ++r) {
+ for (int c = 0; c < blk_w; ++c) {
+ if (frame_tx[frame_buf_idx_r][plane]
+ [(r + pixel_r) * frame_stride + c + pixel_c] !=
+ (uint16_t)(src16 ? src16[r * src_stride + c]
+ : src[r * src_stride + c])) {
+ mismatch = 1;
+ }
+ }
+ }
+ if (mismatch) {
+ printf(
+ "\ncheck_block_tx failed frame_idx %d frame_offset %d plane %d pixel_c "
+ "%d pixel_r "
+ "%d blk_w %d blk_h %d\n",
+ frame_idx_r, frame_offset, plane, pixel_c, pixel_r, blk_w, blk_h);
+ printf("enc\n");
+ for (int rr = 0; rr < blk_h; ++rr) {
+ for (int cc = 0; cc < blk_w; ++cc) {
+ printf("%d ", frame_tx[frame_buf_idx_r][plane]
+ [(rr + pixel_r) * frame_stride + cc + pixel_c]);
+ }
+ printf("\n");
+ }
+
+ printf("dec\n");
+ for (int rr = 0; rr < blk_h; ++rr) {
+ for (int cc = 0; cc < blk_w; ++cc) {
+ printf("%d ",
+ src16 ? src16[rr * src_stride + cc] : src[rr * src_stride + cc]);
+ }
+ printf("\n");
+ }
+ assert(0);
+ }
+}
+#endif // CONFIG_MISMATCH_DEBUG
diff --git a/third_party/aom/aom_util/debug_util.h b/third_party/aom/aom_util/debug_util.h
index 3740620a2..4096801db 100644
--- a/third_party/aom/aom_util/debug_util.h
+++ b/third_party/aom/aom_util/debug_util.h
@@ -12,13 +12,20 @@
#ifndef AOM_UTIL_DEBUG_UTIL_H_
#define AOM_UTIL_DEBUG_UTIL_H_
-#include "./aom_config.h"
+#include "config/aom_config.h"
+
#include "aom_dsp/prob.h"
#ifdef __cplusplus
extern "C" {
#endif
+void bitstream_queue_set_frame_write(int frame_idx);
+int bitstream_queue_get_frame_write(void);
+void bitstream_queue_set_frame_read(int frame_idx);
+int bitstream_queue_get_frame_read(void);
+
+#if CONFIG_BITSTREAM_DEBUG
/* This is a debug tool used to detect bitstream error. On encoder side, it
* pushes each bit and probability into a queue before the bit is written into
* the Arithmetic coder. On decoder side, whenever a bit is read out from the
@@ -35,10 +42,25 @@ void bitstream_queue_pop(int *result, aom_cdf_prob *cdf, int *nsymbs);
void bitstream_queue_push(int result, const aom_cdf_prob *cdf, int nsymbs);
void bitstream_queue_set_skip_write(int skip);
void bitstream_queue_set_skip_read(int skip);
-void bitstream_queue_set_frame_write(int frame_idx);
-int bitstream_queue_get_frame_write(void);
-void bitstream_queue_set_frame_read(int frame_idx);
-int bitstream_queue_get_frame_read(void);
+#endif // CONFIG_BITSTREAM_DEBUG
+
+#if CONFIG_MISMATCH_DEBUG
+void mismatch_move_frame_idx_w();
+void mismatch_move_frame_idx_r();
+void mismatch_reset_frame(int num_planes);
+void mismatch_record_block_pre(const uint8_t *src, int src_stride,
+ int frame_offset, int plane, int pixel_c,
+ int pixel_r, int blk_w, int blk_h, int highbd);
+void mismatch_record_block_tx(const uint8_t *src, int src_stride,
+ int frame_offset, int plane, int pixel_c,
+ int pixel_r, int blk_w, int blk_h, int highbd);
+void mismatch_check_block_pre(const uint8_t *src, int src_stride,
+ int frame_offset, int plane, int pixel_c,
+ int pixel_r, int blk_w, int blk_h, int highbd);
+void mismatch_check_block_tx(const uint8_t *src, int src_stride,
+ int frame_offset, int plane, int pixel_c,
+ int pixel_r, int blk_w, int blk_h, int highbd);
+#endif // CONFIG_MISMATCH_DEBUG
#ifdef __cplusplus
} // extern "C"
diff --git a/third_party/aom/aom_util/endian_inl.h b/third_party/aom/aom_util/endian_inl.h
index 17a238649..2d2822141 100644
--- a/third_party/aom/aom_util/endian_inl.h
+++ b/third_party/aom/aom_util/endian_inl.h
@@ -15,7 +15,9 @@
#define AOM_UTIL_ENDIAN_INL_H_
#include <stdlib.h>
-#include "./aom_config.h"
+
+#include "config/aom_config.h"
+
#include "aom/aom_integer.h"
#if defined(__GNUC__)