Commit c92e443b authored by Thomas Daede's avatar Thomas Daede

Initial commit

parents
[package]
name = "rav1e"
version = "0.1.0"
authors = ["Thomas Daede <tdaede@xiph.org>"]
build = "build.rs"
[dependencies]
bitstream-io = "0.6.1"
byteorder = "1.0.0"
libc = "0.2.24"
rand = "0.3"
y4m = "0.1.1"
[build-dependencies]
gcc = "0.3"
Copyright (c) 2017, Thomas Daede. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Alliance for Open Media Patent License 1.0
1. License Terms.
1.1. Patent License. Subject to the terms and conditions of this License, each
Licensor, on behalf of itself and successors in interest and assigns,
grants Licensee a non-sublicensable, perpetual, worldwide, non-exclusive,
no-charge, royalty-free, irrevocable (except as expressly stated in this
License) patent license to its Necessary Claims to make, use, sell, offer
for sale, import or distribute any Implementation.
1.2. Conditions.
1.2.1. Availability. As a condition to the grant of rights to Licensee to make,
sell, offer for sale, import or distribute an Implementation under
Section 1.1, Licensee must make its Necessary Claims available under
this License, and must reproduce this License with any Implementation
as follows:
a. For distribution in source code, by including this License in the
root directory of the source code with its Implementation.
b. For distribution in any other form (including binary, object form,
and/or hardware description code (e.g., HDL, RTL, Gate Level Netlist,
GDSII, etc.)), by including this License in the documentation, legal
notices, and/or other written materials provided with the
Implementation.
1.2.2. Additional Conditions. This license is directly from Licensor to
Licensee. Licensee acknowledges as a condition of benefiting from it
that no rights from Licensor are received from suppliers, distributors,
or otherwise in connection with this License.
1.3. Defensive Termination. If any Licensee, its Affiliates, or its agents
initiates patent litigation or files, maintains, or voluntarily
participates in a lawsuit against another entity or any person asserting
that any Implementation infringes Necessary Claims, any patent licenses
granted under this License directly to the Licensee are immediately
terminated as of the date of the initiation of action unless 1) that suit
was in response to a corresponding suit regarding an Implementation first
brought against an initiating entity, or 2) that suit was brought to
enforce the terms of this License (including intervention in a third-party
action by a Licensee).
1.4. Disclaimers. The Reference Implementation and Specification are provided
"AS IS" and without warranty. The entire risk as to implementing or
otherwise using the Reference Implementation or Specification is assumed
by the implementer and user. Licensor expressly disclaims any warranties
(express, implied, or otherwise), including implied warranties of
merchantability, non-infringement, fitness for a particular purpose, or
title, related to the material. IN NO EVENT WILL LICENSOR BE LIABLE TO
ANY OTHER PARTY FOR LOST PROFITS OR ANY FORM OF INDIRECT, SPECIAL,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER FROM ANY CAUSES OF
ACTION OF ANY KIND WITH RESPECT TO THIS LICENSE, WHETHER BASED ON BREACH
OF CONTRACT, TORT (INCLUDING NEGLIGENCE), OR OTHERWISE, AND WHETHER OR
NOT THE OTHER PARTRY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2. Definitions.
2.1. Affiliate. “Affiliate” means an entity that directly or indirectly
Controls, is Controlled by, or is under common Control of that party.
2.2. Control. “Control” means direct or indirect control of more than 50% of
the voting power to elect directors of that corporation, or for any other
entity, the power to direct management of such entity.
2.3. Decoder. "Decoder" means any decoder that conforms fully with all
non-optional portions of the Specification.
2.4. Encoder. "Encoder" means any encoder that produces a bitstream that can
be decoded by a Decoder only to the extent it produces such a bitstream.
2.5. Final Deliverable. “Final Deliverable” means the final version of a
deliverable approved by the Alliance for Open Media as a Final
Deliverable.
2.6. Implementation. "Implementation" means any implementation, including the
Reference Implementation, that is an Encoder and/or a Decoder. An
Implementation also includes components of an Implementation only to the
extent they are used as part of an Implementation.
2.7. License. “License” means this license.
2.8. Licensee. “Licensee” means any person or entity who exercises patent
rights granted under this License.
2.9. Licensor. "Licensor" means (i) any Licensee that makes, sells, offers
for sale, imports or distributes any Implementation, or (ii) a person
or entity that has a licensing obligation to the Implementation as a
result of its membership and/or participation in the Alliance for Open
Media working group that developed the Specification.
2.10. Necessary Claims. "Necessary Claims" means all claims of patents or
patent applications, (a) that currently or at any time in the future,
are owned or controlled by the Licensor, and (b) (i) would be an
Essential Claim as defined by the W3C Policy as of February 5, 2004
(https://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential)
as if the Specification was a W3C Recommendation; or (ii) are infringed
by the Reference Implementation.
2.11. Reference Implementation. “Reference Implementation” means an Encoder
and/or Decoder released by the Alliance for Open Media as a Final
Deliverable.
2.12. Specification. “Specification” means the specification designated by
the Alliance for Open Media as a Final Deliverable for which this
License was issued.
The fastest and worstest AV1 compressor.
Input videos must be a multiple of 64 high and wide, in y4m format.
# Compressing video
```
cargo run --release input.y4m output.ivf
```
# Decompressing video
```
git clone https://aomedia.googlesource.com/aom/
cd aom
git checkout 38646e43ba8f9fcabfc68f3b4e28056a39f5ee4c
./configure --enable-debug --enable-experimental --enable-ec_adapt --enable-new_multisymbol --disable-var_tx --disable-unit-tests
make -j8
./aomdec ../output.ivf -o output.y4m
```
// build.rs
// Bring in a dependency on an externally maintained `gcc` package which manages
// invoking the C compiler.
extern crate gcc;
fn main() {
gcc::Config::new()
.file("src/aom_mem/aom_mem.c")
.file("src/aom_dsp/entenc.c")
.file("src/aom_dsp/entcode.c")
.file("src/aom_dsp/fwd_txfm.c")
.file("src/aom_dsp/inv_txfm.c")
.file("src/aom_dsp/intrapred.c")
.file("src/av1/common/odintrin.c")
.file("src/av1/common/entropymode.c")
.file("src/av1/common/entropy.c")
.file("src/av1/common/scan.c")
.file("src/av1/common/quant_common.c")
.file("src/av1/common/av1_inv_txfm1d.c")
.file("src/av1/common/av1_inv_txfm2d.c")
.include("src")
.compile("libntr.a");
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* 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.
*/
#ifndef AOM_AOM_FRAME_BUFFER_H_
#define AOM_AOM_FRAME_BUFFER_H_
/*!\file
* \brief Describes the decoder external frame buffer interface.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "./aom_integer.h"
/*!\brief The maximum number of work buffers used by libaom.
* Support maximum 4 threads to decode video in parallel.
* Each thread will use one work buffer.
* TODO(hkuang): Add support to set number of worker threads dynamically.
*/
#define AOM_MAXIMUM_WORK_BUFFERS 8
/*!\brief The maximum number of reference buffers that a AV1 encoder may use.
*/
#define AOM_MAXIMUM_REF_BUFFERS 8
/*!\brief External frame buffer
*
* This structure holds allocated frame buffers used by the decoder.
*/
typedef struct aom_codec_frame_buffer {
uint8_t *data; /**< Pointer to the data buffer */
size_t size; /**< Size of data in bytes */
void *priv; /**< Frame's private data */
} aom_codec_frame_buffer_t;
/*!\brief get frame buffer callback prototype
*
* This callback is invoked by the decoder to retrieve data for the frame
* buffer in order for the decode call to complete. The callback must
* allocate at least min_size in bytes and assign it to fb->data. The callback
* must zero out all the data allocated. Then the callback must set fb->size
* to the allocated size. The application does not need to align the allocated
* data. The callback is triggered when the decoder needs a frame buffer to
* decode a compressed image into. This function may be called more than once
* for every call to aom_codec_decode. The application may set fb->priv to
* some data which will be passed back in the ximage and the release function
* call. |fb| is guaranteed to not be NULL. On success the callback must
* return 0. Any failure the callback must return a value less than 0.
*
* \param[in] priv Callback's private data
* \param[in] new_size Size in bytes needed by the buffer
* \param[in,out] fb Pointer to aom_codec_frame_buffer_t
*/
typedef int (*aom_get_frame_buffer_cb_fn_t)(void *priv, size_t min_size,
aom_codec_frame_buffer_t *fb);
/*!\brief release frame buffer callback prototype
*
* This callback is invoked by the decoder when the frame buffer is not
* referenced by any other buffers. |fb| is guaranteed to not be NULL. On
* success the callback must return 0. Any failure the callback must return
* a value less than 0.
*
* \param[in] priv Callback's private data
* \param[in] fb Pointer to aom_codec_frame_buffer_t
*/
typedef int (*aom_release_frame_buffer_cb_fn_t)(void *priv,
aom_codec_frame_buffer_t *fb);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // AOM_AOM_FRAME_BUFFER_H_
This diff is collapsed.
/*
* 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.
*/
#ifndef AOM_AOM_INTEGER_H_
#define AOM_AOM_INTEGER_H_
/* get ptrdiff_t, size_t, wchar_t, NULL */
#include <stddef.h>
#if defined(_MSC_VER)
#define AOM_FORCE_INLINE __forceinline
#define AOM_INLINE __inline
#else
#define AOM_FORCE_INLINE __inline__ __attribute__((always_inline))
// TODO(jbb): Allow a way to force inline off for older compilers.
#define AOM_INLINE inline
#endif
#if defined(AOM_EMULATE_INTTYPES)
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#ifndef _UINTPTR_T_DEFINED
typedef size_t uintptr_t;
#endif
#else
/* Most platforms have the C99 standard integer types. */
#if defined(__cplusplus)
#if !defined(__STDC_FORMAT_MACROS)
#define __STDC_FORMAT_MACROS
#endif
#if !defined(__STDC_LIMIT_MACROS)
#define __STDC_LIMIT_MACROS
#endif
#endif // __cplusplus
#include <stdint.h>
#endif
/* VS2010 defines stdint.h, but not inttypes.h */
#if defined(_MSC_VER) && _MSC_VER < 1800
#define PRId64 "I64d"
#else
#include <inttypes.h>
#endif
#endif // AOM_AOM_INTEGER_H_
This diff is collapsed.
/* 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. */
/* This file automatically generated by configure. Do not edit! */
#ifndef AOM_CONFIG_H
#define AOM_CONFIG_H
#define RESTRICT
#define INLINE inline
#define ARCH_ARM 0
#define ARCH_MIPS 0
#define ARCH_X86 0
#define ARCH_X86_64 1
#define HAVE_NEON 0
#define HAVE_NEON_ASM 0
#define HAVE_MIPS32 0
#define HAVE_DSPR2 0
#define HAVE_MSA 0
#define HAVE_MIPS64 0
#define HAVE_MMX 1
#define HAVE_SSE 1
#define HAVE_SSE2 1
#define HAVE_SSE3 1
#define HAVE_SSSE3 1
#define HAVE_SSE4_1 1
#define HAVE_AVX 1
#define HAVE_AVX2 1
#define HAVE_AOM_PORTS 1
#define HAVE_FEXCEPT 1
#define HAVE_PTHREAD_H 1
#define HAVE_UNISTD_H 1
#define HAVE_WXWIDGETS 0
#define CONFIG_DEPENDENCY_TRACKING 1
#define CONFIG_EXTERNAL_BUILD 0
#define CONFIG_INSTALL_DOCS 1
#define CONFIG_INSTALL_BINS 1
#define CONFIG_INSTALL_LIBS 1
#define CONFIG_INSTALL_SRCS 0
#define CONFIG_DEBUG 1
#define CONFIG_GPROF 0
#define CONFIG_GCOV 0
#define CONFIG_RVCT 0
#define CONFIG_GCC 1
#define CONFIG_MSVS 0
#define CONFIG_PIC 0
#define CONFIG_BIG_ENDIAN 0
#define CONFIG_CODEC_SRCS 0
#define CONFIG_DEBUG_LIBS 0
#define CONFIG_RUNTIME_CPU_DETECT 1
#define CONFIG_POSTPROC 1
#define CONFIG_MULTITHREAD 1
#define CONFIG_INTERNAL_STATS 0
#define CONFIG_AV1_ENCODER 1
#define CONFIG_AV1_DECODER 1
#define CONFIG_AV1 1
#define CONFIG_STATIC_MSVCRT 0
#define CONFIG_SPATIAL_RESAMPLING 1
#define CONFIG_REALTIME_ONLY 0
#define CONFIG_ONTHEFLY_BITPACKING 0
#define CONFIG_ERROR_CONCEALMENT 0
#define CONFIG_SHARED 0
#define CONFIG_STATIC 1
#define CONFIG_SMALL 0
#define CONFIG_POSTPROC_VISUALIZER 0
#define CONFIG_OS_SUPPORT 1
#define CONFIG_UNIT_TESTS 1
#define CONFIG_WEBM_IO 1
#define CONFIG_LIBYUV 1
#define CONFIG_ACCOUNTING 0
#define CONFIG_INSPECTION 0
#define CONFIG_DECODE_PERF_TESTS 0
#define CONFIG_ENCODE_PERF_TESTS 0
#define CONFIG_COEFFICIENT_RANGE_CHECKING 0
#define CONFIG_LOWBITDEPTH 0
#define CONFIG_HIGHBITDEPTH 1
#define CONFIG_EXPERIMENTAL 1
#define CONFIG_SIZE_LIMIT 0
#define CONFIG_COLORSPACE_HEADERS 0
#define CONFIG_FP_MB_STATS 0
#define CONFIG_CDEF 1
#define CONFIG_VAR_TX 0
#define CONFIG_RECT_TX 1
#define CONFIG_RECT_TX_EXT 0
#define CONFIG_TPL_MV 0
#define CONFIG_DUAL_FILTER 1
#define CONFIG_CONVOLVE_ROUND 0
#define CONFIG_COMPOUND_ROUND 0
#define CONFIG_EXT_TX 1
#define CONFIG_DPCM_INTRA 0
#define CONFIG_TX64X64 0
#define CONFIG_EXT_INTRA 1
#define CONFIG_INTRA_INTERP 0
#define CONFIG_FILTER_INTRA 0
#define CONFIG_INTRA_EDGE 0
#define CONFIG_INTRABC 0
#define CONFIG_EXT_INTER 1
#define CONFIG_INTERINTRA 1
#define CONFIG_WEDGE 1
#define CONFIG_COMPOUND_SEGMENT 1
#define CONFIG_EXT_REFS 1
#define CONFIG_SPEED_REFS 0
#define CONFIG_GLOBAL_MOTION 1
#define CONFIG_NEW_QUANT 0
#define CONFIG_SUPERTX 0
#define CONFIG_ANS 0
#define CONFIG_LOOP_RESTORATION 0
#define CONFIG_EXT_PARTITION 0
#define CONFIG_EXT_PARTITION_TYPES 0
#define CONFIG_UNPOISON_PARTITION_CTX 0
#define CONFIG_EXT_TILE 0
#define CONFIG_MOTION_VAR 1
#define CONFIG_NCOBMC 0
#define CONFIG_WARPED_MOTION 1
#define CONFIG_Q_ADAPT_PROBS 0
#define CONFIG_BITSTREAM_DEBUG 0
#define CONFIG_ALT_INTRA 1
#define CONFIG_PALETTE 1
#define CONFIG_PALETTE_DELTA_ENCODING 0
#define CONFIG_RAWBITS 0
#define CONFIG_EC_SMALLMUL 1
#define CONFIG_PVQ 0
#define CONFIG_CFL 0
#define CONFIG_XIPHRC 0
#define CONFIG_CB4X4 1
#define CONFIG_CHROMA_2X2 0
#define CONFIG_CHROMA_SUB8X8 1
#define CONFIG_FRAME_SIZE 0
#define CONFIG_DELTA_Q 1
#define CONFIG_EXT_DELTA_Q 1
#define CONFIG_ADAPT_SCAN 0
#define CONFIG_FILTER_7BIT 1
#define CONFIG_PARALLEL_DEBLOCKING 0
#define CONFIG_PARALLEL_DEBLOCKING_15TAP 0
#define CONFIG_LOOPFILTERING_ACROSS_TILES 1
#define CONFIG_TILE_GROUPS 1
#define CONFIG_EC_ADAPT 1
#define CONFIG_TEMPMV_SIGNALING 1
#define CONFIG_RD_DEBUG 0
#define CONFIG_REFERENCE_BUFFER 1
#define CONFIG_COEF_INTERLEAVE 0
#define CONFIG_ENTROPY_STATS 0
#define CONFIG_MASKED_TX 0
#define CONFIG_DEPENDENT_HORZTILES 0
#define CONFIG_DAALA_DIST 0
#define CONFIG_TRIPRED 0
#define CONFIG_PALETTE_THROUGHPUT 1
#define CONFIG_REF_ADAPT 0
#define CONFIG_LV_MAP 0
#define CONFIG_TXK_SEL 0
#define CONFIG_MV_COMPRESS 1
#define CONFIG_FRAME_SUPERRES 0
#define CONFIG_NEW_MULTISYMBOL 1
#define CONFIG_COMPOUND_SINGLEREF 0
#define CONFIG_AOM_QM 0
#define CONFIG_ONE_SIDED_COMPOUND 1
#define CONFIG_EXT_COMP_REFS 0
#define CONFIG_SMOOTH_HV 0
#define CONFIG_VAR_REFS 0
#define CONFIG_RECT_INTRA_PRED 0
#define CONFIG_LGT 0
#define CONFIG_SBL_SYMBOL 0
#define CONFIG_FRAME_CONTEXT_SIGNALING 0
#define CONFIG_ANALYZER 0
#endif /* AOM_CONFIG_H */
thomas@homura.3863:1505316970
\ No newline at end of file
/*
* 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.
*/
#ifndef AOM_DSP_AOM_CONVOLVE_H_
#define AOM_DSP_AOM_CONVOLVE_H_
#include "./aom_config.h"
#include "aom/aom_integer.h"
#ifdef __cplusplus
extern "C" {
#endif
// Note: Fixed size intermediate buffers, place limits on parameters
// of some functions. 2d filtering proceeds in 2 steps:
// (1) Interpolate horizontally into an intermediate buffer, temp.
// (2) Interpolate temp vertically to derive the sub-pixel result.
// Deriving the maximum number of rows in the temp buffer (135):
// --Smallest scaling factor is x1/2 ==> y_step_q4 = 32 (Normative).
// --Largest block size is 64x64 pixels.
// --64 rows in the downscaled frame span a distance of (64 - 1) * 32 in the
// original frame (in 1/16th pixel units).
// --Must round-up because block may be located at sub-pixel position.
// --Require an additional SUBPEL_TAPS rows for the 8-tap filter tails.
// --((64 - 1) * 32 + 15) >> 4 + 8 = 135.
#if CONFIG_AV1 && CONFIG_EXT_PARTITION
#define MAX_EXT_SIZE 263
#else
#define MAX_EXT_SIZE 135
#endif // CONFIG_AV1 && CONFIG_EXT_PARTITION
#if CONFIG_AV1 && CONFIG_LOOP_RESTORATION
#define EXTRAPREC_BITS 2
#define EXTRAPREC_CLAMP_LIMIT(bd) (1 << ((bd) + 1 + EXTRAPREC_BITS))
#endif
typedef void (*convolve_fn_t)(const uint8_t *src, ptrdiff_t src_stride,
uint8_t *dst, ptrdiff_t dst_stride,
const int16_t *filter_x, int x_step_q4,
const int16_t *filter_y, int y_step_q4, int w,
int h);
#if CONFIG_HIGHBITDEPTH
typedef void (*highbd_convolve_fn_t)(const uint8_t *src, ptrdiff_t src_stride,
uint8_t *dst, ptrdiff_t dst_stride,
const int16_t *filter_x, int x_step_q4,
const int16_t *filter_y, int y_step_q4,
int w, int h, int bd);
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif // AOM_DSP_AOM_CONVOLVE_H_
/*
* 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.
*/
#ifndef AOM_DSP_AOM_DSP_COMMON_H_
#define AOM_DSP_AOM_DSP_COMMON_H_
#include "./aom_config.h"
#include "aom/aom_integer.h"
#include "aom_ports/mem.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef MAX_SB_SIZE
#if CONFIG_AV1 && CONFIG_EXT_PARTITION
#define MAX_SB_SIZE 128
#else
#define MAX_SB_SIZE 64
#endif // CONFIG_AV1 && CONFIG_EXT_PARTITION
#endif // ndef MAX_SB_SIZE
#define AOMMIN(x, y) (((x) < (y)) ? (x) : (y))
#define AOMMAX(x, y) (((x) > (y)) ? (x) : (y))
#define NELEMENTS(x) (sizeof((x)) / sizeof((x)[0]))
#define IMPLIES(a, b) (!(a) || (b)) // Logical 'a implies b' (or 'a -> b')
#define IS_POWER_OF_TWO(x) (((x) & ((x)-1)) == 0)
/* Left shifting a negative value became undefined behavior in C99 (downgraded
from merely implementation-defined in C89). This should still compile to the
correct thing on any two's-complement machine, but avoid ubsan warnings.*/
#define AOM_SIGNED_SHL(x, shift) ((x) * (((x)*0 + 1) << (shift)))
// These can be used to give a hint about branch outcomes.
// This can have an effect, even if your target processor has a
// good branch predictor, as these hints can affect basic block
// ordering by the compiler.
#ifdef __GNUC__
#define LIKELY(v) __builtin_expect(v, 1)
#define UNLIKELY(v) __builtin_expect(v, 0)
#else
#define LIKELY(v) (v)
#define UNLIKELY(v) (v)
#endif
#if CONFIG_AOM_QM
typedef uint16_t qm_val_t;
#define AOM_QM_BITS 5
#endif
#if CONFIG_HIGHBITDEPTH
// Note:
// tran_low_t is the datatype used for final transform coefficients.
// tran_high_t is the datatype used for intermediate transform stages.
typedef int64_t tran_high_t;
typedef int32_t tran_low_t;
#else
// Note:
// tran_low_t is the datatype used for final transform coefficients.
// tran_high_t is the datatype used for intermediate transform stages.
typedef int32_t tran_high_t;
typedef int16_t tran_low_t;
#endif // CONFIG_HIGHBITDEPTH
static INLINE uint8_t clip_pixel(int val) {
return (val > 255) ? 255 : (val < 0) ? 0 : val;
}
static INLINE int clamp(int value, int low, int high) {
return value < low ? low : (value > high ? high : value);
}
static INLINE double fclamp(double value, double low, double high) {
return value < low ? low : (value > high ? high : value);
}
static INLINE uint16_t clip_pixel_highbd(int val, int bd) {
switch (bd) {
case 8:
default: return (uint16_t)clamp(val, 0, 255);
case 10: return (uint16_t)clamp(val, 0, 1023);
case 12: return (uint16_t)clamp(val, 0, 4095);
}
}
#ifdef __cplusplus
} // extern "C"
#endif
#endif // AOM_DSP_AOM_DSP_COMMON_H_
/*
* 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.
*/
#ifndef AOM_DSP_AOM_FILTER_H_
#define AOM_DSP_AOM_FILTER_H_
#include "aom/aom_integer.h"
#ifdef __cplusplus
extern "C" {
#endif
#define FILTER_BITS 7
#define SUBPEL_BITS 4
#define SUBPEL_MASK ((1 << SUBPEL_BITS) - 1)
#define SUBPEL_SHIFTS (1 << SUBPEL_BITS)
#define SUBPEL_TAPS 8
typedef int16_t InterpKernel[SUBPEL_TAPS];
#define BIL_SUBPEL_BITS 3
#define BIL_SUBPEL_SHIFTS (1 << BIL_SUBPEL_BITS)
// 2 tap bilinear filters
static const uint8_t bilinear_filters_2t[BIL_SUBPEL_SHIFTS][2] = {
{ 128, 0 }, { 112, 16 }, { 96, 32 }, { 80, 48 },
{ 64, 64 }, { 48, 80 }, { 32, 96 }, { 16, 112 },
};
#ifdef __cplusplus
} // extern "C"
#endif
#endif // AOM_DSP_AOM_FILTER_H_