2015-07-15 23:02:01 +03:00
|
|
|
/*
|
2016-09-02 00:32:49 +03:00
|
|
|
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
2015-07-15 23:02:01 +03:00
|
|
|
*
|
2016-09-02 00:32:49 +03:00
|
|
|
* 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.
|
2015-07-15 23:02:01 +03:00
|
|
|
*/
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
#ifndef AOM_DSP_AOM_DSP_COMMON_H_
|
|
|
|
#define AOM_DSP_AOM_DSP_COMMON_H_
|
2015-07-15 23:02:01 +03:00
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
#include "./aom_config.h"
|
|
|
|
#include "aom/aom_integer.h"
|
2016-08-23 02:08:15 +03:00
|
|
|
#include "aom_ports/mem.h"
|
2015-07-15 23:02:01 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-03-07 16:46:39 +03:00
|
|
|
#ifndef MAX_SB_SIZE
|
2016-08-31 00:01:10 +03:00
|
|
|
#if CONFIG_AV1 && CONFIG_EXT_PARTITION
|
2016-08-09 08:59:08 +03:00
|
|
|
#define MAX_SB_SIZE 128
|
|
|
|
#else
|
|
|
|
#define MAX_SB_SIZE 64
|
2016-08-31 00:01:10 +03:00
|
|
|
#endif // CONFIG_AV1 && CONFIG_EXT_PARTITION
|
2016-03-07 16:46:39 +03:00
|
|
|
#endif // ndef MAX_SB_SIZE
|
2016-03-04 18:55:48 +03:00
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
#define AOMMIN(x, y) (((x) < (y)) ? (x) : (y))
|
|
|
|
#define AOMMAX(x, y) (((x) > (y)) ? (x) : (y))
|
2015-07-15 23:02:01 +03:00
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
#define IMPLIES(a, b) (!(a) || (b)) // Logical 'a implies b' (or 'a -> b')
|
Make superblock size variable at the frame level.
The uncompressed frame header contains a bit to signal whether the
frame is encoded using 64x64 or 128x128 superblocks. This can vary
between any 2 frames.
vpxenc gained the --sb-size={64,128,dynamic} option, which allows the
configuration of the superblock size used (default is dynamic). 64/128
will force the encoder to always use the specified superblock size.
Dynamic would enable the encoder to choose the sb size for each
frame, but this is not implemented yet (dynamic does the same as 128
for now).
Constraints on tile sizes depend on the superblock size, the following
is a summary of the current bitstream syntax and semantics:
If both --enable-ext-tile is OFF and --enable-ext-partition is OFF:
The tile coding in this case is the same as VP9. In particular,
tiles have a minimum width of 256 pixels and a maximum width of
4096 pixels. The tile width must be multiples of 64 pixels
(except for the rightmost tile column). There can be a maximum
of 64 tile columns and 4 tile rows.
If --enable-ext-tile is OFF and --enable-ext-partition is ON:
Same constraints as above, except that tile width must be
multiples of 128 pixels (except for the rightmost tile column).
There is no change in the bitstream syntax used for coding the tile
configuration if --enable-ext-tile is OFF.
If --enable-ext-tile is ON and --enable-ext-partition is ON:
This is the new large scale tile coding configuration. The
minimum/maximum tile width and height are 64/4096 pixels. Tile
width and height must be multiples of 64 pixels. The uncompressed
header contains two 6 bit fields that hold the tile width/heigh
in units of 64 pixels. The maximum number of tile rows/columns
is only limited by the maximum frame size of 65536x65536 pixels
that can be coded in the bitstream. This yields a maximum of
1024x1024 tile rows and columns (of 64x64 tiles in a 65536x65536
frame).
If both --enable-ext-tile is ON and --enable-ext-partition is ON:
Same applies as above, except that in the bitstream the 2 fields
containing the tile width/height are in units of the superblock
size, and the superblock size itself is also coded in the bitstream.
If the uncompressed header signals the use of 64x64 superblocks,
then the tile width/height fields are 6 bits wide and are in units
of 64 pixels. If the uncompressed header signals the use of 128x128
superblocks, then the tile width/height fields are 5 bits wide and
are in units of 128 pixels.
The above is a summary of the bitstream. The user interface to vpxenc
(and the equivalent encoder API) behaves a follows:
If --enable-ext-tile is OFF:
No change in the user interface. --tile-columns and --tile-rows
specify the base 2 logarithm of the desired number of tile columns
and tile rows. The actual number of tile rows and tile columns,
and the particular tile width and tile height are computed by the
codec ensuring all of the above constraints are respected.
If --enable-ext-tile is ON, but --enable-ext-partition is OFF:
No change in the user interface. --tile-columns and --tile-rows
specify the WIDTH and HEIGHT of the tiles in unit of 64 pixels.
The valid values are in the range [1, 64] (which corresponds to
[64, 4096] pixels in increments of 64.
If both --enable-ext-tile is ON and --enable-ext-partition is ON:
If --sb-size=64 (default):
The user interface is the same as in the previous point.
--tile-columns and --tile-rows specify tile WIDTH and HEIGHT,
in units of 64 pixels, in the range [1, 64] (which corresponds
to [64, 4096] pixels in increments of 64).
If --sb-size=128 or --sb-size=dynamic:
--tile-columns and --tile-rows specify tile WIDTH and HEIGHT,
in units of 128 pixels in the range [1, 32] (which corresponds
to [128, 4096] pixels in increments of 128).
Change-Id: Idc9beee1ad12ff1634e83671985d14c680f9179a
2016-03-24 16:56:05 +03:00
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
#define IS_POWER_OF_TWO(x) (((x) & ((x)-1)) == 0)
|
2016-05-20 18:33:12 +03:00
|
|
|
|
2016-02-12 19:04:35 +03:00
|
|
|
// 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__
|
2016-08-09 08:59:08 +03:00
|
|
|
#define LIKELY(v) __builtin_expect(v, 1)
|
|
|
|
#define UNLIKELY(v) __builtin_expect(v, 0)
|
2016-02-12 19:04:35 +03:00
|
|
|
#else
|
2016-08-09 08:59:08 +03:00
|
|
|
#define LIKELY(v) (v)
|
|
|
|
#define UNLIKELY(v) (v)
|
2016-02-12 19:04:35 +03:00
|
|
|
#endif
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
#define AOM_SWAP(type, a, b) \
|
2016-07-15 20:32:04 +03:00
|
|
|
do { \
|
|
|
|
type c = (b); \
|
|
|
|
b = a; \
|
|
|
|
a = c; \
|
|
|
|
} while (0)
|
|
|
|
|
2016-08-11 19:39:47 +03:00
|
|
|
#if CONFIG_AOM_QM
|
|
|
|
typedef uint16_t qm_val_t;
|
|
|
|
#define AOM_QM_BITS 6
|
|
|
|
#endif
|
2016-08-31 00:01:10 +03:00
|
|
|
#if CONFIG_AOM_HIGHBITDEPTH
|
2015-07-17 22:05:42 +03:00
|
|
|
// 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;
|
2016-08-31 00:01:10 +03:00
|
|
|
#endif // CONFIG_AOM_HIGHBITDEPTH
|
2015-07-17 22:05:42 +03:00
|
|
|
|
2015-07-15 23:02:01 +03:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
#if CONFIG_AOM_HIGHBITDEPTH
|
2015-07-20 01:02:56 +03:00
|
|
|
static INLINE uint16_t clip_pixel_highbd(int val, int bd) {
|
|
|
|
switch (bd) {
|
|
|
|
case 8:
|
2016-08-09 08:59:08 +03:00
|
|
|
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);
|
2015-07-20 01:02:56 +03:00
|
|
|
}
|
|
|
|
}
|
2016-08-31 00:01:10 +03:00
|
|
|
#endif // CONFIG_AOM_HIGHBITDEPTH
|
2015-07-20 01:02:56 +03:00
|
|
|
|
2015-07-15 23:02:01 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
#endif // AOM_DSP_AOM_DSP_COMMON_H_
|