update libaom to rev 1f0a4746aa8bfcce3fe7fbd2092aef8fe247aef4 (without moz.build and aom_ports/aom_once.h)

This commit is contained in:
Roy Tam 2019-10-30 15:19:33 +08:00
commit 4f8655fb73
505 changed files with 50582 additions and 27164 deletions

View file

@ -1,13 +1,11 @@
# Generated with cmake-format 0.3.6
# Generated with cmake-format 0.5.1
# How wide to allow formatted cmake files
line_width = 80
# How many spaces to tab for indent
tab_size = 2
# If arglists are longer than this, break them always. This introduces some
# interesting effects with complicated 'if' statements. However, we want file
# lists to look reasonable. Try to strike a balance.
# If arglists are longer than this, break them always
max_subargs_per_line = 10
# If true, separate flow control names from their parentheses with a space
@ -21,10 +19,10 @@ separate_fn_name_with_space = False
dangle_parens = False
# What character to use for bulleted lists
bullet_char = u'*'
bullet_char = '*'
# What character to use as punctuation after numerals in an enumerated list
enum_char = u'.'
enum_char = '.'
# What style line endings to use in the output.
line_ending = u'unix'
@ -32,6 +30,9 @@ line_ending = u'unix'
# Format command names consistently as 'lower' or 'upper' case
command_case = u'lower'
# Format keywords consistently as 'lower' or 'upper' case
keyword_case = u'unchanged'
# Specify structure for custom cmake functions
additional_commands = {
"foo": {
@ -46,3 +47,56 @@ additional_commands = {
}
}
}
# A list of command names which should always be wrapped
always_wrap = []
# Specify the order of wrapping algorithms during successive reflow attempts
algorithm_order = [0, 1, 2, 3, 4]
# If true, the argument lists which are known to be sortable will be sorted
# lexicographicall
autosort = False
# enable comment markup parsing and reflow
enable_markup = True
# If comment markup is enabled, don't reflow the first comment block in
# eachlistfile. Use this to preserve formatting of your
# copyright/licensestatements.
first_comment_is_literal = False
# If comment markup is enabled, don't reflow any comment block which matchesthis
# (regex) pattern. Default is `None` (disabled).
literal_comment_pattern = None
# Regular expression to match preformat fences in comments
# default=r'^\s*([`~]{3}[`~]*)(.*)$'
fence_pattern = u'^\\s*([`~]{3}[`~]*)(.*)$'
# Regular expression to match rulers in comments
# default=r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'
ruler_pattern = u'^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'
# If true, emit the unicode byte-order mark (BOM) at the start of the file
emit_byteorder_mark = False
# If a comment line starts with at least this many consecutive hash characters,
# then don't lstrip() them off. This allows for lazy hash rulers where the first
# hash char is not separated by space
hashruler_min_length = 10
# If true, then insert a space between the first hash char and remaining hash
# chars in a hash ruler, and normalize it's length to fill the column
canonicalize_hashrulers = True
# Specify the encoding of the input file. Defaults to utf-8.
input_encoding = u'utf-8'
# Specify the encoding of the output file. Defaults to utf-8. Note that cmake
# only claims to support utf-8 so be careful when using anything else
output_encoding = u'utf-8'
# A dictionary containing any per-command configuration overrides. Currently
# only `command_case` is supported.
per_command = {}

View file

@ -9,26 +9,27 @@
# can obtain it at www.aomedia.org/license/patent.
#
cmake_minimum_required(VERSION 3.5)
project(AOM C CXX)
if(NOT EMSCRIPTEN)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release"
CACHE "Build type: Debug, Release, RelWithDebInfo or MinSizeRel" STRING
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE
"Release"
CACHE STRING "Build type: Debug, Release, RelWithDebInfo or MinSizeRel"
FORCE)
endif()
endif()
project(AOM C CXX)
set(AOM_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
set(AOM_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
if("${AOM_ROOT}" STREQUAL "${AOM_CONFIG_DIR}")
message(FATAL_ERROR
"Building from within the aom source tree is not supported.\n"
"Hint: Run these commands\n" "$ rm -rf CMakeCache.txt CMakeFiles\n"
"$ mkdir -p ../aom_build\n" "$ cd ../aom_build\n"
"And re-run CMake from the aom_build directory.")
message(
FATAL_ERROR "Building from within the aom source tree is not supported.\n"
"Hint: Run these commands\n"
"$ rm -rf CMakeCache.txt CMakeFiles\n"
"$ mkdir -p ../aom_build\n" "$ cd ../aom_build\n"
"And re-run CMake from the aom_build directory.")
endif()
include("${AOM_ROOT}/build/cmake/aom_configure.cmake")
@ -113,6 +114,7 @@ list(APPEND AOM_SOURCES
"${AOM_ROOT}/aom/aomcx.h"
"${AOM_ROOT}/aom/aomdx.h"
"${AOM_ROOT}/aom/internal/aom_codec_internal.h"
"${AOM_ROOT}/aom/internal/aom_image_internal.h"
"${AOM_ROOT}/aom/src/aom_codec.c"
"${AOM_ROOT}/aom/src/aom_decoder.c"
"${AOM_ROOT}/aom/src/aom_encoder.c"
@ -176,15 +178,18 @@ add_custom_command(OUTPUT "${AOM_CONFIG_DIR}/config/aom_version.h"
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-DPERL_EXECUTABLE=${PERL_EXECUTABLE} -P
"${AOM_ROOT}/build/cmake/version.cmake"
COMMENT "Writing aom_version.h" VERBATIM)
COMMENT "Writing aom_version.h"
VERBATIM)
add_custom_target(aom_version_check
COMMAND ${CMAKE_COMMAND} -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
COMMAND ${CMAKE_COMMAND}
-DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
-DAOM_ROOT=${AOM_ROOT}
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-DPERL_EXECUTABLE=${PERL_EXECUTABLE} -P
"${AOM_ROOT}/build/cmake/version.cmake"
COMMENT "Updating version info if necessary." VERBATIM)
COMMENT "Updating version info if necessary."
VERBATIM)
add_dependencies(aom_version aom_version_check)
# TODO(tomfinegan): Move rtcd target setup where it belongs for each rtcd
@ -236,7 +241,7 @@ endforeach()
# other pieces of the util support without defining usage_exit().
file(WRITE "${AOM_GEN_SRC_DIR}/usage_exit.c" "void usage_exit(void) {}")
file(WRITE "${AOM_GEN_SRC_DIR}/usage_exit.cc"
"extern \"C\" void usage_exit(void) {}")
"extern \"C\" void usage_exit(void) {}")
#
# Application and application support targets.
@ -255,31 +260,31 @@ endif()
if((CONFIG_AV1_DECODER OR CONFIG_AV1_ENCODER) AND ENABLE_EXAMPLES)
add_executable(resize_util "${AOM_ROOT}/examples/resize_util.c"
$<TARGET_OBJECTS:aom_common_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>)
list(APPEND AOM_APP_TARGETS resize_util)
endif()
if(CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
add_executable(aomdec "${AOM_ROOT}/apps/aomdec.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
add_executable(decode_to_md5 "${AOM_ROOT}/examples/decode_to_md5.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
add_executable(decode_with_drops "${AOM_ROOT}/examples/decode_with_drops.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
add_executable(simple_decoder "${AOM_ROOT}/examples/simple_decoder.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
add_executable(scalable_decoder "${AOM_ROOT}/examples/scalable_decoder.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
if(CONFIG_ANALYZER)
add_executable(analyzer "${AOM_ROOT}/examples/analyzer.cc"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
target_link_libraries(analyzer ${AOM_LIB_LINK_TYPE} ${wxWidgets_LIBRARIES})
list(APPEND AOM_APP_TARGETS analyzer)
list(APPEND AOM_DECODER_EXAMPLE_TARGETS analyzer)
@ -287,8 +292,8 @@ if(CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
if(CONFIG_INSPECTION)
add_executable(inspect "${AOM_ROOT}/examples/inspect.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
list(APPEND AOM_DECODER_EXAMPLE_TARGETS inspect)
if(EMSCRIPTEN)
@ -315,8 +320,8 @@ if(CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
endif()
# Maintain a list of decoder example targets.
list(APPEND AOM_DECODER_EXAMPLE_TARGETS aomdec decode_to_md5
decode_with_drops scalable_decoder simple_decoder)
list(APPEND AOM_DECODER_EXAMPLE_TARGETS aomdec decode_to_md5 decode_with_drops
scalable_decoder simple_decoder)
# Add decoder examples to the app targets list.
list(APPEND AOM_APP_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS})
@ -325,31 +330,36 @@ endif()
if(CONFIG_AV1_ENCODER)
if(ENABLE_EXAMPLES)
add_executable(aomenc "${AOM_ROOT}/apps/aomenc.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>
$<TARGET_OBJECTS:aom_encoder_stats>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>
$<TARGET_OBJECTS:aom_encoder_stats>)
add_executable(lossless_encoder "${AOM_ROOT}/examples/lossless_encoder.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
add_executable(set_maps "${AOM_ROOT}/examples/set_maps.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
add_executable(simple_encoder "${AOM_ROOT}/examples/simple_encoder.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
add_executable(twopass_encoder "${AOM_ROOT}/examples/twopass_encoder.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
add_executable(noise_model "${AOM_ROOT}/examples/noise_model.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
add_executable(scalable_encoder "${AOM_ROOT}/examples/scalable_encoder.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
add_executable(svc_encoder_rtc "${AOM_ROOT}/examples/svc_encoder_rtc.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
# Maintain a list of encoder example targets.
list(APPEND AOM_ENCODER_EXAMPLE_TARGETS aomenc lossless_encoder noise_model
set_maps simple_encoder scalable_encoder twopass_encoder)
set_maps simple_encoder scalable_encoder twopass_encoder
svc_encoder_rtc)
endif()
if(ENABLE_TOOLS)
@ -358,7 +368,8 @@ if(CONFIG_AV1_ENCODER)
# TODO(tomfinegan): Sort out why a simple link command with
# aom_entropy_optimizer.c won't work on macos, but dragging in all the
# helper machinery allows the link to succeed.
add_executable(aom_entropy_optimizer "${AOM_GEN_SRC_DIR}/usage_exit.c"
add_executable(aom_entropy_optimizer
"${AOM_GEN_SRC_DIR}/usage_exit.c"
"${AOM_ROOT}/tools/aom_entropy_optimizer.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
@ -385,11 +396,11 @@ endif()
if(ENABLE_TOOLS)
if(CONFIG_AV1_DECODER)
add_executable(dump_obu "${AOM_GEN_SRC_DIR}/usage_exit.cc"
"${AOM_ROOT}/tools/dump_obu.cc"
"${AOM_ROOT}/tools/obu_parser.cc"
"${AOM_ROOT}/tools/obu_parser.h"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
"${AOM_ROOT}/tools/dump_obu.cc"
"${AOM_ROOT}/tools/obu_parser.cc"
"${AOM_ROOT}/tools/obu_parser.h"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
list(APPEND AOM_TOOL_TARGETS dump_obu)
list(APPEND AOM_APP_TARGETS dump_obu)
@ -404,16 +415,16 @@ endif()
if(ENABLE_EXAMPLES AND CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
add_executable(aom_cx_set_ref "${AOM_ROOT}/examples/aom_cx_set_ref.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
list(APPEND AOM_EXAMPLE_TARGETS aom_cx_set_ref)
list(APPEND AOM_APP_TARGETS aom_cx_set_ref)
endif()
if(ENABLE_EXAMPLES AND CONFIG_AV1_ENCODER)
add_executable(lightfield_encoder "${AOM_ROOT}/examples/lightfield_encoder.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
list(APPEND AOM_EXAMPLE_TARGETS lightfield_encoder)
list(APPEND AOM_APP_TARGETS lightfield_encoder)
endif()
@ -429,8 +440,8 @@ endif()
if(ENABLE_EXAMPLES AND CONFIG_AV1_DECODER)
add_executable(lightfield_decoder "${AOM_ROOT}/examples/lightfield_decoder.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
list(APPEND AOM_EXAMPLE_TARGETS lightfield_decoder)
list(APPEND AOM_APP_TARGETS lightfield_decoder)
endif()
@ -591,7 +602,8 @@ if(NOT AOM_DIST_DIR)
endif()
add_custom_target(dist
COMMAND ${CMAKE_COMMAND} -DAOM_ROOT=${AOM_ROOT}
COMMAND ${CMAKE_COMMAND}
-DAOM_ROOT=${AOM_ROOT}
-DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
-DAOM_DIST_DIR=${AOM_DIST_DIR}
-DAOM_DIST_APPS="${AOM_DIST_APPS}"
@ -612,8 +624,8 @@ endif()
# Collect all variables containing libaom source files.
get_cmake_property(all_cmake_vars VARIABLES)
foreach(var ${all_cmake_vars})
if("${var}" MATCHES "SOURCES$\|_INTRIN_\|_ASM_" AND NOT "${var}" MATCHES
"_APP_\|DOXYGEN\|LIBWEBM\|LIBYUV\|_PKG_\|TEST")
if("${var}" MATCHES "SOURCES$\|_INTRIN_\|_ASM_"
AND NOT "${var}" MATCHES "_APP_\|DOXYGEN\|LIBWEBM\|LIBYUV\|_PKG_\|TEST")
list(APPEND aom_source_vars ${var})
endif()
endforeach()
@ -632,9 +644,8 @@ foreach(aom_source_var ${aom_source_vars})
endforeach()
endforeach()
file(APPEND
"${libaom_srcs_txt_file}"
"# Files below this line are generated by the libaom build system.\n")
file(APPEND "${libaom_srcs_txt_file}"
"# Files below this line are generated by the libaom build system.\n")
foreach(aom_source_var ${aom_source_vars})
foreach(file ${${aom_source_var}})
if("${file}" MATCHES "${AOM_CONFIG_DIR}")
@ -667,15 +678,14 @@ foreach(aom_source_var ${aom_source_vars})
endif()
endforeach()
file(APPEND
"${libaom_srcs_gni_file}"
"\n# Files below this line are generated by the libaom build system.\n")
file(APPEND "${libaom_srcs_gni_file}"
"\n# Files below this line are generated by the libaom build system.\n")
foreach(aom_source_var ${aom_source_vars})
if("${${aom_source_var}}" MATCHES "${AOM_CONFIG_DIR}")
string(TOLOWER ${aom_source_var} aom_source_var_lowercase)
file(APPEND "${libaom_srcs_gni_file}"
"\n${aom_source_var_lowercase}_gen = [\n")
"\n${aom_source_var_lowercase}_gen = [\n")
endif()
foreach(file ${${aom_source_var}})
if(NOT "${file}" MATCHES "${AOM_ROOT}")

View file

@ -503,19 +503,6 @@ typedef enum {
*/
const char *aom_obu_type_to_string(OBU_TYPE type);
/*!\brief Config Options
*
* This type allows to enumerate and control options defined for control
* via config file at runtime.
*/
typedef struct cfg_options {
/*!\brief Reflects if ext_partition should be enabled
*
* If this value is non-zero it enabled the feature
*/
unsigned int ext_partition;
} cfg_options_t;
/*!@} - end defgroup codec*/
#ifdef __cplusplus
}

View file

@ -42,7 +42,7 @@ extern "C" {
* fields to structures
*/
#define AOM_DECODER_ABI_VERSION \
(3 + AOM_CODEC_ABI_VERSION) /**<\hideinitializer*/
(4 + AOM_CODEC_ABI_VERSION) /**<\hideinitializer*/
/*! \brief Decoder capabilities bitfield
*
@ -98,7 +98,6 @@ typedef struct aom_codec_dec_cfg {
unsigned int w; /**< Width */
unsigned int h; /**< Height */
unsigned int allow_lowbitdepth; /**< Allow use of low-bitdepth coding path */
cfg_options_t cfg; /**< Options defined per config attributes */
} aom_codec_dec_cfg_t; /**< alias for struct aom_codec_dec_cfg */
/*!\brief Initialize a decoder instance

View file

@ -41,7 +41,7 @@ extern "C" {
* fields to structures
*/
#define AOM_ENCODER_ABI_VERSION \
(5 + AOM_CODEC_ABI_VERSION) /**<\hideinitializer*/
(6 + AOM_CODEC_ABI_VERSION) /**<\hideinitializer*/
/*! \brief Encoder capabilities bitfield
*
@ -74,7 +74,7 @@ extern "C" {
* This structure is able to hold a reference to any fixed size buffer.
*/
typedef struct aom_fixed_buf {
void *buf; /**< Pointer to the data */
void *buf; /**< Pointer to the data. Does NOT own the data! */
size_t sz; /**< Length of the buffer, in chars */
} aom_fixed_buf_t; /**< alias for struct aom_fixed_buf */
@ -723,11 +723,6 @@ typedef struct aom_codec_enc_cfg {
* The number of heights specified is given by tile_height_count
*/
int tile_heights[MAX_TILE_HEIGHTS];
/*!\brief Options defined per config file
*
*/
cfg_options_t cfg;
} aom_codec_enc_cfg_t; /**< alias for struct aom_codec_enc_cfg */
/*!\brief Initialize an encoder instance

View file

@ -30,7 +30,7 @@ extern "C" {
* types, removing or reassigning enums, adding/removing/rearranging
* fields to structures
*/
#define AOM_IMAGE_ABI_VERSION (5) /**<\hideinitializer*/
#define AOM_IMAGE_ABI_VERSION (6) /**<\hideinitializer*/
#define AOM_IMG_FMT_PLANAR 0x100 /**< Image is a planar format. */
#define AOM_IMG_FMT_UV_FLIP 0x200 /**< V plane precedes U in memory. */
@ -137,6 +137,16 @@ typedef enum aom_chroma_sample_position {
AOM_CSP_RESERVED = 3 /**< Reserved value */
} aom_chroma_sample_position_t; /**< alias for enum aom_transfer_function */
/*!\brief Array of aom_metadata structs for an image. */
typedef struct aom_metadata_array aom_metadata_array_t;
/*!\brief Metadata payload. */
typedef struct aom_metadata {
uint8_t type; /**< Metadata type */
uint8_t *payload; /**< Metadata payload data */
size_t sz; /**< Metadata payload size */
} aom_metadata_t;
/**\brief Image Descriptor */
typedef struct aom_image {
aom_img_fmt_t fmt; /**< Image Format */
@ -188,6 +198,9 @@ typedef struct aom_image {
int img_data_owner; /**< private */
int self_allocd; /**< private */
aom_metadata_array_t
*metadata; /**< Metadata payloads associated with the image. */
void *fb_priv; /**< Frame buffer data associated with the image. */
} aom_image_t; /**< alias for struct aom_image */
@ -202,7 +215,7 @@ typedef struct aom_image_rect {
/*!\brief Open a descriptor, allocating storage for the underlying image
*
* Returns a descriptor for storing an image of the given format. The
* storage for the descriptor is allocated on the heap.
* storage for the image is allocated on the heap.
*
* \param[in] img Pointer to storage for descriptor. If this parameter
* is NULL, the storage for the descriptor will be
@ -211,7 +224,7 @@ typedef struct aom_image_rect {
* \param[in] d_w Width of the image
* \param[in] d_h Height of the image
* \param[in] align Alignment, in bytes, of the image buffer and
* each row in the image(stride).
* each row in the image (stride).
*
* \return Returns a pointer to the initialized image descriptor. If the img
* parameter is non-null, the value of the img parameter will be
@ -224,7 +237,7 @@ aom_image_t *aom_img_alloc(aom_image_t *img, aom_img_fmt_t fmt,
/*!\brief Open a descriptor, using existing storage for the underlying image
*
* Returns a descriptor for storing an image of the given format. The
* storage for descriptor has been allocated elsewhere, and a descriptor is
* storage for the image has been allocated elsewhere, and a descriptor is
* desired to "wrap" that storage.
*
* \param[in] img Pointer to storage for descriptor. If this parameter
@ -233,7 +246,8 @@ aom_image_t *aom_img_alloc(aom_image_t *img, aom_img_fmt_t fmt,
* \param[in] fmt Format for the image
* \param[in] d_w Width of the image
* \param[in] d_h Height of the image
* \param[in] align Alignment, in bytes, of each row in the image.
* \param[in] align Alignment, in bytes, of each row in the image
* (stride).
* \param[in] img_data Storage to use for the image
*
* \return Returns a pointer to the initialized image descriptor. If the img
@ -248,7 +262,7 @@ aom_image_t *aom_img_wrap(aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w,
* border
*
* Returns a descriptor for storing an image of the given format and its
* borders. The storage for the descriptor is allocated on the heap.
* borders. The storage for the image is allocated on the heap.
*
* \param[in] img Pointer to storage for descriptor. If this parameter
* is NULL, the storage for the descriptor will be
@ -257,8 +271,8 @@ aom_image_t *aom_img_wrap(aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w,
* \param[in] d_w Width of the image
* \param[in] d_h Height of the image
* \param[in] align Alignment, in bytes, of the image buffer and
* each row in the image(stride).
* \param[in] size_align Alignment, in bytes, of the image width and height.
* each row in the image (stride).
* \param[in] size_align Alignment, in pixels, of the image width and height.
* \param[in] border A border that is padded on four sides of the image.
*
* \return Returns a pointer to the initialized image descriptor. If the img
@ -323,6 +337,52 @@ int aom_img_plane_width(const aom_image_t *img, int plane);
*/
int aom_img_plane_height(const aom_image_t *img, int plane);
/*!\brief Add metadata to image.
*
* Adds metadata to aom_image_t.
* Function makes a copy of the provided data parameter.
*
* \param[in] img Image descriptor
* \param[in] type Metadata type
* \param[in] data Metadata contents
* \param[in] sz Metadata contents size
*/
int aom_img_add_metadata(aom_image_t *img, uint8_t type, uint8_t *data,
size_t sz);
/*!\brief Remove metadata from image.
*
* Removes all metadata in image metadata list and sets metadata list pointer
* to NULL.
* Returns the number of deleted metadata structs.
*
* \param[in] img Image descriptor
*/
size_t aom_img_remove_metadata(aom_image_t *img);
/*!\brief Allocate memory for aom_metadata struct.
*
* Allocates memory for aom_metadata struct and sets its type. Optionally
* allocates storage for the metadata payload and copies the payload data
* into the aom_metadata struct:
* - When sz is > 0 and data is NULL, allocates metadata payload buffer of sz.
* - When sz is > 0 and data is non-NULL, a metadata payload buffer of sz
* is allocated and sz bytes are copied from data into the payload buffer.
*
* \param[in] type Metadata type
* \param[in] data Metadata data pointer
* \param[in] sz Metadata size
*/
aom_metadata_t *aom_img_metadata_alloc(uint8_t type, uint8_t *data, size_t sz);
/*!\brief Free metadata struct.
*
* Free metadata struct and its buffer.
*
* \param[in] metadata Metadata struct pointer
*/
int aom_img_metadata_free(aom_metadata_t *metadata);
#ifdef __cplusplus
} // extern "C"
#endif

View file

@ -173,9 +173,9 @@ enum aome_enc_control_id {
/*!\brief Codec control function to set encoder internal speed settings.
*
* Changes in this value influences, among others, the encoder's selection
* of motion estimation methods. Values greater than 0 will increase encoder
* speed at the expense of quality.
* Changes in this value influences the complexity of algorithms used in
* encoding process, values greater than 0 will increase encoder speed at
* the expense of quality.
*
* \note Valid range: 0..8
*/
@ -218,10 +218,10 @@ enum aome_enc_control_id {
*/
AOME_SET_TUNING = AOME_SET_ARNR_STRENGTH + 2,
/*!\brief Codec control function to set constrained quality level.
/*!\brief Codec control function to set constrained / constant quality level.
*
* \attention For this value to be used aom_codec_enc_cfg_t::rc_end_usage
* must be set to #AOM_CQ.
* must be set to #AOM_CQ or #AOM_Q.
* \note Valid range: 0..63
*/
AOME_SET_CQ_LEVEL,
@ -328,6 +328,12 @@ enum aome_enc_control_id {
*/
AV1E_SET_ENABLE_TPL_MODEL,
/*!\brief Codec control function to enable temporal filtering on key frame.
*
* By default, this feature is on.
*/
AV1E_SET_ENABLE_KEYFRAME_FILTERING,
/*!\brief Codec control function to enable frame parallel decoding feature.
*
* AV1 has a bitstream feature to reduce decoding dependency between frames
@ -518,8 +524,8 @@ enum aome_enc_control_id {
* 4 digits).
* AB: OP index.
* xy: Target level index for the OP. Can be values 0~23(corresponding to
* level 2.0 ~ 7.3) or 31(maximum level parameter, no level-based
* constraints).
* level 2.0 ~ 7.3) or 24(keep level stats only for level monitoring) or
* 31(maximum level parameter, no level-based constraints).
* E.g. "0" means target level index 0 for the 0th OP;
* "111" means target level index 11 for the 1st OP;
* "1021" means target level index 21 for the 10th OP.
@ -528,7 +534,9 @@ enum aome_enc_control_id {
*/
AV1E_SET_TARGET_SEQ_LEVEL_IDX,
/*!\brief Codec control function to get sequence level index.
/*!\brief Codec control function to get sequence level index for each
* operating point. There can be at most 32 operating points. The results will
* be written into a provided integer array of sufficient size.
*/
AV1E_GET_SEQ_LEVEL_IDX,
@ -570,6 +578,16 @@ enum aome_enc_control_id {
*/
AV1E_SET_ENABLE_RESTORATION,
/*!\brief Codec control function to force video mode
*
* 0 = do not force video mode
* 1 = force video mode even for a single frame
*
* By default, the encoder does not force video and allows still picture.
*
*/
AV1E_SET_FORCE_VIDEO_MODE,
/*!\brief Codec control function to predict with OBMC mode.
*
* 0 = do not allow OBMC mode
@ -851,6 +869,15 @@ enum aome_enc_control_id {
*/
AV1E_SET_ENABLE_DUAL_FILTER,
/*!\brief Codec control function to turn on / off delta quantization in chroma
* planes usage for a sequence.
*
* This will enable or disable use of chroma deltaq.
* The default value is 0.
*
*/
AV1E_SET_ENABLE_CHROMA_DELTAQ,
/*!\brief Codec control function to turn on / off masked compound usage
* for a sequence.
*
@ -979,6 +1006,16 @@ enum aome_enc_control_id {
*/
AV1E_SET_ENABLE_SUPERRES,
/*!\brief Codec control function to turn on / off overlay frames for
* fitlered ALTREF frames.
*
* This will enable or disable coding of overlay frames for filtered ALTREF
* frames. When set to 0, overlay frames are not used but show existing frame
* is used to display the filtered ALTREF frame as is. As a result the decoded
* frame rate remains the same as the display frame rate. The default is 1.
*/
AV1E_SET_ENABLE_OVERLAY,
/*!\brief Codec control function to turn on/off palette mode */
AV1E_SET_ENABLE_PALETTE,
@ -1095,11 +1132,39 @@ enum aome_enc_control_id {
*/
AV1E_SET_MODE_COST_UPD_FREQ,
/*!\brief Control to set frequency of the cost updates for motion vectors
* Possible values are:
* 0: Update at SB level (default)
* 1: Update at SB row level in tile
* 2: Update at tile level
*/
AV1E_SET_MV_COST_UPD_FREQ,
/*!\brief Control to set bit mask that specifies which tier each of the 32
* possible operating points conforms to.
* Bit value 0: Main Tier; 1: High Tier.
*/
AV1E_SET_TIER_MASK,
/*!\brief Control to set minimum compression ratio.
* Take integer values. If non-zero, encoder will try to keep the compression
* ratio of each frame to be higher than the given value divided by 100.
* E.g. 850 means minimum compression ratio of 8.5.
*/
AV1E_SET_MIN_CR,
/*!\brief Codec control function to set the layer id.
*/
AV1E_SET_SVC_LAYER_ID = 150,
/*!\brief Codec control function to set SVC paramaeters.
*/
AV1E_SET_SVC_PARAMS = 151,
/*!\brief Codec control function to set reference frame config:
* the ref_idx and the refresh flags for each buffer slot.
*/
AV1E_SET_SVC_REF_FRAME_CONFIG = 152
};
/*!\brief aom 1-D scaling mode
@ -1189,6 +1254,39 @@ typedef enum {
AOM_TUNE_DAALA_DIST
} aom_tune_metric;
#define AOM_MAX_LAYERS 32 /**< Max number of layers */
#define AOM_MAX_SS_LAYERS 4 /**< Max number of spatial layers */
#define AOM_MAX_TS_LAYERS 8 /**< Max number of temporal layers */
/*!brief Struct for spatial and temporal layer ID */
typedef struct aom_svc_layer_id {
int spatial_layer_id; /**< Spatial layer ID */
int temporal_layer_id; /**< Temporal layer ID */
} aom_svc_layer_id_t;
/*!brief Parameter type for SVC */
typedef struct aom_svc_params {
int number_spatial_layers; /**< Number of spatial layers */
int number_temporal_layers; /**< Number of temporal layers */
int max_quantizers[AOM_MAX_LAYERS]; /**< Max Q for each layer */
int min_quantizers[AOM_MAX_LAYERS]; /**< Min Q for each layer */
int scaling_factor_num[AOM_MAX_SS_LAYERS]; /**< Scaling factor-numerator */
int scaling_factor_den[AOM_MAX_SS_LAYERS]; /**< Scaling factor-denominator */
/*! Target bitrate for each layer */
int layer_target_bitrate[AOM_MAX_LAYERS];
/*! Frame rate factor for each temporal layer */
int framerate_factor[AOM_MAX_TS_LAYERS];
} aom_svc_params_t;
/*!brief Parameters for setting ref frame config */
typedef struct aom_svc_ref_frame_config {
// 7 references: LAST_FRAME (0), LAST2_FRAME(1), LAST3_FRAME(2),
// GOLDEN_FRAME(3), BWDREF_FRAME(4), ALTREF2_FRAME(5), ALTREF_FRAME(6).
/*! Buffer slot index for each of 7 references. */
int ref_idx[7];
int refresh[8]; /**< Refresh flag for each of the 8 slots. */
} aom_svc_ref_frame_config_t;
/*!\cond */
/*!\brief Encoder control function parameter type
*
@ -1242,6 +1340,9 @@ AOM_CTRL_USE_TYPE(AV1E_SET_TILE_ROWS, unsigned int)
AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_TPL_MODEL, unsigned int)
#define AOM_CTRL_AV1E_SET_ENABLE_TPL_MODEL
AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_KEYFRAME_FILTERING, unsigned int)
#define AOM_CTRL_AV1E_SET_ENABLE_KEYFRAME_FILTERING
AOM_CTRL_USE_TYPE(AOME_GET_LAST_QUANTIZER, int *)
#define AOM_CTRL_AOME_GET_LAST_QUANTIZER
AOM_CTRL_USE_TYPE(AOME_GET_LAST_QUANTIZER_64, int *)
@ -1267,6 +1368,9 @@ AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_CDEF, unsigned int)
AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_RESTORATION, unsigned int)
#define AOM_CTRL_AV1E_SET_ENABLE_RESTORATION
AOM_CTRL_USE_TYPE(AV1E_SET_FORCE_VIDEO_MODE, unsigned int)
#define AOM_CTRL_AV1E_SET_FORCE_VIDEO_MODE
AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_OBMC, unsigned int)
#define AOM_CTRL_AV1E_SET_ENABLE_OBMC
@ -1344,6 +1448,9 @@ AOM_CTRL_USE_TYPE(AV1E_SET_ALLOW_REF_FRAME_MVS, int)
AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_DUAL_FILTER, int)
#define AOM_CTRL_AV1E_SET_ENABLE_DUAL_FILTER
AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_CHROMA_DELTAQ, int)
#define AOM_CTRL_AV1E_SET_ENABLE_CHROMA_DELTAQ
AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_MASKED_COMP, int)
#define AOM_CTRL_AV1E_SET_ENABLE_MASKED_COMP
@ -1389,6 +1496,9 @@ AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_CFL_INTRA, int)
AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_SUPERRES, int)
#define AOM_CTRL_AV1E_SET_ENABLE_SUPERRES
AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_OVERLAY, int)
#define AOM_CTRL_AV1E_SET_ENABLE_OVERLAY
AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_PALETTE, int)
#define AOM_CTRL_AV1E_SET_ENABLE_PALETTE
@ -1473,13 +1583,11 @@ AOM_CTRL_USE_TYPE(AV1E_SET_FILM_GRAIN_TABLE, const char *)
AOM_CTRL_USE_TYPE(AV1E_SET_CDF_UPDATE_MODE, unsigned int)
#define AOM_CTRL_AV1E_SET_CDF_UPDATE_MODE
#ifdef CONFIG_DENOISE
AOM_CTRL_USE_TYPE(AV1E_SET_DENOISE_NOISE_LEVEL, int);
#define AOM_CTRL_AV1E_SET_DENOISE_NOISE_LEVEL
AOM_CTRL_USE_TYPE(AV1E_SET_DENOISE_BLOCK_SIZE, unsigned int);
#define AOM_CTRL_AV1E_SET_DENOISE_BLOCK_SIZE
#endif
AOM_CTRL_USE_TYPE(AV1E_SET_CHROMA_SUBSAMPLING_X, unsigned int)
#define AOM_CTRL_AV1E_SET_CHROMA_SUBSAMPLING_X
@ -1517,12 +1625,27 @@ AOM_CTRL_USE_TYPE(AV1E_SET_COEFF_COST_UPD_FREQ, unsigned int)
AOM_CTRL_USE_TYPE(AV1E_SET_MODE_COST_UPD_FREQ, unsigned int)
#define AOM_CTRL_AV1E_SET_MODE_COST_UPD_FREQ
AOM_CTRL_USE_TYPE(AV1E_SET_MV_COST_UPD_FREQ, unsigned int)
#define AOM_CTRL_AV1E_SET_MV_COST_UPD_FREQ
AOM_CTRL_USE_TYPE(AV1E_SET_TARGET_SEQ_LEVEL_IDX, int)
#define AOM_CTRL_AV1E_SET_TARGET_SEQ_LEVEL_IDX
AOM_CTRL_USE_TYPE(AV1E_SET_TIER_MASK, unsigned int)
#define AOM_CTRL_AV1E_SET_TIER_MASK
AOM_CTRL_USE_TYPE(AV1E_SET_MIN_CR, unsigned int)
#define AOM_CTRL_AV1E_SET_MIN_CR
AOM_CTRL_USE_TYPE(AV1E_SET_SVC_LAYER_ID, aom_svc_layer_id_t *)
#define AOME_CTRL_AV1E_SET_SVC_LAYER_ID
AOM_CTRL_USE_TYPE(AV1E_SET_SVC_PARAMS, aom_svc_params_t *)
#define AOME_CTRL_AV1E_SET_SVC_PARAMS
AOM_CTRL_USE_TYPE(AV1E_SET_SVC_REF_FRAME_CONFIG, aom_svc_ref_frame_config_t *)
#define AOME_CTRL_AV1E_SET_SVC_REF_FRAME_CONFIG
/*!\endcond */
/*! @} - end defgroup aom_encoder */
#ifdef __cplusplus

View file

@ -10,12 +10,18 @@ text aom_codec_version
text aom_codec_version_extra_str
text aom_codec_version_str
text aom_free
text aom_img_add_metadata
text aom_img_alloc
text aom_img_alloc_with_border
text aom_img_flip
text aom_img_free
text aom_img_metadata_array_free
text aom_img_metadata_array_alloc
text aom_img_metadata_free
text aom_img_metadata_alloc
text aom_img_plane_height
text aom_img_plane_width
text aom_img_remove_metadata
text aom_img_set_rect
text aom_img_wrap
text aom_malloc

View file

@ -1,2 +1,4 @@
text aom_copy_metadata_to_frame_buffer
text aom_dsp_rtcd
text aom_remove_metadata_from_frame_buffer
text aom_scale_rtcd

View file

@ -0,0 +1,94 @@
/*
* Copyright (c) 2019, 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.
*/
/*!\file
* \brief Describes the internal functions associated with the aom image
* descriptor.
*
*/
#ifndef AOM_AOM_INTERNAL_AOM_IMAGE_INTERNAL_H_
#define AOM_AOM_INTERNAL_AOM_IMAGE_INTERNAL_H_
#include "aom/aom_image.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!\brief Array of aom_metadata structs for an image. */
struct aom_metadata_array {
size_t sz; /* Number of metadata structs in the list */
aom_metadata_t **metadata_array; /* Array of metadata structs */
};
/*!\brief Alloc memory for aom_metadata_array struct.
*
* Allocate memory for aom_metadata_array struct.
* If sz is 0 the aom_metadata_array structs internal buffer list will be NULL,
* but the aom_metadata_array struct itself will still be allocated.
* Returns a pointer to the allocated struct or NULL on failure.
*
* \param[in] sz Size of internal metadata list buffer
*/
aom_metadata_array_t *aom_img_metadata_array_alloc(size_t sz);
/*!\brief Free metadata array struct.
*
* Free metadata array struct and all metadata structs inside.
* Returns the number of deleted metadata structs.
*
* \param[in] arr Metadata array struct pointer
*/
size_t aom_img_metadata_array_free(aom_metadata_array_t *arr);
typedef void *(*aom_alloc_img_data_cb_fn_t)(void *priv, size_t size);
/*!\brief Open a descriptor, allocating storage for the underlying image by
* using the provided callback function.
*
* Returns a descriptor for storing an image of the given format. The storage
* for the image is allocated by using the provided callback function. Unlike
* aom_img_alloc(), the returned descriptor does not own the storage for the
* image. The caller is responsible for freeing the storage for the image.
*
* Note: If the callback function is invoked and succeeds,
* aom_img_alloc_with_cb() is guaranteed to succeed. Therefore, if
* aom_img_alloc_with_cb() fails, the caller is assured that no storage was
* allocated.
*
* \param[in] img Pointer to storage for descriptor. If this parameter
* is NULL, the storage for the descriptor will be
* allocated on the heap.
* \param[in] fmt Format for the image
* \param[in] d_w Width of the image
* \param[in] d_h Height of the image
* \param[in] align Alignment, in bytes, of the image buffer and
* each row in the image (stride).
* \param[in] alloc_cb Callback function used to allocate storage for the
* image.
* \param[in] cb_priv The first argument ('priv') for the callback
* function.
*
* \return Returns a pointer to the initialized image descriptor. If the img
* parameter is non-null, the value of the img parameter will be
* returned.
*/
aom_image_t *aom_img_alloc_with_cb(aom_image_t *img, aom_img_fmt_t fmt,
unsigned int d_w, unsigned int d_h,
unsigned int align,
aom_alloc_img_data_cb_fn_t alloc_cb,
void *cb_priv);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // AOM_AOM_INTERNAL_AOM_IMAGE_INTERNAL_H_

View file

@ -144,12 +144,12 @@ aom_codec_err_t aom_codec_enc_init_multi_ver(
aom_codec_err_t aom_codec_enc_config_default(aom_codec_iface_t *iface,
aom_codec_enc_cfg_t *cfg,
unsigned int usage) {
unsigned int reserved) {
aom_codec_err_t res;
aom_codec_enc_cfg_map_t *map;
int i;
if (!iface || !cfg || usage > INT_MAX)
if (!iface || !cfg || reserved > INT_MAX)
res = AOM_CODEC_INVALID_PARAM;
else if (!(iface->caps & AOM_CODEC_CAP_ENCODER))
res = AOM_CODEC_INCAPABLE;
@ -158,20 +158,15 @@ aom_codec_err_t aom_codec_enc_config_default(aom_codec_iface_t *iface,
for (i = 0; i < iface->enc.cfg_map_count; ++i) {
map = iface->enc.cfg_maps + i;
if (map->usage == (int)usage) {
if (map->usage == (int)reserved) {
*cfg = map->cfg;
cfg->g_usage = usage;
cfg->g_usage = reserved;
res = AOM_CODEC_OK;
break;
}
}
}
/* default values */
if (cfg) {
cfg->cfg.ext_partition = 1;
}
return res;
}
@ -190,8 +185,11 @@ aom_codec_err_t aom_codec_enc_config_default(aom_codec_iface_t *iface,
#if HAVE_FEXCEPT && CONFIG_DEBUG
#define FLOATING_POINT_SET_EXCEPTIONS \
const int float_excepts = feenableexcept(FE_DIVBYZERO);
#define FLOATING_POINT_RESTORE_EXCEPTIONS feenableexcept(float_excepts);
const int float_excepts = \
feenableexcept(FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW);
#define FLOATING_POINT_RESTORE_EXCEPTIONS \
fedisableexcept(FE_ALL_EXCEPT); \
feenableexcept(float_excepts);
#else
#define FLOATING_POINT_SET_EXCEPTIONS
#define FLOATING_POINT_RESTORE_EXCEPTIONS

View file

@ -14,6 +14,7 @@
#include "aom/aom_image.h"
#include "aom/aom_integer.h"
#include "aom/internal/aom_image_internal.h"
#include "aom_mem/aom_mem.h"
static INLINE unsigned int align_image_dimension(unsigned int d,
@ -29,8 +30,12 @@ static INLINE unsigned int align_image_dimension(unsigned int d,
static aom_image_t *img_alloc_helper(
aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w, unsigned int d_h,
unsigned int buf_align, unsigned int stride_align, unsigned int size_align,
unsigned char *img_data, unsigned int border) {
unsigned int h, w, s, xcs, ycs, bps;
unsigned int border, unsigned char *img_data,
aom_alloc_img_data_cb_fn_t alloc_cb, void *cb_priv) {
/* NOTE: In this function, bit_depth is either 8 or 16 (if
* AOM_IMG_FMT_HIGHBITDEPTH is set), never 10 or 12.
*/
unsigned int h, w, s, xcs, ycs, bps, bit_depth;
unsigned int stride_in_bytes;
/* Treat align==0 like align==1 */
@ -57,15 +62,17 @@ static aom_image_t *img_alloc_helper(
case AOM_IMG_FMT_YV12:
case AOM_IMG_FMT_AOMI420:
case AOM_IMG_FMT_AOMYV12: bps = 12; break;
case AOM_IMG_FMT_I422:
case AOM_IMG_FMT_I422: bps = 16; break;
case AOM_IMG_FMT_I444: bps = 24; break;
case AOM_IMG_FMT_YV1216:
case AOM_IMG_FMT_I42016: bps = 24; break;
case AOM_IMG_FMT_I42216:
case AOM_IMG_FMT_I42216: bps = 32; break;
case AOM_IMG_FMT_I44416: bps = 48; break;
default: bps = 16; break;
}
bit_depth = (fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 16 : 8;
/* Get chroma shift values for this format */
switch (fmt) {
case AOM_IMG_FMT_I420:
@ -93,9 +100,9 @@ static aom_image_t *img_alloc_helper(
w = align_image_dimension(d_w, xcs, size_align);
h = align_image_dimension(d_h, ycs, size_align);
s = (fmt & AOM_IMG_FMT_PLANAR) ? w : bps * w / 8;
s = (fmt & AOM_IMG_FMT_PLANAR) ? w : bps * w / bit_depth;
s = (s + 2 * border + stride_align - 1) & ~(stride_align - 1);
stride_in_bytes = (fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? s * 2 : s;
stride_in_bytes = s * bit_depth / 8;
/* Allocate the new image */
if (!img) {
@ -113,20 +120,29 @@ static aom_image_t *img_alloc_helper(
if (!img_data) {
const uint64_t alloc_size =
(fmt & AOM_IMG_FMT_PLANAR)
? (uint64_t)(h + 2 * border) * stride_in_bytes * bps / 8
? (uint64_t)(h + 2 * border) * stride_in_bytes * bps / bit_depth
: (uint64_t)(h + 2 * border) * stride_in_bytes;
if (alloc_size != (size_t)alloc_size) goto fail;
img->img_data = (uint8_t *)aom_memalign(buf_align, (size_t)alloc_size);
img->img_data_owner = 1;
if (alloc_cb) {
const size_t padded_alloc_size = (size_t)alloc_size + buf_align - 1;
img->img_data = (uint8_t *)alloc_cb(cb_priv, padded_alloc_size);
if (img->img_data) {
img->img_data = (uint8_t *)aom_align_addr(img->img_data, buf_align);
}
img->img_data_owner = 0;
} else {
img->img_data = (uint8_t *)aom_memalign(buf_align, (size_t)alloc_size);
img->img_data_owner = 1;
}
img->sz = (size_t)alloc_size;
}
if (!img->img_data) goto fail;
img->fmt = fmt;
img->bit_depth = (fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 16 : 8;
img->bit_depth = bit_depth;
// aligned width and aligned height
img->w = w;
img->h = h;
@ -138,8 +154,10 @@ static aom_image_t *img_alloc_helper(
img->stride[AOM_PLANE_Y] = stride_in_bytes;
img->stride[AOM_PLANE_U] = img->stride[AOM_PLANE_V] = stride_in_bytes >> xcs;
/* Default viewport to entire image */
if (!aom_img_set_rect(img, 0, 0, d_w, d_h, border)) return img;
/* Default viewport to entire image. (This aom_img_set_rect call always
* succeeds.) */
aom_img_set_rect(img, 0, 0, d_w, d_h, border);
return img;
fail:
aom_img_free(img);
@ -149,15 +167,26 @@ fail:
aom_image_t *aom_img_alloc(aom_image_t *img, aom_img_fmt_t fmt,
unsigned int d_w, unsigned int d_h,
unsigned int align) {
return img_alloc_helper(img, fmt, d_w, d_h, align, align, 1, NULL, 0);
return img_alloc_helper(img, fmt, d_w, d_h, align, align, 1, 0, NULL, NULL,
NULL);
}
aom_image_t *aom_img_alloc_with_cb(aom_image_t *img, aom_img_fmt_t fmt,
unsigned int d_w, unsigned int d_h,
unsigned int align,
aom_alloc_img_data_cb_fn_t alloc_cb,
void *cb_priv) {
return img_alloc_helper(img, fmt, d_w, d_h, align, align, 1, 0, NULL,
alloc_cb, cb_priv);
}
aom_image_t *aom_img_wrap(aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w,
unsigned int d_h, unsigned int stride_align,
unsigned char *img_data) {
/* By setting buf_align = 1, we don't change buffer alignment in this
* function. */
return img_alloc_helper(img, fmt, d_w, d_h, 1, stride_align, 1, img_data, 0);
/* Set buf_align = 1. It is ignored by img_alloc_helper because img_data is
* not NULL. */
return img_alloc_helper(img, fmt, d_w, d_h, 1, stride_align, 1, 0, img_data,
NULL, NULL);
}
aom_image_t *aom_img_alloc_with_border(aom_image_t *img, aom_img_fmt_t fmt,
@ -165,8 +194,8 @@ aom_image_t *aom_img_alloc_with_border(aom_image_t *img, aom_img_fmt_t fmt,
unsigned int align,
unsigned int size_align,
unsigned int border) {
return img_alloc_helper(img, fmt, d_w, d_h, align, align, size_align, NULL,
border);
return img_alloc_helper(img, fmt, d_w, d_h, align, align, size_align, border,
NULL, NULL, NULL);
}
int aom_img_set_rect(aom_image_t *img, unsigned int x, unsigned int y,
@ -238,6 +267,7 @@ void aom_img_flip(aom_image_t *img) {
void aom_img_free(aom_image_t *img) {
if (img) {
aom_img_remove_metadata(img);
if (img->img_data && img->img_data_owner) aom_free(img->img_data);
if (img->self_allocd) free(img);
@ -257,3 +287,99 @@ int aom_img_plane_height(const aom_image_t *img, int plane) {
else
return img->d_h;
}
aom_metadata_t *aom_img_metadata_alloc(uint8_t type, uint8_t *data, size_t sz) {
aom_metadata_t *metadata =
(aom_metadata_t *)calloc(1, sizeof(aom_metadata_t));
if (!metadata) return NULL;
metadata->type = type;
if (sz > 0) {
metadata->payload = (uint8_t *)calloc(sz, sizeof(uint8_t));
if (!metadata->payload) {
free(metadata);
return NULL;
}
if (data) {
memcpy(metadata->payload, data, sz);
metadata->sz = sz;
}
}
return metadata;
}
int aom_img_metadata_free(aom_metadata_t *metadata) {
if (!metadata) return -1;
if (metadata->payload) free(metadata->payload);
free(metadata);
return 0;
}
aom_metadata_array_t *aom_img_metadata_array_alloc(size_t sz) {
aom_metadata_array_t *arr =
(aom_metadata_array_t *)calloc(1, sizeof(aom_metadata_array_t));
if (!arr) return NULL;
if (sz > 0) {
arr->metadata_array =
(aom_metadata_t **)calloc(sz, sizeof(aom_metadata_t *));
if (!arr->metadata_array) {
aom_img_metadata_array_free(arr);
return NULL;
}
arr->sz = sz;
}
return arr;
}
size_t aom_img_metadata_array_free(aom_metadata_array_t *arr) {
size_t deleted_metadatas = 0;
if (!arr) return deleted_metadatas;
if (arr->metadata_array) {
for (size_t i = 0; i < arr->sz; i++) {
if (aom_img_metadata_free(arr->metadata_array[i]) == 0) {
deleted_metadatas++;
}
}
free(arr->metadata_array);
}
free(arr);
return deleted_metadatas;
}
int aom_img_add_metadata(aom_image_t *img, uint8_t type, uint8_t *data,
size_t sz) {
if (!img) return -1;
if (!img->metadata) {
img->metadata = aom_img_metadata_array_alloc(0);
if (!img->metadata) return -1;
}
aom_metadata_t *metadata = aom_img_metadata_alloc(type, data, sz);
if (!metadata) goto fail;
if (!img->metadata->metadata_array) {
img->metadata->metadata_array =
(aom_metadata_t **)calloc(1, sizeof(metadata));
if (!img->metadata->metadata_array || img->metadata->sz != 0) {
aom_img_metadata_free(metadata);
goto fail;
}
} else {
img->metadata->metadata_array =
(aom_metadata_t **)realloc(img->metadata->metadata_array,
(img->metadata->sz + 1) * sizeof(metadata));
}
img->metadata->metadata_array[img->metadata->sz] = metadata;
img->metadata->sz++;
return 0;
fail:
aom_img_metadata_array_free(img->metadata);
img->metadata = NULL;
return -1;
}
size_t aom_img_remove_metadata(aom_image_t *img) {
if (img && img->metadata) {
size_t sz = aom_img_metadata_array_free(img->metadata);
img->metadata = NULL;
return sz;
}
return 0;
}

View file

@ -130,6 +130,7 @@ void aom_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst,
}
}
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE int highbd_vert_scalar_product(const uint16_t *a,
ptrdiff_t a_stride,
const int16_t *b) {
@ -236,3 +237,4 @@ void aom_highbd_convolve_copy_c(const uint8_t *src8, ptrdiff_t src_stride,
dst += dst_stride;
}
}
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -76,6 +76,12 @@ list(APPEND AOM_DSP_COMMON_INTRIN_SSE2
"${AOM_ROOT}/aom_dsp/x86/avg_intrin_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/bitdepth_conversion_sse2.h")
if(NOT CONFIG_AV1_HIGHBITDEPTH)
list(REMOVE_ITEM AOM_DSP_COMMON_INTRIN_SSE2
"${AOM_ROOT}/aom_dsp/x86/highbd_convolve_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_loopfilter_sse2.c")
endif()
list(APPEND AOM_DSP_COMMON_ASM_SSSE3
"${AOM_ROOT}/aom_dsp/x86/aom_subpixel_8t_ssse3.asm"
"${AOM_ROOT}/aom_dsp/x86/aom_subpixel_bilinear_ssse3.asm")
@ -85,6 +91,11 @@ list(APPEND AOM_DSP_COMMON_INTRIN_SSSE3
"${AOM_ROOT}/aom_dsp/x86/highbd_convolve_ssse3.c"
"${AOM_ROOT}/aom_dsp/x86/intrapred_ssse3.c")
if(NOT CONFIG_AV1_HIGHBITDEPTH)
list(REMOVE_ITEM AOM_DSP_COMMON_INTRIN_SSSE3
"${AOM_ROOT}/aom_dsp/x86/highbd_convolve_ssse3.c")
endif()
list(APPEND AOM_DSP_COMMON_INTRIN_SSE4_1
"${AOM_ROOT}/aom_dsp/x86/blend_mask_sse4.h"
"${AOM_ROOT}/aom_dsp/x86/blend_a64_hmask_sse4.c"
@ -104,8 +115,13 @@ list(APPEND AOM_DSP_COMMON_INTRIN_AVX2
"${AOM_ROOT}/aom_dsp/x86/avg_intrin_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/bitdepth_conversion_avx2.h")
list(APPEND AOM_DSP_COMMON_INTRIN_NEON
"${AOM_ROOT}/aom_dsp/arm/fwd_txfm_neon.c"
if(NOT CONFIG_AV1_HIGHBITDEPTH)
list(REMOVE_ITEM AOM_DSP_COMMON_INTRIN_AVX2
"${AOM_ROOT}/aom_dsp/x86/highbd_convolve_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_loopfilter_avx2.c")
endif()
list(APPEND AOM_DSP_COMMON_INTRIN_NEON "${AOM_ROOT}/aom_dsp/arm/fwd_txfm_neon.c"
"${AOM_ROOT}/aom_dsp/arm/loopfilter_neon.c"
"${AOM_ROOT}/aom_dsp/arm/intrapred_neon.c"
"${AOM_ROOT}/aom_dsp/arm/subtract_neon.c"
@ -151,6 +167,7 @@ if(CONFIG_AV1_ENCODER)
"${AOM_ROOT}/aom_dsp/binary_codes_writer.c"
"${AOM_ROOT}/aom_dsp/binary_codes_writer.h"
"${AOM_ROOT}/aom_dsp/bitwriter.h"
"${AOM_ROOT}/aom_dsp/blk_sse_sum.c"
"${AOM_ROOT}/aom_dsp/daalaboolwriter.c"
"${AOM_ROOT}/aom_dsp/daalaboolwriter.h"
"${AOM_ROOT}/aom_dsp/entenc.c"
@ -195,9 +212,18 @@ if(CONFIG_AV1_ENCODER)
"${AOM_ROOT}/aom_dsp/x86/highbd_variance_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/quantize_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/adaptive_quantize_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_adaptive_quantize_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/quantize_x86.h"
"${AOM_ROOT}/aom_dsp/x86/blk_sse_sum_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/sum_squares_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/variance_sse2.c")
if(NOT CONFIG_AV1_HIGHBITDEPTH)
list(REMOVE_ITEM AOM_DSP_ENCODER_INTRIN_SSE2
"${AOM_ROOT}/aom_dsp/x86/highbd_adaptive_quantize_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_quantize_intrin_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_subtract_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_variance_sse2.c")
endif()
list(APPEND AOM_DSP_ENCODER_ASM_SSSE3_X86_64
"${AOM_ROOT}/aom_dsp/x86/fwd_txfm_ssse3_x86_64.asm"
@ -208,6 +234,7 @@ if(CONFIG_AV1_ENCODER)
"${AOM_ROOT}/aom_dsp/x86/subtract_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_quantize_intrin_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/adaptive_quantize_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_adaptive_quantize_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/sad4d_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/sad_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/sad_highbd_avx2.c"
@ -218,6 +245,7 @@ if(CONFIG_AV1_ENCODER)
"${AOM_ROOT}/aom_dsp/x86/variance_impl_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/obmc_sad_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/obmc_variance_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/blk_sse_sum_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/sum_squares_avx2.c")
list(APPEND AOM_DSP_ENCODER_AVX_ASM_X86_64
@ -239,11 +267,17 @@ if(CONFIG_AV1_ENCODER)
"${AOM_ROOT}/aom_dsp/x86/obmc_sad_sse4.c"
"${AOM_ROOT}/aom_dsp/x86/obmc_variance_sse4.c")
list(APPEND AOM_DSP_ENCODER_INTRIN_NEON
"${AOM_ROOT}/aom_dsp/arm/sad4d_neon.c"
if(NOT CONFIG_AV1_HIGHBITDEPTH)
list(REMOVE_ITEM AOM_DSP_ENCODER_INTRIN_SSE4_1
"${AOM_ROOT}/aom_dsp/x86/highbd_variance_sse4.c")
endif()
list(APPEND AOM_DSP_ENCODER_INTRIN_NEON "${AOM_ROOT}/aom_dsp/arm/sad4d_neon.c"
"${AOM_ROOT}/aom_dsp/arm/sad_neon.c"
"${AOM_ROOT}/aom_dsp/arm/subpel_variance_neon.c"
"${AOM_ROOT}/aom_dsp/arm/variance_neon.c")
"${AOM_ROOT}/aom_dsp/arm/variance_neon.c"
"${AOM_ROOT}/aom_dsp/arm/hadamard_neon.c"
"${AOM_ROOT}/aom_dsp/arm/avg_neon.c")
list(APPEND AOM_DSP_ENCODER_INTRIN_MSA "${AOM_ROOT}/aom_dsp/mips/sad_msa.c"
"${AOM_ROOT}/aom_dsp/mips/subtract_msa.c"

File diff suppressed because it is too large Load diff

49
third_party/aom/aom_dsp/arm/avg_neon.c vendored Normal file
View file

@ -0,0 +1,49 @@
/*
* Copyright (c) 2019, Alliance for Open Media. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <arm_neon.h>
#include "config/aom_dsp_rtcd.h"
#include "aom/aom_integer.h"
#include "aom_dsp/arm/sum_neon.h"
#include "av1/common/arm/mem_neon.h"
#include "av1/common/arm/transpose_neon.h"
unsigned int aom_avg_4x4_neon(const uint8_t *a, int a_stride) {
const uint8x16_t b = load_unaligned_u8q(a, a_stride);
const uint16x8_t c = vaddl_u8(vget_low_u8(b), vget_high_u8(b));
#if defined(__aarch64__)
const uint32_t d = vaddlvq_u16(c);
return (d + 8) >> 4;
#else
const uint32x2_t d = horizontal_add_u16x8(c);
return vget_lane_u32(vrshr_n_u32(d, 4), 0);
#endif
}
unsigned int aom_avg_8x8_neon(const uint8_t *a, int a_stride) {
uint16x8_t sum;
uint32x2_t d;
uint8x8_t b = vld1_u8(a);
a += a_stride;
uint8x8_t c = vld1_u8(a);
a += a_stride;
sum = vaddl_u8(b, c);
for (int i = 0; i < 6; ++i) {
const uint8x8_t e = vld1_u8(a);
a += a_stride;
sum = vaddw_u8(sum, e);
}
d = horizontal_add_u16x8(sum);
return vget_lane_u32(vrshr_n_u32(d, 6), 0);
}

View file

@ -0,0 +1,113 @@
/*
* Copyright (c) 2019, Alliance for Open Media. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <arm_neon.h>
#include "config/aom_dsp_rtcd.h"
#include "aom/aom_integer.h"
#include "av1/common/arm/mem_neon.h"
#include "av1/common/arm/transpose_neon.h"
static void hadamard8x8_one_pass(int16x8_t *a0, int16x8_t *a1, int16x8_t *a2,
int16x8_t *a3, int16x8_t *a4, int16x8_t *a5,
int16x8_t *a6, int16x8_t *a7) {
const int16x8_t b0 = vaddq_s16(*a0, *a1);
const int16x8_t b1 = vsubq_s16(*a0, *a1);
const int16x8_t b2 = vaddq_s16(*a2, *a3);
const int16x8_t b3 = vsubq_s16(*a2, *a3);
const int16x8_t b4 = vaddq_s16(*a4, *a5);
const int16x8_t b5 = vsubq_s16(*a4, *a5);
const int16x8_t b6 = vaddq_s16(*a6, *a7);
const int16x8_t b7 = vsubq_s16(*a6, *a7);
const int16x8_t c0 = vaddq_s16(b0, b2);
const int16x8_t c1 = vaddq_s16(b1, b3);
const int16x8_t c2 = vsubq_s16(b0, b2);
const int16x8_t c3 = vsubq_s16(b1, b3);
const int16x8_t c4 = vaddq_s16(b4, b6);
const int16x8_t c5 = vaddq_s16(b5, b7);
const int16x8_t c6 = vsubq_s16(b4, b6);
const int16x8_t c7 = vsubq_s16(b5, b7);
*a0 = vaddq_s16(c0, c4);
*a1 = vsubq_s16(c2, c6);
*a2 = vsubq_s16(c0, c4);
*a3 = vaddq_s16(c2, c6);
*a4 = vaddq_s16(c3, c7);
*a5 = vsubq_s16(c3, c7);
*a6 = vsubq_s16(c1, c5);
*a7 = vaddq_s16(c1, c5);
}
void aom_hadamard_8x8_neon(const int16_t *src_diff, ptrdiff_t src_stride,
tran_low_t *coeff) {
int16x8_t a0 = vld1q_s16(src_diff);
int16x8_t a1 = vld1q_s16(src_diff + src_stride);
int16x8_t a2 = vld1q_s16(src_diff + 2 * src_stride);
int16x8_t a3 = vld1q_s16(src_diff + 3 * src_stride);
int16x8_t a4 = vld1q_s16(src_diff + 4 * src_stride);
int16x8_t a5 = vld1q_s16(src_diff + 5 * src_stride);
int16x8_t a6 = vld1q_s16(src_diff + 6 * src_stride);
int16x8_t a7 = vld1q_s16(src_diff + 7 * src_stride);
hadamard8x8_one_pass(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
transpose_s16_8x8(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
hadamard8x8_one_pass(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
// Skip the second transpose because it is not required.
store_s16q_to_tran_low(coeff + 0, a0);
store_s16q_to_tran_low(coeff + 8, a1);
store_s16q_to_tran_low(coeff + 16, a2);
store_s16q_to_tran_low(coeff + 24, a3);
store_s16q_to_tran_low(coeff + 32, a4);
store_s16q_to_tran_low(coeff + 40, a5);
store_s16q_to_tran_low(coeff + 48, a6);
store_s16q_to_tran_low(coeff + 56, a7);
}
void aom_hadamard_16x16_neon(const int16_t *src_diff, ptrdiff_t src_stride,
tran_low_t *coeff) {
/* Rearrange 16x16 to 8x32 and remove stride.
* Top left first. */
aom_hadamard_8x8_neon(src_diff + 0 + 0 * src_stride, src_stride, coeff + 0);
/* Top right. */
aom_hadamard_8x8_neon(src_diff + 8 + 0 * src_stride, src_stride, coeff + 64);
/* Bottom left. */
aom_hadamard_8x8_neon(src_diff + 0 + 8 * src_stride, src_stride, coeff + 128);
/* Bottom right. */
aom_hadamard_8x8_neon(src_diff + 8 + 8 * src_stride, src_stride, coeff + 192);
for (int i = 0; i < 64; i += 8) {
const int16x8_t a0 = load_tran_low_to_s16q(coeff + 0);
const int16x8_t a1 = load_tran_low_to_s16q(coeff + 64);
const int16x8_t a2 = load_tran_low_to_s16q(coeff + 128);
const int16x8_t a3 = load_tran_low_to_s16q(coeff + 192);
const int16x8_t b0 = vhaddq_s16(a0, a1);
const int16x8_t b1 = vhsubq_s16(a0, a1);
const int16x8_t b2 = vhaddq_s16(a2, a3);
const int16x8_t b3 = vhsubq_s16(a2, a3);
const int16x8_t c0 = vaddq_s16(b0, b2);
const int16x8_t c1 = vaddq_s16(b1, b3);
const int16x8_t c2 = vsubq_s16(b0, b2);
const int16x8_t c3 = vsubq_s16(b1, b3);
store_s16q_to_tran_low(coeff + 0, c0);
store_s16q_to_tran_low(coeff + 64, c1);
store_s16q_to_tran_low(coeff + 128, c2);
store_s16q_to_tran_low(coeff + 192, c3);
coeff += 8;
}
}

37
third_party/aom/aom_dsp/arm/sum_neon.h vendored Normal file
View file

@ -0,0 +1,37 @@
/*
* Copyright (c) 2019, Alliance for Open Media. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "config/aom_dsp_rtcd.h"
#include "config/aom_config.h"
#include "aom/aom_integer.h"
#include "aom_ports/mem.h"
static INLINE int horizontal_add_s16x8(const int16x8_t v_16x8) {
const int32x4_t a = vpaddlq_s16(v_16x8);
const int64x2_t b = vpaddlq_s32(a);
const int32x2_t c = vadd_s32(vreinterpret_s32_s64(vget_low_s64(b)),
vreinterpret_s32_s64(vget_high_s64(b)));
return vget_lane_s32(c, 0);
}
static INLINE int horizontal_add_s32x4(const int32x4_t v_32x4) {
const int64x2_t b = vpaddlq_s32(v_32x4);
const int32x2_t c = vadd_s32(vreinterpret_s32_s64(vget_low_s64(b)),
vreinterpret_s32_s64(vget_high_s64(b)));
return vget_lane_s32(c, 0);
}
static INLINE uint32x2_t horizontal_add_u16x8(const uint16x8_t a) {
const uint32x4_t b = vpaddlq_u16(a);
const uint64x2_t c = vpaddlq_u32(b);
return vadd_u32(vreinterpret_u32_u64(vget_low_u64(c)),
vreinterpret_u32_u64(vget_high_u64(c)));
}

View file

@ -13,25 +13,10 @@
#include "config/aom_dsp_rtcd.h"
#include "config/aom_config.h"
#include "aom_dsp/arm/sum_neon.h"
#include "aom/aom_integer.h"
#include "aom_ports/mem.h"
static INLINE int horizontal_add_s16x8(const int16x8_t v_16x8) {
const int32x4_t a = vpaddlq_s16(v_16x8);
const int64x2_t b = vpaddlq_s32(a);
const int32x2_t c = vadd_s32(vreinterpret_s32_s64(vget_low_s64(b)),
vreinterpret_s32_s64(vget_high_s64(b)));
return vget_lane_s32(c, 0);
}
static INLINE int horizontal_add_s32x4(const int32x4_t v_32x4) {
const int64x2_t b = vpaddlq_s32(v_32x4);
const int32x2_t c = vadd_s32(vreinterpret_s32_s64(vget_low_s64(b)),
vreinterpret_s32_s64(vget_high_s64(b)));
return vget_lane_s32(c, 0);
}
// w * h must be less than 2048 or local variable v_sum may overflow.
static void variance_neon_w8(const uint8_t *a, int a_stride, const uint8_t *b,
int b_stride, int w, int h, uint32_t *sse,

View file

@ -48,6 +48,46 @@ unsigned int aom_avg_8x8_c(const uint8_t *s, int p) {
return (sum + 32) >> 6;
}
#if CONFIG_AV1_HIGHBITDEPTH
unsigned int aom_highbd_avg_8x8_c(const uint8_t *s8, int p) {
int i, j;
int sum = 0;
const uint16_t *s = CONVERT_TO_SHORTPTR(s8);
for (i = 0; i < 8; ++i, s += p)
for (j = 0; j < 8; sum += s[j], ++j) {
}
return (sum + 32) >> 6;
}
unsigned int aom_highbd_avg_4x4_c(const uint8_t *s8, int p) {
int i, j;
int sum = 0;
const uint16_t *s = CONVERT_TO_SHORTPTR(s8);
for (i = 0; i < 4; ++i, s += p)
for (j = 0; j < 4; sum += s[j], ++j) {
}
return (sum + 8) >> 4;
}
void aom_highbd_minmax_8x8_c(const uint8_t *s8, int p, const uint8_t *d8,
int dp, int *min, int *max) {
int i, j;
const uint16_t *s = CONVERT_TO_SHORTPTR(s8);
const uint16_t *d = CONVERT_TO_SHORTPTR(d8);
*min = 255;
*max = 0;
for (i = 0; i < 8; ++i, s += p, d += dp) {
for (j = 0; j < 8; ++j) {
int diff = abs(s[j] - d[j]);
*min = diff < *min ? diff : *min;
*max = diff > *max ? diff : *max;
}
}
}
#endif // CONFIG_VP9_HIGHBITDEPTH
// src_diff: first pass, 9 bit, dynamic range [-255, 255]
// second pass, 12 bit, dynamic range [-2040, 2040]
static void hadamard_col8(const int16_t *src_diff, ptrdiff_t src_stride,
@ -170,6 +210,164 @@ void aom_hadamard_32x32_c(const int16_t *src_diff, ptrdiff_t src_stride,
}
}
#if CONFIG_AV1_HIGHBITDEPTH
static void hadamard_highbd_col8_first_pass(const int16_t *src_diff,
ptrdiff_t src_stride,
int16_t *coeff) {
int16_t b0 = src_diff[0 * src_stride] + src_diff[1 * src_stride];
int16_t b1 = src_diff[0 * src_stride] - src_diff[1 * src_stride];
int16_t b2 = src_diff[2 * src_stride] + src_diff[3 * src_stride];
int16_t b3 = src_diff[2 * src_stride] - src_diff[3 * src_stride];
int16_t b4 = src_diff[4 * src_stride] + src_diff[5 * src_stride];
int16_t b5 = src_diff[4 * src_stride] - src_diff[5 * src_stride];
int16_t b6 = src_diff[6 * src_stride] + src_diff[7 * src_stride];
int16_t b7 = src_diff[6 * src_stride] - src_diff[7 * src_stride];
int16_t c0 = b0 + b2;
int16_t c1 = b1 + b3;
int16_t c2 = b0 - b2;
int16_t c3 = b1 - b3;
int16_t c4 = b4 + b6;
int16_t c5 = b5 + b7;
int16_t c6 = b4 - b6;
int16_t c7 = b5 - b7;
coeff[0] = c0 + c4;
coeff[7] = c1 + c5;
coeff[3] = c2 + c6;
coeff[4] = c3 + c7;
coeff[2] = c0 - c4;
coeff[6] = c1 - c5;
coeff[1] = c2 - c6;
coeff[5] = c3 - c7;
}
// src_diff: 16 bit, dynamic range [-32760, 32760]
// coeff: 19 bit
static void hadamard_highbd_col8_second_pass(const int16_t *src_diff,
ptrdiff_t src_stride,
int32_t *coeff) {
int32_t b0 = src_diff[0 * src_stride] + src_diff[1 * src_stride];
int32_t b1 = src_diff[0 * src_stride] - src_diff[1 * src_stride];
int32_t b2 = src_diff[2 * src_stride] + src_diff[3 * src_stride];
int32_t b3 = src_diff[2 * src_stride] - src_diff[3 * src_stride];
int32_t b4 = src_diff[4 * src_stride] + src_diff[5 * src_stride];
int32_t b5 = src_diff[4 * src_stride] - src_diff[5 * src_stride];
int32_t b6 = src_diff[6 * src_stride] + src_diff[7 * src_stride];
int32_t b7 = src_diff[6 * src_stride] - src_diff[7 * src_stride];
int32_t c0 = b0 + b2;
int32_t c1 = b1 + b3;
int32_t c2 = b0 - b2;
int32_t c3 = b1 - b3;
int32_t c4 = b4 + b6;
int32_t c5 = b5 + b7;
int32_t c6 = b4 - b6;
int32_t c7 = b5 - b7;
coeff[0] = c0 + c4;
coeff[7] = c1 + c5;
coeff[3] = c2 + c6;
coeff[4] = c3 + c7;
coeff[2] = c0 - c4;
coeff[6] = c1 - c5;
coeff[1] = c2 - c6;
coeff[5] = c3 - c7;
}
// The order of the output coeff of the hadamard is not important. For
// optimization purposes the final transpose may be skipped.
void aom_highbd_hadamard_8x8_c(const int16_t *src_diff, ptrdiff_t src_stride,
tran_low_t *coeff) {
int idx;
int16_t buffer[64];
int32_t buffer2[64];
int16_t *tmp_buf = &buffer[0];
for (idx = 0; idx < 8; ++idx) {
// src_diff: 13 bit
// buffer: 16 bit, dynamic range [-32760, 32760]
hadamard_highbd_col8_first_pass(src_diff, src_stride, tmp_buf);
tmp_buf += 8;
++src_diff;
}
tmp_buf = &buffer[0];
for (idx = 0; idx < 8; ++idx) {
// buffer: 16 bit
// buffer2: 19 bit, dynamic range [-262080, 262080]
hadamard_highbd_col8_second_pass(tmp_buf, 8, buffer2 + 8 * idx);
++tmp_buf;
}
for (idx = 0; idx < 64; ++idx) coeff[idx] = (tran_low_t)buffer2[idx];
}
// In place 16x16 2D Hadamard transform
void aom_highbd_hadamard_16x16_c(const int16_t *src_diff, ptrdiff_t src_stride,
tran_low_t *coeff) {
int idx;
for (idx = 0; idx < 4; ++idx) {
// src_diff: 13 bit, dynamic range [-4095, 4095]
const int16_t *src_ptr =
src_diff + (idx >> 1) * 8 * src_stride + (idx & 0x01) * 8;
aom_highbd_hadamard_8x8_c(src_ptr, src_stride, coeff + idx * 64);
}
// coeff: 19 bit, dynamic range [-262080, 262080]
for (idx = 0; idx < 64; ++idx) {
tran_low_t a0 = coeff[0];
tran_low_t a1 = coeff[64];
tran_low_t a2 = coeff[128];
tran_low_t a3 = coeff[192];
tran_low_t b0 = (a0 + a1) >> 1;
tran_low_t b1 = (a0 - a1) >> 1;
tran_low_t b2 = (a2 + a3) >> 1;
tran_low_t b3 = (a2 - a3) >> 1;
// new coeff dynamic range: 20 bit
coeff[0] = b0 + b2;
coeff[64] = b1 + b3;
coeff[128] = b0 - b2;
coeff[192] = b1 - b3;
++coeff;
}
}
void aom_highbd_hadamard_32x32_c(const int16_t *src_diff, ptrdiff_t src_stride,
tran_low_t *coeff) {
int idx;
for (idx = 0; idx < 4; ++idx) {
// src_diff: 13 bit, dynamic range [-4095, 4095]
const int16_t *src_ptr =
src_diff + (idx >> 1) * 16 * src_stride + (idx & 0x01) * 16;
aom_highbd_hadamard_16x16_c(src_ptr, src_stride, coeff + idx * 256);
}
// coeff: 20 bit
for (idx = 0; idx < 256; ++idx) {
tran_low_t a0 = coeff[0];
tran_low_t a1 = coeff[256];
tran_low_t a2 = coeff[512];
tran_low_t a3 = coeff[768];
tran_low_t b0 = (a0 + a1) >> 2;
tran_low_t b1 = (a0 - a1) >> 2;
tran_low_t b2 = (a2 + a3) >> 2;
tran_low_t b3 = (a2 - a3) >> 2;
// new coeff dynamic range: 20 bit
coeff[0] = b0 + b2;
coeff[256] = b1 + b3;
coeff[512] = b0 - b2;
coeff[768] = b1 - b3;
++coeff;
}
}
#endif // CONFIG_AV1_HIGHBITDEPTH
// coeff: 16 bits, dynamic range [-32640, 32640].
// length: value range {16, 64, 256, 1024}.
int aom_satd_c(const tran_low_t *coeff, int length) {

View file

@ -88,8 +88,8 @@ void aom_wb_write_uvlc(struct aom_write_bit_buffer *wb, uint32_t v) {
aom_wb_write_unsigned_literal(wb, v, (leading_zeroes + 1) >> 1);
}
static void aom_wb_write_primitive_quniform(struct aom_write_bit_buffer *wb,
uint16_t n, uint16_t v) {
static void wb_write_primitive_quniform(struct aom_write_bit_buffer *wb,
uint16_t n, uint16_t v) {
if (n <= 1) return;
const int l = get_msb(n) + 1;
const int m = (1 << l) - n;
@ -101,16 +101,15 @@ static void aom_wb_write_primitive_quniform(struct aom_write_bit_buffer *wb,
}
}
static void aom_wb_write_primitive_subexpfin(struct aom_write_bit_buffer *wb,
uint16_t n, uint16_t k,
uint16_t v) {
static void wb_write_primitive_subexpfin(struct aom_write_bit_buffer *wb,
uint16_t n, uint16_t k, uint16_t v) {
int i = 0;
int mk = 0;
while (1) {
int b = (i ? k + i - 1 : k);
int a = (1 << b);
if (n <= mk + 3 * a) {
aom_wb_write_primitive_quniform(wb, n - mk, v - mk);
wb_write_primitive_quniform(wb, n - mk, v - mk);
break;
} else {
int t = (v >= mk + a);
@ -126,10 +125,10 @@ static void aom_wb_write_primitive_subexpfin(struct aom_write_bit_buffer *wb,
}
}
static void aom_wb_write_primitive_refsubexpfin(struct aom_write_bit_buffer *wb,
uint16_t n, uint16_t k,
uint16_t ref, uint16_t v) {
aom_wb_write_primitive_subexpfin(wb, n, k, recenter_finite_nonneg(n, ref, v));
static void wb_write_primitive_refsubexpfin(struct aom_write_bit_buffer *wb,
uint16_t n, uint16_t k,
uint16_t ref, uint16_t v) {
wb_write_primitive_subexpfin(wb, n, k, recenter_finite_nonneg(n, ref, v));
}
void aom_wb_write_signed_primitive_refsubexpfin(struct aom_write_bit_buffer *wb,
@ -138,5 +137,5 @@ void aom_wb_write_signed_primitive_refsubexpfin(struct aom_write_bit_buffer *wb,
ref += n - 1;
v += n - 1;
const uint16_t scaled_n = (n << 1) - 1;
aom_wb_write_primitive_refsubexpfin(wb, scaled_n, k, ref, v);
wb_write_primitive_refsubexpfin(wb, scaled_n, k, ref, v);
}

View file

@ -40,6 +40,7 @@ void aom_blend_a64_hmask_c(uint8_t *dst, uint32_t dst_stride,
}
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_blend_a64_hmask_c(uint8_t *dst_8, uint32_t dst_stride,
const uint8_t *src0_8, uint32_t src0_stride,
const uint8_t *src1_8, uint32_t src1_stride,
@ -67,3 +68,4 @@ void aom_highbd_blend_a64_hmask_c(uint8_t *dst_8, uint32_t dst_stride,
}
}
}
#endif

View file

@ -120,6 +120,7 @@ void aom_lowbd_blend_a64_d16_mask_c(
}
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_blend_a64_d16_mask_c(
uint8_t *dst_8, uint32_t dst_stride, const CONV_BUF_TYPE *src0,
uint32_t src0_stride, const CONV_BUF_TYPE *src1, uint32_t src1_stride,
@ -219,6 +220,7 @@ void aom_highbd_blend_a64_d16_mask_c(
}
}
}
#endif // CONFIG_AV1_HIGHBITDEPTH
// Blending with alpha mask. Mask values come from the range [0, 64],
// as described for AOM_BLEND_A64 in aom_dsp/blend.h. src0 or src1 can
@ -281,6 +283,7 @@ void aom_blend_a64_mask_c(uint8_t *dst, uint32_t dst_stride,
}
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_blend_a64_mask_c(uint8_t *dst_8, uint32_t dst_stride,
const uint8_t *src0_8, uint32_t src0_stride,
const uint8_t *src1_8, uint32_t src1_stride,
@ -343,3 +346,4 @@ void aom_highbd_blend_a64_mask_c(uint8_t *dst_8, uint32_t dst_stride,
}
}
}
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -41,6 +41,7 @@ void aom_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride,
}
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_blend_a64_vmask_c(uint8_t *dst_8, uint32_t dst_stride,
const uint8_t *src0_8, uint32_t src0_stride,
const uint8_t *src1_8, uint32_t src1_stride,
@ -69,3 +70,4 @@ void aom_highbd_blend_a64_vmask_c(uint8_t *dst_8, uint32_t dst_stride,
}
}
}
#endif

26
third_party/aom/aom_dsp/blk_sse_sum.c vendored Normal file
View file

@ -0,0 +1,26 @@
/*
* Copyright (c) 2019, 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.
*/
#include "config/aom_dsp_rtcd.h"
void aom_get_blk_sse_sum_c(const int16_t *data, int stride, int bw, int bh,
int *x_sum, int64_t *x2_sum) {
*x_sum = 0;
*x2_sum = 0;
for (int i = 0; i < bh; ++i) {
for (int j = 0; j < bw; ++j) {
const int val = data[j];
*x_sum += val;
*x2_sum += val * val;
}
data += stride;
}
}

View file

@ -54,7 +54,7 @@ static INLINE int aom_daala_read(daala_reader *r, int prob) {
#if CONFIG_BITSTREAM_DEBUG
/*{
const int queue_r = bitstream_queue_get_read();
const int frame_idx = bitstream_queue_get_frame_read();
const int frame_idx = aom_bitstream_queue_get_frame_read();
if (frame_idx == 0 && queue_r == 0) {
fprintf(stderr, "\n *** bitstream queue at frame_idx_r %d queue_r %d\n",
frame_idx, queue_r);
@ -70,7 +70,7 @@ static INLINE int aom_daala_read(daala_reader *r, int prob) {
int ref_bit, ref_nsymbs;
aom_cdf_prob ref_cdf[16];
const int queue_r = bitstream_queue_get_read();
const int frame_idx = bitstream_queue_get_frame_read();
const int frame_idx = aom_bitstream_queue_get_frame_read();
bitstream_queue_pop(&ref_bit, ref_cdf, &ref_nsymbs);
if (ref_nsymbs != 2) {
fprintf(stderr,
@ -114,7 +114,7 @@ static INLINE int daala_read_symbol(daala_reader *r, const aom_cdf_prob *cdf,
int ref_symb, ref_nsymbs;
aom_cdf_prob ref_cdf[16];
const int queue_r = bitstream_queue_get_read();
const int frame_idx = bitstream_queue_get_frame_read();
const int frame_idx = aom_bitstream_queue_get_frame_read();
bitstream_queue_pop(&ref_symb, ref_cdf, &ref_nsymbs);
if (nsymbs != ref_nsymbs) {
fprintf(stderr,

View file

@ -43,7 +43,7 @@ static INLINE void aom_daala_write(daala_writer *w, int bit, int prob) {
/*int queue_r = 0;
int frame_idx_r = 0;
int queue_w = bitstream_queue_get_write();
int frame_idx_w = bitstream_queue_get_frame_write();
int frame_idx_w = aom_bitstream_queue_get_frame_writee();
if (frame_idx_w == frame_idx_r && queue_w == queue_r) {
fprintf(stderr, "\n *** bitstream queue at frame_idx_w %d queue_w %d\n",
frame_idx_w, queue_w);
@ -60,7 +60,7 @@ static INLINE void daala_write_symbol(daala_writer *w, int symb,
/*int queue_r = 0;
int frame_idx_r = 0;
int queue_w = bitstream_queue_get_write();
int frame_idx_w = bitstream_queue_get_frame_write();
int frame_idx_w = aom_bitstream_queue_get_frame_writee();
if (frame_idx_w == frame_idx_r && queue_w == queue_r) {
fprintf(stderr, "\n *** bitstream queue at frame_idx_w %d queue_w %d\n",
frame_idx_w, queue_w);

View file

@ -97,7 +97,9 @@ void aom_fdct8x8_c(const int16_t *input, tran_low_t *final_output, int stride) {
}
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_fdct8x8_c(const int16_t *input, tran_low_t *final_output,
int stride) {
aom_fdct8x8_c(input, final_output, stride);
}
#endif

View file

@ -203,7 +203,7 @@ int aom_film_grain_table_lookup(aom_film_grain_table_t *t, int64_t time_stamp,
aom_film_grain_t *grain) {
aom_film_grain_table_entry_t *entry = t->head;
aom_film_grain_table_entry_t *prev_entry = 0;
int16_t random_seed = grain ? grain->random_seed : 0;
uint16_t random_seed = grain ? grain->random_seed : 0;
if (grain) memset(grain, 0, sizeof(*grain));
while (entry) {

View file

@ -21,6 +21,7 @@ static INLINE int8_t signed_char_clamp(int t) {
return (int8_t)clamp(t, -128, 127);
}
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE int16_t signed_char_clamp_high(int t, int bd) {
switch (bd) {
case 10: return (int16_t)clamp(t, -128 * 4, 128 * 4 - 1);
@ -29,6 +30,7 @@ static INLINE int16_t signed_char_clamp_high(int t, int bd) {
default: return (int16_t)clamp(t, -128, 128 - 1);
}
}
#endif
// should we apply any filter at all: 11111111 yes, 00000000 no
static INLINE int8_t filter_mask2(uint8_t limit, uint8_t blimit, uint8_t p1,
@ -103,11 +105,11 @@ static INLINE void filter4(int8_t mask, uint8_t thresh, uint8_t *op1,
uint8_t *op0, uint8_t *oq0, uint8_t *oq1) {
int8_t filter1, filter2;
const int8_t ps1 = (int8_t)*op1 ^ 0x80;
const int8_t ps0 = (int8_t)*op0 ^ 0x80;
const int8_t qs0 = (int8_t)*oq0 ^ 0x80;
const int8_t qs1 = (int8_t)*oq1 ^ 0x80;
const uint8_t hev = hev_mask(thresh, *op1, *op0, *oq0, *oq1);
const int8_t ps1 = (int8_t)(*op1 ^ 0x80);
const int8_t ps0 = (int8_t)(*op0 ^ 0x80);
const int8_t qs0 = (int8_t)(*oq0 ^ 0x80);
const int8_t qs1 = (int8_t)(*oq1 ^ 0x80);
const int8_t hev = hev_mask(thresh, *op1, *op0, *oq0, *oq1);
// add outer taps if we have high edge variance
int8_t filter = signed_char_clamp(ps1 - qs1) & hev;
@ -121,14 +123,14 @@ static INLINE void filter4(int8_t mask, uint8_t thresh, uint8_t *op1,
filter1 = signed_char_clamp(filter + 4) >> 3;
filter2 = signed_char_clamp(filter + 3) >> 3;
*oq0 = signed_char_clamp(qs0 - filter1) ^ 0x80;
*op0 = signed_char_clamp(ps0 + filter2) ^ 0x80;
*oq0 = (uint8_t)(signed_char_clamp(qs0 - filter1) ^ 0x80);
*op0 = (uint8_t)(signed_char_clamp(ps0 + filter2) ^ 0x80);
// outer tap adjustments
filter = ROUND_POWER_OF_TWO(filter1, 1) & ~hev;
*oq1 = signed_char_clamp(qs1 - filter) ^ 0x80;
*op1 = signed_char_clamp(ps1 + filter) ^ 0x80;
*oq1 = (uint8_t)(signed_char_clamp(qs1 - filter) ^ 0x80);
*op1 = (uint8_t)(signed_char_clamp(ps1 + filter) ^ 0x80);
}
void aom_lpf_horizontal_4_c(uint8_t *s, int p /* pitch */,
@ -442,6 +444,7 @@ void aom_lpf_vertical_14_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0,
mb_lpf_vertical_edge_w(s + 4 * pitch, pitch, blimit1, limit1, thresh1, 4);
}
#if CONFIG_AV1_HIGHBITDEPTH
// Should we apply any filter at all: 11111111 yes, 00000000 no ?
static INLINE int8_t highbd_filter_mask2(uint8_t limit, uint8_t blimit,
uint16_t p1, uint16_t p0, uint16_t q0,
@ -539,7 +542,7 @@ static INLINE void highbd_filter4(int8_t mask, uint8_t thresh, uint16_t *op1,
const int16_t ps0 = (int16_t)*op0 - (0x80 << shift);
const int16_t qs0 = (int16_t)*oq0 - (0x80 << shift);
const int16_t qs1 = (int16_t)*oq1 - (0x80 << shift);
const uint16_t hev = highbd_hev_mask(thresh, *op1, *op0, *oq0, *oq1, bd);
const int16_t hev = highbd_hev_mask(thresh, *op1, *op0, *oq0, *oq1, bd);
// Add outer taps if we have high edge variance.
int16_t filter = signed_char_clamp_high(ps1 - qs1, bd) & hev;
@ -865,10 +868,10 @@ static void highbd_mb_lpf_horizontal_edge_w(uint16_t *s, int p,
}
}
void aom_highbd_lpf_horizontal_14_c(uint16_t *s, int p, const uint8_t *blimit,
const uint8_t *limit, const uint8_t *thresh,
int bd) {
highbd_mb_lpf_horizontal_edge_w(s, p, blimit, limit, thresh, 1, bd);
void aom_highbd_lpf_horizontal_14_c(uint16_t *s, int pitch,
const uint8_t *blimit, const uint8_t *limit,
const uint8_t *thresh, int bd) {
highbd_mb_lpf_horizontal_edge_w(s, pitch, blimit, limit, thresh, 1, bd);
}
void aom_highbd_lpf_horizontal_14_dual_c(
@ -923,3 +926,4 @@ void aom_highbd_lpf_vertical_14_dual_c(
highbd_mb_lpf_vertical_edge_w(s + 4 * pitch, pitch, blimit1, limit1, thresh1,
4, bd);
}
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -96,7 +96,9 @@ void aom_noise_tx_filter(struct aom_noise_tx_t *noise_tx, const float *psd) {
for (int x = 0; x < block_size; ++x) {
int i = y * block_size + x;
float *c = noise_tx->tx_block + 2 * i;
const float p = c[0] * c[0] + c[1] * c[1];
const float c0 = AOMMAX((float)fabs(c[0]), 1e-8f);
const float c1 = AOMMAX((float)fabs(c[1]), 1e-8f);
const float p = c0 * c0 + c1 * c1;
if (p > kBeta * psd[i] && p > 1e-6) {
noise_tx->tx_block[2 * i + 0] *= (p - psd[i]) / AOMMAX(p, kEps);
noise_tx->tx_block[2 * i + 1] *= (p - psd[i]) / AOMMAX(p, kEps);

View file

@ -49,6 +49,7 @@ static void encoder_variance(const uint8_t *a, int a_stride, const uint8_t *b,
}
}
#if CONFIG_AV1_HIGHBITDEPTH
static void encoder_highbd_variance64(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride, int w,
int h, uint64_t *sse, int64_t *sum) {
@ -81,6 +82,7 @@ static void encoder_highbd_8_variance(const uint8_t *a8, int a_stride,
*sse = (unsigned int)sse_long;
*sum = (int)sum_long;
}
#endif // CONFIG_AV1_HIGHBITDEPTH
static int64_t get_sse(const uint8_t *a, int a_stride, const uint8_t *b,
int b_stride, int width, int height) {
@ -122,6 +124,7 @@ static int64_t get_sse(const uint8_t *a, int a_stride, const uint8_t *b,
return total_sse;
}
#if CONFIG_AV1_HIGHBITDEPTH
static int64_t highbd_get_sse_shift(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride, int width,
int height, unsigned int input_shift) {
@ -174,6 +177,7 @@ static int64_t highbd_get_sse(const uint8_t *a, int a_stride, const uint8_t *b,
}
return total_sse;
}
#endif // CONFIG_AV1_HIGHBITDEPTH
int64_t aom_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, int hstart, int width,
@ -226,6 +230,7 @@ int64_t aom_get_v_sse(const YV12_BUFFER_CONFIG *a,
a->uv_crop_width, a->uv_crop_height);
}
#if CONFIG_AV1_HIGHBITDEPTH
int64_t aom_highbd_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, int hstart,
int width, int vstart, int height) {
@ -284,9 +289,11 @@ int64_t aom_highbd_get_v_sse(const YV12_BUFFER_CONFIG *a,
return highbd_get_sse(a->v_buffer, a->uv_stride, b->v_buffer, b->uv_stride,
a->uv_crop_width, a->uv_crop_height);
}
#endif // CONFIG_AV1_HIGHBITDEPTH
int64_t aom_get_sse_plane(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, int plane, int highbd) {
#if CONFIG_AV1_HIGHBITDEPTH
if (highbd) {
switch (plane) {
case 0: return aom_highbd_get_y_sse(a, b);
@ -294,15 +301,26 @@ int64_t aom_get_sse_plane(const YV12_BUFFER_CONFIG *a,
case 2: return aom_highbd_get_v_sse(a, b);
default: assert(plane >= 0 && plane <= 2); return 0;
}
} else {
switch (plane) {
case 0: return aom_get_y_sse(a, b);
case 1: return aom_get_u_sse(a, b);
case 2: return aom_get_v_sse(a, b);
default: assert(plane >= 0 && plane <= 2); return 0;
}
}
#else
(void)highbd;
switch (plane) {
case 0: return aom_get_y_sse(a, b);
case 1: return aom_get_u_sse(a, b);
case 2: return aom_get_v_sse(a, b);
default: assert(plane >= 0 && plane <= 2); return 0;
}
#endif
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr,
uint32_t bit_depth, uint32_t in_bit_depth) {
@ -347,6 +365,7 @@ void aom_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a,
psnr->psnr[0] =
aom_sse_to_psnr((double)total_samples, peak, (double)total_sse);
}
#endif
void aom_calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b,
PSNR_STATS *psnr) {

View file

@ -49,6 +49,7 @@ int64_t aom_get_v_sse_part(const YV12_BUFFER_CONFIG *a,
int64_t aom_get_v_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
int64_t aom_get_sse_plane(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, int plane, int highbd);
#if CONFIG_AV1_HIGHBITDEPTH
int64_t aom_highbd_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, int hstart,
int width, int vstart, int height);
@ -67,6 +68,7 @@ int64_t aom_highbd_get_v_sse(const YV12_BUFFER_CONFIG *a,
void aom_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr,
unsigned int bit_depth, unsigned int in_bit_depth);
#endif
void aom_calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b,
PSNR_STATS *psnr);

View file

@ -131,8 +131,24 @@ static double calc_psnrhvs(const unsigned char *src, int _systride,
int pixels;
int x;
int y;
float sum1;
float sum2;
float delt;
(void)_par;
ret = pixels = 0;
sum1 = sum2 = delt = 0.0f;
for (y = 0; y < _h; y++) {
for (x = 0; x < _w; x++) {
if (!buf_is_hbd) {
sum1 += _src8[y * _systride + x];
sum2 += _dst8[y * _dystride + x];
} else {
sum1 += _src16[y * _systride + x] >> _shift;
sum2 += _dst16[y * _dystride + x] >> _shift;
}
}
}
delt = (sum1 - sum2) / (_w * _h);
/*In the PSNR-HVS-M paper[1] the authors describe the construction of
their masking table as "we have used the quantization table for the
color component Y of JPEG [6] that has been also obtained on the
@ -183,6 +199,7 @@ static double calc_psnrhvs(const unsigned char *src, int _systride,
dct_s[i * 8 + j] = _src16[(y + i) * _systride + (j + x)] >> _shift;
dct_d[i * 8 + j] = _dst16[(y + i) * _dystride + (j + x)] >> _shift;
}
dct_d[i * 8 + j] += (int)(delt + 0.5f);
s_gmean += dct_s[i * 8 + j];
d_gmean += dct_d[i * 8 + j];
s_means[sub] += dct_s[i * 8 + j];
@ -242,6 +259,7 @@ static double calc_psnrhvs(const unsigned char *src, int _systride,
}
if (pixels <= 0) return 0;
ret /= pixels;
ret += 0.04 * delt * delt;
return ret;
}

View file

@ -13,7 +13,7 @@
#include "aom_mem/aom_mem.h"
#include "av1/encoder/av1_quantize.h"
void quantize_b_adaptive_helper_c(
void aom_quantize_b_adaptive_helper_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
@ -104,14 +104,15 @@ void quantize_b_adaptive_helper_c(
*eob_ptr = eob + 1;
}
void quantize_b_helper_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr, const int16_t *round_ptr,
const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr,
uint16_t *eob_ptr, const int16_t *scan,
const int16_t *iscan, const qm_val_t *qm_ptr,
const qm_val_t *iqm_ptr, const int log_scale) {
void aom_quantize_b_helper_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr, const int16_t *round_ptr,
const int16_t *quant_ptr,
const int16_t *quant_shift_ptr,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan,
const qm_val_t *qm_ptr, const qm_val_t *iqm_ptr,
const int log_scale) {
const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
const int nzbins[2] = { zbins[0] * -1, zbins[1] * -1 };
@ -166,21 +167,19 @@ void quantize_b_helper_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
*eob_ptr = eob + 1;
}
void highbd_quantize_b_adaptive_helper_c(
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_quantize_b_adaptive_helper_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan, const qm_val_t *qm_ptr,
const qm_val_t *iqm_ptr, const int log_scale) {
int i, eob = -1;
const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
const int nzbins[2] = { zbins[0] * -1, zbins[1] * -1 };
int dequant;
int idx_arr[4096];
(void)iscan;
int idx = 0;
int i, non_zero_count = (int)n_coeffs, eob = -1;
memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr));
memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr));
@ -190,47 +189,49 @@ void highbd_quantize_b_adaptive_helper_c(
prescan_add[i] = ROUND_POWER_OF_TWO(dequant_ptr[i] * EOB_FACTOR, 7);
// Pre-scan pass
for (i = 0; i < n_coeffs; i++) {
for (i = (int)n_coeffs - 1; i >= 0; i--) {
const int rc = scan[i];
const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
const int coeff = coeff_ptr[rc] * wt;
// If the coefficient is out of the base ZBIN range, keep it for
// quantization.
const int prescan_add_val = prescan_add[rc != 0];
if (coeff >= (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val) &&
coeff <= (nzbins[rc != 0] * (1 << AOM_QM_BITS) - prescan_add_val))
idx_arr[idx++] = i;
if (coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val) &&
coeff > (nzbins[rc != 0] * (1 << AOM_QM_BITS) - prescan_add_val))
non_zero_count--;
else
break;
}
// Quantization pass: only process the coefficients selected in
// pre-scan pass. Note: idx can be zero.
// Quantization pass: All coefficients with index >= zero_flag are
// skippable. Note: zero_flag can be zero.
#if SKIP_EOB_FACTOR_ADJUST
int first = -1;
#endif // SKIP_EOB_FACTOR_ADJUST
for (i = 0; i < idx; i++) {
const int rc = scan[idx_arr[i]];
for (i = 0; i < non_zero_count; i++) {
const int rc = scan[i];
const int coeff = coeff_ptr[rc];
const int coeff_sign = (coeff >> 31);
const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
const qm_val_t iwt = iqm_ptr != NULL ? iqm_ptr[rc] : (1 << AOM_QM_BITS);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
const int64_t tmp1 =
abs_coeff + ROUND_POWER_OF_TWO(round_ptr[rc != 0], log_scale);
const int64_t tmpw = tmp1 * wt;
const int64_t tmp2 = ((tmpw * quant_ptr[rc != 0]) >> 16) + tmpw;
const int abs_qcoeff = (int)((tmp2 * quant_shift_ptr[rc != 0]) >>
(16 - log_scale + AOM_QM_BITS));
qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign);
dequant =
(dequant_ptr[rc != 0] * iwt + (1 << (AOM_QM_BITS - 1))) >> AOM_QM_BITS;
const tran_low_t abs_dqcoeff = (abs_qcoeff * dequant) >> log_scale;
dqcoeff_ptr[rc] = (tran_low_t)((abs_dqcoeff ^ coeff_sign) - coeff_sign);
if (abs_qcoeff) {
eob = idx_arr[i];
if (abs_coeff * wt >= (zbins[rc != 0] << AOM_QM_BITS)) {
const int64_t tmp1 =
abs_coeff + ROUND_POWER_OF_TWO(round_ptr[rc != 0], log_scale);
const int64_t tmpw = tmp1 * wt;
const int64_t tmp2 = ((tmpw * quant_ptr[rc != 0]) >> 16) + tmpw;
const int abs_qcoeff = (int)((tmp2 * quant_shift_ptr[rc != 0]) >>
(16 - log_scale + AOM_QM_BITS));
qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign);
const qm_val_t iwt = iqm_ptr != NULL ? iqm_ptr[rc] : (1 << AOM_QM_BITS);
const int dequant =
(dequant_ptr[rc != 0] * iwt + (1 << (AOM_QM_BITS - 1))) >>
AOM_QM_BITS;
const tran_low_t abs_dqcoeff = (abs_qcoeff * dequant) >> log_scale;
dqcoeff_ptr[rc] = (tran_low_t)((abs_dqcoeff ^ coeff_sign) - coeff_sign);
if (abs_qcoeff) {
eob = i;
#if SKIP_EOB_FACTOR_ADJUST
if (first == -1) first = eob;
if (first == -1) first = eob;
#endif // SKIP_EOB_FACTOR_ADJUST
}
}
}
#if SKIP_EOB_FACTOR_ADJUST
@ -254,7 +255,7 @@ void highbd_quantize_b_adaptive_helper_c(
*eob_ptr = eob + 1;
}
void highbd_quantize_b_helper_c(
void aom_highbd_quantize_b_helper_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
@ -310,6 +311,7 @@ void highbd_quantize_b_helper_c(
}
*eob_ptr = eob + 1;
}
#endif // CONFIG_AV1_HIGHBITDEPTH
/* These functions should only be called when quantisation matrices
are not used. */
@ -321,10 +323,10 @@ void aom_quantize_b_adaptive_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
NULL, NULL, 0);
aom_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan,
iscan, NULL, NULL, 0);
}
void aom_quantize_b_32x32_adaptive_c(
@ -333,10 +335,10 @@ void aom_quantize_b_32x32_adaptive_c(
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
NULL, NULL, 1);
aom_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan,
iscan, NULL, NULL, 1);
}
void aom_quantize_b_64x64_adaptive_c(
@ -345,22 +347,23 @@ void aom_quantize_b_64x64_adaptive_c(
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
NULL, NULL, 2);
aom_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan,
iscan, NULL, NULL, 2);
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_quantize_b_adaptive_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
highbd_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan,
iscan, NULL, NULL, 0);
aom_highbd_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr,
round_ptr, quant_ptr, quant_shift_ptr,
qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 0);
}
void aom_highbd_quantize_b_32x32_adaptive_c(
@ -369,10 +372,10 @@ void aom_highbd_quantize_b_32x32_adaptive_c(
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
highbd_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan,
iscan, NULL, NULL, 1);
aom_highbd_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr,
round_ptr, quant_ptr, quant_shift_ptr,
qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 1);
}
void aom_highbd_quantize_b_64x64_adaptive_c(
@ -381,11 +384,12 @@ void aom_highbd_quantize_b_64x64_adaptive_c(
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
highbd_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan,
iscan, NULL, NULL, 2);
aom_highbd_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr,
round_ptr, quant_ptr, quant_shift_ptr,
qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 2);
}
#endif // CONFIG_AV1_HIGHBITDEPTH
void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr, const int16_t *round_ptr,
@ -393,9 +397,9 @@ void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 0);
aom_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 0);
}
void aom_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
@ -405,9 +409,9 @@ void aom_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 1);
aom_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 1);
}
void aom_quantize_b_64x64_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
@ -417,11 +421,12 @@ void aom_quantize_b_64x64_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 2);
aom_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 2);
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr, const int16_t *round_ptr,
const int16_t *quant_ptr,
@ -429,10 +434,10 @@ void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
NULL, NULL, 0);
aom_highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
NULL, NULL, 0);
}
void aom_highbd_quantize_b_32x32_c(
@ -441,10 +446,10 @@ void aom_highbd_quantize_b_32x32_c(
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
NULL, NULL, 1);
aom_highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
NULL, NULL, 1);
}
void aom_highbd_quantize_b_64x64_c(
@ -453,8 +458,9 @@ void aom_highbd_quantize_b_64x64_c(
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
NULL, NULL, 2);
aom_highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
NULL, NULL, 2);
}
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -20,7 +20,7 @@
extern "C" {
#endif
void quantize_b_adaptive_helper_c(
void aom_quantize_b_adaptive_helper_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
@ -51,7 +51,8 @@ void aom_quantize_b_64x64_adaptive_c(
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan);
void highbd_quantize_b_adaptive_helper_c(
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_quantize_b_adaptive_helper_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
@ -79,15 +80,17 @@ void aom_highbd_quantize_b_64x64_adaptive_c(
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan);
#endif // CONFIG_AV1_HIGHBITDEPTH
void quantize_b_helper_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr, const int16_t *round_ptr,
const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr,
uint16_t *eob_ptr, const int16_t *scan,
const int16_t *iscan, const qm_val_t *qm_ptr,
const qm_val_t *iqm_ptr, const int log_scale);
void aom_quantize_b_helper_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr, const int16_t *round_ptr,
const int16_t *quant_ptr,
const int16_t *quant_shift_ptr,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan,
const qm_val_t *qm_ptr, const qm_val_t *iqm_ptr,
const int log_scale);
void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr, const int16_t *round_ptr,
@ -96,7 +99,8 @@ void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan);
void highbd_quantize_b_helper_c(
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_quantize_b_helper_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
@ -111,6 +115,7 @@ void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan);
#endif // CONFIG_AV1_HIGHBITDEPTH
#ifdef __cplusplus
} // extern "C"

View file

@ -159,6 +159,7 @@ sadMxNx4D(16, 64);
sadMxN(64, 16);
sadMxNx4D(64, 16);
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE unsigned int highbd_sad(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride,
int width, int height) {
@ -178,11 +179,12 @@ static INLINE unsigned int highbd_sad(const uint8_t *a8, int a_stride,
}
static INLINE unsigned int highbd_sadb(const uint8_t *a8, int a_stride,
const uint16_t *b, int b_stride,
const uint8_t *b8, int b_stride,
int width, int height) {
int y, x;
unsigned int sad = 0;
const uint16_t *a = CONVERT_TO_SHORTPTR(a8);
const uint16_t *b = CONVERT_TO_SHORTPTR(b8);
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
sad += abs(a[x] - b[x]);
@ -204,18 +206,18 @@ static INLINE unsigned int highbd_sadb(const uint8_t *a8, int a_stride,
const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, \
const uint8_t *second_pred) { \
uint16_t comp_pred[m * n]; \
aom_highbd_comp_avg_pred(CONVERT_TO_BYTEPTR(comp_pred), second_pred, m, n, \
ref, ref_stride); \
return highbd_sadb(src, src_stride, comp_pred, m, m, n); \
uint8_t *const comp_pred8 = CONVERT_TO_BYTEPTR(comp_pred); \
aom_highbd_comp_avg_pred(comp_pred8, second_pred, m, n, ref, ref_stride); \
return highbd_sadb(src, src_stride, comp_pred8, m, m, n); \
} \
unsigned int aom_highbd_dist_wtd_sad##m##x##n##_avg_c( \
const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, \
const uint8_t *second_pred, const DIST_WTD_COMP_PARAMS *jcp_param) { \
uint16_t comp_pred[m * n]; \
aom_highbd_dist_wtd_comp_avg_pred(CONVERT_TO_BYTEPTR(comp_pred), \
second_pred, m, n, ref, ref_stride, \
jcp_param); \
return highbd_sadb(src, src_stride, comp_pred, m, m, n); \
uint8_t *const comp_pred8 = CONVERT_TO_BYTEPTR(comp_pred); \
aom_highbd_dist_wtd_comp_avg_pred(comp_pred8, second_pred, m, n, ref, \
ref_stride, jcp_param); \
return highbd_sadb(src, src_stride, comp_pred8, m, m, n); \
}
#define highbd_sadMxNx4D(m, n) \
@ -305,3 +307,4 @@ highbd_sadMxN(16, 64);
highbd_sadMxNx4D(16, 64);
highbd_sadMxN(64, 16);
highbd_sadMxNx4D(64, 16);
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -75,10 +75,10 @@ MASKSADMxN(8, 32)
MASKSADMxN(32, 8)
MASKSADMxN(16, 64)
MASKSADMxN(64, 16)
/* clang-format on */
/* clang-format on */
static INLINE
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE
unsigned int highbd_masked_sad(const uint8_t *src8, int src_stride,
const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride,
@ -141,6 +141,7 @@ HIGHBD_MASKSADMXN(8, 32)
HIGHBD_MASKSADMXN(32, 8)
HIGHBD_MASKSADMXN(16, 64)
HIGHBD_MASKSADMXN(64, 16)
#endif // CONFIG_AV1_HIGHBITDEPTH
// pre: predictor being evaluated
// wsrc: target weighted prediction (has been *4096 to keep precision)
@ -193,9 +194,10 @@ OBMCSADMxN(8, 32)
OBMCSADMxN(32, 8)
OBMCSADMxN(16, 64)
OBMCSADMxN(64, 16)
/* clang-format on */
/* clang-format on */
static INLINE
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE
unsigned int highbd_obmc_sad(const uint8_t *pre8, int pre_stride,
const int32_t *wsrc, const int32_t *mask,
int width, int height) {
@ -246,3 +248,4 @@ HIGHBD_OBMCSADMXN(32, 8)
HIGHBD_OBMCSADMXN(16, 64)
HIGHBD_OBMCSADMXN(64, 16)
/* clang-format on */
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -89,7 +89,8 @@ SIMD_INLINE v128 v128_dup_32(uint32_t x) { return _mm_set1_epi32(x); }
SIMD_INLINE v128 v128_dup_64(uint64_t x) {
// _mm_set_pi64x and _mm_cvtsi64x_si64 missing in some compilers
return _mm_set_epi32(x >> 32, (uint32_t)x, x >> 32, (uint32_t)x);
return _mm_set_epi32((uint32_t)(x >> 32), (uint32_t)x, (uint32_t)(x >> 32),
(uint32_t)x);
}
SIMD_INLINE v128 v128_add_8(v128 a, v128 b) { return _mm_add_epi8(a, b); }
@ -538,7 +539,7 @@ SIMD_INLINE v128 v128_shl_8(v128 a, unsigned int c) {
}
SIMD_INLINE v128 v128_shr_u8(v128 a, unsigned int c) {
return _mm_and_si128(_mm_set1_epi8(0xff >> c),
return _mm_and_si128(_mm_set1_epi8((char)(0xff >> c)),
_mm_srl_epi16(a, _mm_cvtsi32_si128(c)));
}

View file

@ -603,7 +603,7 @@ SIMD_INLINE v256 v256_shl_8(v256 a, unsigned int c) {
}
SIMD_INLINE v256 v256_shr_u8(v256 a, unsigned int c) {
return _mm256_and_si256(_mm256_set1_epi8(0xff >> c),
return _mm256_and_si256(_mm256_set1_epi8((char)(0xff >> c)),
_mm256_srl_epi16(a, _mm_cvtsi32_si128(c)));
}

View file

@ -171,14 +171,14 @@ SIMD_INLINE c_v64 c_v64_dup_32(uint32_t x) {
SIMD_INLINE c_v64 c_v64_add_8(c_v64 a, c_v64 b) {
c_v64 t;
int c;
for (c = 0; c < 8; c++) t.u8[c] = a.u8[c] + b.u8[c];
for (c = 0; c < 8; c++) t.u8[c] = (uint8_t)(a.u8[c] + b.u8[c]);
return t;
}
SIMD_INLINE c_v64 c_v64_add_16(c_v64 a, c_v64 b) {
c_v64 t;
int c;
for (c = 0; c < 4; c++) t.u16[c] = a.u16[c] + b.u16[c];
for (c = 0; c < 4; c++) t.u16[c] = (uint16_t)(a.u16[c] + b.u16[c]);
return t;
}
@ -228,7 +228,7 @@ SIMD_INLINE c_v64 c_v64_add_32(c_v64 a, c_v64 b) {
SIMD_INLINE c_v64 c_v64_sub_8(c_v64 a, c_v64 b) {
c_v64 t;
int c;
for (c = 0; c < 8; c++) t.u8[c] = a.u8[c] - b.u8[c];
for (c = 0; c < 8; c++) t.u8[c] = (uint8_t)(a.u8[c] - b.u8[c]);
return t;
}
@ -252,7 +252,7 @@ SIMD_INLINE c_v64 c_v64_ssub_s8(c_v64 a, c_v64 b) {
SIMD_INLINE c_v64 c_v64_sub_16(c_v64 a, c_v64 b) {
c_v64 t;
int c;
for (c = 0; c < 4; c++) t.u16[c] = a.u16[c] - b.u16[c];
for (c = 0; c < 4; c++) t.u16[c] = (uint16_t)(a.u16[c] - b.u16[c]);
return t;
}
@ -288,14 +288,15 @@ SIMD_INLINE c_v64 c_v64_abs_s16(c_v64 a) {
c_v64 t;
int c;
for (c = 0; c < 4; c++)
t.u16[c] = (int16_t)a.u16[c] > 0 ? a.u16[c] : -a.u16[c];
t.u16[c] = (uint16_t)((int16_t)a.u16[c] > 0 ? a.u16[c] : -a.u16[c]);
return t;
}
SIMD_INLINE c_v64 c_v64_abs_s8(c_v64 a) {
c_v64 t;
int c;
for (c = 0; c < 8; c++) t.u8[c] = (int8_t)a.u8[c] > 0 ? a.u8[c] : -a.u8[c];
for (c = 0; c < 8; c++)
t.u8[c] = (uint8_t)((int8_t)a.u8[c] > 0 ? a.u8[c] : -a.u8[c]);
return t;
}
@ -526,14 +527,14 @@ SIMD_INLINE c_v64 c_v64_pack_s16_s8(c_v64 a, c_v64 b) {
a = b;
b = u;
}
t.u8[7] = a.s16[3] > 127 ? 127 : a.s16[3] < -128 ? 128 : a.s16[3];
t.u8[6] = a.s16[2] > 127 ? 127 : a.s16[2] < -128 ? 128 : a.s16[2];
t.u8[5] = a.s16[1] > 127 ? 127 : a.s16[1] < -128 ? 128 : a.s16[1];
t.u8[4] = a.s16[0] > 127 ? 127 : a.s16[0] < -128 ? 128 : a.s16[0];
t.u8[3] = b.s16[3] > 127 ? 127 : b.s16[3] < -128 ? 128 : b.s16[3];
t.u8[2] = b.s16[2] > 127 ? 127 : b.s16[2] < -128 ? 128 : b.s16[2];
t.u8[1] = b.s16[1] > 127 ? 127 : b.s16[1] < -128 ? 128 : b.s16[1];
t.u8[0] = b.s16[0] > 127 ? 127 : b.s16[0] < -128 ? 128 : b.s16[0];
t.u8[7] = (uint8_t)(a.s16[3] > 127 ? 127 : a.s16[3] < -128 ? 128 : a.s16[3]);
t.u8[6] = (uint8_t)(a.s16[2] > 127 ? 127 : a.s16[2] < -128 ? 128 : a.s16[2]);
t.u8[5] = (uint8_t)(a.s16[1] > 127 ? 127 : a.s16[1] < -128 ? 128 : a.s16[1]);
t.u8[4] = (uint8_t)(a.s16[0] > 127 ? 127 : a.s16[0] < -128 ? 128 : a.s16[0]);
t.u8[3] = (uint8_t)(b.s16[3] > 127 ? 127 : b.s16[3] < -128 ? 128 : b.s16[3]);
t.u8[2] = (uint8_t)(b.s16[2] > 127 ? 127 : b.s16[2] < -128 ? 128 : b.s16[2]);
t.u8[1] = (uint8_t)(b.s16[1] > 127 ? 127 : b.s16[1] < -128 ? 128 : b.s16[1]);
t.u8[0] = (uint8_t)(b.s16[0] > 127 ? 127 : b.s16[0] < -128 ? 128 : b.s16[0]);
return t;
}
@ -817,7 +818,7 @@ SIMD_INLINE c_v64 c_v64_shl_8(c_v64 a, unsigned int n) {
fprintf(stderr, "Error: Undefined u8 shift left %d\n", n);
abort();
}
for (c = 0; c < 8; c++) t.s8[c] = a.u8[c] << n;
for (c = 0; c < 8; c++) t.s8[c] = (int8_t)(a.u8[c] << n);
return t;
}
@ -850,7 +851,7 @@ SIMD_INLINE c_v64 c_v64_shl_16(c_v64 a, unsigned int n) {
fprintf(stderr, "Error: Undefined u16 shift left %d\n", n);
abort();
}
for (c = 0; c < 4; c++) t.u16[c] = a.u16[c] << n;
for (c = 0; c < 4; c++) t.u16[c] = (uint16_t)(a.u16[c] << n);
return t;
}

View file

@ -433,12 +433,12 @@ SIMD_INLINE v64 v64_cmplt_s16(v64 a, v64 b) { return _mm_cmplt_epi16(a, b); }
SIMD_INLINE v64 v64_cmpeq_16(v64 a, v64 b) { return _mm_cmpeq_epi16(a, b); }
SIMD_INLINE v64 v64_shl_8(v64 a, unsigned int c) {
return _mm_and_si128(_mm_set1_epi8((uint8_t)(0xff << c)),
return _mm_and_si128(_mm_set1_epi8((char)(0xff << c)),
_mm_sll_epi16(a, _mm_cvtsi32_si128(c)));
}
SIMD_INLINE v64 v64_shr_u8(v64 a, unsigned int c) {
return _mm_and_si128(_mm_set1_epi8(0xff >> c),
return _mm_and_si128(_mm_set1_epi8((char)(0xff >> c)),
_mm_srl_epi16(a, _mm_cvtsi32_si128(c)));
}

View file

@ -33,6 +33,7 @@ int64_t aom_sse_c(const uint8_t *a, int a_stride, const uint8_t *b,
return sse;
}
#if CONFIG_AV1_HIGHBITDEPTH
int64_t aom_highbd_sse_c(const uint8_t *a8, int a_stride, const uint8_t *b8,
int b_stride, int width, int height) {
int y, x;
@ -50,3 +51,4 @@ int64_t aom_highbd_sse_c(const uint8_t *a8, int a_stride, const uint8_t *b8,
}
return sse;
}
#endif

View file

@ -49,6 +49,7 @@ void aom_ssim_parms_8x8_c(const uint8_t *s, int sp, const uint8_t *r, int rp,
}
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_ssim_parms_8x8_c(const uint16_t *s, int sp, const uint16_t *r,
int rp, uint32_t *sum_s, uint32_t *sum_r,
uint32_t *sum_sq_s, uint32_t *sum_sq_r,
@ -64,6 +65,7 @@ void aom_highbd_ssim_parms_8x8_c(const uint16_t *s, int sp, const uint16_t *r,
}
}
}
#endif
static const int64_t cc1 = 26634; // (64^2*(.01*255)^2
static const int64_t cc2 = 239708; // (64^2*(.03*255)^2

View file

@ -32,6 +32,7 @@ void aom_subtract_block_c(int rows, int cols, int16_t *diff,
}
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_subtract_block_c(int rows, int cols, int16_t *diff,
ptrdiff_t diff_stride, const uint8_t *src8,
ptrdiff_t src_stride, const uint8_t *pred8,
@ -51,3 +52,4 @@ void aom_highbd_subtract_block_c(int rows, int cols, int16_t *diff,
src += src_stride;
}
}
#endif

View file

@ -339,30 +339,25 @@ void aom_upsampled_pred_c(MACROBLOCKD *xd, const AV1_COMMON *const cm,
pre_buf->buf0 + (pos_y >> SCALE_SUBPEL_BITS) * pre_buf->stride +
(pos_x >> SCALE_SUBPEL_BITS);
InterPredParams inter_pred_params;
const SubpelParams subpel_params = { sf->x_step_q4, sf->y_step_q4,
pos_x & SCALE_SUBPEL_MASK,
pos_y & SCALE_SUBPEL_MASK };
// Get warp types.
const WarpedMotionParams *const wm =
&xd->global_motion[mi->ref_frame[ref_num]];
const int is_global = is_global_mv_block(mi, wm->wmtype);
WarpTypesAllowed warp_types;
warp_types.global_warp_allowed = is_global;
warp_types.local_warp_allowed = mi->motion_mode == WARPED_CAUSAL;
// Get convolve parameters.
ConvolveParams conv_params = get_conv_params(0, plane, xd->bd);
const InterpFilters filters =
inter_pred_params.conv_params = get_conv_params(0, plane, xd->bd);
const int_interpfilters filters =
av1_broadcast_interp_filter(EIGHTTAP_REGULAR);
av1_init_inter_params(
&inter_pred_params, width, height, mi_y >> pd->subsampling_y,
mi_x >> pd->subsampling_x, pd->subsampling_x, pd->subsampling_y,
xd->bd, is_cur_buf_hbd(xd), mi->use_intrabc, sf, filters);
// Get the inter predictor.
const int build_for_obmc = 0;
av1_make_inter_predictor(pre, pre_buf->stride, comp_pred, width,
&subpel_params, sf, width, height, &conv_params,
filters, &warp_types, mi_x >> pd->subsampling_x,
mi_y >> pd->subsampling_y, plane, ref_num, mi,
build_for_obmc, xd, cm->allow_warped_motion);
&inter_pred_params, &subpel_params);
return;
}
@ -468,6 +463,7 @@ void aom_dist_wtd_comp_avg_upsampled_pred_c(
}
}
#if CONFIG_AV1_HIGHBITDEPTH
static void highbd_variance64(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride, int w, int h,
uint64_t *sse, int64_t *sum) {
@ -931,30 +927,25 @@ void aom_highbd_upsampled_pred_c(MACROBLOCKD *xd,
pre_buf->buf0 + (pos_y >> SCALE_SUBPEL_BITS) * pre_buf->stride +
(pos_x >> SCALE_SUBPEL_BITS);
InterPredParams inter_pred_params;
const SubpelParams subpel_params = { sf->x_step_q4, sf->y_step_q4,
pos_x & SCALE_SUBPEL_MASK,
pos_y & SCALE_SUBPEL_MASK };
// Get warp types.
const WarpedMotionParams *const wm =
&xd->global_motion[mi->ref_frame[ref_num]];
const int is_global = is_global_mv_block(mi, wm->wmtype);
WarpTypesAllowed warp_types;
warp_types.global_warp_allowed = is_global;
warp_types.local_warp_allowed = mi->motion_mode == WARPED_CAUSAL;
// Get convolve parameters.
ConvolveParams conv_params = get_conv_params(0, plane, xd->bd);
const InterpFilters filters =
inter_pred_params.conv_params = get_conv_params(0, plane, xd->bd);
const int_interpfilters filters =
av1_broadcast_interp_filter(EIGHTTAP_REGULAR);
av1_init_inter_params(
&inter_pred_params, width, height, mi_y >> pd->subsampling_y,
mi_x >> pd->subsampling_x, pd->subsampling_x, pd->subsampling_y,
xd->bd, is_cur_buf_hbd(xd), mi->use_intrabc, sf, filters);
// Get the inter predictor.
const int build_for_obmc = 0;
av1_make_inter_predictor(pre, pre_buf->stride, comp_pred8, width,
&subpel_params, sf, width, height, &conv_params,
filters, &warp_types, mi_x >> pd->subsampling_x,
mi_y >> pd->subsampling_y, plane, ref_num, mi,
build_for_obmc, xd, cm->allow_warped_motion);
&inter_pred_params, &subpel_params);
return;
}
@ -1070,6 +1061,7 @@ void aom_highbd_dist_wtd_comp_avg_upsampled_pred_c(
pred += width;
}
}
#endif // CONFIG_AV1_HIGHBITDEPTH
void aom_comp_mask_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width,
int height, const uint8_t *ref, int ref_stride,
@ -1153,6 +1145,7 @@ MASK_SUBPIX_VAR(32, 8)
MASK_SUBPIX_VAR(16, 64)
MASK_SUBPIX_VAR(64, 16)
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_comp_mask_pred_c(uint8_t *comp_pred8, const uint8_t *pred8,
int width, int height, const uint8_t *ref8,
int ref_stride, const uint8_t *mask,
@ -1277,6 +1270,7 @@ HIGHBD_MASK_SUBPIX_VAR(8, 32)
HIGHBD_MASK_SUBPIX_VAR(32, 8)
HIGHBD_MASK_SUBPIX_VAR(16, 64)
HIGHBD_MASK_SUBPIX_VAR(64, 16)
#endif // CONFIG_AV1_HIGHBITDEPTH
static INLINE void obmc_variance(const uint8_t *pre, int pre_stride,
const int32_t *wsrc, const int32_t *mask,
@ -1384,6 +1378,7 @@ OBMC_SUBPIX_VAR(16, 64)
OBMC_VAR(64, 16)
OBMC_SUBPIX_VAR(64, 16)
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE void highbd_obmc_variance64(const uint8_t *pre8, int pre_stride,
const int32_t *wsrc,
const int32_t *mask, int w, int h,
@ -1575,3 +1570,4 @@ HIGHBD_OBMC_VAR(16, 64)
HIGHBD_OBMC_SUBPIX_VAR(16, 64)
HIGHBD_OBMC_VAR(64, 16)
HIGHBD_OBMC_SUBPIX_VAR(64, 16)
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -49,6 +49,7 @@ filter8_1dfunction aom_filter_block1d4_h2_sse2;
FUN_CONV_1D(horiz, x_step_q4, filter_x, h, src, , sse2);
FUN_CONV_1D(vert, y_step_q4, filter_y, v, src - src_stride * 3, , sse2);
#if CONFIG_AV1_HIGHBITDEPTH
highbd_filter8_1dfunction aom_highbd_filter_block1d16_v8_sse2;
highbd_filter8_1dfunction aom_highbd_filter_block1d16_h8_sse2;
highbd_filter8_1dfunction aom_highbd_filter_block1d8_v8_sse2;
@ -90,5 +91,5 @@ highbd_filter8_1dfunction aom_highbd_filter_block1d4_h2_sse2;
// int w, int h, int bd);
HIGH_FUN_CONV_1D(horiz, x_step_q4, filter_x, h, src, , sse2);
HIGH_FUN_CONV_1D(vert, y_step_q4, filter_y, v, src - src_stride * 3, , sse2);
#endif
#endif // HAVE_SSE2

View file

@ -224,17 +224,217 @@ void aom_hadamard_32x32_avx2(const int16_t *src_diff, ptrdiff_t src_stride,
}
}
#if CONFIG_AV1_HIGHBITDEPTH
static void highbd_hadamard_col8_avx2(__m256i *in, int iter) {
__m256i a0 = in[0];
__m256i a1 = in[1];
__m256i a2 = in[2];
__m256i a3 = in[3];
__m256i a4 = in[4];
__m256i a5 = in[5];
__m256i a6 = in[6];
__m256i a7 = in[7];
__m256i b0 = _mm256_add_epi32(a0, a1);
__m256i b1 = _mm256_sub_epi32(a0, a1);
__m256i b2 = _mm256_add_epi32(a2, a3);
__m256i b3 = _mm256_sub_epi32(a2, a3);
__m256i b4 = _mm256_add_epi32(a4, a5);
__m256i b5 = _mm256_sub_epi32(a4, a5);
__m256i b6 = _mm256_add_epi32(a6, a7);
__m256i b7 = _mm256_sub_epi32(a6, a7);
a0 = _mm256_add_epi32(b0, b2);
a1 = _mm256_add_epi32(b1, b3);
a2 = _mm256_sub_epi32(b0, b2);
a3 = _mm256_sub_epi32(b1, b3);
a4 = _mm256_add_epi32(b4, b6);
a5 = _mm256_add_epi32(b5, b7);
a6 = _mm256_sub_epi32(b4, b6);
a7 = _mm256_sub_epi32(b5, b7);
if (iter == 0) {
b0 = _mm256_add_epi32(a0, a4);
b7 = _mm256_add_epi32(a1, a5);
b3 = _mm256_add_epi32(a2, a6);
b4 = _mm256_add_epi32(a3, a7);
b2 = _mm256_sub_epi32(a0, a4);
b6 = _mm256_sub_epi32(a1, a5);
b1 = _mm256_sub_epi32(a2, a6);
b5 = _mm256_sub_epi32(a3, a7);
a0 = _mm256_unpacklo_epi32(b0, b1);
a1 = _mm256_unpacklo_epi32(b2, b3);
a2 = _mm256_unpackhi_epi32(b0, b1);
a3 = _mm256_unpackhi_epi32(b2, b3);
a4 = _mm256_unpacklo_epi32(b4, b5);
a5 = _mm256_unpacklo_epi32(b6, b7);
a6 = _mm256_unpackhi_epi32(b4, b5);
a7 = _mm256_unpackhi_epi32(b6, b7);
b0 = _mm256_unpacklo_epi64(a0, a1);
b1 = _mm256_unpacklo_epi64(a4, a5);
b2 = _mm256_unpackhi_epi64(a0, a1);
b3 = _mm256_unpackhi_epi64(a4, a5);
b4 = _mm256_unpacklo_epi64(a2, a3);
b5 = _mm256_unpacklo_epi64(a6, a7);
b6 = _mm256_unpackhi_epi64(a2, a3);
b7 = _mm256_unpackhi_epi64(a6, a7);
in[0] = _mm256_permute2x128_si256(b0, b1, 0x20);
in[1] = _mm256_permute2x128_si256(b0, b1, 0x31);
in[2] = _mm256_permute2x128_si256(b2, b3, 0x20);
in[3] = _mm256_permute2x128_si256(b2, b3, 0x31);
in[4] = _mm256_permute2x128_si256(b4, b5, 0x20);
in[5] = _mm256_permute2x128_si256(b4, b5, 0x31);
in[6] = _mm256_permute2x128_si256(b6, b7, 0x20);
in[7] = _mm256_permute2x128_si256(b6, b7, 0x31);
} else {
in[0] = _mm256_add_epi32(a0, a4);
in[7] = _mm256_add_epi32(a1, a5);
in[3] = _mm256_add_epi32(a2, a6);
in[4] = _mm256_add_epi32(a3, a7);
in[2] = _mm256_sub_epi32(a0, a4);
in[6] = _mm256_sub_epi32(a1, a5);
in[1] = _mm256_sub_epi32(a2, a6);
in[5] = _mm256_sub_epi32(a3, a7);
}
}
void aom_highbd_hadamard_8x8_avx2(const int16_t *src_diff, ptrdiff_t src_stride,
tran_low_t *coeff) {
__m128i src16[8];
__m256i src32[8];
src16[0] = _mm_loadu_si128((const __m128i *)src_diff);
src16[1] = _mm_loadu_si128((const __m128i *)(src_diff += src_stride));
src16[2] = _mm_loadu_si128((const __m128i *)(src_diff += src_stride));
src16[3] = _mm_loadu_si128((const __m128i *)(src_diff += src_stride));
src16[4] = _mm_loadu_si128((const __m128i *)(src_diff += src_stride));
src16[5] = _mm_loadu_si128((const __m128i *)(src_diff += src_stride));
src16[6] = _mm_loadu_si128((const __m128i *)(src_diff += src_stride));
src16[7] = _mm_loadu_si128((const __m128i *)(src_diff += src_stride));
src32[0] = _mm256_cvtepi16_epi32(src16[0]);
src32[1] = _mm256_cvtepi16_epi32(src16[1]);
src32[2] = _mm256_cvtepi16_epi32(src16[2]);
src32[3] = _mm256_cvtepi16_epi32(src16[3]);
src32[4] = _mm256_cvtepi16_epi32(src16[4]);
src32[5] = _mm256_cvtepi16_epi32(src16[5]);
src32[6] = _mm256_cvtepi16_epi32(src16[6]);
src32[7] = _mm256_cvtepi16_epi32(src16[7]);
highbd_hadamard_col8_avx2(src32, 0);
highbd_hadamard_col8_avx2(src32, 1);
_mm256_storeu_si256((__m256i *)coeff, src32[0]);
coeff += 8;
_mm256_storeu_si256((__m256i *)coeff, src32[1]);
coeff += 8;
_mm256_storeu_si256((__m256i *)coeff, src32[2]);
coeff += 8;
_mm256_storeu_si256((__m256i *)coeff, src32[3]);
coeff += 8;
_mm256_storeu_si256((__m256i *)coeff, src32[4]);
coeff += 8;
_mm256_storeu_si256((__m256i *)coeff, src32[5]);
coeff += 8;
_mm256_storeu_si256((__m256i *)coeff, src32[6]);
coeff += 8;
_mm256_storeu_si256((__m256i *)coeff, src32[7]);
}
void aom_highbd_hadamard_16x16_avx2(const int16_t *src_diff,
ptrdiff_t src_stride, tran_low_t *coeff) {
int idx;
tran_low_t *t_coeff = coeff;
for (idx = 0; idx < 4; ++idx) {
const int16_t *src_ptr =
src_diff + (idx >> 1) * 8 * src_stride + (idx & 0x01) * 8;
aom_highbd_hadamard_8x8_avx2(src_ptr, src_stride, t_coeff + idx * 64);
}
for (idx = 0; idx < 64; idx += 8) {
__m256i coeff0 = _mm256_loadu_si256((const __m256i *)t_coeff);
__m256i coeff1 = _mm256_loadu_si256((const __m256i *)(t_coeff + 64));
__m256i coeff2 = _mm256_loadu_si256((const __m256i *)(t_coeff + 128));
__m256i coeff3 = _mm256_loadu_si256((const __m256i *)(t_coeff + 192));
__m256i b0 = _mm256_add_epi32(coeff0, coeff1);
__m256i b1 = _mm256_sub_epi32(coeff0, coeff1);
__m256i b2 = _mm256_add_epi32(coeff2, coeff3);
__m256i b3 = _mm256_sub_epi32(coeff2, coeff3);
b0 = _mm256_srai_epi32(b0, 1);
b1 = _mm256_srai_epi32(b1, 1);
b2 = _mm256_srai_epi32(b2, 1);
b3 = _mm256_srai_epi32(b3, 1);
coeff0 = _mm256_add_epi32(b0, b2);
coeff1 = _mm256_add_epi32(b1, b3);
coeff2 = _mm256_sub_epi32(b0, b2);
coeff3 = _mm256_sub_epi32(b1, b3);
_mm256_storeu_si256((__m256i *)coeff, coeff0);
_mm256_storeu_si256((__m256i *)(coeff + 64), coeff1);
_mm256_storeu_si256((__m256i *)(coeff + 128), coeff2);
_mm256_storeu_si256((__m256i *)(coeff + 192), coeff3);
coeff += 8;
t_coeff += 8;
}
}
void aom_highbd_hadamard_32x32_avx2(const int16_t *src_diff,
ptrdiff_t src_stride, tran_low_t *coeff) {
int idx;
tran_low_t *t_coeff = coeff;
for (idx = 0; idx < 4; ++idx) {
const int16_t *src_ptr =
src_diff + (idx >> 1) * 16 * src_stride + (idx & 0x01) * 16;
aom_highbd_hadamard_16x16_avx2(src_ptr, src_stride, t_coeff + idx * 256);
}
for (idx = 0; idx < 256; idx += 8) {
__m256i coeff0 = _mm256_loadu_si256((const __m256i *)t_coeff);
__m256i coeff1 = _mm256_loadu_si256((const __m256i *)(t_coeff + 256));
__m256i coeff2 = _mm256_loadu_si256((const __m256i *)(t_coeff + 512));
__m256i coeff3 = _mm256_loadu_si256((const __m256i *)(t_coeff + 768));
__m256i b0 = _mm256_add_epi32(coeff0, coeff1);
__m256i b1 = _mm256_sub_epi32(coeff0, coeff1);
__m256i b2 = _mm256_add_epi32(coeff2, coeff3);
__m256i b3 = _mm256_sub_epi32(coeff2, coeff3);
b0 = _mm256_srai_epi32(b0, 2);
b1 = _mm256_srai_epi32(b1, 2);
b2 = _mm256_srai_epi32(b2, 2);
b3 = _mm256_srai_epi32(b3, 2);
coeff0 = _mm256_add_epi32(b0, b2);
coeff1 = _mm256_add_epi32(b1, b3);
coeff2 = _mm256_sub_epi32(b0, b2);
coeff3 = _mm256_sub_epi32(b1, b3);
_mm256_storeu_si256((__m256i *)coeff, coeff0);
_mm256_storeu_si256((__m256i *)(coeff + 256), coeff1);
_mm256_storeu_si256((__m256i *)(coeff + 512), coeff2);
_mm256_storeu_si256((__m256i *)(coeff + 768), coeff3);
coeff += 8;
t_coeff += 8;
}
}
#endif // CONFIG_AV1_HIGHBITDEPTH
int aom_satd_avx2(const tran_low_t *coeff, int length) {
const __m256i one = _mm256_set1_epi16(1);
__m256i accum = _mm256_setzero_si256();
int i;
for (i = 0; i < length; i += 16) {
const __m256i src_line = load_tran_low(coeff);
const __m256i abs = _mm256_abs_epi16(src_line);
const __m256i sum = _mm256_madd_epi16(abs, one);
accum = _mm256_add_epi32(accum, sum);
coeff += 16;
for (i = 0; i < length; i += 8, coeff += 8) {
const __m256i src_line = _mm256_loadu_si256((const __m256i *)coeff);
const __m256i abs = _mm256_abs_epi32(src_line);
accum = _mm256_add_epi32(accum, abs);
}
{ // 32 bit horizontal add

View file

@ -406,3 +406,75 @@ int aom_satd_sse2(const tran_low_t *coeff, int length) {
return _mm_cvtsi128_si32(accum);
}
void aom_int_pro_row_sse2(int16_t *hbuf, const uint8_t *ref,
const int ref_stride, const int height) {
int idx = 1;
__m128i zero = _mm_setzero_si128();
__m128i src_line = _mm_loadu_si128((const __m128i *)ref);
__m128i s0 = _mm_unpacklo_epi8(src_line, zero);
__m128i s1 = _mm_unpackhi_epi8(src_line, zero);
__m128i t0, t1;
int height_1 = height - 1;
ref += ref_stride;
do {
src_line = _mm_loadu_si128((const __m128i *)ref);
t0 = _mm_unpacklo_epi8(src_line, zero);
t1 = _mm_unpackhi_epi8(src_line, zero);
s0 = _mm_adds_epu16(s0, t0);
s1 = _mm_adds_epu16(s1, t1);
ref += ref_stride;
src_line = _mm_loadu_si128((const __m128i *)ref);
t0 = _mm_unpacklo_epi8(src_line, zero);
t1 = _mm_unpackhi_epi8(src_line, zero);
s0 = _mm_adds_epu16(s0, t0);
s1 = _mm_adds_epu16(s1, t1);
ref += ref_stride;
idx += 2;
} while (idx < height_1);
src_line = _mm_loadu_si128((const __m128i *)ref);
t0 = _mm_unpacklo_epi8(src_line, zero);
t1 = _mm_unpackhi_epi8(src_line, zero);
s0 = _mm_adds_epu16(s0, t0);
s1 = _mm_adds_epu16(s1, t1);
if (height == 128) {
s0 = _mm_srai_epi16(s0, 6);
s1 = _mm_srai_epi16(s1, 6);
} else if (height == 64) {
s0 = _mm_srai_epi16(s0, 5);
s1 = _mm_srai_epi16(s1, 5);
} else if (height == 32) {
s0 = _mm_srai_epi16(s0, 4);
s1 = _mm_srai_epi16(s1, 4);
} else {
assert(height == 16);
s0 = _mm_srai_epi16(s0, 3);
s1 = _mm_srai_epi16(s1, 3);
}
_mm_storeu_si128((__m128i *)hbuf, s0);
hbuf += 8;
_mm_storeu_si128((__m128i *)hbuf, s1);
}
int16_t aom_int_pro_col_sse2(const uint8_t *ref, const int width) {
__m128i zero = _mm_setzero_si128();
__m128i src_line = _mm_loadu_si128((const __m128i *)ref);
__m128i s0 = _mm_sad_epu8(src_line, zero);
__m128i s1;
int i;
for (i = 16; i < width; i += 16) {
ref += 16;
src_line = _mm_loadu_si128((const __m128i *)ref);
s1 = _mm_sad_epu8(src_line, zero);
s0 = _mm_adds_epu16(s0, s1);
}
s1 = _mm_srli_si128(s0, 8);
s0 = _mm_adds_epu16(s0, s1);
return _mm_extract_epi16(s0, 0);
}

View file

@ -24,6 +24,7 @@ void aom_blend_a64_hmask_sse4_1(uint8_t *dst, uint32_t dst_stride,
src1_stride, mask, 0, w, h, 0, 0);
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_blend_a64_hmask_sse4_1(
uint8_t *dst_8, uint32_t dst_stride, const uint8_t *src0_8,
uint32_t src0_stride, const uint8_t *src1_8, uint32_t src1_stride,
@ -32,3 +33,4 @@ void aom_highbd_blend_a64_hmask_sse4_1(
src1_8, src1_stride, mask, 0, w, h, 0, 0,
bd);
}
#endif

View file

@ -870,7 +870,7 @@ void aom_blend_a64_mask_avx2(uint8_t *dst, uint32_t dst_stride,
const uint8_t *src0, uint32_t src0_stride,
const uint8_t *src1, uint32_t src1_stride,
const uint8_t *mask, uint32_t mask_stride, int w,
int h, int subx, int suby) {
int h, int subw, int subh) {
assert(IMPLIES(src0 == dst, src0_stride == dst_stride));
assert(IMPLIES(src1 == dst, src1_stride == dst_stride));
@ -881,15 +881,15 @@ void aom_blend_a64_mask_avx2(uint8_t *dst, uint32_t dst_stride,
if (UNLIKELY((h | w) & 3)) { // if (w <= 2 || h <= 2)
aom_blend_a64_mask_c(dst, dst_stride, src0, src0_stride, src1, src1_stride,
mask, mask_stride, w, h, subx, suby);
mask, mask_stride, w, h, subw, subh);
} else {
if (subx & suby) {
if (subw & subh) {
blend_a64_mask_sx_sy_avx2(dst, dst_stride, src0, src0_stride, src1,
src1_stride, mask, mask_stride, w, h);
} else if (subx) {
} else if (subw) {
blend_a64_mask_sx_avx2(dst, dst_stride, src0, src0_stride, src1,
src1_stride, mask, mask_stride, w, h);
} else if (suby) {
} else if (subh) {
blend_a64_mask_sy_avx2(dst, dst_stride, src0, src0_stride, src1,
src1_stride, mask, mask_stride, w, h);
} else {
@ -899,6 +899,7 @@ void aom_blend_a64_mask_avx2(uint8_t *dst, uint32_t dst_stride,
}
}
#if CONFIG_AV1_HIGHBITDEPTH
//////////////////////////////////////////////////////////////////////////////
// aom_highbd_blend_a64_d16_mask_avx2()
//////////////////////////////////////////////////////////////////////////////
@ -1370,3 +1371,4 @@ void aom_highbd_blend_a64_d16_mask_avx2(
subh, conv_params, bd);
}
}
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -339,8 +339,8 @@ static void blend_a64_mask_sx_sy_w16n_sse4_1(
uint8_t *dst, uint32_t dst_stride, const uint8_t *src0,
uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride,
const uint8_t *mask, uint32_t mask_stride, int w, int h) {
const __m128i v_zmask_b = _mm_set_epi8(0, 0xff, 0, 0xff, 0, 0xff, 0, 0xff, 0,
0xff, 0, 0xff, 0, 0xff, 0, 0xff);
const __m128i v_zmask_b =
_mm_set_epi8(0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1);
const __m128i v_maxval_b = _mm_set1_epi8(AOM_BLEND_A64_MAX_ALPHA);
const __m128i _r = _mm_set1_epi16(1 << (15 - AOM_BLEND_A64_ROUND_BITS));
do {
@ -386,7 +386,7 @@ void aom_blend_a64_mask_sse4_1(uint8_t *dst, uint32_t dst_stride,
const uint8_t *src0, uint32_t src0_stride,
const uint8_t *src1, uint32_t src1_stride,
const uint8_t *mask, uint32_t mask_stride, int w,
int h, int subx, int suby) {
int h, int subw, int subh) {
typedef void (*blend_fn)(
uint8_t * dst, uint32_t dst_stride, const uint8_t *src0,
uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride,
@ -415,14 +415,15 @@ void aom_blend_a64_mask_sse4_1(uint8_t *dst, uint32_t dst_stride,
if (UNLIKELY((h | w) & 3)) { // if (w <= 2 || h <= 2)
aom_blend_a64_mask_c(dst, dst_stride, src0, src0_stride, src1, src1_stride,
mask, mask_stride, w, h, subx, suby);
mask, mask_stride, w, h, subw, subh);
} else {
blend[(w >> 2) & 3][subx != 0][suby != 0](dst, dst_stride, src0,
blend[(w >> 2) & 3][subw != 0][subh != 0](dst, dst_stride, src0,
src0_stride, src1, src1_stride,
mask, mask_stride, w, h);
}
}
#if CONFIG_AV1_HIGHBITDEPTH
//////////////////////////////////////////////////////////////////////////////
// No sub-sampling
//////////////////////////////////////////////////////////////////////////////
@ -518,8 +519,8 @@ static INLINE void blend_a64_mask_bn_sx_w4_sse4_1(
uint16_t *dst, uint32_t dst_stride, const uint16_t *src0,
uint32_t src0_stride, const uint16_t *src1, uint32_t src1_stride,
const uint8_t *mask, uint32_t mask_stride, int h, blend_unit_fn blend) {
const __m128i v_zmask_b = _mm_set_epi8(0, 0xff, 0, 0xff, 0, 0xff, 0, 0xff, 0,
0xff, 0, 0xff, 0, 0xff, 0, 0xff);
const __m128i v_zmask_b =
_mm_set_epi8(0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1);
const __m128i v_maxval_w = _mm_set1_epi16(AOM_BLEND_A64_MAX_ALPHA);
do {
@ -565,8 +566,8 @@ static INLINE void blend_a64_mask_bn_sx_w8n_sse4_1(
uint32_t src0_stride, const uint16_t *src1, uint32_t src1_stride,
const uint8_t *mask, uint32_t mask_stride, int w, int h,
blend_unit_fn blend) {
const __m128i v_zmask_b = _mm_set_epi8(0, 0xff, 0, 0xff, 0, 0xff, 0, 0xff, 0,
0xff, 0, 0xff, 0, 0xff, 0, 0xff);
const __m128i v_zmask_b =
_mm_set_epi8(0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1);
const __m128i v_maxval_w = _mm_set1_epi16(AOM_BLEND_A64_MAX_ALPHA);
do {
@ -710,8 +711,8 @@ static INLINE void blend_a64_mask_bn_sx_sy_w4_sse4_1(
uint16_t *dst, uint32_t dst_stride, const uint16_t *src0,
uint32_t src0_stride, const uint16_t *src1, uint32_t src1_stride,
const uint8_t *mask, uint32_t mask_stride, int h, blend_unit_fn blend) {
const __m128i v_zmask_b = _mm_set_epi8(0, 0xff, 0, 0xff, 0, 0xff, 0, 0xff, 0,
0xff, 0, 0xff, 0, 0xff, 0, 0xff);
const __m128i v_zmask_b =
_mm_set_epi8(0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1);
const __m128i v_maxval_w = _mm_set1_epi16(AOM_BLEND_A64_MAX_ALPHA);
do {
@ -762,8 +763,8 @@ static INLINE void blend_a64_mask_bn_sx_sy_w8n_sse4_1(
uint32_t src0_stride, const uint16_t *src1, uint32_t src1_stride,
const uint8_t *mask, uint32_t mask_stride, int w, int h,
blend_unit_fn blend) {
const __m128i v_zmask_b = _mm_set_epi8(0, 0xff, 0, 0xff, 0, 0xff, 0, 0xff, 0,
0xff, 0, 0xff, 0, 0xff, 0, 0xff);
const __m128i v_zmask_b =
_mm_set_epi8(0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1);
const __m128i v_maxval_w = _mm_set1_epi16(AOM_BLEND_A64_MAX_ALPHA);
do {
@ -812,20 +813,19 @@ static void blend_a64_mask_b12_sx_sy_w8n_sse4_1(
//////////////////////////////////////////////////////////////////////////////
// Dispatch
//////////////////////////////////////////////////////////////////////////////
void aom_highbd_blend_a64_mask_sse4_1(uint8_t *dst_8, uint32_t dst_stride,
const uint8_t *src0_8,
uint32_t src0_stride,
const uint8_t *src1_8,
uint32_t src1_stride, const uint8_t *mask,
uint32_t mask_stride, int w, int h,
int subx, int suby, int bd) {
int subw, int subh, int bd) {
typedef void (*blend_fn)(
uint16_t * dst, uint32_t dst_stride, const uint16_t *src0,
uint32_t src0_stride, const uint16_t *src1, uint32_t src1_stride,
const uint8_t *mask, uint32_t mask_stride, int w, int h);
// Dimensions are: bd_index X width_index X subx X suby
// Dimensions are: bd_index X width_index X subw X subh
static const blend_fn blend[2][2][2][2] = {
{ // bd == 8 or 10
{ // w % 8 == 0
@ -858,18 +858,19 @@ void aom_highbd_blend_a64_mask_sse4_1(uint8_t *dst_8, uint32_t dst_stride,
assert(bd == 8 || bd == 10 || bd == 12);
if (UNLIKELY((h | w) & 3)) { // if (w <= 2 || h <= 2)
aom_highbd_blend_a64_mask_c(dst_8, dst_stride, src0_8, src0_stride, src1_8,
src1_stride, mask, mask_stride, w, h, subx,
suby, bd);
src1_stride, mask, mask_stride, w, h, subw,
subh, bd);
} else {
uint16_t *const dst = CONVERT_TO_SHORTPTR(dst_8);
const uint16_t *const src0 = CONVERT_TO_SHORTPTR(src0_8);
const uint16_t *const src1 = CONVERT_TO_SHORTPTR(src1_8);
blend[bd == 12][(w >> 2) & 1][subx != 0][suby != 0](
blend[bd == 12][(w >> 2) & 1][subw != 0][subh != 0](
dst, dst_stride, src0, src0_stride, src1, src1_stride, mask,
mask_stride, w, h);
}
}
#endif // CONFIG_AV1_HIGHBITDEPTH
static INLINE void blend_a64_d16_mask_w16_sse41(
uint8_t *dst, const CONV_BUF_TYPE *src0, const CONV_BUF_TYPE *src1,
@ -1111,7 +1112,7 @@ void aom_lowbd_blend_a64_d16_mask_sse4_1(
//////////////////////////////////////////////////////////////////////////////
// aom_highbd_blend_a64_d16_mask_sse4_1()
//////////////////////////////////////////////////////////////////////////////
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE void highbd_blend_a64_d16_mask_w4_sse4_1(
uint16_t *dst, int dst_stride, const CONV_BUF_TYPE *src0, int src0_stride,
const CONV_BUF_TYPE *src1, int src1_stride, const __m128i *mask0a,
@ -1556,3 +1557,4 @@ void aom_highbd_blend_a64_d16_mask_sse4_1(
subh, conv_params, bd);
}
}
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -143,6 +143,7 @@ void aom_blend_a64_vmask_sse4_1(uint8_t *dst, uint32_t dst_stride,
h);
}
#if CONFIG_AV1_HIGHBITDEPTH
//////////////////////////////////////////////////////////////////////////////
// Implementation - No sub-sampling
//////////////////////////////////////////////////////////////////////////////
@ -281,3 +282,4 @@ void aom_highbd_blend_a64_vmask_sse4_1(
src1_stride, mask, w, h);
}
}
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -0,0 +1,185 @@
/*
* Copyright (c) 2019, 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.
*/
#include <immintrin.h>
#include "config/aom_dsp_rtcd.h"
static INLINE void accumulate_sse_sum(__m256i regx_sum, __m256i regx2_sum,
int *x_sum, int64_t *x2_sum) {
__m256i sum_buffer, sse_buffer;
__m128i out_buffer;
// Accumulate the various elements of register into first element.
sum_buffer = _mm256_permute2f128_si256(regx_sum, regx_sum, 1);
regx_sum = _mm256_add_epi32(sum_buffer, regx_sum);
regx_sum = _mm256_add_epi32(regx_sum, _mm256_srli_si256(regx_sum, 8));
regx_sum = _mm256_add_epi32(regx_sum, _mm256_srli_si256(regx_sum, 4));
sse_buffer = _mm256_permute2f128_si256(regx2_sum, regx2_sum, 1);
regx2_sum = _mm256_add_epi64(sse_buffer, regx2_sum);
regx2_sum = _mm256_add_epi64(regx2_sum, _mm256_srli_si256(regx2_sum, 8));
out_buffer = _mm256_castsi256_si128(regx_sum);
*x_sum += _mm_cvtsi128_si32(out_buffer);
out_buffer = _mm256_castsi256_si128(regx2_sum);
#if ARCH_X86_64
*x2_sum += _mm_cvtsi128_si64(out_buffer);
#else
{
int64_t tmp;
_mm_storel_epi64((__m128i *)&tmp, out_buffer);
*x2_sum += tmp;
}
#endif
}
static INLINE void sse_sum_wd4_avx2(const int16_t *data, int stride, int bh,
int *x_sum, int64_t *x2_sum) {
__m128i row1, row2, row3;
__m256i regx_sum, regx2_sum, load_pixels, sum_buffer, sse_buffer,
temp_buffer1, temp_buffer2, row_sum_buffer, row_sse_buffer;
const int16_t *data_tmp = data;
__m256i one = _mm256_set1_epi16(1);
regx_sum = _mm256_setzero_si256();
regx2_sum = regx_sum;
sum_buffer = _mm256_setzero_si256();
sse_buffer = sum_buffer;
for (int j = 0; j < (bh >> 2); ++j) {
// Load 4 rows at a time.
row1 = _mm_loadl_epi64((__m128i const *)(data_tmp));
row2 = _mm_loadl_epi64((__m128i const *)(data_tmp + stride));
row1 = _mm_unpacklo_epi64(row1, row2);
row2 = _mm_loadl_epi64((__m128i const *)(data_tmp + 2 * stride));
row3 = _mm_loadl_epi64((__m128i const *)(data_tmp + 3 * stride));
row2 = _mm_unpacklo_epi64(row2, row3);
load_pixels =
_mm256_insertf128_si256(_mm256_castsi128_si256(row1), row2, 1);
row_sum_buffer = _mm256_madd_epi16(load_pixels, one);
row_sse_buffer = _mm256_madd_epi16(load_pixels, load_pixels);
sum_buffer = _mm256_add_epi32(row_sum_buffer, sum_buffer);
sse_buffer = _mm256_add_epi32(row_sse_buffer, sse_buffer);
data_tmp += 4 * stride;
}
// To prevent 32-bit variable overflow, unpack the elements to 64-bit.
temp_buffer1 = _mm256_unpacklo_epi32(sse_buffer, _mm256_setzero_si256());
temp_buffer2 = _mm256_unpackhi_epi32(sse_buffer, _mm256_setzero_si256());
sse_buffer = _mm256_add_epi64(temp_buffer1, temp_buffer2);
regx_sum = _mm256_add_epi32(sum_buffer, regx_sum);
regx2_sum = _mm256_add_epi64(sse_buffer, regx2_sum);
accumulate_sse_sum(regx_sum, regx2_sum, x_sum, x2_sum);
}
static INLINE void sse_sum_wd8_avx2(const int16_t *data, int stride, int bh,
int *x_sum, int64_t *x2_sum) {
__m128i load_128bit, load_next_128bit;
__m256i regx_sum, regx2_sum, load_pixels, sum_buffer, sse_buffer,
temp_buffer1, temp_buffer2, row_sum_buffer, row_sse_buffer;
const int16_t *data_tmp = data;
__m256i one = _mm256_set1_epi16(1);
regx_sum = _mm256_setzero_si256();
regx2_sum = regx_sum;
sum_buffer = _mm256_setzero_si256();
sse_buffer = sum_buffer;
for (int j = 0; j < (bh >> 1); ++j) {
// Load 2 rows at a time.
load_128bit = _mm_loadu_si128((__m128i const *)(data_tmp));
load_next_128bit = _mm_loadu_si128((__m128i const *)(data_tmp + stride));
load_pixels = _mm256_insertf128_si256(_mm256_castsi128_si256(load_128bit),
load_next_128bit, 1);
row_sum_buffer = _mm256_madd_epi16(load_pixels, one);
row_sse_buffer = _mm256_madd_epi16(load_pixels, load_pixels);
sum_buffer = _mm256_add_epi32(row_sum_buffer, sum_buffer);
sse_buffer = _mm256_add_epi32(row_sse_buffer, sse_buffer);
data_tmp += 2 * stride;
}
temp_buffer1 = _mm256_unpacklo_epi32(sse_buffer, _mm256_setzero_si256());
temp_buffer2 = _mm256_unpackhi_epi32(sse_buffer, _mm256_setzero_si256());
sse_buffer = _mm256_add_epi64(temp_buffer1, temp_buffer2);
regx_sum = _mm256_add_epi32(sum_buffer, regx_sum);
regx2_sum = _mm256_add_epi64(sse_buffer, regx2_sum);
accumulate_sse_sum(regx_sum, regx2_sum, x_sum, x2_sum);
}
static INLINE void sse_sum_wd16_avx2(const int16_t *data, int stride, int bh,
int *x_sum, int64_t *x2_sum,
int loop_count) {
__m256i regx_sum, regx2_sum, load_pixels, sum_buffer, sse_buffer,
temp_buffer1, temp_buffer2, row_sum_buffer, row_sse_buffer;
const int16_t *data_tmp = data;
__m256i one = _mm256_set1_epi16(1);
regx_sum = _mm256_setzero_si256();
regx2_sum = regx_sum;
sum_buffer = _mm256_setzero_si256();
sse_buffer = sum_buffer;
for (int i = 0; i < loop_count; ++i) {
data_tmp = data + 16 * i;
for (int j = 0; j < bh; ++j) {
load_pixels = _mm256_lddqu_si256((__m256i const *)(data_tmp));
row_sum_buffer = _mm256_madd_epi16(load_pixels, one);
row_sse_buffer = _mm256_madd_epi16(load_pixels, load_pixels);
sum_buffer = _mm256_add_epi32(row_sum_buffer, sum_buffer);
sse_buffer = _mm256_add_epi32(row_sse_buffer, sse_buffer);
data_tmp += stride;
}
}
temp_buffer1 = _mm256_unpacklo_epi32(sse_buffer, _mm256_setzero_si256());
temp_buffer2 = _mm256_unpackhi_epi32(sse_buffer, _mm256_setzero_si256());
sse_buffer = _mm256_add_epi64(temp_buffer1, temp_buffer2);
regx_sum = _mm256_add_epi32(sum_buffer, regx_sum);
regx2_sum = _mm256_add_epi64(sse_buffer, regx2_sum);
accumulate_sse_sum(regx_sum, regx2_sum, x_sum, x2_sum);
}
void aom_get_blk_sse_sum_avx2(const int16_t *data, int stride, int bw, int bh,
int *x_sum, int64_t *x2_sum) {
*x_sum = 0;
*x2_sum = 0;
if ((bh & 3) == 0) {
switch (bw) {
// For smaller block widths, compute multiple rows simultaneously.
case 4: sse_sum_wd4_avx2(data, stride, bh, x_sum, x2_sum); break;
case 8: sse_sum_wd8_avx2(data, stride, bh, x_sum, x2_sum); break;
case 16:
case 32:
sse_sum_wd16_avx2(data, stride, bh, x_sum, x2_sum, bw >> 4);
break;
case 64:
// 32-bit variables will overflow for 64 rows at a single time, so
// compute 32 rows at a time.
if (bh <= 32) {
sse_sum_wd16_avx2(data, stride, bh, x_sum, x2_sum, bw >> 4);
} else {
sse_sum_wd16_avx2(data, stride, 32, x_sum, x2_sum, bw >> 4);
sse_sum_wd16_avx2(data + 32 * stride, stride, 32, x_sum, x2_sum,
bw >> 4);
}
break;
default: aom_get_blk_sse_sum_c(data, stride, bw, bh, x_sum, x2_sum);
}
} else {
aom_get_blk_sse_sum_c(data, stride, bw, bh, x_sum, x2_sum);
}
}

View file

@ -0,0 +1,138 @@
/*
* Copyright (c) 2019, 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.
*/
#include <emmintrin.h>
#include "config/aom_dsp_rtcd.h"
static INLINE void sse_sum_wd4_sse2(const int16_t *data, int stride, int bh,
int *x_sum, int64_t *x2_sum) {
const int16_t *data_tmp = data;
__m128i temp_buffer1, temp_buffer2;
__m128i load_pixels_low, load_pixels_hi, sum_buffer, sse_buffer;
__m128i one = _mm_set1_epi16(1);
__m128i regx_sum = _mm_setzero_si128();
__m128i regx2_sum = regx_sum;
for (int j = 0; j < (bh >> 1); ++j) {
// Load 2 rows (8 pixels) at a time.
load_pixels_low = _mm_loadl_epi64((__m128i const *)(data_tmp));
load_pixels_hi = _mm_loadl_epi64((__m128i const *)(data_tmp + stride));
load_pixels_low = _mm_unpacklo_epi64(load_pixels_low, load_pixels_hi);
sum_buffer = _mm_madd_epi16(load_pixels_low, one);
sse_buffer = _mm_madd_epi16(load_pixels_low, load_pixels_low);
regx_sum = _mm_add_epi32(sum_buffer, regx_sum);
regx2_sum = _mm_add_epi32(sse_buffer, regx2_sum);
data_tmp += 2 * stride;
}
regx_sum = _mm_add_epi32(regx_sum, _mm_srli_si128(regx_sum, 8));
regx_sum = _mm_add_epi32(regx_sum, _mm_srli_si128(regx_sum, 4));
*x_sum = _mm_cvtsi128_si32(regx_sum);
temp_buffer1 = _mm_unpacklo_epi32(regx2_sum, _mm_setzero_si128());
temp_buffer2 = _mm_unpackhi_epi32(regx2_sum, _mm_setzero_si128());
regx2_sum = _mm_add_epi64(temp_buffer1, temp_buffer2);
regx2_sum = _mm_add_epi64(regx2_sum, _mm_srli_si128(regx2_sum, 8));
#if ARCH_X86_64
*x2_sum += _mm_cvtsi128_si64(regx2_sum);
#else
{
int64_t tmp;
_mm_storel_epi64((__m128i *)&tmp, regx2_sum);
*x2_sum += tmp;
}
#endif
}
static INLINE void sse_sum_wd8_sse2(const int16_t *data, int stride, int bh,
int *x_sum, int64_t *x2_sum,
int loop_cycles) {
const int16_t *data_tmp;
__m128i temp_buffer1, temp_buffer2;
__m128i one = _mm_set1_epi16(1);
__m128i regx_sum = _mm_setzero_si128();
__m128i regx2_sum = regx_sum;
__m128i load_pixels, sum_buffer, sse_buffer;
for (int i = 0; i < loop_cycles; ++i) {
data_tmp = data + (8 * i);
for (int j = 0; j < bh; ++j) {
// Load 1 row (8-pixels) at a time.
load_pixels = _mm_loadu_si128((__m128i const *)(data_tmp));
sum_buffer = _mm_madd_epi16(load_pixels, one);
sse_buffer = _mm_madd_epi16(load_pixels, load_pixels);
regx_sum = _mm_add_epi32(sum_buffer, regx_sum);
regx2_sum = _mm_add_epi32(sse_buffer, regx2_sum);
data_tmp += stride;
}
}
regx_sum = _mm_add_epi32(regx_sum, _mm_srli_si128(regx_sum, 8));
regx_sum = _mm_add_epi32(regx_sum, _mm_srli_si128(regx_sum, 4));
*x_sum += _mm_cvtsi128_si32(regx_sum);
temp_buffer1 = _mm_unpacklo_epi32(regx2_sum, _mm_setzero_si128());
temp_buffer2 = _mm_unpackhi_epi32(regx2_sum, _mm_setzero_si128());
regx2_sum = _mm_add_epi64(temp_buffer1, temp_buffer2);
regx2_sum = _mm_add_epi64(regx2_sum, _mm_srli_si128(regx2_sum, 8));
#if ARCH_X86_64
*x2_sum += _mm_cvtsi128_si64(regx2_sum);
#else
{
int64_t tmp;
_mm_storel_epi64((__m128i *)&tmp, regx2_sum);
*x2_sum += tmp;
}
#endif
}
// This functions adds SSE2 Support for the functions 'get_blk_sse_sum_c'
void aom_get_blk_sse_sum_sse2(const int16_t *data, int stride, int bw, int bh,
int *x_sum, int64_t *x2_sum) {
*x_sum = 0;
*x2_sum = 0;
if ((bh & 3) == 0) {
switch (bw) {
case 4: sse_sum_wd4_sse2(data, stride, bh, x_sum, x2_sum); break;
case 8:
case 16:
sse_sum_wd8_sse2(data, stride, bh, x_sum, x2_sum, bw >> 3);
break;
// For widths 32 and 64, the registers may overflow. So compute
// partial widths at a time.
case 32:
if (bh <= 32) {
sse_sum_wd8_sse2(data, stride, bh, x_sum, x2_sum, bw >> 3);
break;
} else {
sse_sum_wd8_sse2(data, stride, 32, x_sum, x2_sum, bw >> 3);
sse_sum_wd8_sse2(data + 32 * stride, stride, 32, x_sum, x2_sum,
bw >> 3);
break;
}
case 64:
if (bh <= 16) {
sse_sum_wd8_sse2(data, stride, bh, x_sum, x2_sum, bw >> 3);
break;
} else {
for (int i = 0; i < bh; i += 16)
sse_sum_wd8_sse2(data + i * stride, stride, 16, x_sum, x2_sum,
bw >> 3);
break;
}
default: aom_get_blk_sse_sum_c(data, stride, bw, bh, x_sum, x2_sum);
}
} else {
aom_get_blk_sse_sum_c(data, stride, bw, bh, x_sum, x2_sum);
}
}

View file

@ -107,6 +107,7 @@ typedef void filter8_1dfunction(const uint8_t *src_ptr, ptrdiff_t src_pitch,
} \
}
#if CONFIG_AV1_HIGHBITDEPTH
typedef void highbd_filter8_1dfunction(const uint16_t *src_ptr,
const ptrdiff_t src_pitch,
uint16_t *output_ptr,
@ -197,5 +198,6 @@ typedef void highbd_filter8_1dfunction(const uint16_t *src_ptr,
dst_stride, filter_x, x_step_q4, filter_y, y_step_q4, w, h, bd); \
} \
}
#endif // CONFIG_AV1_HIGHBITDEPTH
#endif // AOM_AOM_DSP_X86_CONVOLVE_H_

View file

@ -138,8 +138,8 @@ DECLARE_ALIGNED(32, static const uint8_t, filt4_global_avx2[32]) = {
xx_storel_32(p_0, res_0); \
xx_storel_32(p_1, res_1); \
} else { \
*(uint16_t *)p_0 = _mm_cvtsi128_si32(res_0); \
*(uint16_t *)p_1 = _mm_cvtsi128_si32(res_1); \
*(uint16_t *)p_0 = (uint16_t)_mm_cvtsi128_si32(res_0); \
*(uint16_t *)p_1 = (uint16_t)_mm_cvtsi128_si32(res_1); \
} \
\
s[0] = s[1]; \
@ -281,7 +281,7 @@ static INLINE void prepare_coeffs_lowbd(
// Since all filter co-efficients are even, this change will not affect the
// end result
assert(_mm_test_all_zeros(_mm_and_si128(coeffs_8, _mm_set1_epi16(1)),
_mm_set1_epi16(0xffff)));
_mm_set1_epi16((short)0xffff)));
const __m256i coeffs_1 = _mm256_srai_epi16(filter_coeffs, 1);

View file

@ -22,8 +22,12 @@
#include "aom_dsp/x86/fwd_txfm_impl_sse2.h"
#undef FDCT8x8_2D
#if CONFIG_AV1_HIGHBITDEPTH
#undef DCT_HIGH_BIT_DEPTH
#define DCT_HIGH_BIT_DEPTH 1
#define FDCT8x8_2D aom_highbd_fdct8x8_sse2
#include "aom_dsp/x86/fwd_txfm_impl_sse2.h" // NOLINT
#undef FDCT8x8_2D
#endif

View file

@ -0,0 +1,457 @@
/*
* Copyright (c) 2019, 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.
*/
#include <immintrin.h>
#include "config/aom_dsp_rtcd.h"
#include "aom/aom_integer.h"
#include "aom_dsp/x86/quantize_x86.h"
#include "av1/encoder/av1_quantize.h"
static INLINE void highbd_load_b_values_avx2(
const int16_t *zbin_ptr, __m256i *zbin, const int16_t *round_ptr,
__m256i *round, const int16_t *quant_ptr, __m256i *quant,
const int16_t *dequant_ptr, __m256i *dequant, const int16_t *shift_ptr,
__m256i *shift) {
*zbin = _mm256_cvtepi16_epi32(_mm_load_si128((const __m128i *)zbin_ptr));
*zbin = _mm256_sub_epi32(*zbin, _mm256_set1_epi32(1));
*round = _mm256_cvtepi16_epi32(_mm_load_si128((const __m128i *)round_ptr));
*quant = _mm256_cvtepi16_epi32(_mm_load_si128((const __m128i *)quant_ptr));
*dequant =
_mm256_cvtepi16_epi32(_mm_load_si128((const __m128i *)dequant_ptr));
*shift = _mm256_cvtepi16_epi32(_mm_load_si128((const __m128i *)shift_ptr));
}
static INLINE void highbd_update_mask1_avx2(__m256i *cmp_mask,
const int16_t *iscan_ptr,
int *is_found, __m256i *mask) {
__m256i temp_mask = _mm256_setzero_si256();
if (_mm256_movemask_epi8(*cmp_mask)) {
__m256i iscan = _mm256_loadu_si256((const __m256i *)(iscan_ptr));
temp_mask = _mm256_and_si256(*cmp_mask, iscan);
*is_found = 1;
}
*mask = _mm256_max_epi16(temp_mask, *mask);
}
static INLINE void highbd_update_mask0_avx2(__m256i *qcoeff0, __m256i *qcoeff1,
__m256i *threshold,
const int16_t *iscan_ptr,
int *is_found, __m256i *mask) {
__m256i coeff[2], cmp_mask0, cmp_mask1;
coeff[0] = _mm256_slli_epi32(*qcoeff0, AOM_QM_BITS);
cmp_mask0 = _mm256_cmpgt_epi32(coeff[0], threshold[0]);
coeff[1] = _mm256_slli_epi32(*qcoeff1, AOM_QM_BITS);
cmp_mask1 = _mm256_cmpgt_epi32(coeff[1], threshold[1]);
cmp_mask0 =
_mm256_permute4x64_epi64(_mm256_packs_epi32(cmp_mask0, cmp_mask1), 0xd8);
highbd_update_mask1_avx2(&cmp_mask0, iscan_ptr, is_found, mask);
}
static INLINE void highbd_mul_shift_avx2(const __m256i *x, const __m256i *y,
__m256i *p, const int shift) {
__m256i prod_lo = _mm256_mul_epi32(*x, *y);
__m256i prod_hi = _mm256_srli_epi64(*x, 32);
const __m256i mult_hi = _mm256_srli_epi64(*y, 32);
prod_hi = _mm256_mul_epi32(prod_hi, mult_hi);
prod_lo = _mm256_srli_epi64(prod_lo, shift);
prod_hi = _mm256_srli_epi64(prod_hi, shift);
prod_hi = _mm256_slli_epi64(prod_hi, 32);
*p = _mm256_blend_epi32(prod_lo, prod_hi, 0xaa);
}
static INLINE void highbd_calculate_qcoeff_avx2(__m256i *coeff,
const __m256i *round,
const __m256i *quant,
const __m256i *shift,
const int *log_scale) {
__m256i tmp, qcoeff;
qcoeff = _mm256_add_epi32(*coeff, *round);
highbd_mul_shift_avx2(&qcoeff, quant, &tmp, 16);
qcoeff = _mm256_add_epi32(tmp, qcoeff);
highbd_mul_shift_avx2(&qcoeff, shift, coeff, 16 - *log_scale);
}
static INLINE __m256i highbd_calculate_dqcoeff_avx2(__m256i qcoeff,
__m256i dequant) {
return _mm256_mullo_epi32(qcoeff, dequant);
}
static INLINE __m256i highbd_calculate_dqcoeff_log_scale_avx2(
__m256i qcoeff, __m256i dequant, const int log_scale) {
__m256i abs_coeff = _mm256_abs_epi32(qcoeff);
highbd_mul_shift_avx2(&abs_coeff, &dequant, &abs_coeff, log_scale);
return _mm256_sign_epi32(abs_coeff, qcoeff);
}
static INLINE void highbd_store_coefficients_avx2(__m256i coeff0,
__m256i coeff1,
tran_low_t *coeff_ptr) {
_mm256_store_si256((__m256i *)(coeff_ptr), coeff0);
_mm256_store_si256((__m256i *)(coeff_ptr + 8), coeff1);
}
void aom_highbd_quantize_b_adaptive_avx2(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
int index = 16;
int non_zero_count = 0;
int non_zero_count_prescan_add_zero = 0;
int is_found0 = 0, is_found1 = 0;
int eob = -1;
const __m256i zero = _mm256_setzero_si256();
__m256i zbin, round, quant, dequant, shift;
__m256i coeff0, qcoeff0, coeff1, qcoeff1;
__m256i cmp_mask, mask0 = zero, mask1 = zero;
__m128i temp_mask0, temp_mask1;
int prescan_add[2];
int thresh[2];
const int log_scale = 0;
const qm_val_t wt = (1 << AOM_QM_BITS);
for (int i = 0; i < 2; ++i) {
prescan_add[i] = ROUND_POWER_OF_TWO(dequant_ptr[i] * EOB_FACTOR, 7);
thresh[i] = (zbin_ptr[i] * wt + prescan_add[i]) - 1;
}
__m256i threshold[2];
threshold[0] = _mm256_set1_epi32(thresh[0]);
threshold[1] = _mm256_set1_epi32(thresh[1]);
threshold[0] = _mm256_blend_epi32(threshold[0], threshold[1], 0xfe);
#if SKIP_EOB_FACTOR_ADJUST
int first = -1;
#endif
// Setup global values.
highbd_load_b_values_avx2(zbin_ptr, &zbin, round_ptr, &round, quant_ptr,
&quant, dequant_ptr, &dequant, quant_shift_ptr,
&shift);
// Do DC and first 15 AC.
coeff0 = _mm256_load_si256((__m256i *)(coeff_ptr));
qcoeff0 = _mm256_abs_epi32(coeff0);
coeff1 = _mm256_load_si256((__m256i *)(coeff_ptr + 8));
qcoeff1 = _mm256_abs_epi32(coeff1);
highbd_update_mask0_avx2(&qcoeff0, &qcoeff1, threshold, iscan, &is_found0,
&mask0);
__m256i temp0 = _mm256_cmpgt_epi32(qcoeff0, zbin);
zbin = _mm256_unpackhi_epi64(zbin, zbin);
__m256i temp1 = _mm256_cmpgt_epi32(qcoeff1, zbin);
cmp_mask = _mm256_permute4x64_epi64(_mm256_packs_epi32(temp0, temp1), 0xd8);
highbd_update_mask1_avx2(&cmp_mask, iscan, &is_found1, &mask1);
threshold[0] = threshold[1];
if (_mm256_movemask_epi8(cmp_mask) == 0) {
_mm256_store_si256((__m256i *)(qcoeff_ptr), zero);
_mm256_store_si256((__m256i *)(qcoeff_ptr + 8), zero);
_mm256_store_si256((__m256i *)(dqcoeff_ptr), zero);
_mm256_store_si256((__m256i *)(dqcoeff_ptr + 8), zero);
round = _mm256_unpackhi_epi64(round, round);
quant = _mm256_unpackhi_epi64(quant, quant);
shift = _mm256_unpackhi_epi64(shift, shift);
dequant = _mm256_unpackhi_epi64(dequant, dequant);
} else {
highbd_calculate_qcoeff_avx2(&qcoeff0, &round, &quant, &shift, &log_scale);
round = _mm256_unpackhi_epi64(round, round);
quant = _mm256_unpackhi_epi64(quant, quant);
shift = _mm256_unpackhi_epi64(shift, shift);
highbd_calculate_qcoeff_avx2(&qcoeff1, &round, &quant, &shift, &log_scale);
// Reinsert signs
qcoeff0 = _mm256_sign_epi32(qcoeff0, coeff0);
qcoeff1 = _mm256_sign_epi32(qcoeff1, coeff1);
// Mask out zbin threshold coeffs
qcoeff0 = _mm256_and_si256(qcoeff0, temp0);
qcoeff1 = _mm256_and_si256(qcoeff1, temp1);
highbd_store_coefficients_avx2(qcoeff0, qcoeff1, qcoeff_ptr);
coeff0 = highbd_calculate_dqcoeff_avx2(qcoeff0, dequant);
dequant = _mm256_unpackhi_epi64(dequant, dequant);
coeff1 = highbd_calculate_dqcoeff_avx2(qcoeff1, dequant);
highbd_store_coefficients_avx2(coeff0, coeff1, dqcoeff_ptr);
}
// AC only loop.
while (index < n_coeffs) {
coeff0 = _mm256_load_si256((__m256i *)(coeff_ptr + index));
qcoeff0 = _mm256_abs_epi32(coeff0);
coeff1 = _mm256_load_si256((__m256i *)(coeff_ptr + index + 8));
qcoeff1 = _mm256_abs_epi32(coeff1);
highbd_update_mask0_avx2(&qcoeff0, &qcoeff1, threshold, iscan + index,
&is_found0, &mask0);
temp0 = _mm256_cmpgt_epi32(qcoeff0, zbin);
temp1 = _mm256_cmpgt_epi32(qcoeff1, zbin);
cmp_mask = _mm256_permute4x64_epi64(_mm256_packs_epi32(temp0, temp1), 0xd8);
highbd_update_mask1_avx2(&cmp_mask, iscan + index, &is_found1, &mask1);
if (_mm256_movemask_epi8(cmp_mask) == 0) {
_mm256_store_si256((__m256i *)(qcoeff_ptr + index), zero);
_mm256_store_si256((__m256i *)(qcoeff_ptr + index + 8), zero);
_mm256_store_si256((__m256i *)(dqcoeff_ptr + index), zero);
_mm256_store_si256((__m256i *)(dqcoeff_ptr + index + 8), zero);
index += 16;
continue;
}
highbd_calculate_qcoeff_avx2(&qcoeff0, &round, &quant, &shift, &log_scale);
highbd_calculate_qcoeff_avx2(&qcoeff1, &round, &quant, &shift, &log_scale);
qcoeff0 = _mm256_sign_epi32(qcoeff0, coeff0);
qcoeff1 = _mm256_sign_epi32(qcoeff1, coeff1);
qcoeff0 = _mm256_and_si256(qcoeff0, temp0);
qcoeff1 = _mm256_and_si256(qcoeff1, temp1);
highbd_store_coefficients_avx2(qcoeff0, qcoeff1, qcoeff_ptr + index);
coeff0 = highbd_calculate_dqcoeff_avx2(qcoeff0, dequant);
coeff1 = highbd_calculate_dqcoeff_avx2(qcoeff1, dequant);
highbd_store_coefficients_avx2(coeff0, coeff1, dqcoeff_ptr + index);
index += 16;
}
if (is_found0) {
temp_mask0 = _mm_max_epi16(_mm256_castsi256_si128(mask0),
_mm256_extracti128_si256(mask0, 1));
non_zero_count = calculate_non_zero_count(temp_mask0);
}
if (is_found1) {
temp_mask1 = _mm_max_epi16(_mm256_castsi256_si128(mask1),
_mm256_extracti128_si256(mask1, 1));
non_zero_count_prescan_add_zero = calculate_non_zero_count(temp_mask1);
}
for (int i = non_zero_count_prescan_add_zero - 1; i >= non_zero_count; i--) {
const int rc = scan[i];
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
}
for (int i = non_zero_count - 1; i >= 0; i--) {
const int rc = scan[i];
if (qcoeff_ptr[rc]) {
eob = i;
break;
}
}
*eob_ptr = eob + 1;
#if SKIP_EOB_FACTOR_ADJUST
// TODO(Aniket): Experiment the following loop with intrinsic by combining
// with the quantization loop above
for (int i = 0; i < non_zero_count; i++) {
const int rc = scan[i];
const int qcoeff = qcoeff_ptr[rc];
if (qcoeff) {
first = i;
break;
}
}
if ((*eob_ptr - 1) >= 0 && first == (*eob_ptr - 1)) {
const int rc = scan[(*eob_ptr - 1)];
if (qcoeff_ptr[rc] == 1 || qcoeff_ptr[rc] == -1) {
const int coeff = coeff_ptr[rc] * wt;
const int coeff_sign = (coeff >> 31);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
const int factor = EOB_FACTOR + SKIP_EOB_FACTOR_ADJUST;
const int prescan_add_val =
ROUND_POWER_OF_TWO(dequant_ptr[rc != 0] * factor, 7);
if (abs_coeff <
(zbin_ptr[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val)) {
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
*eob_ptr = 0;
}
}
}
#endif
}
void aom_highbd_quantize_b_32x32_adaptive_avx2(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
int index = 16;
int non_zero_count = 0;
int non_zero_count_prescan_add_zero = 0;
int is_found0 = 0, is_found1 = 0;
int eob = -1;
const int log_scale = 1;
const __m256i zero = _mm256_setzero_si256();
__m256i zbin, round, quant, dequant, shift;
__m256i coeff0, qcoeff0, coeff1, qcoeff1;
__m256i cmp_mask, mask0 = zero, mask1 = zero;
__m128i temp_mask0, temp_mask1;
const __m256i one = _mm256_set1_epi32(1);
const __m256i log_scale_vec = _mm256_set1_epi32(log_scale);
int prescan_add[2];
int thresh[2];
const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
const qm_val_t wt = (1 << AOM_QM_BITS);
for (int i = 0; i < 2; ++i) {
prescan_add[i] = ROUND_POWER_OF_TWO(dequant_ptr[i] * EOB_FACTOR, 7);
thresh[i] = (zbins[i] * wt + prescan_add[i]) - 1;
}
__m256i threshold[2];
threshold[0] = _mm256_set1_epi32(thresh[0]);
threshold[1] = _mm256_set1_epi32(thresh[1]);
threshold[0] = _mm256_blend_epi32(threshold[0], threshold[1], 0xfe);
#if SKIP_EOB_FACTOR_ADJUST
int first = -1;
#endif
// Setup global values.
zbin = _mm256_cvtepi16_epi32(_mm_load_si128((const __m128i *)zbin_ptr));
round = _mm256_cvtepi16_epi32(_mm_load_si128((const __m128i *)round_ptr));
quant = _mm256_cvtepi16_epi32(_mm_load_si128((const __m128i *)quant_ptr));
dequant = _mm256_cvtepi16_epi32(_mm_load_si128((const __m128i *)dequant_ptr));
shift =
_mm256_cvtepi16_epi32(_mm_load_si128((const __m128i *)quant_shift_ptr));
// Shift with rounding.
zbin = _mm256_add_epi32(zbin, log_scale_vec);
round = _mm256_add_epi32(round, log_scale_vec);
zbin = _mm256_srli_epi32(zbin, log_scale);
round = _mm256_srli_epi32(round, log_scale);
zbin = _mm256_sub_epi32(zbin, one);
// Do DC and first 15 AC.
coeff0 = _mm256_load_si256((__m256i *)(coeff_ptr));
qcoeff0 = _mm256_abs_epi32(coeff0);
coeff1 = _mm256_load_si256((__m256i *)(coeff_ptr + 8));
qcoeff1 = _mm256_abs_epi32(coeff1);
highbd_update_mask0_avx2(&qcoeff0, &qcoeff1, threshold, iscan, &is_found0,
&mask0);
__m256i temp0 = _mm256_cmpgt_epi32(qcoeff0, zbin);
zbin = _mm256_permute2x128_si256(zbin, zbin, 0x11);
__m256i temp1 = _mm256_cmpgt_epi32(qcoeff1, zbin);
cmp_mask = _mm256_permute4x64_epi64(_mm256_packs_epi32(temp0, temp1), 0xd8);
highbd_update_mask1_avx2(&cmp_mask, iscan, &is_found1, &mask1);
threshold[0] = threshold[1];
if (_mm256_movemask_epi8(cmp_mask) == 0) {
_mm256_store_si256((__m256i *)(qcoeff_ptr), zero);
_mm256_store_si256((__m256i *)(qcoeff_ptr + 8), zero);
_mm256_store_si256((__m256i *)(dqcoeff_ptr), zero);
_mm256_store_si256((__m256i *)(dqcoeff_ptr + 8), zero);
round = _mm256_permute2x128_si256(round, round, 0x11);
quant = _mm256_permute2x128_si256(quant, quant, 0x11);
shift = _mm256_permute2x128_si256(shift, shift, 0x11);
dequant = _mm256_permute2x128_si256(dequant, dequant, 0x11);
} else {
highbd_calculate_qcoeff_avx2(&qcoeff0, &round, &quant, &shift, &log_scale);
round = _mm256_permute2x128_si256(round, round, 0x11);
quant = _mm256_permute2x128_si256(quant, quant, 0x11);
shift = _mm256_permute2x128_si256(shift, shift, 0x11);
highbd_calculate_qcoeff_avx2(&qcoeff1, &round, &quant, &shift, &log_scale);
// Reinsert signs
qcoeff0 = _mm256_sign_epi32(qcoeff0, coeff0);
qcoeff1 = _mm256_sign_epi32(qcoeff1, coeff1);
// Mask out zbin threshold coeffs
qcoeff0 = _mm256_and_si256(qcoeff0, temp0);
qcoeff1 = _mm256_and_si256(qcoeff1, temp1);
highbd_store_coefficients_avx2(qcoeff0, qcoeff1, qcoeff_ptr);
coeff0 =
highbd_calculate_dqcoeff_log_scale_avx2(qcoeff0, dequant, log_scale);
dequant = _mm256_permute2x128_si256(dequant, dequant, 0x11);
coeff1 =
highbd_calculate_dqcoeff_log_scale_avx2(qcoeff1, dequant, log_scale);
highbd_store_coefficients_avx2(coeff0, coeff1, dqcoeff_ptr);
}
// AC only loop.
while (index < n_coeffs) {
coeff0 = _mm256_load_si256((__m256i *)(coeff_ptr + index));
qcoeff0 = _mm256_abs_epi32(coeff0);
coeff1 = _mm256_load_si256((__m256i *)(coeff_ptr + index + 8));
qcoeff1 = _mm256_abs_epi32(coeff1);
highbd_update_mask0_avx2(&qcoeff0, &qcoeff1, threshold, iscan + index,
&is_found0, &mask0);
temp0 = _mm256_cmpgt_epi32(qcoeff0, zbin);
temp1 = _mm256_cmpgt_epi32(qcoeff1, zbin);
cmp_mask = _mm256_permute4x64_epi64(_mm256_packs_epi32(temp0, temp1), 0xd8);
highbd_update_mask1_avx2(&cmp_mask, iscan + index, &is_found1, &mask1);
if (_mm256_movemask_epi8(cmp_mask) == 0) {
_mm256_store_si256((__m256i *)(qcoeff_ptr + index), zero);
_mm256_store_si256((__m256i *)(qcoeff_ptr + index + 8), zero);
_mm256_store_si256((__m256i *)(dqcoeff_ptr + index), zero);
_mm256_store_si256((__m256i *)(dqcoeff_ptr + index + 8), zero);
index += 16;
continue;
}
highbd_calculate_qcoeff_avx2(&qcoeff0, &round, &quant, &shift, &log_scale);
highbd_calculate_qcoeff_avx2(&qcoeff1, &round, &quant, &shift, &log_scale);
qcoeff0 = _mm256_sign_epi32(qcoeff0, coeff0);
qcoeff1 = _mm256_sign_epi32(qcoeff1, coeff1);
qcoeff0 = _mm256_and_si256(qcoeff0, temp0);
qcoeff1 = _mm256_and_si256(qcoeff1, temp1);
highbd_store_coefficients_avx2(qcoeff0, qcoeff1, qcoeff_ptr + index);
coeff0 =
highbd_calculate_dqcoeff_log_scale_avx2(qcoeff0, dequant, log_scale);
coeff1 =
highbd_calculate_dqcoeff_log_scale_avx2(qcoeff1, dequant, log_scale);
highbd_store_coefficients_avx2(coeff0, coeff1, dqcoeff_ptr + index);
index += 16;
}
if (is_found0) {
temp_mask0 = _mm_max_epi16(_mm256_castsi256_si128(mask0),
_mm256_extracti128_si256(mask0, 1));
non_zero_count = calculate_non_zero_count(temp_mask0);
}
if (is_found1) {
temp_mask1 = _mm_max_epi16(_mm256_castsi256_si128(mask1),
_mm256_extracti128_si256(mask1, 1));
non_zero_count_prescan_add_zero = calculate_non_zero_count(temp_mask1);
}
for (int i = non_zero_count_prescan_add_zero - 1; i >= non_zero_count; i--) {
const int rc = scan[i];
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
}
for (int i = non_zero_count - 1; i >= 0; i--) {
const int rc = scan[i];
if (qcoeff_ptr[rc]) {
eob = i;
break;
}
}
*eob_ptr = eob + 1;
#if SKIP_EOB_FACTOR_ADJUST
// TODO(Aniket): Experiment the following loop with intrinsic by combining
// with the quantization loop above
for (int i = 0; i < non_zero_count; i++) {
const int rc = scan[i];
const int qcoeff = qcoeff_ptr[rc];
if (qcoeff) {
first = i;
break;
}
}
if ((*eob_ptr - 1) >= 0 && first == (*eob_ptr - 1)) {
const int rc = scan[(*eob_ptr - 1)];
if (qcoeff_ptr[rc] == 1 || qcoeff_ptr[rc] == -1) {
const int coeff = coeff_ptr[rc] * wt;
const int coeff_sign = (coeff >> 31);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
const int factor = EOB_FACTOR + SKIP_EOB_FACTOR_ADJUST;
const int prescan_add_val =
ROUND_POWER_OF_TWO(dequant_ptr[rc != 0] * factor, 7);
if (abs_coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val)) {
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
*eob_ptr = 0;
}
}
}
#endif
}

View file

@ -0,0 +1,732 @@
/*
* Copyright (c) 2019, 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.
*/
#include <emmintrin.h>
#include "config/aom_dsp_rtcd.h"
#include "aom/aom_integer.h"
#include "aom_dsp/x86/quantize_x86.h"
#include "av1/encoder/av1_quantize.h"
static INLINE __m128i highbd_invert_sign_64bit_sse2(__m128i a, __m128i sign) {
a = _mm_xor_si128(a, sign);
return _mm_sub_epi64(a, sign);
}
static INLINE void highbd_mul_shift_sse2(const __m128i *x, const __m128i *y,
__m128i *p, const int shift) {
__m128i sign = _mm_srai_epi32(*y, 31);
__m128i sign_lo = _mm_unpacklo_epi32(sign, sign);
__m128i sign_hi = _mm_unpackhi_epi32(sign, sign);
__m128i abs_y = invert_sign_32_sse2(*y, sign);
__m128i prod_lo = _mm_mul_epu32(*x, abs_y);
__m128i prod_hi = _mm_srli_epi64(*x, 32);
const __m128i mult_hi = _mm_srli_epi64(abs_y, 32);
prod_hi = _mm_mul_epu32(prod_hi, mult_hi);
prod_lo = highbd_invert_sign_64bit_sse2(prod_lo, sign_lo);
prod_hi = highbd_invert_sign_64bit_sse2(prod_hi, sign_hi);
prod_lo = _mm_srli_epi64(prod_lo, shift);
const __m128i mask = _mm_set_epi32(0, -1, 0, -1);
prod_lo = _mm_and_si128(prod_lo, mask);
prod_hi = _mm_srli_epi64(prod_hi, shift);
prod_hi = _mm_slli_epi64(prod_hi, 32);
*p = _mm_or_si128(prod_lo, prod_hi);
}
static INLINE void highbd_calculate_qcoeff(__m128i *coeff, const __m128i *round,
const __m128i *quant,
const __m128i *shift,
const int *log_scale) {
__m128i tmp, qcoeff;
qcoeff = _mm_add_epi32(*coeff, *round);
highbd_mul_shift_sse2(&qcoeff, quant, &tmp, 16);
qcoeff = _mm_add_epi32(tmp, qcoeff);
highbd_mul_shift_sse2(&qcoeff, shift, coeff, 16 - *log_scale);
}
static INLINE void highbd_update_mask1(__m128i *cmp_mask0,
const int16_t *iscan_ptr, int *is_found,
__m128i *mask) {
__m128i temp_mask = _mm_setzero_si128();
if (_mm_movemask_epi8(*cmp_mask0)) {
__m128i iscan0 = _mm_load_si128((const __m128i *)(iscan_ptr));
__m128i mask0 = _mm_and_si128(*cmp_mask0, iscan0);
temp_mask = mask0;
*is_found = 1;
}
*mask = _mm_max_epi16(temp_mask, *mask);
}
static INLINE void highbd_update_mask0(__m128i *qcoeff0, __m128i *qcoeff1,
__m128i *threshold,
const int16_t *iscan_ptr, int *is_found,
__m128i *mask) {
__m128i coeff[2], cmp_mask0, cmp_mask1;
coeff[0] = _mm_slli_epi32(*qcoeff0, AOM_QM_BITS);
cmp_mask0 = _mm_cmpgt_epi32(coeff[0], threshold[0]);
coeff[1] = _mm_slli_epi32(*qcoeff1, AOM_QM_BITS);
cmp_mask1 = _mm_cmpgt_epi32(coeff[1], threshold[1]);
cmp_mask0 = _mm_packs_epi32(cmp_mask0, cmp_mask1);
highbd_update_mask1(&cmp_mask0, iscan_ptr, is_found, mask);
}
static INLINE __m128i highbd_calculate_dqcoeff(__m128i qcoeff, __m128i dequant,
const int log_scale) {
__m128i coeff_sign = _mm_srai_epi32(qcoeff, 31);
__m128i abs_coeff = invert_sign_32_sse2(qcoeff, coeff_sign);
highbd_mul_shift_sse2(&abs_coeff, &dequant, &abs_coeff, log_scale);
return invert_sign_32_sse2(abs_coeff, coeff_sign);
}
void aom_highbd_quantize_b_adaptive_sse2(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
int index = 8;
const int log_scale = 0;
int non_zero_count = 0;
int non_zero_count_prescan_add_zero = 0;
int is_found0 = 0, is_found1 = 0;
int eob = -1;
const __m128i zero = _mm_setzero_si128();
const __m128i one = _mm_set1_epi32(1);
__m128i zbin, round, quant, dequant, shift;
__m128i coeff0, coeff1, coeff0_sign, coeff1_sign;
__m128i qcoeff0, qcoeff1;
__m128i cmp_mask0, cmp_mask1, cmp_mask;
__m128i all_zero;
__m128i mask0 = zero, mask1 = zero;
int prescan_add[2];
int thresh[4];
const qm_val_t wt = (1 << AOM_QM_BITS);
for (int i = 0; i < 2; ++i) {
prescan_add[i] = ROUND_POWER_OF_TWO(dequant_ptr[i] * EOB_FACTOR, 7);
thresh[i] = (zbin_ptr[i] * wt + prescan_add[i]) - 1;
}
thresh[2] = thresh[3] = thresh[1];
__m128i threshold[2];
threshold[0] = _mm_loadu_si128((__m128i *)&thresh[0]);
threshold[1] = _mm_unpackhi_epi64(threshold[0], threshold[0]);
#if SKIP_EOB_FACTOR_ADJUST
int first = -1;
#endif
// Setup global values.
zbin = _mm_load_si128((const __m128i *)zbin_ptr);
round = _mm_load_si128((const __m128i *)round_ptr);
quant = _mm_load_si128((const __m128i *)quant_ptr);
dequant = _mm_load_si128((const __m128i *)dequant_ptr);
shift = _mm_load_si128((const __m128i *)quant_shift_ptr);
__m128i zbin_sign = _mm_srai_epi16(zbin, 15);
__m128i round_sign = _mm_srai_epi16(round, 15);
__m128i quant_sign = _mm_srai_epi16(quant, 15);
__m128i dequant_sign = _mm_srai_epi16(dequant, 15);
__m128i shift_sign = _mm_srai_epi16(shift, 15);
zbin = _mm_unpacklo_epi16(zbin, zbin_sign);
round = _mm_unpacklo_epi16(round, round_sign);
quant = _mm_unpacklo_epi16(quant, quant_sign);
dequant = _mm_unpacklo_epi16(dequant, dequant_sign);
shift = _mm_unpacklo_epi16(shift, shift_sign);
zbin = _mm_sub_epi32(zbin, one);
// Do DC and first 15 AC.
coeff0 = _mm_load_si128((__m128i *)(coeff_ptr));
coeff1 = _mm_load_si128((__m128i *)(coeff_ptr + 4));
coeff0_sign = _mm_srai_epi32(coeff0, 31);
coeff1_sign = _mm_srai_epi32(coeff1, 31);
qcoeff0 = invert_sign_32_sse2(coeff0, coeff0_sign);
qcoeff1 = invert_sign_32_sse2(coeff1, coeff1_sign);
highbd_update_mask0(&qcoeff0, &qcoeff1, threshold, iscan, &is_found0, &mask0);
cmp_mask0 = _mm_cmpgt_epi32(qcoeff0, zbin);
zbin = _mm_unpackhi_epi64(zbin, zbin); // Switch DC to AC
cmp_mask1 = _mm_cmpgt_epi32(qcoeff1, zbin);
cmp_mask = _mm_packs_epi32(cmp_mask0, cmp_mask1);
highbd_update_mask1(&cmp_mask, iscan, &is_found1, &mask1);
threshold[0] = threshold[1];
all_zero = _mm_or_si128(cmp_mask0, cmp_mask1);
if (_mm_movemask_epi8(all_zero) == 0) {
_mm_store_si128((__m128i *)(qcoeff_ptr), zero);
_mm_store_si128((__m128i *)(qcoeff_ptr + 4), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr + 4), zero);
round = _mm_unpackhi_epi64(round, round);
quant = _mm_unpackhi_epi64(quant, quant);
shift = _mm_unpackhi_epi64(shift, shift);
dequant = _mm_unpackhi_epi64(dequant, dequant);
} else {
highbd_calculate_qcoeff(&qcoeff0, &round, &quant, &shift, &log_scale);
round = _mm_unpackhi_epi64(round, round);
quant = _mm_unpackhi_epi64(quant, quant);
shift = _mm_unpackhi_epi64(shift, shift);
highbd_calculate_qcoeff(&qcoeff1, &round, &quant, &shift, &log_scale);
// Reinsert signs
qcoeff0 = invert_sign_32_sse2(qcoeff0, coeff0_sign);
qcoeff1 = invert_sign_32_sse2(qcoeff1, coeff1_sign);
// Mask out zbin threshold coeffs
qcoeff0 = _mm_and_si128(qcoeff0, cmp_mask0);
qcoeff1 = _mm_and_si128(qcoeff1, cmp_mask1);
_mm_store_si128((__m128i *)(qcoeff_ptr), qcoeff0);
_mm_store_si128((__m128i *)(qcoeff_ptr + 4), qcoeff1);
coeff0 = highbd_calculate_dqcoeff(qcoeff0, dequant, log_scale);
dequant = _mm_unpackhi_epi64(dequant, dequant);
coeff1 = highbd_calculate_dqcoeff(qcoeff1, dequant, log_scale);
_mm_store_si128((__m128i *)(dqcoeff_ptr), coeff0);
_mm_store_si128((__m128i *)(dqcoeff_ptr + 4), coeff1);
}
// AC only loop.
while (index < n_coeffs) {
coeff0 = _mm_load_si128((__m128i *)(coeff_ptr + index));
coeff1 = _mm_load_si128((__m128i *)(coeff_ptr + index + 4));
coeff0_sign = _mm_srai_epi32(coeff0, 31);
coeff1_sign = _mm_srai_epi32(coeff1, 31);
qcoeff0 = invert_sign_32_sse2(coeff0, coeff0_sign);
qcoeff1 = invert_sign_32_sse2(coeff1, coeff1_sign);
highbd_update_mask0(&qcoeff0, &qcoeff1, threshold, iscan + index,
&is_found0, &mask0);
cmp_mask0 = _mm_cmpgt_epi32(qcoeff0, zbin);
cmp_mask1 = _mm_cmpgt_epi32(qcoeff1, zbin);
cmp_mask = _mm_packs_epi32(cmp_mask0, cmp_mask1);
highbd_update_mask1(&cmp_mask, iscan + index, &is_found1, &mask1);
all_zero = _mm_or_si128(cmp_mask0, cmp_mask1);
if (_mm_movemask_epi8(all_zero) == 0) {
_mm_store_si128((__m128i *)(qcoeff_ptr + index), zero);
_mm_store_si128((__m128i *)(qcoeff_ptr + index + 4), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr + index), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr + index + 4), zero);
index += 8;
continue;
}
highbd_calculate_qcoeff(&qcoeff0, &round, &quant, &shift, &log_scale);
highbd_calculate_qcoeff(&qcoeff1, &round, &quant, &shift, &log_scale);
qcoeff0 = invert_sign_32_sse2(qcoeff0, coeff0_sign);
qcoeff1 = invert_sign_32_sse2(qcoeff1, coeff1_sign);
qcoeff0 = _mm_and_si128(qcoeff0, cmp_mask0);
qcoeff1 = _mm_and_si128(qcoeff1, cmp_mask1);
_mm_store_si128((__m128i *)(qcoeff_ptr + index), qcoeff0);
_mm_store_si128((__m128i *)(qcoeff_ptr + index + 4), qcoeff1);
coeff0 = highbd_calculate_dqcoeff(qcoeff0, dequant, log_scale);
coeff1 = highbd_calculate_dqcoeff(qcoeff1, dequant, log_scale);
_mm_store_si128((__m128i *)(dqcoeff_ptr + index), coeff0);
_mm_store_si128((__m128i *)(dqcoeff_ptr + index + 4), coeff1);
index += 8;
}
if (is_found0) non_zero_count = calculate_non_zero_count(mask0);
if (is_found1)
non_zero_count_prescan_add_zero = calculate_non_zero_count(mask1);
for (int i = non_zero_count_prescan_add_zero - 1; i >= non_zero_count; i--) {
const int rc = scan[i];
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
}
for (int i = non_zero_count - 1; i >= 0; i--) {
const int rc = scan[i];
if (qcoeff_ptr[rc]) {
eob = i;
break;
}
}
*eob_ptr = eob + 1;
#if SKIP_EOB_FACTOR_ADJUST
// TODO(Aniket): Experiment the following loop with intrinsic by combining
// with the quantization loop above
for (int i = 0; i < non_zero_count; i++) {
const int rc = scan[i];
const int qcoeff = qcoeff_ptr[rc];
if (qcoeff) {
first = i;
break;
}
}
if ((*eob_ptr - 1) >= 0 && first == (*eob_ptr - 1)) {
const int rc = scan[(*eob_ptr - 1)];
if (qcoeff_ptr[rc] == 1 || qcoeff_ptr[rc] == -1) {
const int coeff = coeff_ptr[rc] * wt;
const int coeff_sign = (coeff >> 31);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
const int factor = EOB_FACTOR + SKIP_EOB_FACTOR_ADJUST;
const int prescan_add_val =
ROUND_POWER_OF_TWO(dequant_ptr[rc != 0] * factor, 7);
if (abs_coeff <
(zbin_ptr[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val)) {
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
*eob_ptr = 0;
}
}
}
#endif
}
void aom_highbd_quantize_b_32x32_adaptive_sse2(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
int index = 8;
const int log_scale = 1;
int non_zero_count = 0;
int non_zero_count_prescan_add_zero = 0;
int is_found0 = 0, is_found1 = 0;
int eob = -1;
const __m128i zero = _mm_setzero_si128();
const __m128i one = _mm_set1_epi32(1);
const __m128i log_scale_vec = _mm_set1_epi32(log_scale);
__m128i zbin, round, quant, dequant, shift;
__m128i coeff0, coeff1, coeff0_sign, coeff1_sign;
__m128i qcoeff0, qcoeff1;
__m128i cmp_mask0, cmp_mask1, cmp_mask;
__m128i all_zero;
__m128i mask0 = zero, mask1 = zero;
const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
int prescan_add[2];
int thresh[4];
const qm_val_t wt = (1 << AOM_QM_BITS);
for (int i = 0; i < 2; ++i) {
prescan_add[i] = ROUND_POWER_OF_TWO(dequant_ptr[i] * EOB_FACTOR, 7);
thresh[i] = (zbins[i] * wt + prescan_add[i]) - 1;
}
thresh[2] = thresh[3] = thresh[1];
__m128i threshold[2];
threshold[0] = _mm_loadu_si128((__m128i *)&thresh[0]);
threshold[1] = _mm_unpackhi_epi64(threshold[0], threshold[0]);
#if SKIP_EOB_FACTOR_ADJUST
int first = -1;
#endif
// Setup global values.
zbin = _mm_load_si128((const __m128i *)zbin_ptr);
round = _mm_load_si128((const __m128i *)round_ptr);
quant = _mm_load_si128((const __m128i *)quant_ptr);
dequant = _mm_load_si128((const __m128i *)dequant_ptr);
shift = _mm_load_si128((const __m128i *)quant_shift_ptr);
__m128i zbin_sign = _mm_srai_epi16(zbin, 15);
__m128i round_sign = _mm_srai_epi16(round, 15);
__m128i quant_sign = _mm_srai_epi16(quant, 15);
__m128i dequant_sign = _mm_srai_epi16(dequant, 15);
__m128i shift_sign = _mm_srai_epi16(shift, 15);
zbin = _mm_unpacklo_epi16(zbin, zbin_sign);
round = _mm_unpacklo_epi16(round, round_sign);
quant = _mm_unpacklo_epi16(quant, quant_sign);
dequant = _mm_unpacklo_epi16(dequant, dequant_sign);
shift = _mm_unpacklo_epi16(shift, shift_sign);
// Shift with rounding.
zbin = _mm_add_epi32(zbin, log_scale_vec);
round = _mm_add_epi32(round, log_scale_vec);
zbin = _mm_srli_epi32(zbin, log_scale);
round = _mm_srli_epi32(round, log_scale);
zbin = _mm_sub_epi32(zbin, one);
// Do DC and first 15 AC.
coeff0 = _mm_load_si128((__m128i *)(coeff_ptr));
coeff1 = _mm_load_si128((__m128i *)(coeff_ptr + 4));
coeff0_sign = _mm_srai_epi32(coeff0, 31);
coeff1_sign = _mm_srai_epi32(coeff1, 31);
qcoeff0 = invert_sign_32_sse2(coeff0, coeff0_sign);
qcoeff1 = invert_sign_32_sse2(coeff1, coeff1_sign);
highbd_update_mask0(&qcoeff0, &qcoeff1, threshold, iscan, &is_found0, &mask0);
cmp_mask0 = _mm_cmpgt_epi32(qcoeff0, zbin);
zbin = _mm_unpackhi_epi64(zbin, zbin); // Switch DC to AC
cmp_mask1 = _mm_cmpgt_epi32(qcoeff1, zbin);
cmp_mask = _mm_packs_epi32(cmp_mask0, cmp_mask1);
highbd_update_mask1(&cmp_mask, iscan, &is_found1, &mask1);
threshold[0] = threshold[1];
all_zero = _mm_or_si128(cmp_mask0, cmp_mask1);
if (_mm_movemask_epi8(all_zero) == 0) {
_mm_store_si128((__m128i *)(qcoeff_ptr), zero);
_mm_store_si128((__m128i *)(qcoeff_ptr + 4), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr + 4), zero);
round = _mm_unpackhi_epi64(round, round);
quant = _mm_unpackhi_epi64(quant, quant);
shift = _mm_unpackhi_epi64(shift, shift);
dequant = _mm_unpackhi_epi64(dequant, dequant);
} else {
highbd_calculate_qcoeff(&qcoeff0, &round, &quant, &shift, &log_scale);
round = _mm_unpackhi_epi64(round, round);
quant = _mm_unpackhi_epi64(quant, quant);
shift = _mm_unpackhi_epi64(shift, shift);
highbd_calculate_qcoeff(&qcoeff1, &round, &quant, &shift, &log_scale);
// Reinsert signs
qcoeff0 = invert_sign_32_sse2(qcoeff0, coeff0_sign);
qcoeff1 = invert_sign_32_sse2(qcoeff1, coeff1_sign);
// Mask out zbin threshold coeffs
qcoeff0 = _mm_and_si128(qcoeff0, cmp_mask0);
qcoeff1 = _mm_and_si128(qcoeff1, cmp_mask1);
_mm_store_si128((__m128i *)(qcoeff_ptr), qcoeff0);
_mm_store_si128((__m128i *)(qcoeff_ptr + 4), qcoeff1);
coeff0 = highbd_calculate_dqcoeff(qcoeff0, dequant, log_scale);
dequant = _mm_unpackhi_epi64(dequant, dequant);
coeff1 = highbd_calculate_dqcoeff(qcoeff1, dequant, log_scale);
_mm_store_si128((__m128i *)(dqcoeff_ptr), coeff0);
_mm_store_si128((__m128i *)(dqcoeff_ptr + 4), coeff1);
}
// AC only loop.
while (index < n_coeffs) {
coeff0 = _mm_load_si128((__m128i *)(coeff_ptr + index));
coeff1 = _mm_load_si128((__m128i *)(coeff_ptr + index + 4));
coeff0_sign = _mm_srai_epi32(coeff0, 31);
coeff1_sign = _mm_srai_epi32(coeff1, 31);
qcoeff0 = invert_sign_32_sse2(coeff0, coeff0_sign);
qcoeff1 = invert_sign_32_sse2(coeff1, coeff1_sign);
highbd_update_mask0(&qcoeff0, &qcoeff1, threshold, iscan + index,
&is_found0, &mask0);
cmp_mask0 = _mm_cmpgt_epi32(qcoeff0, zbin);
cmp_mask1 = _mm_cmpgt_epi32(qcoeff1, zbin);
cmp_mask = _mm_packs_epi32(cmp_mask0, cmp_mask1);
highbd_update_mask1(&cmp_mask, iscan + index, &is_found1, &mask1);
all_zero = _mm_or_si128(cmp_mask0, cmp_mask1);
if (_mm_movemask_epi8(all_zero) == 0) {
_mm_store_si128((__m128i *)(qcoeff_ptr + index), zero);
_mm_store_si128((__m128i *)(qcoeff_ptr + index + 4), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr + index), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr + index + 4), zero);
index += 8;
continue;
}
highbd_calculate_qcoeff(&qcoeff0, &round, &quant, &shift, &log_scale);
highbd_calculate_qcoeff(&qcoeff1, &round, &quant, &shift, &log_scale);
qcoeff0 = invert_sign_32_sse2(qcoeff0, coeff0_sign);
qcoeff1 = invert_sign_32_sse2(qcoeff1, coeff1_sign);
qcoeff0 = _mm_and_si128(qcoeff0, cmp_mask0);
qcoeff1 = _mm_and_si128(qcoeff1, cmp_mask1);
_mm_store_si128((__m128i *)(qcoeff_ptr + index), qcoeff0);
_mm_store_si128((__m128i *)(qcoeff_ptr + index + 4), qcoeff1);
coeff0 = highbd_calculate_dqcoeff(qcoeff0, dequant, log_scale);
coeff1 = highbd_calculate_dqcoeff(qcoeff1, dequant, log_scale);
_mm_store_si128((__m128i *)(dqcoeff_ptr + index), coeff0);
_mm_store_si128((__m128i *)(dqcoeff_ptr + index + 4), coeff1);
index += 8;
}
if (is_found0) non_zero_count = calculate_non_zero_count(mask0);
if (is_found1)
non_zero_count_prescan_add_zero = calculate_non_zero_count(mask1);
for (int i = non_zero_count_prescan_add_zero - 1; i >= non_zero_count; i--) {
const int rc = scan[i];
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
}
for (int i = non_zero_count - 1; i >= 0; i--) {
const int rc = scan[i];
if (qcoeff_ptr[rc]) {
eob = i;
break;
}
}
*eob_ptr = eob + 1;
#if SKIP_EOB_FACTOR_ADJUST
// TODO(Aniket): Experiment the following loop with intrinsic by combining
// with the quantization loop above
for (int i = 0; i < non_zero_count; i++) {
const int rc = scan[i];
const int qcoeff = qcoeff_ptr[rc];
if (qcoeff) {
first = i;
break;
}
}
if ((*eob_ptr - 1) >= 0 && first == (*eob_ptr - 1)) {
const int rc = scan[(*eob_ptr - 1)];
if (qcoeff_ptr[rc] == 1 || qcoeff_ptr[rc] == -1) {
const int coeff = coeff_ptr[rc] * wt;
const int coeff_sign = (coeff >> 31);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
const int factor = EOB_FACTOR + SKIP_EOB_FACTOR_ADJUST;
const int prescan_add_val =
ROUND_POWER_OF_TWO(dequant_ptr[rc != 0] * factor, 7);
if (abs_coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val)) {
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
*eob_ptr = 0;
}
}
}
#endif
}
void aom_highbd_quantize_b_64x64_adaptive_sse2(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
int index = 8;
const int log_scale = 2;
int non_zero_count = 0;
int non_zero_count_prescan_add_zero = 0;
int is_found0 = 0, is_found1 = 0;
int eob = -1;
const __m128i zero = _mm_setzero_si128();
const __m128i one = _mm_set1_epi32(1);
const __m128i log_scale_vec = _mm_set1_epi32(log_scale);
__m128i zbin, round, quant, dequant, shift;
__m128i coeff0, coeff1, coeff0_sign, coeff1_sign;
__m128i qcoeff0, qcoeff1;
__m128i cmp_mask0, cmp_mask1, cmp_mask;
__m128i all_zero;
__m128i mask0 = zero, mask1 = zero;
const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
int prescan_add[2];
int thresh[4];
const qm_val_t wt = (1 << AOM_QM_BITS);
for (int i = 0; i < 2; ++i) {
prescan_add[i] = ROUND_POWER_OF_TWO(dequant_ptr[i] * EOB_FACTOR, 7);
thresh[i] = (zbins[i] * wt + prescan_add[i]) - 1;
}
thresh[2] = thresh[3] = thresh[1];
__m128i threshold[2];
threshold[0] = _mm_loadu_si128((__m128i *)&thresh[0]);
threshold[1] = _mm_unpackhi_epi64(threshold[0], threshold[0]);
#if SKIP_EOB_FACTOR_ADJUST
int first = -1;
#endif
// Setup global values.
zbin = _mm_load_si128((const __m128i *)zbin_ptr);
round = _mm_load_si128((const __m128i *)round_ptr);
quant = _mm_load_si128((const __m128i *)quant_ptr);
dequant = _mm_load_si128((const __m128i *)dequant_ptr);
shift = _mm_load_si128((const __m128i *)quant_shift_ptr);
__m128i zbin_sign = _mm_srai_epi16(zbin, 15);
__m128i round_sign = _mm_srai_epi16(round, 15);
__m128i quant_sign = _mm_srai_epi16(quant, 15);
__m128i dequant_sign = _mm_srai_epi16(dequant, 15);
__m128i shift_sign = _mm_srai_epi16(shift, 15);
zbin = _mm_unpacklo_epi16(zbin, zbin_sign);
round = _mm_unpacklo_epi16(round, round_sign);
quant = _mm_unpacklo_epi16(quant, quant_sign);
dequant = _mm_unpacklo_epi16(dequant, dequant_sign);
shift = _mm_unpacklo_epi16(shift, shift_sign);
// Shift with rounding.
zbin = _mm_add_epi32(zbin, log_scale_vec);
round = _mm_add_epi32(round, log_scale_vec);
zbin = _mm_srli_epi32(zbin, log_scale);
round = _mm_srli_epi32(round, log_scale);
zbin = _mm_sub_epi32(zbin, one);
// Do DC and first 15 AC.
coeff0 = _mm_load_si128((__m128i *)(coeff_ptr));
coeff1 = _mm_load_si128((__m128i *)(coeff_ptr + 4));
coeff0_sign = _mm_srai_epi32(coeff0, 31);
coeff1_sign = _mm_srai_epi32(coeff1, 31);
qcoeff0 = invert_sign_32_sse2(coeff0, coeff0_sign);
qcoeff1 = invert_sign_32_sse2(coeff1, coeff1_sign);
highbd_update_mask0(&qcoeff0, &qcoeff1, threshold, iscan, &is_found0, &mask0);
cmp_mask0 = _mm_cmpgt_epi32(qcoeff0, zbin);
zbin = _mm_unpackhi_epi64(zbin, zbin); // Switch DC to AC
cmp_mask1 = _mm_cmpgt_epi32(qcoeff1, zbin);
cmp_mask = _mm_packs_epi32(cmp_mask0, cmp_mask1);
highbd_update_mask1(&cmp_mask, iscan, &is_found1, &mask1);
threshold[0] = threshold[1];
all_zero = _mm_or_si128(cmp_mask0, cmp_mask1);
if (_mm_movemask_epi8(all_zero) == 0) {
_mm_store_si128((__m128i *)(qcoeff_ptr), zero);
_mm_store_si128((__m128i *)(qcoeff_ptr + 4), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr + 4), zero);
round = _mm_unpackhi_epi64(round, round);
quant = _mm_unpackhi_epi64(quant, quant);
shift = _mm_unpackhi_epi64(shift, shift);
dequant = _mm_unpackhi_epi64(dequant, dequant);
} else {
highbd_calculate_qcoeff(&qcoeff0, &round, &quant, &shift, &log_scale);
round = _mm_unpackhi_epi64(round, round);
quant = _mm_unpackhi_epi64(quant, quant);
shift = _mm_unpackhi_epi64(shift, shift);
highbd_calculate_qcoeff(&qcoeff1, &round, &quant, &shift, &log_scale);
// Reinsert signs
qcoeff0 = invert_sign_32_sse2(qcoeff0, coeff0_sign);
qcoeff1 = invert_sign_32_sse2(qcoeff1, coeff1_sign);
// Mask out zbin threshold coeffs
qcoeff0 = _mm_and_si128(qcoeff0, cmp_mask0);
qcoeff1 = _mm_and_si128(qcoeff1, cmp_mask1);
_mm_store_si128((__m128i *)(qcoeff_ptr), qcoeff0);
_mm_store_si128((__m128i *)(qcoeff_ptr + 4), qcoeff1);
coeff0 = highbd_calculate_dqcoeff(qcoeff0, dequant, log_scale);
dequant = _mm_unpackhi_epi64(dequant, dequant);
coeff1 = highbd_calculate_dqcoeff(qcoeff1, dequant, log_scale);
_mm_store_si128((__m128i *)(dqcoeff_ptr), coeff0);
_mm_store_si128((__m128i *)(dqcoeff_ptr + 4), coeff1);
}
// AC only loop.
while (index < n_coeffs) {
coeff0 = _mm_load_si128((__m128i *)(coeff_ptr + index));
coeff1 = _mm_load_si128((__m128i *)(coeff_ptr + index + 4));
coeff0_sign = _mm_srai_epi32(coeff0, 31);
coeff1_sign = _mm_srai_epi32(coeff1, 31);
qcoeff0 = invert_sign_32_sse2(coeff0, coeff0_sign);
qcoeff1 = invert_sign_32_sse2(coeff1, coeff1_sign);
highbd_update_mask0(&qcoeff0, &qcoeff1, threshold, iscan + index,
&is_found0, &mask0);
cmp_mask0 = _mm_cmpgt_epi32(qcoeff0, zbin);
cmp_mask1 = _mm_cmpgt_epi32(qcoeff1, zbin);
cmp_mask = _mm_packs_epi32(cmp_mask0, cmp_mask1);
highbd_update_mask1(&cmp_mask, iscan + index, &is_found1, &mask1);
all_zero = _mm_or_si128(cmp_mask0, cmp_mask1);
if (_mm_movemask_epi8(all_zero) == 0) {
_mm_store_si128((__m128i *)(qcoeff_ptr + index), zero);
_mm_store_si128((__m128i *)(qcoeff_ptr + index + 4), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr + index), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr + index + 4), zero);
index += 8;
continue;
}
highbd_calculate_qcoeff(&qcoeff0, &round, &quant, &shift, &log_scale);
highbd_calculate_qcoeff(&qcoeff1, &round, &quant, &shift, &log_scale);
qcoeff0 = invert_sign_32_sse2(qcoeff0, coeff0_sign);
qcoeff1 = invert_sign_32_sse2(qcoeff1, coeff1_sign);
qcoeff0 = _mm_and_si128(qcoeff0, cmp_mask0);
qcoeff1 = _mm_and_si128(qcoeff1, cmp_mask1);
_mm_store_si128((__m128i *)(qcoeff_ptr + index), qcoeff0);
_mm_store_si128((__m128i *)(qcoeff_ptr + index + 4), qcoeff1);
coeff0 = highbd_calculate_dqcoeff(qcoeff0, dequant, log_scale);
coeff1 = highbd_calculate_dqcoeff(qcoeff1, dequant, log_scale);
_mm_store_si128((__m128i *)(dqcoeff_ptr + index), coeff0);
_mm_store_si128((__m128i *)(dqcoeff_ptr + index + 4), coeff1);
index += 8;
}
if (is_found0) non_zero_count = calculate_non_zero_count(mask0);
if (is_found1)
non_zero_count_prescan_add_zero = calculate_non_zero_count(mask1);
for (int i = non_zero_count_prescan_add_zero - 1; i >= non_zero_count; i--) {
const int rc = scan[i];
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
}
for (int i = non_zero_count - 1; i >= 0; i--) {
const int rc = scan[i];
if (qcoeff_ptr[rc]) {
eob = i;
break;
}
}
*eob_ptr = eob + 1;
#if SKIP_EOB_FACTOR_ADJUST
// TODO(Aniket): Experiment the following loop with intrinsic by combining
// with the quantization loop above
for (int i = 0; i < non_zero_count; i++) {
const int rc = scan[i];
const int qcoeff = qcoeff_ptr[rc];
if (qcoeff) {
first = i;
break;
}
}
if ((*eob_ptr - 1) >= 0 && first == (*eob_ptr - 1)) {
const int rc = scan[(*eob_ptr - 1)];
if (qcoeff_ptr[rc] == 1 || qcoeff_ptr[rc] == -1) {
const int coeff = coeff_ptr[rc] * wt;
const int coeff_sign = (coeff >> 31);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
const int factor = EOB_FACTOR + SKIP_EOB_FACTOR_ADJUST;
const int prescan_add_val =
ROUND_POWER_OF_TWO(dequant_ptr[rc != 0] * factor, 7);
if (abs_coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val)) {
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
*eob_ptr = 0;
}
}
}
#endif
}

View file

@ -115,13 +115,13 @@ void av1_highbd_convolve_y_sr_avx2(const uint16_t *src, int src_stride,
uint16_t *dst, int dst_stride, int w, int h,
const InterpFilterParams *filter_params_x,
const InterpFilterParams *filter_params_y,
const int subpel_x_q4, const int subpel_y_q4,
const int subpel_x_qn, const int subpel_y_qn,
ConvolveParams *conv_params, int bd) {
int i, j;
const int fo_vert = filter_params_y->taps / 2 - 1;
const uint16_t *const src_ptr = src - fo_vert * src_stride;
(void)filter_params_x;
(void)subpel_x_q4;
(void)subpel_x_qn;
(void)conv_params;
assert(conv_params->round_0 <= FILTER_BITS);
@ -138,7 +138,7 @@ void av1_highbd_convolve_y_sr_avx2(const uint16_t *src, int src_stride,
_mm256_set1_epi16(bd == 10 ? 1023 : (bd == 12 ? 4095 : 255));
const __m256i zero = _mm256_setzero_si256();
prepare_coeffs(filter_params_y, subpel_y_q4, coeffs_y);
prepare_coeffs(filter_params_y, subpel_y_qn, coeffs_y);
for (j = 0; j < w; j += 8) {
const uint16_t *data = &src_ptr[j];
@ -264,12 +264,12 @@ void av1_highbd_convolve_x_sr_avx2(const uint16_t *src, int src_stride,
uint16_t *dst, int dst_stride, int w, int h,
const InterpFilterParams *filter_params_x,
const InterpFilterParams *filter_params_y,
const int subpel_x_q4, const int subpel_y_q4,
const int subpel_x_qn, const int subpel_y_qn,
ConvolveParams *conv_params, int bd) {
int i, j;
const int fo_horiz = filter_params_x->taps / 2 - 1;
const uint16_t *const src_ptr = src - fo_horiz;
(void)subpel_y_q4;
(void)subpel_y_qn;
(void)filter_params_y;
// Check that, even with 12-bit input, the intermediate values will fit
@ -293,7 +293,7 @@ void av1_highbd_convolve_x_sr_avx2(const uint16_t *src, int src_stride,
assert((FILTER_BITS - conv_params->round_1) >= 0 ||
((conv_params->round_0 + conv_params->round_1) == 2 * FILTER_BITS));
prepare_coeffs(filter_params_x, subpel_x_q4, coeffs_x);
prepare_coeffs(filter_params_x, subpel_x_qn, coeffs_x);
for (j = 0; j < w; j += 8) {
/* Horizontal filter */

View file

@ -20,14 +20,14 @@ void av1_highbd_convolve_y_sr_ssse3(const uint16_t *src, int src_stride,
uint16_t *dst, int dst_stride, int w, int h,
const InterpFilterParams *filter_params_x,
const InterpFilterParams *filter_params_y,
const int subpel_x_q4,
const int subpel_y_q4,
const int subpel_x_qn,
const int subpel_y_qn,
ConvolveParams *conv_params, int bd) {
int i, j;
const int fo_vert = filter_params_y->taps / 2 - 1;
const uint16_t *const src_ptr = src - fo_vert * src_stride;
(void)filter_params_x;
(void)subpel_x_q4;
(void)subpel_x_qn;
(void)conv_params;
assert(conv_params->round_0 <= FILTER_BITS);
@ -44,7 +44,7 @@ void av1_highbd_convolve_y_sr_ssse3(const uint16_t *src, int src_stride,
_mm_set1_epi16(bd == 10 ? 1023 : (bd == 12 ? 4095 : 255));
const __m128i zero = _mm_setzero_si128();
prepare_coeffs(filter_params_y, subpel_y_q4, coeffs_y);
prepare_coeffs(filter_params_y, subpel_y_qn, coeffs_y);
for (j = 0; j < w; j += 8) {
const uint16_t *data = &src_ptr[j];
@ -168,13 +168,13 @@ void av1_highbd_convolve_x_sr_ssse3(const uint16_t *src, int src_stride,
uint16_t *dst, int dst_stride, int w, int h,
const InterpFilterParams *filter_params_x,
const InterpFilterParams *filter_params_y,
const int subpel_x_q4,
const int subpel_y_q4,
const int subpel_x_qn,
const int subpel_y_qn,
ConvolveParams *conv_params, int bd) {
int i, j;
const int fo_horiz = filter_params_x->taps / 2 - 1;
const uint16_t *const src_ptr = src - fo_horiz;
(void)subpel_y_q4;
(void)subpel_y_qn;
(void)filter_params_y;
// Check that, even with 12-bit input, the intermediate values will fit
@ -195,7 +195,7 @@ void av1_highbd_convolve_x_sr_ssse3(const uint16_t *src, int src_stride,
_mm_set1_epi16(bd == 10 ? 1023 : (bd == 12 ? 4095 : 255));
const __m128i zero = _mm_setzero_si128();
prepare_coeffs(filter_params_x, subpel_x_q4, coeffs_x);
prepare_coeffs(filter_params_x, subpel_x_qn, coeffs_x);
for (j = 0; j < w; j += 8) {
/* Horizontal filter */

View file

@ -90,7 +90,7 @@ static INLINE void highbd_filter_mask_dual(const __m128i *p, const __m128i *q,
const __m128i zero = _mm_setzero_si128();
const __m128i one = _mm_set1_epi16(1);
const __m128i ffff = _mm_set1_epi16(0xFFFF);
const __m128i ffff = _mm_set1_epi16((short)0xFFFF);
__m128i max = _mm_subs_epu16(_mm_adds_epu16(abs_p0q0, abs_p1q1), *bl);
max = _mm_xor_si128(_mm_cmpeq_epi16(max, zero), ffff);
@ -112,7 +112,7 @@ static INLINE void highbd_hev_filter_mask_x_sse2(__m128i *pq, int x,
__m128i *hev, __m128i *mask) {
const __m128i zero = _mm_setzero_si128();
const __m128i one = _mm_set1_epi16(1);
const __m128i ffff = _mm_set1_epi16(0xFFFF);
const __m128i ffff = _mm_set1_epi16((short)0xFFFF);
__m128i abs_p0q0_p1q1, abs_p0q0, abs_p1q1, abs_q1q0;
__m128i max, max01, h;
@ -497,8 +497,9 @@ static AOM_FORCE_INLINE void highbd_lpf_internal_14_sse2(
}
void aom_highbd_lpf_horizontal_14_sse2(uint16_t *s, int pitch,
const uint8_t *blt, const uint8_t *lt,
const uint8_t *thr, int bd) {
const uint8_t *blimit,
const uint8_t *limit,
const uint8_t *thresh, int bd) {
__m128i p[7], q[7], pq[7];
int i;
@ -507,7 +508,7 @@ void aom_highbd_lpf_horizontal_14_sse2(uint16_t *s, int pitch,
q[i] = _mm_loadl_epi64((__m128i *)(s + i * pitch));
}
highbd_lpf_internal_14_sse2(p, q, pq, blt, lt, thr, bd);
highbd_lpf_internal_14_sse2(p, q, pq, blimit, limit, thresh, bd);
for (i = 0; i < 6; i++) {
_mm_storel_epi64((__m128i *)(s - (i + 1) * pitch), pq[i]);

View file

@ -372,3 +372,71 @@ HIGH_SAD8XN 8, 1 ; highbd_sad8x8_avg_sse2
HIGH_SAD8XN 4, 1 ; highbd_sad8x4_avg_sse2
HIGH_SAD8XN 32 ; highbd_sad_8x32_sse2
HIGH_SAD8XN 32, 1 ; highbd_sad_8x32_avg_sse2
; unsigned int aom_highbd_sad4x{4,8,16}_sse2(uint8_t *src, int src_stride,
; uint8_t *ref, int ref_stride);
%macro HIGH_SAD4XN 1-2 0
HIGH_SAD_FN 4, %1, 7, %2
mov n_rowsd, %1/4
pxor m0, m0
pxor m6, m6
.loop:
movq m1, [refq]
movq m2, [refq+ref_strideq*2]
movq m3, [refq+ref_strideq*4]
movq m4, [refq+ref_stride3q*2]
punpcklwd m1, m3
punpcklwd m2, m4
%if %2 == 1
movq m3, [second_predq+8*0]
movq m5, [second_predq+8*2]
punpcklwd m3, m5
movq m4, [second_predq+8*1]
movq m5, [second_predq+8*3]
punpcklwd m4, m5
lea second_predq, [second_predq+8*4]
pavgw m1, m3
pavgw m2, m4
%endif
movq m5, [srcq]
movq m3, [srcq+src_strideq*4]
punpcklwd m5, m3
movdqa m3, m1
psubusw m1, m5
psubusw m5, m3
por m1, m5
movq m5, [srcq+src_strideq*2]
movq m4, [srcq+src_stride3q*2]
punpcklwd m5, m4
movdqa m4, m2
psubusw m2, m5
psubusw m5, m4
por m2, m5
paddw m1, m2
movdqa m2, m1
punpcklwd m1, m6
punpckhwd m2, m6
lea refq, [refq+ref_strideq*8]
paddd m0, m1
lea srcq, [srcq+src_strideq*8]
paddd m0, m2
dec n_rowsd
jg .loop
movhlps m1, m0
paddd m0, m1
punpckldq m0, m6
movhlps m1, m0
paddd m0, m1
movd eax, m0
RET
%endmacro
INIT_XMM sse2
HIGH_SAD4XN 16 ; highbd_sad4x16_sse2
HIGH_SAD4XN 8 ; highbd_sad4x8_sse2
HIGH_SAD4XN 4 ; highbd_sad4x4_sse2
HIGH_SAD4XN 16, 1 ; highbd_sad4x16_avg_sse2
HIGH_SAD4XN 8, 1 ; highbd_sad4x8_avg_sse2
HIGH_SAD4XN 4, 1 ; highbd_sad4x4_avg_sse2

View file

@ -192,7 +192,6 @@ VAR_FN(16, 16, 16, 8);
VAR_FN(16, 8, 8, 7);
VAR_FN(8, 16, 8, 7);
VAR_FN(8, 8, 8, 6);
VAR_FN(16, 4, 16, 6);
VAR_FN(8, 32, 8, 8);
VAR_FN(32, 8, 8, 8);
VAR_FN(16, 64, 16, 10);
@ -303,19 +302,19 @@ DECLS(sse2);
sse += sse2; \
if (w > wf) { \
se2 = aom_highbd_sub_pixel_variance##wf##xh_##opt( \
src + 16, src_stride, x_offset, y_offset, dst + 16, dst_stride, h, \
src + wf, src_stride, x_offset, y_offset, dst + wf, dst_stride, h, \
&sse2, NULL, NULL); \
se += se2; \
sse += sse2; \
if (w > wf * 2) { \
se2 = aom_highbd_sub_pixel_variance##wf##xh_##opt( \
src + 32, src_stride, x_offset, y_offset, dst + 32, dst_stride, \
h, &sse2, NULL, NULL); \
src + 2 * wf, src_stride, x_offset, y_offset, dst + 2 * wf, \
dst_stride, h, &sse2, NULL, NULL); \
se += se2; \
sse += sse2; \
se2 = aom_highbd_sub_pixel_variance##wf##xh_##opt( \
src + 48, src_stride, x_offset, y_offset, dst + 48, dst_stride, \
h, &sse2, NULL, NULL); \
src + 3 * wf, src_stride, x_offset, y_offset, dst + 3 * wf, \
dst_stride, h, &sse2, NULL, NULL); \
se += se2; \
sse += sse2; \
} \
@ -346,19 +345,19 @@ DECLS(sse2);
if (w > wf) { \
uint32_t sse2; \
se2 = aom_highbd_sub_pixel_variance##wf##xh_##opt( \
src + 16, src_stride, x_offset, y_offset, dst + 16, dst_stride, h, \
src + wf, src_stride, x_offset, y_offset, dst + wf, dst_stride, h, \
&sse2, NULL, NULL); \
se += se2; \
long_sse += sse2; \
if (w > wf * 2) { \
se2 = aom_highbd_sub_pixel_variance##wf##xh_##opt( \
src + 32, src_stride, x_offset, y_offset, dst + 32, dst_stride, \
h, &sse2, NULL, NULL); \
src + 2 * wf, src_stride, x_offset, y_offset, dst + 2 * wf, \
dst_stride, h, &sse2, NULL, NULL); \
se += se2; \
long_sse += sse2; \
se2 = aom_highbd_sub_pixel_variance##wf##xh_##opt( \
src + 48, src_stride, x_offset, y_offset, dst + 48, dst_stride, \
h, &sse2, NULL, NULL); \
src + 3 * wf, src_stride, x_offset, y_offset, dst + 3 * wf, \
dst_stride, h, &sse2, NULL, NULL); \
se += se2; \
long_sse += sse2; \
} \
@ -397,19 +396,19 @@ DECLS(sse2);
long_sse += sse2; \
if (w > wf) { \
se2 = aom_highbd_sub_pixel_variance##wf##xh_##opt( \
src_tmp + 16, src_stride, x_offset, y_offset, dst_tmp + 16, \
src_tmp + wf, src_stride, x_offset, y_offset, dst_tmp + wf, \
dst_stride, height, &sse2, NULL, NULL); \
se += se2; \
long_sse += sse2; \
if (w > wf * 2) { \
se2 = aom_highbd_sub_pixel_variance##wf##xh_##opt( \
src_tmp + 32, src_stride, x_offset, y_offset, dst_tmp + 32, \
dst_stride, height, &sse2, NULL, NULL); \
src_tmp + 2 * wf, src_stride, x_offset, y_offset, \
dst_tmp + 2 * wf, dst_stride, height, &sse2, NULL, NULL); \
se += se2; \
long_sse += sse2; \
se2 = aom_highbd_sub_pixel_variance##wf##xh_##opt( \
src_tmp + 48, src_stride, x_offset, y_offset, dst_tmp + 48, \
dst_stride, height, &sse2, NULL, NULL); \
src_tmp + 3 * wf, src_stride, x_offset, y_offset, \
dst_tmp + 3 * wf, dst_stride, height, &sse2, NULL, NULL); \
se += se2; \
long_sse += sse2; \
} \
@ -479,19 +478,19 @@ DECLS(sse2);
if (w > wf) { \
uint32_t sse2; \
int se2 = aom_highbd_sub_pixel_avg_variance##wf##xh_##opt( \
src + 16, src_stride, x_offset, y_offset, dst + 16, dst_stride, \
sec + 16, w, h, &sse2, NULL, NULL); \
src + wf, src_stride, x_offset, y_offset, dst + wf, dst_stride, \
sec + wf, w, h, &sse2, NULL, NULL); \
se += se2; \
sse += sse2; \
if (w > wf * 2) { \
se2 = aom_highbd_sub_pixel_avg_variance##wf##xh_##opt( \
src + 32, src_stride, x_offset, y_offset, dst + 32, dst_stride, \
sec + 32, w, h, &sse2, NULL, NULL); \
src + 2 * wf, src_stride, x_offset, y_offset, dst + 2 * wf, \
dst_stride, sec + 2 * wf, w, h, &sse2, NULL, NULL); \
se += se2; \
sse += sse2; \
se2 = aom_highbd_sub_pixel_avg_variance##wf##xh_##opt( \
src + 48, src_stride, x_offset, y_offset, dst + 48, dst_stride, \
sec + 48, w, h, &sse2, NULL, NULL); \
src + 3 * wf, src_stride, x_offset, y_offset, dst + 3 * wf, \
dst_stride, sec + 3 * wf, w, h, &sse2, NULL, NULL); \
se += se2; \
sse += sse2; \
} \
@ -515,19 +514,19 @@ DECLS(sse2);
if (w > wf) { \
uint32_t sse2; \
int se2 = aom_highbd_sub_pixel_avg_variance##wf##xh_##opt( \
src + 16, src_stride, x_offset, y_offset, dst + 16, dst_stride, \
sec + 16, w, h, &sse2, NULL, NULL); \
src + wf, src_stride, x_offset, y_offset, dst + wf, dst_stride, \
sec + wf, w, h, &sse2, NULL, NULL); \
se += se2; \
sse += sse2; \
if (w > wf * 2) { \
se2 = aom_highbd_sub_pixel_avg_variance##wf##xh_##opt( \
src + 32, src_stride, x_offset, y_offset, dst + 32, dst_stride, \
sec + 32, w, h, &sse2, NULL, NULL); \
src + 2 * wf, src_stride, x_offset, y_offset, dst + 2 * wf, \
dst_stride, sec + 2 * wf, w, h, &sse2, NULL, NULL); \
se += se2; \
sse += sse2; \
se2 = aom_highbd_sub_pixel_avg_variance##wf##xh_##opt( \
src + 48, src_stride, x_offset, y_offset, dst + 48, dst_stride, \
sec + 48, w, h, &sse2, NULL, NULL); \
src + 3 * wf, src_stride, x_offset, y_offset, dst + 3 * wf, \
dst_stride, sec + 3 * wf, w, h, &sse2, NULL, NULL); \
se += se2; \
sse += sse2; \
} \
@ -562,22 +561,22 @@ DECLS(sse2);
long_sse += sse2; \
if (w > wf) { \
se2 = aom_highbd_sub_pixel_avg_variance##wf##xh_##opt( \
src + 16 + (start_row * src_stride), src_stride, x_offset, \
y_offset, dst + 16 + (start_row * dst_stride), dst_stride, \
sec + 16 + (start_row * w), w, height, &sse2, NULL, NULL); \
src + wf + (start_row * src_stride), src_stride, x_offset, \
y_offset, dst + wf + (start_row * dst_stride), dst_stride, \
sec + wf + (start_row * w), w, height, &sse2, NULL, NULL); \
se += se2; \
long_sse += sse2; \
if (w > wf * 2) { \
se2 = aom_highbd_sub_pixel_avg_variance##wf##xh_##opt( \
src + 32 + (start_row * src_stride), src_stride, x_offset, \
y_offset, dst + 32 + (start_row * dst_stride), dst_stride, \
sec + 32 + (start_row * w), w, height, &sse2, NULL, NULL); \
src + 2 * wf + (start_row * src_stride), src_stride, x_offset, \
y_offset, dst + 2 * wf + (start_row * dst_stride), dst_stride, \
sec + 2 * wf + (start_row * w), w, height, &sse2, NULL, NULL); \
se += se2; \
long_sse += sse2; \
se2 = aom_highbd_sub_pixel_avg_variance##wf##xh_##opt( \
src + 48 + (start_row * src_stride), src_stride, x_offset, \
y_offset, dst + 48 + (start_row * dst_stride), dst_stride, \
sec + 48 + (start_row * w), w, height, &sse2, NULL, NULL); \
src + 3 * wf + (start_row * src_stride), src_stride, x_offset, \
y_offset, dst + 3 * wf + (start_row * dst_stride), dst_stride, \
sec + 3 * wf + (start_row * w), w, height, &sse2, NULL, NULL); \
se += se2; \
long_sse += sse2; \
} \
@ -672,30 +671,26 @@ void aom_highbd_upsampled_pred_sse2(MACROBLOCKD *xd,
const uint8_t *const pre =
pre_buf->buf0 + (pos_y >> SCALE_SUBPEL_BITS) * pre_buf->stride +
(pos_x >> SCALE_SUBPEL_BITS);
InterPredParams inter_pred_params;
const SubpelParams subpel_params = { sf->x_step_q4, sf->y_step_q4,
pos_x & SCALE_SUBPEL_MASK,
pos_y & SCALE_SUBPEL_MASK };
// Get warp types.
const WarpedMotionParams *const wm =
&xd->global_motion[mi->ref_frame[ref_num]];
const int is_global = is_global_mv_block(mi, wm->wmtype);
WarpTypesAllowed warp_types;
warp_types.global_warp_allowed = is_global;
warp_types.local_warp_allowed = mi->motion_mode == WARPED_CAUSAL;
// Get convolve parameters.
ConvolveParams conv_params = get_conv_params(0, plane, xd->bd);
const InterpFilters filters =
inter_pred_params.conv_params = get_conv_params(0, plane, xd->bd);
const int_interpfilters filters =
av1_broadcast_interp_filter(EIGHTTAP_REGULAR);
av1_init_inter_params(
&inter_pred_params, width, height, mi_y >> pd->subsampling_y,
mi_x >> pd->subsampling_x, pd->subsampling_x, pd->subsampling_y,
xd->bd, is_cur_buf_hbd(xd), mi->use_intrabc, sf, filters);
// Get the inter predictor.
const int build_for_obmc = 0;
av1_make_inter_predictor(pre, pre_buf->stride, comp_pred8, width,
&subpel_params, sf, width, height, &conv_params,
filters, &warp_types, mi_x >> pd->subsampling_x,
mi_y >> pd->subsampling_y, plane, ref_num, mi,
build_for_obmc, xd, cm->allow_warped_motion);
&inter_pred_params, &subpel_params);
return;
}
}

View file

@ -775,7 +775,7 @@ void aom_paeth_predictor_16x8_avx2(uint8_t *dst, ptrdiff_t stride,
__m128i x = _mm_loadl_epi64((const __m128i *)left);
const __m256i l = _mm256_inserti128_si256(_mm256_castsi128_si256(x), x, 1);
const __m256i tl16 = _mm256_set1_epi16((uint16_t)above[-1]);
__m256i rep = _mm256_set1_epi16(0x8000);
__m256i rep = _mm256_set1_epi16((short)0x8000);
const __m256i one = _mm256_set1_epi16(1);
const __m256i top = get_top_vector(above);
@ -799,7 +799,7 @@ void aom_paeth_predictor_16x16_avx2(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) {
const __m256i l = get_left_vector(left);
const __m256i tl16 = _mm256_set1_epi16((uint16_t)above[-1]);
__m256i rep = _mm256_set1_epi16(0x8000);
__m256i rep = _mm256_set1_epi16((short)0x8000);
const __m256i one = _mm256_set1_epi16(1);
const __m256i top = get_top_vector(above);
@ -818,7 +818,7 @@ void aom_paeth_predictor_16x32_avx2(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) {
__m256i l = get_left_vector(left);
const __m256i tl16 = _mm256_set1_epi16((uint16_t)above[-1]);
__m256i rep = _mm256_set1_epi16(0x8000);
__m256i rep = _mm256_set1_epi16((short)0x8000);
const __m256i one = _mm256_set1_epi16(1);
const __m256i top = get_top_vector(above);
@ -833,7 +833,7 @@ void aom_paeth_predictor_16x32_avx2(uint8_t *dst, ptrdiff_t stride,
}
l = get_left_vector(left + 16);
rep = _mm256_set1_epi16(0x8000);
rep = _mm256_set1_epi16((short)0x8000);
for (i = 0; i < 16; ++i) {
const __m256i l16 = _mm256_shuffle_epi8(l, rep);
const __m128i row = paeth_16x1_pred(&l16, &top, &tl16);
@ -852,7 +852,7 @@ void aom_paeth_predictor_16x64_avx2(uint8_t *dst, ptrdiff_t stride,
for (int j = 0; j < 4; ++j) {
const __m256i l = get_left_vector(left + j * 16);
__m256i rep = _mm256_set1_epi16(0x8000);
__m256i rep = _mm256_set1_epi16((short)0x8000);
for (int i = 0; i < 16; ++i) {
const __m256i l16 = _mm256_shuffle_epi8(l, rep);
const __m128i row = paeth_16x1_pred(&l16, &top, &tl16);
@ -885,7 +885,7 @@ void aom_paeth_predictor_32x16_avx2(uint8_t *dst, ptrdiff_t stride,
const __m256i t0 = get_top_vector(above);
const __m256i t1 = get_top_vector(above + 16);
const __m256i tl = _mm256_set1_epi16((uint16_t)above[-1]);
__m256i rep = _mm256_set1_epi16(0x8000);
__m256i rep = _mm256_set1_epi16((short)0x8000);
const __m256i one = _mm256_set1_epi16(1);
int i;
@ -907,7 +907,7 @@ void aom_paeth_predictor_32x32_avx2(uint8_t *dst, ptrdiff_t stride,
const __m256i t0 = get_top_vector(above);
const __m256i t1 = get_top_vector(above + 16);
const __m256i tl = _mm256_set1_epi16((uint16_t)above[-1]);
__m256i rep = _mm256_set1_epi16(0x8000);
__m256i rep = _mm256_set1_epi16((short)0x8000);
const __m256i one = _mm256_set1_epi16(1);
int i;
@ -925,7 +925,7 @@ void aom_paeth_predictor_32x32_avx2(uint8_t *dst, ptrdiff_t stride,
}
l = get_left_vector(left + 16);
rep = _mm256_set1_epi16(0x8000);
rep = _mm256_set1_epi16((short)0x8000);
for (i = 0; i < 16; ++i) {
const __m256i l16 = _mm256_shuffle_epi8(l, rep);
@ -950,7 +950,7 @@ void aom_paeth_predictor_32x64_avx2(uint8_t *dst, ptrdiff_t stride,
int i, j;
for (j = 0; j < 4; ++j) {
const __m256i l = get_left_vector(left + j * 16);
__m256i rep = _mm256_set1_epi16(0x8000);
__m256i rep = _mm256_set1_epi16((short)0x8000);
for (i = 0; i < 16; ++i) {
const __m256i l16 = _mm256_shuffle_epi8(l, rep);
@ -978,7 +978,7 @@ void aom_paeth_predictor_64x32_avx2(uint8_t *dst, ptrdiff_t stride,
int i, j;
for (j = 0; j < 2; ++j) {
const __m256i l = get_left_vector(left + j * 16);
__m256i rep = _mm256_set1_epi16(0x8000);
__m256i rep = _mm256_set1_epi16((short)0x8000);
for (i = 0; i < 16; ++i) {
const __m256i l16 = _mm256_shuffle_epi8(l, rep);
@ -1010,7 +1010,7 @@ void aom_paeth_predictor_64x64_avx2(uint8_t *dst, ptrdiff_t stride,
int i, j;
for (j = 0; j < 4; ++j) {
const __m256i l = get_left_vector(left + j * 16);
__m256i rep = _mm256_set1_epi16(0x8000);
__m256i rep = _mm256_set1_epi16((short)0x8000);
for (i = 0; i < 16; ++i) {
const __m256i l16 = _mm256_shuffle_epi8(l, rep);
@ -1041,7 +1041,7 @@ void aom_paeth_predictor_64x16_avx2(uint8_t *dst, ptrdiff_t stride,
int i;
const __m256i l = get_left_vector(left);
__m256i rep = _mm256_set1_epi16(0x8000);
__m256i rep = _mm256_set1_epi16((short)0x8000);
for (i = 0; i < 16; ++i) {
const __m256i l16 = _mm256_shuffle_epi8(l, rep);
@ -2758,7 +2758,7 @@ static void highbd_dr_prediction_z2_HxW_avx2(
__m256i resxy, j256, r6;
__m128i a0_x128, a1_x128, a0_1_x128, a1_1_x128;
int y = r + 1;
ydx = _mm256_set1_epi16(y * dx);
ydx = _mm256_set1_epi16((short)(y * dx));
for (int j = 0; j < W; j += 16) {
j256 = _mm256_set1_epi16(j);
@ -3569,7 +3569,18 @@ static DECLARE_ALIGNED(16, uint8_t, EvenOddMaskx[8][16]) = {
{ 0, 0, 0, 0, 0, 0, 6, 8, 0, 0, 0, 0, 0, 0, 7, 9 },
{ 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 8 }
};
/* clang-format off */
static DECLARE_ALIGNED(32, int, LoadMaskz2[8][8]) = {
{ -1, 0, 0, 0, 0, 0, 0, 0},
{ -1, -1, 0, 0, 0, 0, 0, 0},
{ -1, -1, -1, 0, 0, 0, 0, 0},
{ -1, -1, -1, -1, 0, 0, 0, 0},
{ -1, -1, -1, -1, -1, 0, 0, 0},
{ -1, -1, -1, -1, -1, -1, 0, 0},
{ -1, -1, -1, -1, -1, -1, -1, 0},
{ -1, -1, -1, -1, -1, -1, -1, -1},
};
/* clang-format on */
static AOM_FORCE_INLINE void dr_prediction_z1_HxW_internal_avx2(
int H, int W, __m128i *dst, const uint8_t *above, int upsample_above,
int dx) {
@ -3816,11 +3827,15 @@ static void dr_prediction_z1_64xN_avx2(int N, uint8_t *dst, ptrdiff_t stride,
res, _mm256_castsi128_si256(
_mm256_extracti128_si256(res, 1))); // 16 8bit values
base_inc128 = _mm_setr_epi8(
base + j, base + j + 1, base + j + 2, base + j + 3, base + j + 4,
base + j + 5, base + j + 6, base + j + 7, base + j + 8,
base + j + 9, base + j + 10, base + j + 11, base + j + 12,
base + j + 13, base + j + 14, base + j + 15);
base_inc128 =
_mm_setr_epi8((uint8_t)(base + j), (uint8_t)(base + j + 1),
(uint8_t)(base + j + 2), (uint8_t)(base + j + 3),
(uint8_t)(base + j + 4), (uint8_t)(base + j + 5),
(uint8_t)(base + j + 6), (uint8_t)(base + j + 7),
(uint8_t)(base + j + 8), (uint8_t)(base + j + 9),
(uint8_t)(base + j + 10), (uint8_t)(base + j + 11),
(uint8_t)(base + j + 12), (uint8_t)(base + j + 13),
(uint8_t)(base + j + 14), (uint8_t)(base + j + 15));
mask128 = _mm_cmpgt_epi8(_mm_subs_epu8(max_base_x128, base_inc128),
_mm_setzero_si128());
@ -4139,7 +4154,7 @@ static void dr_prediction_z2_HxW_avx2(int H, int W, uint8_t *dst,
__m128i resx, resy;
__m128i resxy;
int y = r + 1;
ydx = _mm256_set1_epi16(y * dx);
ydx = _mm256_set1_epi16((uint16_t)(y * dx));
int base_x = (-y * dx) >> frac_bits_x;
for (int j = 0; j < W; j += 16) {
@ -4193,27 +4208,53 @@ static void dr_prediction_z2_HxW_avx2(int H, int W, uint8_t *dst,
base_y_c256 = _mm256_srai_epi16(y_c256, frac_bits_y);
mask256 = _mm256_cmpgt_epi16(min_base_y256, base_y_c256);
base_y_c256 = _mm256_andnot_si256(mask256, base_y_c256);
_mm256_store_si256((__m256i *)base_y_c, base_y_c256); /**/
a0_y = _mm256_setr_epi16(
left[base_y_c[0]], left[base_y_c[1]], left[base_y_c[2]],
left[base_y_c[3]], left[base_y_c[4]], left[base_y_c[5]],
left[base_y_c[6]], left[base_y_c[7]], left[base_y_c[8]],
left[base_y_c[9]], left[base_y_c[10]], left[base_y_c[11]],
left[base_y_c[12]], left[base_y_c[13]], left[base_y_c[14]],
left[base_y_c[15]]);
base_y_c256 = _mm256_add_epi16(base_y_c256, c1);
_mm256_store_si256((__m256i *)base_y_c, base_y_c256);
base_y_c256 = _mm256_blendv_epi8(base_y_c256, min_base_y256, mask256);
int16_t min_y = (int16_t)_mm_extract_epi16(
_mm256_extracti128_si256(base_y_c256, 1), 7);
int16_t max_y =
(int16_t)_mm_extract_epi16(_mm256_castsi256_si128(base_y_c256), 0);
int16_t offset_diff = max_y - min_y;
a1_y = _mm256_setr_epi16(
left[base_y_c[0]], left[base_y_c[1]], left[base_y_c[2]],
left[base_y_c[3]], left[base_y_c[4]], left[base_y_c[5]],
left[base_y_c[6]], left[base_y_c[7]], left[base_y_c[8]],
left[base_y_c[9]], left[base_y_c[10]], left[base_y_c[11]],
left[base_y_c[12]], left[base_y_c[13]], left[base_y_c[14]],
left[base_y_c[15]]);
if (offset_diff < 16) {
__m256i min_y256 = _mm256_set1_epi16(min_y);
__m256i base_y_offset = _mm256_sub_epi16(base_y_c256, min_y256);
__m128i base_y_offset128 =
_mm_packs_epi16(_mm256_extracti128_si256(base_y_offset, 0),
_mm256_extracti128_si256(base_y_offset, 1));
__m128i a0_y128 = _mm_maskload_epi32(
(int *)(left + min_y), *(__m128i *)LoadMaskz2[offset_diff / 4]);
__m128i a1_y128 =
_mm_maskload_epi32((int *)(left + min_y + 1),
*(__m128i *)LoadMaskz2[offset_diff / 4]);
a0_y128 = _mm_shuffle_epi8(a0_y128, base_y_offset128);
a1_y128 = _mm_shuffle_epi8(a1_y128, base_y_offset128);
a0_y = _mm256_cvtepu8_epi16(a0_y128);
a1_y = _mm256_cvtepu8_epi16(a1_y128);
} else {
base_y_c256 = _mm256_andnot_si256(mask256, base_y_c256);
_mm256_store_si256((__m256i *)base_y_c, base_y_c256);
a0_y = _mm256_setr_epi16(
left[base_y_c[0]], left[base_y_c[1]], left[base_y_c[2]],
left[base_y_c[3]], left[base_y_c[4]], left[base_y_c[5]],
left[base_y_c[6]], left[base_y_c[7]], left[base_y_c[8]],
left[base_y_c[9]], left[base_y_c[10]], left[base_y_c[11]],
left[base_y_c[12]], left[base_y_c[13]], left[base_y_c[14]],
left[base_y_c[15]]);
base_y_c256 = _mm256_add_epi16(base_y_c256, c1);
_mm256_store_si256((__m256i *)base_y_c, base_y_c256);
a1_y = _mm256_setr_epi16(
left[base_y_c[0]], left[base_y_c[1]], left[base_y_c[2]],
left[base_y_c[3]], left[base_y_c[4]], left[base_y_c[5]],
left[base_y_c[6]], left[base_y_c[7]], left[base_y_c[8]],
left[base_y_c[9]], left[base_y_c[10]], left[base_y_c[11]],
left[base_y_c[12]], left[base_y_c[13]], left[base_y_c[14]],
left[base_y_c[15]]);
}
shifty = _mm256_srli_epi16(_mm256_and_si256(y_c256, c3f), 1);
diff = _mm256_sub_epi16(a1_y, a0_y); // a[x+1] - a[x]

View file

@ -48,7 +48,7 @@ void aom_paeth_predictor_4x4_ssse3(uint8_t *dst, ptrdiff_t stride,
const __m128i zero = _mm_setzero_si128();
const __m128i t16 = _mm_unpacklo_epi8(t, zero);
const __m128i tl16 = _mm_set1_epi16((uint16_t)above[-1]);
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
const __m128i one = _mm_set1_epi16(1);
int i;
@ -69,7 +69,7 @@ void aom_paeth_predictor_4x8_ssse3(uint8_t *dst, ptrdiff_t stride,
const __m128i zero = _mm_setzero_si128();
const __m128i t16 = _mm_unpacklo_epi8(t, zero);
const __m128i tl16 = _mm_set1_epi16((uint16_t)above[-1]);
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
const __m128i one = _mm_set1_epi16(1);
int i;
@ -90,7 +90,7 @@ void aom_paeth_predictor_4x16_ssse3(uint8_t *dst, ptrdiff_t stride,
const __m128i zero = _mm_setzero_si128();
const __m128i t16 = _mm_unpacklo_epi8(t, zero);
const __m128i tl16 = _mm_set1_epi16((uint16_t)above[-1]);
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
const __m128i one = _mm_set1_epi16(1);
for (int i = 0; i < 16; ++i) {
@ -110,7 +110,7 @@ void aom_paeth_predictor_8x4_ssse3(uint8_t *dst, ptrdiff_t stride,
const __m128i zero = _mm_setzero_si128();
const __m128i t16 = _mm_unpacklo_epi8(t, zero);
const __m128i tl16 = _mm_set1_epi16((uint16_t)above[-1]);
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
const __m128i one = _mm_set1_epi16(1);
int i;
@ -131,7 +131,7 @@ void aom_paeth_predictor_8x8_ssse3(uint8_t *dst, ptrdiff_t stride,
const __m128i zero = _mm_setzero_si128();
const __m128i t16 = _mm_unpacklo_epi8(t, zero);
const __m128i tl16 = _mm_set1_epi16((uint16_t)above[-1]);
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
const __m128i one = _mm_set1_epi16(1);
int i;
@ -152,7 +152,7 @@ void aom_paeth_predictor_8x16_ssse3(uint8_t *dst, ptrdiff_t stride,
const __m128i zero = _mm_setzero_si128();
const __m128i t16 = _mm_unpacklo_epi8(t, zero);
const __m128i tl16 = _mm_set1_epi16((uint16_t)above[-1]);
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
const __m128i one = _mm_set1_epi16(1);
int i;
@ -176,7 +176,7 @@ void aom_paeth_predictor_8x32_ssse3(uint8_t *dst, ptrdiff_t stride,
for (int j = 0; j < 2; ++j) {
const __m128i l = _mm_load_si128((const __m128i *)(left + j * 16));
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
for (int i = 0; i < 16; ++i) {
const __m128i l16 = _mm_shuffle_epi8(l, rep);
const __m128i row = paeth_8x1_pred(&l16, &t16, &tl16);
@ -205,7 +205,7 @@ void aom_paeth_predictor_16x4_ssse3(uint8_t *dst, ptrdiff_t stride,
const __m128i top0 = _mm_unpacklo_epi8(t, zero);
const __m128i top1 = _mm_unpackhi_epi8(t, zero);
const __m128i tl16 = _mm_set1_epi16((uint16_t)above[-1]);
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
const __m128i one = _mm_set1_epi16(1);
for (int i = 0; i < 4; ++i) {
@ -226,7 +226,7 @@ void aom_paeth_predictor_16x8_ssse3(uint8_t *dst, ptrdiff_t stride,
const __m128i top0 = _mm_unpacklo_epi8(t, zero);
const __m128i top1 = _mm_unpackhi_epi8(t, zero);
const __m128i tl16 = _mm_set1_epi16((uint16_t)above[-1]);
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
const __m128i one = _mm_set1_epi16(1);
int i;
@ -249,7 +249,7 @@ void aom_paeth_predictor_16x16_ssse3(uint8_t *dst, ptrdiff_t stride,
const __m128i top0 = _mm_unpacklo_epi8(t, zero);
const __m128i top1 = _mm_unpackhi_epi8(t, zero);
const __m128i tl16 = _mm_set1_epi16((uint16_t)above[-1]);
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
const __m128i one = _mm_set1_epi16(1);
int i;
@ -272,7 +272,7 @@ void aom_paeth_predictor_16x32_ssse3(uint8_t *dst, ptrdiff_t stride,
const __m128i top0 = _mm_unpacklo_epi8(t, zero);
const __m128i top1 = _mm_unpackhi_epi8(t, zero);
const __m128i tl16 = _mm_set1_epi16((uint16_t)above[-1]);
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
const __m128i one = _mm_set1_epi16(1);
__m128i l16;
@ -287,7 +287,7 @@ void aom_paeth_predictor_16x32_ssse3(uint8_t *dst, ptrdiff_t stride,
}
l = _mm_load_si128((const __m128i *)(left + 16));
rep = _mm_set1_epi16(0x8000);
rep = _mm_set1_epi16((short)0x8000);
for (i = 0; i < 16; ++i) {
l16 = _mm_shuffle_epi8(l, rep);
const __m128i row = paeth_16x1_pred(&l16, &top0, &top1, &tl16);
@ -310,7 +310,7 @@ void aom_paeth_predictor_16x64_ssse3(uint8_t *dst, ptrdiff_t stride,
for (int j = 0; j < 4; ++j) {
const __m128i l = _mm_load_si128((const __m128i *)(left + j * 16));
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
for (int i = 0; i < 16; ++i) {
const __m128i l16 = _mm_shuffle_epi8(l, rep);
const __m128i row = paeth_16x1_pred(&l16, &top0, &top1, &tl16);
@ -332,7 +332,7 @@ void aom_paeth_predictor_32x8_ssse3(uint8_t *dst, ptrdiff_t stride,
const __m128i bh = _mm_unpackhi_epi8(b, zero);
const __m128i tl16 = _mm_set1_epi16((uint16_t)above[-1]);
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
const __m128i one = _mm_set1_epi16(1);
const __m128i l = _mm_loadl_epi64((const __m128i *)left);
__m128i l16;
@ -361,7 +361,7 @@ void aom_paeth_predictor_32x16_ssse3(uint8_t *dst, ptrdiff_t stride,
const __m128i bh = _mm_unpackhi_epi8(b, zero);
const __m128i tl16 = _mm_set1_epi16((uint16_t)above[-1]);
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
const __m128i one = _mm_set1_epi16(1);
__m128i l = _mm_load_si128((const __m128i *)left);
__m128i l16;
@ -391,7 +391,7 @@ void aom_paeth_predictor_32x32_ssse3(uint8_t *dst, ptrdiff_t stride,
const __m128i bh = _mm_unpackhi_epi8(b, zero);
const __m128i tl16 = _mm_set1_epi16((uint16_t)above[-1]);
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
const __m128i one = _mm_set1_epi16(1);
__m128i l = _mm_load_si128((const __m128i *)left);
__m128i l16;
@ -408,7 +408,7 @@ void aom_paeth_predictor_32x32_ssse3(uint8_t *dst, ptrdiff_t stride,
rep = _mm_add_epi16(rep, one);
}
rep = _mm_set1_epi16(0x8000);
rep = _mm_set1_epi16((short)0x8000);
l = _mm_load_si128((const __m128i *)(left + 16));
for (i = 0; i < 16; ++i) {
l16 = _mm_shuffle_epi8(l, rep);
@ -440,7 +440,7 @@ void aom_paeth_predictor_32x64_ssse3(uint8_t *dst, ptrdiff_t stride,
int i, j;
for (j = 0; j < 4; ++j) {
const __m128i l = _mm_load_si128((const __m128i *)(left + j * 16));
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
for (i = 0; i < 16; ++i) {
l16 = _mm_shuffle_epi8(l, rep);
const __m128i r32l = paeth_16x1_pred(&l16, &al, &ah, &tl16);
@ -478,7 +478,7 @@ void aom_paeth_predictor_64x32_ssse3(uint8_t *dst, ptrdiff_t stride,
int i, j;
for (j = 0; j < 2; ++j) {
const __m128i l = _mm_load_si128((const __m128i *)(left + j * 16));
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
for (i = 0; i < 16; ++i) {
l16 = _mm_shuffle_epi8(l, rep);
const __m128i r0 = paeth_16x1_pred(&l16, &al, &ah, &tl16);
@ -520,7 +520,7 @@ void aom_paeth_predictor_64x64_ssse3(uint8_t *dst, ptrdiff_t stride,
int i, j;
for (j = 0; j < 4; ++j) {
const __m128i l = _mm_load_si128((const __m128i *)(left + j * 16));
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
for (i = 0; i < 16; ++i) {
l16 = _mm_shuffle_epi8(l, rep);
const __m128i r0 = paeth_16x1_pred(&l16, &al, &ah, &tl16);
@ -561,7 +561,7 @@ void aom_paeth_predictor_64x16_ssse3(uint8_t *dst, ptrdiff_t stride,
int i;
const __m128i l = _mm_load_si128((const __m128i *)left);
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
for (i = 0; i < 16; ++i) {
l16 = _mm_shuffle_epi8(l, rep);
const __m128i r0 = paeth_16x1_pred(&l16, &al, &ah, &tl16);
@ -636,7 +636,8 @@ static INLINE void smooth_pred_4xh(const __m128i *pixel, const __m128i *wh,
const __m128i one = _mm_set1_epi16(1);
const __m128i inc = _mm_set1_epi16(0x202);
const __m128i gat = _mm_set1_epi32(0xc080400);
__m128i rep = second_half ? _mm_set1_epi16(0x8008) : _mm_set1_epi16(0x8000);
__m128i rep = second_half ? _mm_set1_epi16((short)0x8008)
: _mm_set1_epi16((short)0x8000);
__m128i d = _mm_set1_epi16(0x100);
for (int i = 0; i < h; ++i) {
@ -792,7 +793,8 @@ static INLINE void smooth_pred_8xh(const __m128i *pixels, const __m128i *wh,
const __m128i inc = _mm_set1_epi16(0x202);
const __m128i gat = _mm_set_epi32(0, 0, 0xe0c0a08, 0x6040200);
__m128i rep = second_half ? _mm_set1_epi16(0x8008) : _mm_set1_epi16(0x8000);
__m128i rep = second_half ? _mm_set1_epi16((short)0x8008)
: _mm_set1_epi16((short)0x8000);
__m128i d = _mm_set1_epi16(0x100);
int i;
@ -1400,7 +1402,7 @@ static INLINE void smooth_h_pred_4xh(const __m128i *pixel,
const __m128i pred_round = _mm_set1_epi32((1 << (sm_weight_log2_scale - 1)));
const __m128i one = _mm_set1_epi16(1);
const __m128i gat = _mm_set1_epi32(0xc080400);
__m128i rep = _mm_set1_epi16(0x8000);
__m128i rep = _mm_set1_epi16((short)0x8000);
for (int i = 0; i < h; ++i) {
__m128i b = _mm_shuffle_epi8(pixel[0], rep);
@ -1499,7 +1501,8 @@ static INLINE void smooth_h_pred_8xh(const __m128i *pixels, const __m128i *ww,
const __m128i pred_round = _mm_set1_epi32((1 << (sm_weight_log2_scale - 1)));
const __m128i one = _mm_set1_epi16(1);
const __m128i gat = _mm_set_epi32(0, 0, 0xe0c0a08, 0x6040200);
__m128i rep = second_half ? _mm_set1_epi16(0x8008) : _mm_set1_epi16(0x8000);
__m128i rep = second_half ? _mm_set1_epi16((short)0x8008)
: _mm_set1_epi16((short)0x8000);
for (int i = 0; i < h; ++i) {
__m128i b = _mm_shuffle_epi8(pixels[0], rep);

View file

@ -146,7 +146,7 @@ static AOM_FORCE_INLINE void filter4_sse2(__m128i *p1p0, __m128i *q1q0,
__m128i hev1;
const __m128i t3t4 =
_mm_set_epi8(0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 4, 4, 4, 4);
const __m128i t80 = _mm_set1_epi8(0x80);
const __m128i t80 = _mm_set1_epi8((char)0x80);
const __m128i ff = _mm_cmpeq_epi8(t80, t80);
ps1ps0_work = _mm_xor_si128(*p1p0, t80); /* ^ 0x80 */
@ -195,7 +195,7 @@ static AOM_FORCE_INLINE void filter4_dual_sse2(__m128i *p1p0, __m128i *q1q0,
__m128i *ps1ps0) {
const __m128i t3t4 =
_mm_set_epi8(3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4);
const __m128i t80 = _mm_set1_epi8(0x80);
const __m128i t80 = _mm_set1_epi8((char)0x80);
__m128i filter, filter2filter1, work;
__m128i ps1ps0_work, qs1qs0_work;
__m128i hev1;
@ -410,7 +410,7 @@ static AOM_FORCE_INLINE void lpf_internal_14_dual_sse2(
__m128i fe, ff, work;
abs_p1p0 = abs_diff(*q1p1, *q0p0);
abs_q1q0 = _mm_srli_si128(abs_p1p0, 8);
fe = _mm_set1_epi8(0xfe);
fe = _mm_set1_epi8((char)0xfe);
ff = _mm_cmpeq_epi8(abs_p1p0, abs_p1p0);
abs_p0q0 = abs_diff(p1p0, q1q0);
abs_p1q1 = _mm_srli_si128(abs_p0q0, 8);
@ -714,7 +714,7 @@ static AOM_FORCE_INLINE void lpf_internal_14_sse2(
__m128i abs_p1q1, abs_p0q0, abs_q1q0;
abs_p1p0 = abs_diff(*q1p1, *q0p0);
abs_q1q0 = _mm_srli_si128(abs_p1p0, 4);
fe = _mm_set1_epi8(0xfe);
fe = _mm_set1_epi8((char)0xfe);
ff = _mm_cmpeq_epi8(fe, fe);
abs_p0q0 = abs_diff(p1p0, q1q0);
abs_p1q1 = _mm_srli_si128(abs_p0q0, 4);
@ -1003,7 +1003,7 @@ static AOM_FORCE_INLINE void lpf_internal_6_dual_sse2(
*q1q0 = _mm_unpackhi_epi64(q0p0, q1p1);
const __m128i one = _mm_set1_epi8(1);
const __m128i fe = _mm_set1_epi8(0xfe);
const __m128i fe = _mm_set1_epi8((char)0xfe);
const __m128i ff = _mm_cmpeq_epi8(fe, fe);
{
@ -1132,7 +1132,7 @@ static AOM_FORCE_INLINE void lpf_internal_6_sse2(
*q1q0 = _mm_unpacklo_epi32(*q0, *q1);
const __m128i one = _mm_set1_epi8(1);
const __m128i fe = _mm_set1_epi8(0xfe);
const __m128i fe = _mm_set1_epi8((char)0xfe);
const __m128i ff = _mm_cmpeq_epi8(fe, fe);
{
// filter_mask and hev_mask
@ -1337,7 +1337,7 @@ static AOM_FORCE_INLINE void lpf_internal_8_sse2(
// otherwise - not
const __m128i one = _mm_set1_epi8(1);
const __m128i fe = _mm_set1_epi8(0xfe);
const __m128i fe = _mm_set1_epi8((char)0xfe);
const __m128i ff = _mm_cmpeq_epi8(fe, fe);
__m128i abs_p1q1, abs_p0q0, abs_q1q0, abs_p1p0, work;
@ -1492,7 +1492,7 @@ static AOM_FORCE_INLINE void lpf_internal_8_dual_sse2(
// otherwise - not
const __m128i one = _mm_set1_epi8(1);
const __m128i fe = _mm_set1_epi8(0xfe);
const __m128i fe = _mm_set1_epi8((char)0xfe);
const __m128i ff = _mm_cmpeq_epi8(fe, fe);
__m128i abs_p1q1, abs_p0q0, abs_q1q0, abs_p1p0, work;

View file

@ -17,7 +17,7 @@
#include "aom_dsp/blend.h"
#include "aom/aom_integer.h"
#include "aom_dsp/x86/synonyms.h"
#include "aom_dsp/x86//masked_sad_intrin_ssse3.h"
#include "aom_dsp/x86/masked_sad_intrin_ssse3.h"
static INLINE unsigned int masked_sad32xh_avx2(
const uint8_t *src_ptr, int src_stride, const uint8_t *a_ptr, int a_stride,

View file

@ -19,7 +19,7 @@
#include "aom/aom_integer.h"
#include "aom_dsp/x86/synonyms.h"
#include "aom_dsp/x86//masked_sad_intrin_ssse3.h"
#include "aom_dsp/x86/masked_sad_intrin_ssse3.h"
// For width a multiple of 16
static INLINE unsigned int masked_sad_ssse3(const uint8_t *src_ptr,

View file

@ -517,6 +517,7 @@ static void masked_variance4xh(const uint8_t *src_ptr, int src_stride,
*sse = _mm_cvtsi128_si32(_mm_srli_si128(sum, 4));
}
#if CONFIG_AV1_HIGHBITDEPTH
// For width a multiple of 8
static void highbd_bilinear_filter(const uint16_t *src, int src_stride,
int xoffset, int yoffset, uint16_t *dst,
@ -1025,6 +1026,7 @@ static void highbd_masked_variance4xh(const uint16_t *src_ptr, int src_stride,
*sum_ = _mm_cvtsi128_si32(sum);
*sse = _mm_cvtsi128_si32(_mm_srli_si128(sum, 4));
}
#endif // CONFIG_AV1_HIGHBITDEPTH
void aom_comp_mask_pred_ssse3(uint8_t *comp_pred, const uint8_t *pred,
int width, int height, const uint8_t *ref,

View file

@ -166,7 +166,7 @@ OBMC_SUBPIX_VAR(64, 16)
////////////////////////////////////////////////////////////////////////////////
// High bit-depth
////////////////////////////////////////////////////////////////////////////////
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE void hbd_obmc_variance_w4(
const uint8_t *pre8, const int pre_stride, const int32_t *wsrc,
const int32_t *mask, uint64_t *const sse, int64_t *const sum, const int h) {
@ -378,3 +378,4 @@ HBD_OBMCVARWXH(8, 32)
HBD_OBMCVARWXH(32, 8)
HBD_OBMCVARWXH(16, 64)
HBD_OBMCVARWXH(64, 16)
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -229,6 +229,23 @@ unsigned int aom_highbd_sad32x16_avx2(const uint8_t *src, int src_stride,
return get_sad_from_mm256_epi32(&sad);
}
unsigned int aom_highbd_sad32x8_avx2(const uint8_t *src, int src_stride,
const uint8_t *ref, int ref_stride) {
__m256i sad = _mm256_setzero_si256();
uint16_t *srcp = CONVERT_TO_SHORTPTR(src);
uint16_t *refp = CONVERT_TO_SHORTPTR(ref);
const int left_shift = 2;
int row_section = 0;
while (row_section < 2) {
sad32x4(srcp, src_stride, refp, ref_stride, NULL, &sad);
srcp += src_stride << left_shift;
refp += ref_stride << left_shift;
row_section += 1;
}
return get_sad_from_mm256_epi32(&sad);
}
unsigned int aom_highbd_sad16x32_avx2(const uint8_t *src, int src_stride,
const uint8_t *ref, int ref_stride) {
uint32_t sum = aom_highbd_sad16x16_avx2(src, src_stride, ref, ref_stride);
@ -352,6 +369,23 @@ unsigned int aom_highbd_sad64x32_avx2(const uint8_t *src, int src_stride,
return get_sad_from_mm256_epi32(&sad);
}
unsigned int aom_highbd_sad64x16_avx2(const uint8_t *src, int src_stride,
const uint8_t *ref, int ref_stride) {
__m256i sad = _mm256_setzero_si256();
uint16_t *srcp = CONVERT_TO_SHORTPTR(src);
uint16_t *refp = CONVERT_TO_SHORTPTR(ref);
const int left_shift = 1;
int row_section = 0;
while (row_section < 8) {
sad64x2(srcp, src_stride, refp, ref_stride, NULL, &sad);
srcp += src_stride << left_shift;
refp += ref_stride << left_shift;
row_section += 1;
}
return get_sad_from_mm256_epi32(&sad);
}
unsigned int aom_highbd_sad64x64_avx2(const uint8_t *src, int src_stride,
const uint8_t *ref, int ref_stride) {
uint32_t sum = aom_highbd_sad64x32_avx2(src, src_stride, ref, ref_stride);
@ -520,6 +554,27 @@ static INLINE void sad16x4(const uint16_t *src_ptr, int src_stride,
*sad_acc = _mm256_add_epi32(*sad_acc, r0);
}
unsigned int aom_highbd_sad16x4_avx2(const uint8_t *src, int src_stride,
const uint8_t *ref, int ref_stride) {
__m256i sad = _mm256_setzero_si256();
uint16_t *srcp = CONVERT_TO_SHORTPTR(src);
uint16_t *refp = CONVERT_TO_SHORTPTR(ref);
sad16x4(srcp, src_stride, refp, ref_stride, NULL, &sad);
return get_sad_from_mm256_epi32(&sad);
}
unsigned int aom_highbd_sad16x4_avg_avx2(const uint8_t *src, int src_stride,
const uint8_t *ref, int ref_stride,
const uint8_t *second_pred) {
__m256i sad = _mm256_setzero_si256();
uint16_t *srcp = CONVERT_TO_SHORTPTR(src);
uint16_t *refp = CONVERT_TO_SHORTPTR(ref);
uint16_t *secp = CONVERT_TO_SHORTPTR(second_pred);
sad16x4(srcp, src_stride, refp, ref_stride, secp, &sad);
return get_sad_from_mm256_epi32(&sad);
}
unsigned int aom_highbd_sad16x8_avg_avx2(const uint8_t *src, int src_stride,
const uint8_t *ref, int ref_stride,
const uint8_t *second_pred) {
@ -566,6 +621,50 @@ unsigned int aom_highbd_sad16x32_avg_avx2(const uint8_t *src, int src_stride,
return sum;
}
unsigned int aom_highbd_sad16x64_avx2(const uint8_t *src, int src_stride,
const uint8_t *ref, int ref_stride) {
const int left_shift = 5;
uint32_t sum = aom_highbd_sad16x32_avx2(src, src_stride, ref, ref_stride);
src += src_stride << left_shift;
ref += ref_stride << left_shift;
sum += aom_highbd_sad16x32_avx2(src, src_stride, ref, ref_stride);
return sum;
}
unsigned int aom_highbd_sad16x64_avg_avx2(const uint8_t *src, int src_stride,
const uint8_t *ref, int ref_stride,
const uint8_t *second_pred) {
const int left_shift = 5;
uint32_t sum = aom_highbd_sad16x32_avg_avx2(src, src_stride, ref, ref_stride,
second_pred);
src += src_stride << left_shift;
ref += ref_stride << left_shift;
second_pred += 16 << left_shift;
sum += aom_highbd_sad16x32_avg_avx2(src, src_stride, ref, ref_stride,
second_pred);
return sum;
}
unsigned int aom_highbd_sad32x8_avg_avx2(const uint8_t *src, int src_stride,
const uint8_t *ref, int ref_stride,
const uint8_t *second_pred) {
__m256i sad = _mm256_setzero_si256();
uint16_t *srcp = CONVERT_TO_SHORTPTR(src);
uint16_t *refp = CONVERT_TO_SHORTPTR(ref);
uint16_t *secp = CONVERT_TO_SHORTPTR(second_pred);
const int left_shift = 2;
int row_section = 0;
while (row_section < 2) {
sad32x4(srcp, src_stride, refp, ref_stride, secp, &sad);
srcp += src_stride << left_shift;
refp += ref_stride << left_shift;
secp += 32 << left_shift;
row_section += 1;
}
return get_sad_from_mm256_epi32(&sad);
}
unsigned int aom_highbd_sad32x16_avg_avx2(const uint8_t *src, int src_stride,
const uint8_t *ref, int ref_stride,
const uint8_t *second_pred) {
@ -614,6 +713,26 @@ unsigned int aom_highbd_sad32x64_avg_avx2(const uint8_t *src, int src_stride,
return sum;
}
unsigned int aom_highbd_sad64x16_avg_avx2(const uint8_t *src, int src_stride,
const uint8_t *ref, int ref_stride,
const uint8_t *second_pred) {
__m256i sad = _mm256_setzero_si256();
uint16_t *srcp = CONVERT_TO_SHORTPTR(src);
uint16_t *refp = CONVERT_TO_SHORTPTR(ref);
uint16_t *secp = CONVERT_TO_SHORTPTR(second_pred);
const int left_shift = 1;
int row_section = 0;
while (row_section < 8) {
sad64x2(srcp, src_stride, refp, ref_stride, secp, &sad);
srcp += src_stride << left_shift;
refp += ref_stride << left_shift;
secp += 64 << left_shift;
row_section += 1;
}
return get_sad_from_mm256_epi32(&sad);
}
unsigned int aom_highbd_sad64x32_avg_avx2(const uint8_t *src, int src_stride,
const uint8_t *ref, int ref_stride,
const uint8_t *second_pred) {
@ -752,6 +871,25 @@ static void init_sad(__m256i *s) {
s[3] = _mm256_setzero_si256();
}
void aom_highbd_sad16x4x4d_avx2(const uint8_t *src, int src_stride,
const uint8_t *const ref_array[],
int ref_stride, uint32_t *sad_array) {
__m256i sad_vec[4];
const uint16_t *refp[4];
const uint16_t *keep = CONVERT_TO_SHORTPTR(src);
const uint16_t *srcp;
int i;
init_sad(sad_vec);
convert_pointers(ref_array, refp);
for (i = 0; i < 4; ++i) {
srcp = keep;
sad16x4(srcp, src_stride, refp[i], ref_stride, 0, &sad_vec[i]);
}
get_4d_sad_from_mm256_epi32(sad_vec, sad_array);
}
void aom_highbd_sad16x8x4d_avx2(const uint8_t *src, int src_stride,
const uint8_t *const ref_array[],
int ref_stride, uint32_t *sad_array) {
@ -827,6 +965,59 @@ void aom_highbd_sad16x32x4d_avx2(const uint8_t *src, int src_stride,
sad_array[3] = first_half[3] + second_half[3];
}
void aom_highbd_sad16x64x4d_avx2(const uint8_t *src, int src_stride,
const uint8_t *const ref_array[],
int ref_stride, uint32_t *sad_array) {
uint32_t first_half[4];
uint32_t second_half[4];
const uint8_t *ref[4];
const int shift_for_rows = 5;
ref[0] = ref_array[0];
ref[1] = ref_array[1];
ref[2] = ref_array[2];
ref[3] = ref_array[3];
aom_highbd_sad16x32x4d_avx2(src, src_stride, ref, ref_stride, first_half);
src += src_stride << shift_for_rows;
ref[0] += ref_stride << shift_for_rows;
ref[1] += ref_stride << shift_for_rows;
ref[2] += ref_stride << shift_for_rows;
ref[3] += ref_stride << shift_for_rows;
aom_highbd_sad16x32x4d_avx2(src, src_stride, ref, ref_stride, second_half);
sad_array[0] = first_half[0] + second_half[0];
sad_array[1] = first_half[1] + second_half[1];
sad_array[2] = first_half[2] + second_half[2];
sad_array[3] = first_half[3] + second_half[3];
}
void aom_highbd_sad32x8x4d_avx2(const uint8_t *src, int src_stride,
const uint8_t *const ref_array[],
int ref_stride, uint32_t *sad_array) {
__m256i sad_vec[4];
const uint16_t *refp[4];
const uint16_t *keep = CONVERT_TO_SHORTPTR(src);
const uint16_t *srcp;
const int shift_for_4_rows = 2;
int i;
int rows_section;
init_sad(sad_vec);
convert_pointers(ref_array, refp);
for (i = 0; i < 4; ++i) {
srcp = keep;
rows_section = 0;
while (rows_section < 2) {
sad32x4(srcp, src_stride, refp[i], ref_stride, 0, &sad_vec[i]);
srcp += src_stride << shift_for_4_rows;
refp[i] += ref_stride << shift_for_4_rows;
rows_section++;
}
}
get_4d_sad_from_mm256_epi32(sad_vec, sad_array);
}
void aom_highbd_sad32x16x4d_avx2(const uint8_t *src, int src_stride,
const uint8_t *const ref_array[],
int ref_stride, uint32_t *sad_array) {
@ -906,6 +1097,33 @@ void aom_highbd_sad32x64x4d_avx2(const uint8_t *src, int src_stride,
sad_array[3] = first_half[3] + second_half[3];
}
void aom_highbd_sad64x16x4d_avx2(const uint8_t *src, int src_stride,
const uint8_t *const ref_array[],
int ref_stride, uint32_t *sad_array) {
__m256i sad_vec[4];
const uint16_t *refp[4];
const uint16_t *keep = CONVERT_TO_SHORTPTR(src);
const uint16_t *srcp;
const int shift_for_rows = 1;
int i;
int rows_section;
init_sad(sad_vec);
convert_pointers(ref_array, refp);
for (i = 0; i < 4; ++i) {
srcp = keep;
rows_section = 0;
while (rows_section < 8) {
sad64x2(srcp, src_stride, refp[i], ref_stride, NULL, &sad_vec[i]);
srcp += src_stride << shift_for_rows;
refp[i] += ref_stride << shift_for_rows;
rows_section++;
}
}
get_4d_sad_from_mm256_epi32(sad_vec, sad_array);
}
void aom_highbd_sad64x32x4d_avx2(const uint8_t *src, int src_stride,
const uint8_t *const ref_array[],
int ref_stride, uint32_t *sad_array) {

View file

@ -45,6 +45,7 @@ static INLINE int64_t summary_all_avx2(const __m256i *sum_all) {
return sum;
}
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE void summary_32_avx2(const __m256i *sum32, __m256i *sum) {
const __m256i sum0_4x64 =
_mm256_cvtepu32_epi64(_mm256_castsi256_si128(*sum32));
@ -63,6 +64,7 @@ static INLINE int64_t summary_4x64_avx2(const __m256i sum_4x64) {
xx_storel_64(&sum, sum_1x64);
return sum;
}
#endif
static INLINE void sse_w4x4_avx2(const uint8_t *a, int a_stride,
const uint8_t *b, int b_stride, __m256i *sum) {
@ -211,6 +213,7 @@ int64_t aom_sse_avx2(const uint8_t *a, int a_stride, const uint8_t *b,
return sse;
}
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE void highbd_sse_w16_avx2(__m256i *sum, const uint16_t *a,
const uint16_t *b) {
const __m256i v_a_w = yy_loadu_256(a);
@ -378,3 +381,4 @@ int64_t aom_highbd_sse_avx2(const uint8_t *a8, int a_stride, const uint8_t *b8,
}
return sse;
}
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -28,12 +28,14 @@ static INLINE int64_t summary_all_sse4(const __m128i *sum_all) {
return sum;
}
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE void summary_32_sse4(const __m128i *sum32, __m128i *sum64) {
const __m128i sum0 = _mm_cvtepu32_epi64(*sum32);
const __m128i sum1 = _mm_cvtepu32_epi64(_mm_srli_si128(*sum32, 8));
*sum64 = _mm_add_epi64(sum0, *sum64);
*sum64 = _mm_add_epi64(sum1, *sum64);
}
#endif
static INLINE void sse_w16_sse4_1(__m128i *sum, const uint8_t *a,
const uint8_t *b) {
@ -175,6 +177,7 @@ int64_t aom_sse_sse4_1(const uint8_t *a, int a_stride, const uint8_t *b,
return sse;
}
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE void highbd_sse_w4x2_sse4_1(__m128i *sum, const uint16_t *a,
int a_stride, const uint16_t *b,
int b_stride) {
@ -348,3 +351,4 @@ int64_t aom_highbd_sse_sse4_1(const uint8_t *a8, int a_stride,
}
return sse;
}
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -114,58 +114,85 @@ static INLINE void load_buffer_32bit_to_16bit_w16_avx2(const int32_t *in,
}
}
static INLINE void transpose2_8x8_avx2(const __m256i *const in,
__m256i *const out) {
__m256i t[16], u[16];
// (1st, 2nd) ==> (lo, hi)
// (0, 1) ==> (0, 1)
// (2, 3) ==> (2, 3)
// (4, 5) ==> (4, 5)
// (6, 7) ==> (6, 7)
for (int i = 0; i < 4; i++) {
t[2 * i] = _mm256_unpacklo_epi16(in[2 * i], in[2 * i + 1]);
t[2 * i + 1] = _mm256_unpackhi_epi16(in[2 * i], in[2 * i + 1]);
}
// (1st, 2nd) ==> (lo, hi)
// (0, 2) ==> (0, 2)
// (1, 3) ==> (1, 3)
// (4, 6) ==> (4, 6)
// (5, 7) ==> (5, 7)
for (int i = 0; i < 2; i++) {
u[i] = _mm256_unpacklo_epi32(t[i], t[i + 2]);
u[i + 2] = _mm256_unpackhi_epi32(t[i], t[i + 2]);
u[i + 4] = _mm256_unpacklo_epi32(t[i + 4], t[i + 6]);
u[i + 6] = _mm256_unpackhi_epi32(t[i + 4], t[i + 6]);
}
// (1st, 2nd) ==> (lo, hi)
// (0, 4) ==> (0, 1)
// (1, 5) ==> (4, 5)
// (2, 6) ==> (2, 3)
// (3, 7) ==> (6, 7)
for (int i = 0; i < 2; i++) {
out[2 * i] = _mm256_unpacklo_epi64(u[2 * i], u[2 * i + 4]);
out[2 * i + 1] = _mm256_unpackhi_epi64(u[2 * i], u[2 * i + 4]);
out[2 * i + 4] = _mm256_unpacklo_epi64(u[2 * i + 1], u[2 * i + 5]);
out[2 * i + 5] = _mm256_unpackhi_epi64(u[2 * i + 1], u[2 * i + 5]);
}
}
static INLINE void transpose_16bit_16x16_avx2(const __m256i *const in,
__m256i *const out) {
// Unpack 16 bit elements. Goes from:
// in[0]: 00 01 02 03 08 09 0a 0b 04 05 06 07 0c 0d 0e 0f
// in[1]: 10 11 12 13 18 19 1a 1b 14 15 16 17 1c 1d 1e 1f
// in[2]: 20 21 22 23 28 29 2a 2b 24 25 26 27 2c 2d 2e 2f
// in[3]: 30 31 32 33 38 39 3a 3b 34 35 36 37 3c 3d 3e 3f
// in[4]: 40 41 42 43 48 49 4a 4b 44 45 46 47 4c 4d 4e 4f
// in[5]: 50 51 52 53 58 59 5a 5b 54 55 56 57 5c 5d 5e 5f
// in[6]: 60 61 62 63 68 69 6a 6b 64 65 66 67 6c 6d 6e 6f
// in[7]: 70 71 72 73 78 79 7a 7b 74 75 76 77 7c 7d 7e 7f
// in[8]: 80 81 82 83 88 89 8a 8b 84 85 86 87 8c 8d 8e 8f
// to:
// a0: 00 10 01 11 02 12 03 13 04 14 05 15 06 16 07 17
// a1: 20 30 21 31 22 32 23 33 24 34 25 35 26 36 27 37
// a2: 40 50 41 51 42 52 43 53 44 54 45 55 46 56 47 57
// a3: 60 70 61 71 62 72 63 73 64 74 65 75 66 76 67 77
// ...
__m256i a[16];
for (int i = 0; i < 16; i += 2) {
a[i / 2 + 0] = _mm256_unpacklo_epi16(in[i], in[i + 1]);
a[i / 2 + 8] = _mm256_unpackhi_epi16(in[i], in[i + 1]);
}
__m256i b[16];
for (int i = 0; i < 16; i += 2) {
b[i / 2 + 0] = _mm256_unpacklo_epi32(a[i], a[i + 1]);
b[i / 2 + 8] = _mm256_unpackhi_epi32(a[i], a[i + 1]);
}
__m256i c[16];
for (int i = 0; i < 16; i += 2) {
c[i / 2 + 0] = _mm256_unpacklo_epi64(b[i], b[i + 1]);
c[i / 2 + 8] = _mm256_unpackhi_epi64(b[i], b[i + 1]);
}
out[0 + 0] = _mm256_permute2x128_si256(c[0], c[1], 0x20);
out[1 + 0] = _mm256_permute2x128_si256(c[8], c[9], 0x20);
out[2 + 0] = _mm256_permute2x128_si256(c[4], c[5], 0x20);
out[3 + 0] = _mm256_permute2x128_si256(c[12], c[13], 0x20);
__m256i t[16];
out[0 + 8] = _mm256_permute2x128_si256(c[0], c[1], 0x31);
out[1 + 8] = _mm256_permute2x128_si256(c[8], c[9], 0x31);
out[2 + 8] = _mm256_permute2x128_si256(c[4], c[5], 0x31);
out[3 + 8] = _mm256_permute2x128_si256(c[12], c[13], 0x31);
#define LOADL(idx) \
t[idx] = _mm256_castsi128_si256(_mm_load_si128((__m128i const *)&in[idx])); \
t[idx] = _mm256_inserti128_si256( \
t[idx], _mm_load_si128((__m128i const *)&in[idx + 8]), 1);
out[4 + 0] = _mm256_permute2x128_si256(c[0 + 2], c[1 + 2], 0x20);
out[5 + 0] = _mm256_permute2x128_si256(c[8 + 2], c[9 + 2], 0x20);
out[6 + 0] = _mm256_permute2x128_si256(c[4 + 2], c[5 + 2], 0x20);
out[7 + 0] = _mm256_permute2x128_si256(c[12 + 2], c[13 + 2], 0x20);
#define LOADR(idx) \
t[8 + idx] = \
_mm256_castsi128_si256(_mm_load_si128((__m128i const *)&in[idx] + 1)); \
t[8 + idx] = _mm256_inserti128_si256( \
t[8 + idx], _mm_load_si128((__m128i const *)&in[idx + 8] + 1), 1);
out[4 + 8] = _mm256_permute2x128_si256(c[0 + 2], c[1 + 2], 0x31);
out[5 + 8] = _mm256_permute2x128_si256(c[8 + 2], c[9 + 2], 0x31);
out[6 + 8] = _mm256_permute2x128_si256(c[4 + 2], c[5 + 2], 0x31);
out[7 + 8] = _mm256_permute2x128_si256(c[12 + 2], c[13 + 2], 0x31);
// load left 8x16
LOADL(0)
LOADL(1)
LOADL(2)
LOADL(3)
LOADL(4)
LOADL(5)
LOADL(6)
LOADL(7)
// load right 8x16
LOADR(0)
LOADR(1)
LOADR(2)
LOADR(3)
LOADR(4)
LOADR(5)
LOADR(6)
LOADR(7)
// get the top 16x8 result
transpose2_8x8_avx2(t, out);
// get the bottom 16x8 result
transpose2_8x8_avx2(&t[8], &out[8]);
}
static INLINE void transpose_16bit_16x8_avx2(const __m256i *const in,

View file

@ -28,7 +28,7 @@ static INLINE __m128i mm256_add_hi_lo_epi32(const __m256i val) {
static INLINE void variance_kernel_avx2(const __m256i src, const __m256i ref,
__m256i *const sse,
__m256i *const sum) {
const __m256i adj_sub = _mm256_set1_epi16(0xff01); // (1,-1)
const __m256i adj_sub = _mm256_set1_epi16((short)0xff01); // (1,-1)
// unpack into pairs of source and reference values
const __m256i src_ref0 = _mm256_unpacklo_epi8(src, ref);

View file

@ -144,6 +144,7 @@ static INLINE void variance8_sse2(const uint8_t *src, const int src_stride,
__m128i *const sum) {
assert(h <= 128); // May overflow for larger height.
*sum = _mm_setzero_si128();
*sse = _mm_setzero_si128();
for (int i = 0; i < h; i++) {
const __m128i s = load8_8to16_sse2(src);
const __m128i r = load8_8to16_sse2(ref);
@ -236,6 +237,14 @@ static INLINE void variance128_sse2(const uint8_t *src, const int src_stride,
}
}
void aom_get8x8var_sse2(const uint8_t *src_ptr, int src_stride,
const uint8_t *ref_ptr, int ref_stride,
unsigned int *sse, int *sum) {
__m128i vsse, vsum;
variance8_sse2(src_ptr, src_stride, ref_ptr, ref_stride, 8, &vsse, &vsum);
variance_final_128_pel_sse2(vsse, vsum, sse, sum);
}
#define AOM_VAR_NO_LOOP_SSE2(bw, bh, bits, max_pixels) \
unsigned int aom_variance##bw##x##bh##_sse2( \
const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, \
@ -542,30 +551,23 @@ void aom_upsampled_pred_sse2(MACROBLOCKD *xd, const struct AV1Common *const cm,
pre_buf->buf0 + (pos_y >> SCALE_SUBPEL_BITS) * pre_buf->stride +
(pos_x >> SCALE_SUBPEL_BITS);
InterPredParams inter_pred_params;
const SubpelParams subpel_params = { sf->x_step_q4, sf->y_step_q4,
pos_x & SCALE_SUBPEL_MASK,
pos_y & SCALE_SUBPEL_MASK };
// Get warp types.
const WarpedMotionParams *const wm =
&xd->global_motion[mi->ref_frame[ref_num]];
const int is_global = is_global_mv_block(mi, wm->wmtype);
WarpTypesAllowed warp_types;
warp_types.global_warp_allowed = is_global;
warp_types.local_warp_allowed = mi->motion_mode == WARPED_CAUSAL;
// Get convolve parameters.
ConvolveParams conv_params = get_conv_params(0, plane, xd->bd);
const InterpFilters filters =
inter_pred_params.conv_params = get_conv_params(0, plane, xd->bd);
const int_interpfilters filters =
av1_broadcast_interp_filter(EIGHTTAP_REGULAR);
av1_init_inter_params(
&inter_pred_params, width, height, mi_y >> pd->subsampling_y,
mi_x >> pd->subsampling_x, pd->subsampling_x, pd->subsampling_y,
xd->bd, is_cur_buf_hbd(xd), mi->use_intrabc, sf, filters);
// Get the inter predictor.
const int build_for_obmc = 0;
av1_make_inter_predictor(pre, pre_buf->stride, comp_pred, width,
&subpel_params, sf, width, height, &conv_params,
filters, &warp_types, mi_x >> pd->subsampling_x,
mi_y >> pd->subsampling_y, plane, ref_num, mi,
build_for_obmc, xd, cm->allow_warped_motion);
&inter_pred_params, &subpel_params);
return;
}

View file

@ -54,7 +54,7 @@ void *aom_memalign(size_t align, size_t size) {
#endif
void *const addr = malloc(aligned_size);
if (addr) {
x = align_addr((unsigned char *)addr + ADDRESS_STORAGE_SIZE, align);
x = aom_align_addr((unsigned char *)addr + ADDRESS_STORAGE_SIZE, align);
SetActualMallocAddress(x, addr);
}
return x;

View file

@ -38,6 +38,10 @@ void *aom_calloc(size_t num, size_t size);
void aom_free(void *memblk);
void *aom_memset16(void *dest, int val, size_t length);
/*returns an addr aligned to the byte boundary specified by align*/
#define aom_align_addr(addr, align) \
(void *)(((size_t)(addr) + ((align)-1)) & ~(size_t)((align)-1))
#include <string.h>
#ifdef AOM_MEM_PLTFRM

View file

@ -26,8 +26,4 @@
#endif
#endif
/*returns an addr aligned to the byte boundary specified by align*/
#define align_addr(addr, align) \
(void *)(((size_t)(addr) + ((align)-1)) & ~(size_t)((align)-1))
#endif // AOM_AOM_MEM_INCLUDE_AOM_MEM_INTRNL_H_

View file

@ -64,8 +64,8 @@ function(setup_aom_ports_targets)
if(aom_ports_has_symbols)
target_sources(aom_ports PRIVATE ${AOM_PORTS_INCLUDES})
if("${AOM_TARGET_CPU}" STREQUAL "x86" OR "${AOM_TARGET_CPU}" STREQUAL
"x86_64")
if("${AOM_TARGET_CPU}" STREQUAL "x86"
OR "${AOM_TARGET_CPU}" STREQUAL "x86_64")
target_sources(aom_ports PRIVATE ${AOM_PORTS_INCLUDES_X86})
endif()
@ -73,8 +73,8 @@ function(setup_aom_ports_targets)
else()
target_sources(aom PRIVATE ${AOM_PORTS_INCLUDES})
if("${AOM_TARGET_CPU}" STREQUAL "x86" OR "${AOM_TARGET_CPU}" STREQUAL
"x86_64")
if("${AOM_TARGET_CPU}" STREQUAL "x86"
OR "${AOM_TARGET_CPU}" STREQUAL "x86_64")
target_sources(aom PRIVATE ${AOM_PORTS_INCLUDES_X86})
endif()
endif()

View file

@ -23,27 +23,23 @@
/****************************************************************************
*
****************************************************************************/
#define yv12_align_addr(addr, align) \
(void *)(((size_t)(addr) + ((align)-1)) & (size_t) - (align))
// TODO(jkoleszar): Maybe replace this with struct aom_image
int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf) {
if (ybf) {
if (ybf->buffer_alloc_sz > 0) {
aom_free(ybf->buffer_alloc);
}
if (ybf->y_buffer_8bit) aom_free(ybf->y_buffer_8bit);
aom_remove_metadata_from_frame_buffer(ybf);
/* buffer_alloc isn't accessed by most functions. Rather y_buffer,
u_buffer and v_buffer point to buffer_alloc and are used. Clear out
all of this so that a freed pointer isn't inadvertently used */
memset(ybf, 0, sizeof(YV12_BUFFER_CONFIG));
} else {
return -1;
return 0;
}
return 0;
return AOM_CODEC_MEM_ERROR;
}
static int realloc_frame_buffer_aligned(
@ -69,7 +65,8 @@ static int realloc_frame_buffer_aligned(
// The decoder may allocate REF_FRAMES frame buffers in the frame buffer
// pool. Bound the total amount of allocated memory as if these REF_FRAMES
// frame buffers were allocated in a single allocation.
if (alloc_size > AOM_MAX_ALLOCABLE_MEMORY / REF_FRAMES) return -1;
if (alloc_size > AOM_MAX_ALLOCABLE_MEMORY / REF_FRAMES)
return AOM_CODEC_MEM_ERROR;
#endif
if (cb != NULL) {
@ -78,14 +75,17 @@ static int realloc_frame_buffer_aligned(
assert(fb != NULL);
if (external_frame_size != (size_t)external_frame_size) return -1;
if (external_frame_size != (size_t)external_frame_size)
return AOM_CODEC_MEM_ERROR;
// Allocation to hold larger frame, or first allocation.
if (cb(cb_priv, (size_t)external_frame_size, fb) < 0) return -1;
if (cb(cb_priv, (size_t)external_frame_size, fb) < 0)
return AOM_CODEC_MEM_ERROR;
if (fb->data == NULL || fb->size < external_frame_size) return -1;
if (fb->data == NULL || fb->size < external_frame_size)
return AOM_CODEC_MEM_ERROR;
ybf->buffer_alloc = (uint8_t *)yv12_align_addr(fb->data, 32);
ybf->buffer_alloc = (uint8_t *)aom_align_addr(fb->data, 32);
#if defined(__has_feature)
#if __has_feature(memory_sanitizer)
@ -101,10 +101,10 @@ static int realloc_frame_buffer_aligned(
ybf->buffer_alloc = NULL;
ybf->buffer_alloc_sz = 0;
if (frame_size != (size_t)frame_size) return -1;
if (frame_size != (size_t)frame_size) return AOM_CODEC_MEM_ERROR;
ybf->buffer_alloc = (uint8_t *)aom_memalign(32, (size_t)frame_size);
if (!ybf->buffer_alloc) return -1;
if (!ybf->buffer_alloc) return AOM_CODEC_MEM_ERROR;
ybf->buffer_alloc_sz = (size_t)frame_size;
@ -140,22 +140,22 @@ static int realloc_frame_buffer_aligned(
ybf->flags = 0;
}
ybf->y_buffer = (uint8_t *)yv12_align_addr(
ybf->y_buffer = (uint8_t *)aom_align_addr(
buf + (border * y_stride) + border, aom_byte_align);
ybf->u_buffer = (uint8_t *)yv12_align_addr(
ybf->u_buffer = (uint8_t *)aom_align_addr(
buf + yplane_size + (uv_border_h * uv_stride) + uv_border_w,
aom_byte_align);
ybf->v_buffer =
(uint8_t *)yv12_align_addr(buf + yplane_size + uvplane_size +
(uv_border_h * uv_stride) + uv_border_w,
aom_byte_align);
(uint8_t *)aom_align_addr(buf + yplane_size + uvplane_size +
(uv_border_h * uv_stride) + uv_border_w,
aom_byte_align);
ybf->use_external_reference_buffers = 0;
if (use_highbitdepth) {
if (ybf->y_buffer_8bit) aom_free(ybf->y_buffer_8bit);
ybf->y_buffer_8bit = (uint8_t *)aom_memalign(32, (size_t)yplane_size);
if (!ybf->y_buffer_8bit) return -1;
if (!ybf->y_buffer_8bit) return AOM_CODEC_MEM_ERROR;
} else {
if (ybf->y_buffer_8bit) {
aom_free(ybf->y_buffer_8bit);
@ -167,7 +167,7 @@ static int realloc_frame_buffer_aligned(
ybf->corrupted = 0; /* assume not corrupted by errors */
return 0;
}
return -2;
return AOM_CODEC_MEM_ERROR;
}
static int calc_stride_and_planesize(const int ss_x, const int ss_y,
@ -182,7 +182,7 @@ static int calc_stride_and_planesize(const int ss_x, const int ss_y,
* the start of the chroma rows without introducing an arbitrary gap
* between planes, which would break the semantics of things like
* aom_img_set_rect(). */
if (border & 0x1f) return -3;
if (border & 0x1f) return AOM_CODEC_MEM_ERROR;
*y_stride = ((aligned_width + 2 * border) + 31) & ~31;
*yplane_size =
(aligned_height + 2 * border) * (uint64_t)(*y_stride) + byte_alignment;
@ -199,7 +199,8 @@ int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
aom_codec_frame_buffer_t *fb,
aom_get_frame_buffer_cb_fn_t cb, void *cb_priv) {
#if CONFIG_SIZE_LIMIT
if (width > DECODE_WIDTH_LIMIT || height > DECODE_HEIGHT_LIMIT) return -1;
if (width > DECODE_WIDTH_LIMIT || height > DECODE_HEIGHT_LIMIT)
return AOM_CODEC_MEM_ERROR;
#endif
if (ybf) {
@ -224,7 +225,7 @@ int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
aligned_width, aligned_height, uv_width, uv_height, uv_stride,
uv_border_w, uv_border_h);
}
return -2;
return AOM_CODEC_MEM_ERROR;
}
// TODO(anyone): This function allocates memory for
@ -272,7 +273,7 @@ int aom_realloc_lookahead_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
aligned_width, aligned_height, uv_width, uv_height, uv_stride,
uv_border_w, uv_border_h);
}
return -2;
return AOM_CODEC_MEM_ERROR;
}
int aom_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
@ -284,5 +285,34 @@ int aom_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
use_highbitdepth, border, byte_alignment,
NULL, NULL, NULL);
}
return -2;
return AOM_CODEC_MEM_ERROR;
}
size_t aom_remove_metadata_from_frame_buffer(YV12_BUFFER_CONFIG *ybf) {
if (ybf && ybf->metadata) {
size_t sz = aom_img_metadata_array_free(ybf->metadata);
ybf->metadata = NULL;
return sz;
}
return 0;
}
int aom_copy_metadata_to_frame_buffer(YV12_BUFFER_CONFIG *ybf,
aom_metadata_array_t *arr) {
if (!ybf || !arr || !arr->metadata_array) return -1;
aom_remove_metadata_from_frame_buffer(ybf);
ybf->metadata = aom_img_metadata_array_alloc(arr->sz);
if (!ybf->metadata) return 0;
for (size_t i = 0; i < ybf->metadata->sz; i++) {
ybf->metadata->metadata_array[i] = aom_img_metadata_alloc(
arr->metadata_array[i]->type, arr->metadata_array[i]->payload,
arr->metadata_array[i]->sz);
if (ybf->metadata->metadata_array[i] == NULL) {
aom_img_metadata_array_free(ybf->metadata);
ybf->metadata = NULL;
return -1;
}
}
ybf->metadata->sz = arr->sz;
return 0;
}

View file

@ -59,6 +59,7 @@ static void extend_plane(uint8_t *const src, int src_stride, int width,
}
}
#if CONFIG_AV1_HIGHBITDEPTH
static void extend_plane_high(uint8_t *const src8, int src_stride, int width,
int height, int extend_top, int extend_left,
int extend_bottom, int extend_right) {
@ -99,6 +100,7 @@ static void extend_plane_high(uint8_t *const src8, int src_stride, int width,
dst_ptr2 += src_stride;
}
}
#endif // CONFIG_AV1_HIGHBITDEPTH
void aom_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf,
const int num_planes) {
@ -108,6 +110,7 @@ void aom_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf,
assert(ybf->y_height - ybf->y_crop_height >= 0);
assert(ybf->y_width - ybf->y_crop_width >= 0);
#if CONFIG_AV1_HIGHBITDEPTH
if (ybf->flags & YV12_FLAG_HIGHBITDEPTH) {
for (int plane = 0; plane < num_planes; ++plane) {
const int is_uv = plane > 0;
@ -120,6 +123,8 @@ void aom_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf,
}
return;
}
#endif
for (int plane = 0; plane < num_planes; ++plane) {
const int is_uv = plane > 0;
const int plane_border = ybf->border >> is_uv;
@ -141,6 +146,7 @@ static void extend_frame(YV12_BUFFER_CONFIG *const ybf, int ext_size,
assert(ybf->y_height - ybf->y_crop_height >= 0);
assert(ybf->y_width - ybf->y_crop_width >= 0);
#if CONFIG_AV1_HIGHBITDEPTH
if (ybf->flags & YV12_FLAG_HIGHBITDEPTH) {
for (int plane = 0; plane < num_planes; ++plane) {
const int is_uv = plane > 0;
@ -154,6 +160,8 @@ static void extend_frame(YV12_BUFFER_CONFIG *const ybf, int ext_size,
}
return;
}
#endif
for (int plane = 0; plane < num_planes; ++plane) {
const int is_uv = plane > 0;
const int top = ext_size >> (is_uv ? ss_y : 0);
@ -184,7 +192,7 @@ void aom_extend_frame_borders_y_c(YV12_BUFFER_CONFIG *ybf) {
assert(ybf->y_width - ybf->y_crop_width < 16);
assert(ybf->y_height - ybf->y_crop_height >= 0);
assert(ybf->y_width - ybf->y_crop_width >= 0);
#if CONFIG_AV1_HIGHBITDEPTH
if (ybf->flags & YV12_FLAG_HIGHBITDEPTH) {
extend_plane_high(ybf->y_buffer, ybf->y_stride, ybf->y_crop_width,
ybf->y_crop_height, ext_size, ext_size,
@ -192,17 +200,20 @@ void aom_extend_frame_borders_y_c(YV12_BUFFER_CONFIG *ybf) {
ext_size + ybf->y_width - ybf->y_crop_width);
return;
}
#endif
extend_plane(ybf->y_buffer, ybf->y_stride, ybf->y_crop_width,
ybf->y_crop_height, ext_size, ext_size,
ext_size + ybf->y_height - ybf->y_crop_height,
ext_size + ybf->y_width - ybf->y_crop_width);
}
#if CONFIG_AV1_HIGHBITDEPTH
static void memcpy_short_addr(uint8_t *dst8, const uint8_t *src8, int num) {
uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
uint16_t *src = CONVERT_TO_SHORTPTR(src8);
memcpy(dst, src, num * sizeof(uint16_t));
}
#endif
// Copies the source image into the destination image and updates the
// destination's UMV borders.
@ -217,6 +228,7 @@ void aom_yv12_copy_frame_c(const YV12_BUFFER_CONFIG *src_bc,
assert(src_bc->y_height == dst_bc->y_height);
#endif
#if CONFIG_AV1_HIGHBITDEPTH
assert((src_bc->flags & YV12_FLAG_HIGHBITDEPTH) ==
(dst_bc->flags & YV12_FLAG_HIGHBITDEPTH));
@ -235,6 +247,7 @@ void aom_yv12_copy_frame_c(const YV12_BUFFER_CONFIG *src_bc,
aom_yv12_extend_frame_borders_c(dst_bc, num_planes);
return;
}
#endif
for (int plane = 0; plane < num_planes; ++plane) {
const uint8_t *plane_src = src_bc->buffers[plane];
uint8_t *plane_dst = dst_bc->buffers[plane];
@ -255,6 +268,7 @@ void aom_yv12_copy_y_c(const YV12_BUFFER_CONFIG *src_ybc,
const uint8_t *src = src_ybc->y_buffer;
uint8_t *dst = dst_ybc->y_buffer;
#if CONFIG_AV1_HIGHBITDEPTH
if (src_ybc->flags & YV12_FLAG_HIGHBITDEPTH) {
const uint16_t *src16 = CONVERT_TO_SHORTPTR(src);
uint16_t *dst16 = CONVERT_TO_SHORTPTR(dst);
@ -265,6 +279,7 @@ void aom_yv12_copy_y_c(const YV12_BUFFER_CONFIG *src_ybc,
}
return;
}
#endif
for (row = 0; row < src_ybc->y_height; ++row) {
memcpy(dst, src, src_ybc->y_width);
@ -278,7 +293,7 @@ void aom_yv12_copy_u_c(const YV12_BUFFER_CONFIG *src_bc,
int row;
const uint8_t *src = src_bc->u_buffer;
uint8_t *dst = dst_bc->u_buffer;
#if CONFIG_AV1_HIGHBITDEPTH
if (src_bc->flags & YV12_FLAG_HIGHBITDEPTH) {
const uint16_t *src16 = CONVERT_TO_SHORTPTR(src);
uint16_t *dst16 = CONVERT_TO_SHORTPTR(dst);
@ -289,7 +304,7 @@ void aom_yv12_copy_u_c(const YV12_BUFFER_CONFIG *src_bc,
}
return;
}
#endif
for (row = 0; row < src_bc->uv_height; ++row) {
memcpy(dst, src, src_bc->uv_width);
src += src_bc->uv_stride;
@ -302,7 +317,7 @@ void aom_yv12_copy_v_c(const YV12_BUFFER_CONFIG *src_bc,
int row;
const uint8_t *src = src_bc->v_buffer;
uint8_t *dst = dst_bc->v_buffer;
#if CONFIG_AV1_HIGHBITDEPTH
if (src_bc->flags & YV12_FLAG_HIGHBITDEPTH) {
const uint16_t *src16 = CONVERT_TO_SHORTPTR(src);
uint16_t *dst16 = CONVERT_TO_SHORTPTR(dst);
@ -313,7 +328,7 @@ void aom_yv12_copy_v_c(const YV12_BUFFER_CONFIG *src_bc,
}
return;
}
#endif
for (row = 0; row < src_bc->uv_height; ++row) {
memcpy(dst, src, src_bc->uv_width);
src += src_bc->uv_stride;
@ -328,7 +343,7 @@ void aom_yv12_partial_copy_y_c(const YV12_BUFFER_CONFIG *src_ybc, int hstart1,
int row;
const uint8_t *src = src_ybc->y_buffer;
uint8_t *dst = dst_ybc->y_buffer;
#if CONFIG_AV1_HIGHBITDEPTH
if (src_ybc->flags & YV12_FLAG_HIGHBITDEPTH) {
const uint16_t *src16 =
CONVERT_TO_SHORTPTR(src + vstart1 * src_ybc->y_stride + hstart1);
@ -342,6 +357,7 @@ void aom_yv12_partial_copy_y_c(const YV12_BUFFER_CONFIG *src_ybc, int hstart1,
}
return;
}
#endif
src = (src + vstart1 * src_ybc->y_stride + hstart1);
dst = (dst + vstart2 * dst_ybc->y_stride + hstart2);
@ -366,7 +382,7 @@ void aom_yv12_partial_copy_u_c(const YV12_BUFFER_CONFIG *src_bc, int hstart1,
int row;
const uint8_t *src = src_bc->u_buffer;
uint8_t *dst = dst_bc->u_buffer;
#if CONFIG_AV1_HIGHBITDEPTH
if (src_bc->flags & YV12_FLAG_HIGHBITDEPTH) {
const uint16_t *src16 =
CONVERT_TO_SHORTPTR(src + vstart1 * src_bc->uv_stride + hstart1);
@ -379,7 +395,7 @@ void aom_yv12_partial_copy_u_c(const YV12_BUFFER_CONFIG *src_bc, int hstart1,
}
return;
}
#endif
src = (src + vstart1 * src_bc->uv_stride + hstart1);
dst = (dst + vstart2 * dst_bc->uv_stride + hstart2);
@ -404,7 +420,7 @@ void aom_yv12_partial_copy_v_c(const YV12_BUFFER_CONFIG *src_bc, int hstart1,
int row;
const uint8_t *src = src_bc->v_buffer;
uint8_t *dst = dst_bc->v_buffer;
#if CONFIG_AV1_HIGHBITDEPTH
if (src_bc->flags & YV12_FLAG_HIGHBITDEPTH) {
const uint16_t *src16 =
CONVERT_TO_SHORTPTR(src + vstart1 * src_bc->uv_stride + hstart1);
@ -417,7 +433,7 @@ void aom_yv12_partial_copy_v_c(const YV12_BUFFER_CONFIG *src_bc, int hstart1,
}
return;
}
#endif
src = (src + vstart1 * src_bc->uv_stride + hstart1);
dst = (dst + vstart2 * dst_bc->uv_stride + hstart2);

View file

@ -21,6 +21,7 @@ extern "C" {
#include "aom/aom_codec.h"
#include "aom/aom_frame_buffer.h"
#include "aom/aom_integer.h"
#include "aom/internal/aom_image_internal.h"
#define AOMINNERBORDERINPIXELS 160
#define AOM_INTERP_EXTEND 4
@ -105,6 +106,7 @@ typedef struct yv12_buffer_config {
int corrupted;
int flags;
aom_metadata_array_t *metadata;
} YV12_BUFFER_CONFIG;
#define YV12_FLAG_HIGHBITDEPTH 8
@ -135,6 +137,30 @@ int aom_realloc_lookahead_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf);
/*!\brief Removes metadata from YUV_BUFFER_CONFIG struct.
*
* Frees metadata in frame buffer.
* Frame buffer metadata pointer will be set to NULL.
* Returns the number of deleted metadata structs.
*
* \param[in] ybf Frame buffer struct pointer
*/
size_t aom_remove_metadata_from_frame_buffer(YV12_BUFFER_CONFIG *ybf);
/*!\brief Copy metadata to YUV_BUFFER_CONFIG struct.
*
* Copies metadata in frame buffer.
* Frame buffer will clear any previous metadata and will reallocate the
* metadata array to the new metadata size. Then, it will copy the new metadata
* array into it.
* Returns 0 on success or -1 on failure.
*
* \param[in] ybf Frame buffer struct pointer
* \param[in] arr Metadata array struct pointer
*/
int aom_copy_metadata_to_frame_buffer(YV12_BUFFER_CONFIG *ybf,
aom_metadata_array_t *arr);
#ifdef __cplusplus
}
#endif

View file

@ -18,13 +18,17 @@ static int frame_idx_w = 0;
static int frame_idx_r = 0;
void bitstream_queue_set_frame_write(int frame_idx) { frame_idx_w = frame_idx; }
void aom_bitstream_queue_set_frame_write(int frame_idx) {
frame_idx_w = frame_idx;
}
int bitstream_queue_get_frame_write(void) { return frame_idx_w; }
int aom_bitstream_queue_get_frame_writee(void) { return frame_idx_w; }
void bitstream_queue_set_frame_read(int frame_idx) { frame_idx_r = frame_idx; }
void aom_bitstream_queue_set_frame_read(int frame_idx) {
frame_idx_r = frame_idx;
}
int bitstream_queue_get_frame_read(void) { return frame_idx_r; }
int aom_bitstream_queue_get_frame_read(void) { return frame_idx_r; }
#if CONFIG_BITSTREAM_DEBUG
#define QUEUE_MAX_SIZE 2000000

View file

@ -20,10 +20,10 @@
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);
void aom_bitstream_queue_set_frame_write(int frame_idx);
int aom_bitstream_queue_get_frame_writee(void);
void aom_bitstream_queue_set_frame_read(int frame_idx);
int aom_bitstream_queue_get_frame_read(void);
#if CONFIG_BITSTREAM_DEBUG
/* This is a debug tool used to detect bitstream error. On encoder side, it

View file

@ -451,7 +451,7 @@ static int main_loop(int argc, const char **argv_) {
int opt_yv12 = 0;
int opt_i420 = 0;
int opt_raw = 0;
aom_codec_dec_cfg_t cfg = { 0, 0, 0, CONFIG_LOWBITDEPTH, { 1 } };
aom_codec_dec_cfg_t cfg = { 0, 0, 0, !FORCE_HIGHBITDEPTH_DECODING };
unsigned int fixed_output_bit_depth = 0;
unsigned int is_annexb = 0;
int frames_corrupted = 0;

View file

@ -158,11 +158,6 @@ static const arg_def_t verbosearg =
ARG_DEF("v", "verbose", 0, "Show encoder parameters");
static const arg_def_t psnrarg =
ARG_DEF(NULL, "psnr", 0, "Show PSNR in status line");
#if CONFIG_FILEOPTIONS
static const arg_def_t use_cfg = ARG_DEF("c", "cfg", 1, "Config file to use");
static const arg_def_t ext_partition =
ARG_DEF(NULL, "ext-partition", 1, "corresponds to extended partitions");
#endif
static const struct arg_enum_list test_decode_enum[] = {
{ "off", TEST_DECODE_OFF },
@ -205,9 +200,6 @@ static const arg_def_t input_chroma_subsampling_y = ARG_DEF(
NULL, "input-chroma-subsampling-y", 1, "chroma subsampling y value.");
static const arg_def_t *main_args[] = { &help,
#if CONFIG_FILEOPTIONS
&use_cfg,
#endif
&debugmode,
&outputfile,
&codecarg,
@ -396,7 +388,7 @@ static const arg_def_t arnr_strength =
static const struct arg_enum_list tuning_enum[] = {
{ "psnr", AOM_TUNE_PSNR },
{ "ssim", AOM_TUNE_SSIM },
#ifdef CONFIG_DIST_8X8
#if CONFIG_DIST_8X8
{ "cdef-dist", AOM_TUNE_CDEF_DIST },
{ "daala-dist", AOM_TUNE_DAALA_DIST },
#endif
@ -411,7 +403,7 @@ static const arg_def_t max_intra_rate_pct =
#if CONFIG_AV1_ENCODER
static const arg_def_t cpu_used_av1 =
ARG_DEF(NULL, "cpu-used", 1, "CPU Used (0..8)");
ARG_DEF(NULL, "cpu-used", 1, "CPU Used (0..5)");
static const arg_def_t rowmtarg =
ARG_DEF(NULL, "row-mt", 1,
"Enable row based multi-threading (0: off, 1: on (default))");
@ -421,7 +413,12 @@ static const arg_def_t tile_rows =
ARG_DEF(NULL, "tile-rows", 1, "Number of tile rows to use, log2");
static const arg_def_t enable_tpl_model =
ARG_DEF(NULL, "enable-tpl-model", 1,
"RDO modulation based on frame temporal dependency");
"RDO based on frame temporal dependency "
"(0: off, 1: backward source based, 2: forward 2-pass");
static const arg_def_t enable_keyframe_filtering =
ARG_DEF(NULL, "enable-keyframe-filtering", 1,
"Apply temporal filtering on key frame "
"(0: false, 1: true (default)");
static const arg_def_t tile_width =
ARG_DEF(NULL, "tile-width", 1, "Tile widths (comma separated)");
static const arg_def_t tile_height =
@ -432,10 +429,10 @@ static const arg_def_t enable_cdef =
ARG_DEF(NULL, "enable-cdef", 1,
"Enable the constrained directional enhancement filter (0: false, "
"1: true (default))");
static const arg_def_t enable_restoration =
ARG_DEF(NULL, "enable-restoration", 1,
"Enable the loop restoration filter (0: false, "
"1: true (default))");
static const arg_def_t enable_restoration = ARG_DEF(
NULL, "enable-restoration", 1,
"Enable the loop restoration filter (0: false (default in Realtime mode), "
"1: true (default in Non-realtime mode))");
static const arg_def_t enable_rect_partitions =
ARG_DEF(NULL, "enable-rect-partitions", 1,
"Enable rectangular partitions "
@ -450,7 +447,9 @@ static const arg_def_t enable_1to4_partitions =
static const arg_def_t min_partition_size =
ARG_DEF(NULL, "min-partition-size", 4,
"Set min partition size "
"(4:4x4, 8:8x8, 16:16x16, 32:32x32, 64:64x64, 128:128x128)");
"(4:4x4, 8:8x8, 16:16x16, 32:32x32, 64:64x64, 128:128x128)."
"On frame with 4k+ resolutions or higher speed settings, the min "
"partition size will have a minimum of 8.");
static const arg_def_t max_partition_size =
ARG_DEF(NULL, "max-partition-size", 128,
"Set max partition size "
@ -459,6 +458,10 @@ static const arg_def_t enable_dual_filter =
ARG_DEF(NULL, "enable-dual-filter", 1,
"Enable dual filter "
"(0: false, 1: true (default))");
static const arg_def_t enable_chroma_deltaq =
ARG_DEF(NULL, "enable-chroma-deltaq", 1,
"Enable chroma delta quant "
"(0: false (default), 1: true)");
static const arg_def_t enable_intra_edge_filter =
ARG_DEF(NULL, "enable-intra-edge-filter", 1,
"Enable intra edge filtering "
@ -471,7 +474,7 @@ static const arg_def_t enable_tx64 =
ARG_DEF(NULL, "enable-tx64", 1,
"Enable 64-pt transform (0: false, 1: true (default))");
static const arg_def_t tx_size_search_method =
ARG_DEF(NULL, "tx-size-search-method", 0,
ARG_DEF(NULL, "tx-size-search-method", 1,
"Set transform block size search method "
"(0: Full RD (default), 1: Fast RD, 2: use largest allowed)");
static const arg_def_t enable_flip_idtx =
@ -535,8 +538,14 @@ static const arg_def_t enable_cfl_intra =
ARG_DEF(NULL, "enable-cfl-intra", 1,
"Enable chroma from luma intra prediction mode "
"(0: false, 1: true (default))");
static const arg_def_t force_video_mode =
ARG_DEF(NULL, "force-video-mode", 1,
"Force video mode (0: false, 1: true (default))");
static const arg_def_t enable_obmc = ARG_DEF(
NULL, "enable-obmc", 1, "Enable OBMC (0: false, 1: true (default))");
static const arg_def_t enable_overlay =
ARG_DEF(NULL, "enable-overlay", 1,
"Enable coding overlay frames (0: false, 1: true (default))");
static const arg_def_t enable_palette =
ARG_DEF(NULL, "enable-palette", 1,
"Enable palette prediction mode (0: false, 1: true (default))");
@ -578,6 +587,10 @@ static const arg_def_t mode_cost_upd_freq =
ARG_DEF(NULL, "mode-cost-upd-freq", 1,
"Update freq for mode costs"
"0: SB, 1: SB Row per Tile, 2: Tile");
static const arg_def_t mv_cost_upd_freq =
ARG_DEF(NULL, "mv-cost-upd-freq", 1,
"Update freq for mv costs"
"0: SB, 1: SB Row per Tile, 2: Tile, 3: Off");
#if CONFIG_DIST_8X8
static const arg_def_t enable_dist_8x8 =
ARG_DEF(NULL, "enable-dist-8x8", 1,
@ -631,7 +644,7 @@ static const arg_def_t aq_mode = ARG_DEF(
"3: cyclic refresh)");
static const arg_def_t deltaq_mode =
ARG_DEF(NULL, "deltaq-mode", 1,
"Delta qindex mode (0: off (default), 1: deltaq pred efficiency, "
"Delta qindex mode (0: off, 1: deltaq pred efficiency (default), "
"2: deltaq perceptual)");
static const arg_def_t deltalf_mode = ARG_DEF(
NULL, "delta-lf-mode", 1, "Enable delta-lf-mode (0: off (default), 1: on)");
@ -667,6 +680,11 @@ static const arg_def_t target_seq_level_idx =
"xy: Target level index for the OP. "
"E.g. \"0\" means target level index 0 for the 0th OP; "
"\"1021\" means target level index 21 for the 10th OP.");
static const arg_def_t set_min_cr =
ARG_DEF(NULL, "min-cr", 1,
"Set minimum compression ratio. Take integer values. Default is 0. "
"If non-zero, encoder will try to keep the compression ratio of "
"each frame to be higher than the given value divided by 100.");
static const struct arg_enum_list color_primaries_enum[] = {
{ "bt709", AOM_CICP_CP_BT_709 },
@ -786,6 +804,7 @@ static const arg_def_t *av1_args[] = { &cpu_used_av1,
&tile_cols,
&tile_rows,
&enable_tpl_model,
&enable_keyframe_filtering,
&arnr_maxframes,
&arnr_strength,
&tune_metric,
@ -802,6 +821,7 @@ static const arg_def_t *av1_args[] = { &cpu_used_av1,
&min_partition_size,
&max_partition_size,
&enable_dual_filter,
&enable_chroma_deltaq,
&enable_intra_edge_filter,
&enable_order_hint,
&enable_tx64,
@ -821,7 +841,9 @@ static const arg_def_t *av1_args[] = { &cpu_used_av1,
&enable_smooth_intra,
&enable_paeth_intra,
&enable_cfl_intra,
&force_video_mode,
&enable_obmc,
&enable_overlay,
&enable_palette,
&enable_intrabc,
&enable_angle_delta,
@ -836,6 +858,7 @@ static const arg_def_t *av1_args[] = { &cpu_used_av1,
&quant_b_adapt,
&coeff_cost_upd_freq,
&mode_cost_upd_freq,
&mv_cost_upd_freq,
#if CONFIG_DIST_8X8
&enable_dist_8x8,
#endif
@ -870,6 +893,7 @@ static const arg_def_t *av1_args[] = { &cpu_used_av1,
&enable_ref_frame_mvs,
&target_seq_level_idx,
&set_tier_mask,
&set_min_cr,
&bitdeptharg,
&inbitdeptharg,
&input_chroma_subsampling_x,
@ -886,6 +910,7 @@ static const int av1_arg_ctrl_map[] = { AOME_SET_CPUUSED,
AV1E_SET_TILE_COLUMNS,
AV1E_SET_TILE_ROWS,
AV1E_SET_ENABLE_TPL_MODEL,
AV1E_SET_ENABLE_KEYFRAME_FILTERING,
AOME_SET_ARNR_MAXFRAMES,
AOME_SET_ARNR_STRENGTH,
AOME_SET_TUNING,
@ -902,6 +927,7 @@ static const int av1_arg_ctrl_map[] = { AOME_SET_CPUUSED,
AV1E_SET_MIN_PARTITION_SIZE,
AV1E_SET_MAX_PARTITION_SIZE,
AV1E_SET_ENABLE_DUAL_FILTER,
AV1E_SET_ENABLE_CHROMA_DELTAQ,
AV1E_SET_ENABLE_INTRA_EDGE_FILTER,
AV1E_SET_ENABLE_ORDER_HINT,
AV1E_SET_ENABLE_TX64,
@ -921,7 +947,9 @@ static const int av1_arg_ctrl_map[] = { AOME_SET_CPUUSED,
AV1E_SET_ENABLE_SMOOTH_INTRA,
AV1E_SET_ENABLE_PAETH_INTRA,
AV1E_SET_ENABLE_CFL_INTRA,
AV1E_SET_FORCE_VIDEO_MODE,
AV1E_SET_ENABLE_OBMC,
AV1E_SET_ENABLE_OVERLAY,
AV1E_SET_ENABLE_PALETTE,
AV1E_SET_ENABLE_INTRABC,
AV1E_SET_ENABLE_ANGLE_DELTA,
@ -936,6 +964,7 @@ static const int av1_arg_ctrl_map[] = { AOME_SET_CPUUSED,
AV1E_SET_QUANT_B_ADAPT,
AV1E_SET_COEFF_COST_UPD_FREQ,
AV1E_SET_MODE_COST_UPD_FREQ,
AV1E_SET_MV_COST_UPD_FREQ,
#if CONFIG_DIST_8X8
AV1E_SET_ENABLE_DIST_8X8,
#endif
@ -970,6 +999,7 @@ static const int av1_arg_ctrl_map[] = { AOME_SET_CPUUSED,
AV1E_SET_ENABLE_REF_FRAME_MVS,
AV1E_SET_TARGET_SEQ_LEVEL_IDX,
AV1E_SET_TIER_MASK,
AV1E_SET_MIN_CR,
0 };
#endif // CONFIG_AV1_ENCODER
@ -1085,15 +1115,11 @@ static void validate_positive_rational(const char *msg,
/* Parses global config arguments into the AvxEncoderConfig. Note that
* argv is modified and overwrites all parsed arguments.
*/
static void parse_global_config(struct AvxEncoderConfig *global, int argc,
char ***argv) {
static void parse_global_config(struct AvxEncoderConfig *global, char ***argv) {
char **argi, **argj;
struct arg arg;
const int num_encoder = get_aom_encoder_count();
char **argv_local = (char **)*argv;
#if CONFIG_FILEOPTIONS
int argc_local = argc;
#endif
if (num_encoder < 1) die("Error: no valid encoder available\n");
/* Initialize default parameters */
@ -1103,27 +1129,8 @@ static void parse_global_config(struct AvxEncoderConfig *global, int argc,
global->color_type = I420;
global->csp = AOM_CSP_UNKNOWN;
#if CONFIG_FILEOPTIONS
const char *cfg = NULL;
int cfg_included = 0;
#endif
for (argi = argj = argv_local; (*argj = *argi); argi += arg.argv_step) {
arg.argv_step = 1;
#if CONFIG_FILEOPTIONS
if (arg_match(&arg, &use_cfg, argi)) {
if (cfg_included) continue;
cfg = arg.val;
arg_cfg(&argc_local, &argv_local, cfg);
*argj = *argi = *argv_local;
argj = argi = argv_local;
*argv = argv_local;
cfg_included = 1;
continue;
}
#endif
if (arg_match(&arg, &help, argi)) {
show_help(stdout, 0);
exit(EXIT_SUCCESS);
@ -1539,10 +1546,11 @@ static int parse_stream_params(struct AvxEncoderConfig *global,
} else if (arg_match(&arg, &tile_height, argi)) {
config->cfg.tile_height_count =
arg_parse_list(&arg, config->cfg.tile_heights, MAX_TILE_HEIGHTS);
#if CONFIG_FILEOPTIONS
} else if (arg_match(&arg, &ext_partition, argi)) {
config->cfg.cfg.ext_partition = !!arg_parse_uint(&arg) > 0;
#endif
} else if (global->usage == AOM_USAGE_REALTIME &&
arg_match(&arg, &enable_restoration, argi)) {
if (arg_parse_uint(&arg) == 1) {
warn("non-zero %s option ignored in realtime mode.\n", arg.name);
}
} else {
int i, match = 0;
for (i = 0; ctrl_args[i]; i++) {
@ -1557,7 +1565,7 @@ static int parse_stream_params(struct AvxEncoderConfig *global,
}
}
config->use_16bit_internal =
config->cfg.g_bit_depth > AOM_BITS_8 || !CONFIG_LOWBITDEPTH;
config->cfg.g_bit_depth > AOM_BITS_8 || FORCE_HIGHBITDEPTH_DECODING;
return eos_mark_found;
}
@ -1814,7 +1822,7 @@ static void initialize_encoder(struct stream_state *stream,
#if CONFIG_AV1_DECODER
if (global->test_decode != TEST_DECODE_OFF) {
const AvxInterface *decoder = get_aom_decoder_by_name(global->codec->name);
aom_codec_dec_cfg_t cfg = { 0, 0, 0, CONFIG_LOWBITDEPTH, { 1 } };
aom_codec_dec_cfg_t cfg = { 0, 0, 0, !FORCE_HIGHBITDEPTH_DECODING };
aom_codec_dec_init(&stream->decoder, decoder->codec_interface(), &cfg, 0);
if (strcmp(global->codec->name, "av1") == 0) {
@ -2152,13 +2160,9 @@ int main(int argc, const char **argv_) {
* codec.
*/
argv = argv_dup(argc - 1, argv_ + 1);
parse_global_config(&global, argc, &argv);
parse_global_config(&global, &argv);
#if CONFIG_FILEOPTIONS
if (argc < 2) usage_exit();
#else
if (argc < 3) usage_exit();
#endif
switch (global.color_type) {
case I420: input.fmt = AOM_IMG_FMT_I420; break;

View file

@ -88,6 +88,10 @@ list(APPEND AOM_AV1_COMMON_SOURCES
"${AOM_ROOT}/av1/common/warped_motion.c"
"${AOM_ROOT}/av1/common/warped_motion.h")
if(CONFIG_LPF_MASK)
list(APPEND AOM_AV1_COMMON_SOURCES "${AOM_ROOT}/av1/common/loopfiltermask.c")
endif()
list(APPEND AOM_AV1_DECODER_SOURCES
"${AOM_ROOT}/av1/av1_dx_iface.c"
"${AOM_ROOT}/av1/decoder/decodeframe.c"
@ -112,6 +116,7 @@ list(APPEND AOM_AV1_ENCODER_SOURCES
"${AOM_ROOT}/av1/encoder/aq_cyclicrefresh.h"
"${AOM_ROOT}/av1/encoder/aq_variance.c"
"${AOM_ROOT}/av1/encoder/aq_variance.h"
"${AOM_ROOT}/av1/encoder/enc_enums.h"
"${AOM_ROOT}/av1/encoder/av1_fwd_txfm1d.c"
"${AOM_ROOT}/av1/encoder/av1_fwd_txfm1d.h"
"${AOM_ROOT}/av1/encoder/av1_fwd_txfm1d_cfg.h"
@ -123,6 +128,8 @@ list(APPEND AOM_AV1_ENCODER_SOURCES
"${AOM_ROOT}/av1/encoder/bitstream.c"
"${AOM_ROOT}/av1/encoder/bitstream.h"
"${AOM_ROOT}/av1/encoder/block.h"
"${AOM_ROOT}/av1/encoder/cnn.c"
"${AOM_ROOT}/av1/encoder/cnn.h"
"${AOM_ROOT}/av1/encoder/context_tree.c"
"${AOM_ROOT}/av1/encoder/context_tree.h"
"${AOM_ROOT}/av1/encoder/corner_detect.c"
@ -196,6 +203,8 @@ list(APPEND AOM_AV1_ENCODER_SOURCES
"${AOM_ROOT}/av1/encoder/segmentation.h"
"${AOM_ROOT}/av1/encoder/speed_features.c"
"${AOM_ROOT}/av1/encoder/speed_features.h"
"${AOM_ROOT}/av1/encoder/svc_layercontext.c"
"${AOM_ROOT}/av1/encoder/svc_layercontext.h"
"${AOM_ROOT}/av1/encoder/temporal_filter.c"
"${AOM_ROOT}/av1/encoder/temporal_filter.h"
"${AOM_ROOT}/av1/encoder/tokenize.c"
@ -222,7 +231,13 @@ list(APPEND AOM_AV1_COMMON_INTRIN_SSE2
"${AOM_ROOT}/av1/common/x86/highbd_convolve_2d_sse2.c"
"${AOM_ROOT}/av1/common/x86/jnt_convolve_sse2.c"
"${AOM_ROOT}/av1/common/x86/wiener_convolve_sse2.c"
"${AOM_ROOT}/av1/common/x86/av1_txfm_sse2.h")
"${AOM_ROOT}/av1/common/x86/av1_txfm_sse2.h"
"${AOM_ROOT}/av1/common/x86/warp_plane_sse2.c")
if(NOT CONFIG_AV1_HIGHBITDEPTH)
list(REMOVE_ITEM AOM_AV1_COMMON_INTRIN_SSE2
"${AOM_ROOT}/av1/common/x86/highbd_convolve_2d_sse2.c")
endif()
list(APPEND AOM_AV1_COMMON_INTRIN_SSSE3
"${AOM_ROOT}/av1/common/cdef_block_ssse3.c"
@ -234,11 +249,15 @@ list(APPEND AOM_AV1_COMMON_INTRIN_SSSE3
"${AOM_ROOT}/av1/common/x86/jnt_convolve_ssse3.c"
"${AOM_ROOT}/av1/common/x86/reconinter_ssse3.c")
if(NOT CONFIG_AV1_HIGHBITDEPTH)
list(REMOVE_ITEM AOM_AV1_COMMON_INTRIN_SSSE3
"${AOM_ROOT}/av1/common/x86/highbd_convolve_2d_ssse3.c")
endif()
list(APPEND AOM_AV1_COMMON_INTRIN_SSE4_1
"${AOM_ROOT}/av1/common/cdef_block_sse4.c"
"${AOM_ROOT}/av1/common/x86/av1_convolve_horiz_rs_sse4.c"
"${AOM_ROOT}/av1/common/x86/av1_convolve_scale_sse4.c"
"${AOM_ROOT}/av1/common/x86/av1_highbd_convolve_sse4.c"
"${AOM_ROOT}/av1/common/x86/av1_txfm_sse4.c"
"${AOM_ROOT}/av1/common/x86/av1_txfm_sse4.h"
"${AOM_ROOT}/av1/common/x86/filterintra_sse4.c"
@ -251,6 +270,12 @@ list(APPEND AOM_AV1_COMMON_INTRIN_SSE4_1
"${AOM_ROOT}/av1/common/x86/selfguided_sse4.c"
"${AOM_ROOT}/av1/common/x86/warp_plane_sse4.c")
if(NOT CONFIG_AV1_HIGHBITDEPTH)
list(REMOVE_ITEM AOM_AV1_COMMON_INTRIN_SSE4_1
"${AOM_ROOT}/av1/common/x86/highbd_convolve_2d_sse4.c"
"${AOM_ROOT}/av1/common/x86/highbd_warp_plane_sse4.c")
endif()
list(APPEND AOM_AV1_COMMON_INTRIN_AVX2
"${AOM_ROOT}/av1/common/cdef_block_avx2.c"
"${AOM_ROOT}/av1/common/x86/av1_inv_txfm_avx2.c"
@ -265,8 +290,14 @@ list(APPEND AOM_AV1_COMMON_INTRIN_AVX2
"${AOM_ROOT}/av1/common/x86/jnt_convolve_avx2.c"
"${AOM_ROOT}/av1/common/x86/reconinter_avx2.c"
"${AOM_ROOT}/av1/common/x86/selfguided_avx2.c"
"${AOM_ROOT}/av1/common/x86/warp_plane_avx2.c"
"${AOM_ROOT}/av1/common/x86/wiener_convolve_avx2.c")
if(NOT CONFIG_AV1_HIGHBITDEPTH)
list(REMOVE_ITEM AOM_AV1_COMMON_INTRIN_AVX2
"${AOM_ROOT}/av1/common/x86/highbd_convolve_2d_avx2.c")
endif()
list(APPEND AOM_AV1_ENCODER_ASM_SSE2 "${AOM_ROOT}/av1/encoder/x86/dct_sse2.asm"
"${AOM_ROOT}/av1/encoder/x86/error_sse2.asm")
@ -278,6 +309,12 @@ list(APPEND AOM_AV1_ENCODER_INTRIN_SSE2
"${AOM_ROOT}/av1/encoder/x86/highbd_block_error_intrin_sse2.c"
"${AOM_ROOT}/av1/encoder/x86/wedge_utils_sse2.c")
if(NOT CONFIG_AV1_HIGHBITDEPTH)
list(
REMOVE_ITEM AOM_AV1_ENCODER_INTRIN_SSE2
"${AOM_ROOT}/av1/encoder/x86/highbd_block_error_intrin_sse2.c")
endif()
list(APPEND AOM_AV1_ENCODER_INTRIN_SSE3 "${AOM_ROOT}/av1/encoder/x86/ml_sse3.c")
list(APPEND AOM_AV1_ENCODER_ASM_SSSE3_X86_64
@ -310,8 +347,15 @@ list(APPEND AOM_AV1_ENCODER_INTRIN_AVX2
"${AOM_ROOT}/av1/encoder/x86/rdopt_avx2.c"
"${AOM_ROOT}/av1/encoder/x86/pickrst_avx2.c")
if(NOT CONFIG_AV1_HIGHBITDEPTH)
list(
REMOVE_ITEM AOM_AV1_ENCODER_INTRIN_AVX2
"${AOM_ROOT}/av1/encoder/x86/highbd_block_error_intrin_avx2.c")
endif()
list(APPEND AOM_AV1_ENCODER_INTRIN_NEON
"${AOM_ROOT}/av1/encoder/arm/neon/quantize_neon.c")
"${AOM_ROOT}/av1/encoder/arm/neon/quantize_neon.c"
"${AOM_ROOT}/av1/encoder/arm/neon/av1_error_neon.c")
list(APPEND AOM_AV1_ENCODER_INTRIN_MSA
"${AOM_ROOT}/av1/encoder/mips/msa/error_msa.c"
@ -355,6 +399,28 @@ if(CONFIG_INTERNAL_STATS)
list(APPEND AOM_AV1_ENCODER_SOURCES "${AOM_ROOT}/av1/encoder/blockiness.c")
endif()
if(CONFIG_REALTIME_ONLY)
list(REMOVE_ITEM AOM_AV1_ENCODER_SOURCES
"${AOM_ROOT}/av1/encoder/cnn.c"
"${AOM_ROOT}/av1/encoder/cnn.h"
"${AOM_ROOT}/av1/encoder/firstpass.c"
"${AOM_ROOT}/av1/encoder/firstpass.h"
"${AOM_ROOT}/av1/encoder/gop_structure.c"
"${AOM_ROOT}/av1/encoder/gop_structure.h"
"${AOM_ROOT}/av1/encoder/mbgraph.c"
"${AOM_ROOT}/av1/encoder/mbgraph.h"
"${AOM_ROOT}/av1/encoder/partition_cnn_weights.h"
"${AOM_ROOT}/av1/encoder/partition_model_weights.h"
"${AOM_ROOT}/av1/encoder/pass2_strategy.c"
"${AOM_ROOT}/av1/encoder/temporal_filter.c"
"${AOM_ROOT}/av1/encoder/temporal_filter.h"
"${AOM_ROOT}/av1/encoder/temporal_filter_constants.h"
"${AOM_ROOT}/av1/encoder/tpl_model.c"
"${AOM_ROOT}/av1/encoder/tpl_model.h"
"${AOM_ROOT}/av1/encoder/x86/temporal_filter_sse4.c"
"${AOM_ROOT}/av1/encoder/x86/highbd_temporal_filter_sse4.c")
endif()
# Setup AV1 common/decoder/encoder targets. The libaom target must exist before
# this function is called.
function(setup_av1_targets)

View file

@ -30,7 +30,7 @@
#define MAX_NUM_ENHANCEMENT_LAYERS 3
struct av1_extracfg {
int cpu_used; // available cpu percentage in 1/16
int cpu_used;
unsigned int enable_auto_alt_ref;
unsigned int enable_auto_bwd_ref;
unsigned int noise_sensitivity;
@ -40,6 +40,7 @@ struct av1_extracfg {
unsigned int tile_columns; // log2 number of tile columns
unsigned int tile_rows; // log2 number of tile rows
unsigned int enable_tpl_model;
unsigned int enable_keyframe_filtering;
unsigned int arnr_max_frames;
unsigned int arnr_strength;
unsigned int min_gf_interval;
@ -53,6 +54,7 @@ struct av1_extracfg {
unsigned int lossless;
unsigned int enable_cdef;
unsigned int enable_restoration;
unsigned int force_video_mode;
unsigned int enable_obmc;
unsigned int disable_trellis_quant;
unsigned int enable_qm;
@ -70,6 +72,7 @@ struct av1_extracfg {
aom_timing_info_type_t timing_info_type;
unsigned int frame_parallel_decoding_mode;
int enable_dual_filter;
unsigned int enable_chroma_deltaq;
AQ_MODE aq_mode;
DELTAQ_MODE deltaq_mode;
int deltalf_mode;
@ -122,6 +125,7 @@ struct av1_extracfg {
int enable_paeth_intra; // enable Paeth intra mode for sequence
int enable_cfl_intra; // enable CFL uv intra mode for sequence
int enable_superres;
int enable_overlay; // enable overlay for filtered arf frames
int enable_palette;
int enable_intrabc;
int enable_angle_delta;
@ -141,8 +145,11 @@ struct av1_extracfg {
// Bit mask to specify which tier each of the 32 possible operating points
// conforms to.
unsigned int tier_mask;
// min_cr / 100 is the target minimum compression ratio for each frame.
unsigned int min_cr;
COST_UPDATE_TYPE coeff_cost_upd_freq;
COST_UPDATE_TYPE mode_cost_upd_freq;
COST_UPDATE_TYPE mv_cost_upd_freq;
};
static struct av1_extracfg default_extra_cfg = {
@ -155,7 +162,8 @@ static struct av1_extracfg default_extra_cfg = {
1, // row_mt
0, // tile_columns
0, // tile_rows
0, // enable_tpl_model
1, // enable_tpl_model
1, // enable_keyframe_filtering
7, // arnr_max_frames
5, // arnr_strength
0, // min_gf_interval; 0 -> default decision
@ -169,6 +177,7 @@ static struct av1_extracfg default_extra_cfg = {
0, // lossless
!CONFIG_SHARP_SETTINGS, // enable_cdef
1, // enable_restoration
1, // force_video_mode
1, // enable_obmc
3, // disable_trellis_quant
0, // enable_qm
@ -185,8 +194,9 @@ static struct av1_extracfg default_extra_cfg = {
AOM_TIMING_UNSPECIFIED, // No picture timing signaling in bitstream
0, // frame_parallel_decoding_mode
1, // enable dual filter
0, // enable delta quant in chroma planes
NO_AQ, // aq_mode
NO_DELTA_Q, // deltaq_mode
DELTA_Q_OBJECTIVE, // deltaq_mode
0, // delta lf mode
0, // frame_periodic_delta_q
AOM_BITS_8, // Bit depth
@ -236,6 +246,7 @@ static struct av1_extracfg default_extra_cfg = {
1, // enable Paeth intra mode usage for sequence
1, // enable CFL uv intra mode usage for sequence
1, // superres
1, // enable overlay
1, // enable palette
!CONFIG_SHARP_SETTINGS, // enable intrabc
1, // enable angle delta
@ -251,12 +262,19 @@ static struct av1_extracfg default_extra_cfg = {
0, // use_intra_default_tx_only
0, // quant_b_adapt
{
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
}, // target_seq_level_idx
0, // tier_mask
0, // min_cr
COST_UPD_SB, // coeff_cost_upd_freq
COST_UPD_SB, // mode_cost_upd_freq
COST_UPD_SB, // mv_cost_upd_freq
};
struct aom_codec_alg_priv {
@ -362,8 +380,8 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
RANGE_CHECK_HI(extra_cfg, min_gf_interval, MAX_LAG_BUFFERS - 1);
RANGE_CHECK_HI(extra_cfg, max_gf_interval, MAX_LAG_BUFFERS - 1);
if (extra_cfg->max_gf_interval > 0) {
RANGE_CHECK(extra_cfg, max_gf_interval, MAX(2, extra_cfg->min_gf_interval),
(MAX_LAG_BUFFERS - 1));
RANGE_CHECK(extra_cfg, max_gf_interval,
AOMMAX(2, extra_cfg->min_gf_interval), (MAX_LAG_BUFFERS - 1));
}
RANGE_CHECK_HI(extra_cfg, gf_max_pyr_height, 4);
@ -419,10 +437,6 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
RANGE_CHECK(cfg, g_input_bit_depth, 8, 12);
RANGE_CHECK(extra_cfg, content, AOM_CONTENT_DEFAULT, AOM_CONTENT_INVALID - 1);
// TODO(yaowu): remove this when ssim tuning is implemented for av1
if (extra_cfg->tuning == AOM_TUNE_SSIM)
ERROR("Option --tune=ssim is not currently supported in AV1.");
if (cfg->g_pass == AOM_RC_LAST_PASS) {
const size_t packet_sz = sizeof(FIRSTPASS_STATS);
const int n_packets = (int)(cfg->rc_twopass_stats_in.sz / packet_sz);
@ -476,12 +490,19 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
if (extra_cfg->lossless) {
if (extra_cfg->aq_mode != 0)
ERROR("Only --aq_mode=0 can be used with --lossless=1.");
if (extra_cfg->enable_chroma_deltaq)
ERROR("Only --enable_chroma_deltaq=0 can be used with --lossless=1.");
#if CONFIG_DIST_8X8
if (extra_cfg->enable_dist_8x8)
ERROR("dist-8x8 cannot be used with lossless compression.");
#endif
}
if (cfg->rc_resize_mode != RESIZE_NONE &&
extra_cfg->aq_mode == CYCLIC_REFRESH_AQ) {
ERROR("--aq_mode=3 is only supported for --resize-mode=0.");
}
RANGE_CHECK(extra_cfg, max_reference_frames, 3, 7);
RANGE_CHECK(extra_cfg, enable_reduced_reference_set, 0, 1);
RANGE_CHECK_HI(extra_cfg, chroma_subsampling_x, 1);
@ -490,6 +511,7 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
RANGE_CHECK_HI(extra_cfg, disable_trellis_quant, 3);
RANGE_CHECK(extra_cfg, coeff_cost_upd_freq, 0, 2);
RANGE_CHECK(extra_cfg, mode_cost_upd_freq, 0, 2);
RANGE_CHECK(extra_cfg, mv_cost_upd_freq, 0, 3);
RANGE_CHECK(extra_cfg, min_partition_size, 4, 128);
RANGE_CHECK(extra_cfg, max_partition_size, 4, 128);
@ -498,8 +520,10 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
RANGE_CHECK(extra_cfg, tx_size_search_method, 0, 2);
for (int i = 0; i < MAX_NUM_OPERATING_POINTS; ++i) {
if (!is_valid_seq_level_idx(extra_cfg->target_seq_level_idx[i]))
const int level_idx = extra_cfg->target_seq_level_idx[i];
if (!is_valid_seq_level_idx(level_idx) && level_idx != SEQ_LEVELS) {
ERROR("Target sequence level index is invalid");
}
}
return AOM_CODEC_OK;
@ -569,7 +593,7 @@ static aom_codec_err_t set_encoder_config(
oxcf->profile = cfg->g_profile;
oxcf->fwd_kf_enabled = cfg->fwd_kf_enabled;
oxcf->max_threads = (int)cfg->g_threads;
oxcf->mode = (cfg->g_usage == 1) ? REALTIME : GOOD;
oxcf->mode = (cfg->g_usage == AOM_USAGE_REALTIME) ? REALTIME : GOOD;
oxcf->width = cfg->g_w;
oxcf->height = cfg->g_h;
oxcf->forced_max_frame_width = cfg->g_forced_max_frame_width;
@ -612,7 +636,6 @@ static aom_codec_err_t set_encoder_config(
oxcf->init_framerate = 30;
oxcf->timing_info_present = 0;
}
oxcf->cfg = &cfg->cfg;
switch (cfg->g_pass) {
case AOM_RC_ONE_PASS: oxcf->pass = 0; break;
@ -620,8 +643,7 @@ static aom_codec_err_t set_encoder_config(
case AOM_RC_LAST_PASS: oxcf->pass = 2; break;
}
oxcf->lag_in_frames =
cfg->g_pass == AOM_RC_FIRST_PASS ? 0 : cfg->g_lag_in_frames;
oxcf->lag_in_frames = cfg->g_lag_in_frames;
oxcf->rc_mode = cfg->rc_end_usage;
// Convert target bandwidth from Kbit/s to Bit/s
@ -638,8 +660,11 @@ static aom_codec_err_t set_encoder_config(
oxcf->fixed_q = -1;
oxcf->enable_cdef = extra_cfg->enable_cdef;
oxcf->enable_restoration = extra_cfg->enable_restoration;
oxcf->enable_restoration =
(cfg->g_usage == AOM_USAGE_REALTIME) ? 0 : extra_cfg->enable_restoration;
oxcf->force_video_mode = extra_cfg->force_video_mode;
oxcf->enable_obmc = extra_cfg->enable_obmc;
oxcf->enable_overlay = extra_cfg->enable_overlay;
oxcf->enable_palette = extra_cfg->enable_palette;
oxcf->enable_intrabc = extra_cfg->enable_intrabc;
oxcf->enable_angle_delta = extra_cfg->enable_angle_delta;
@ -657,6 +682,7 @@ static aom_codec_err_t set_encoder_config(
oxcf->quant_b_adapt = extra_cfg->quant_b_adapt;
oxcf->coeff_cost_upd_freq = (COST_UPDATE_TYPE)extra_cfg->coeff_cost_upd_freq;
oxcf->mode_cost_upd_freq = (COST_UPDATE_TYPE)extra_cfg->mode_cost_upd_freq;
oxcf->mv_cost_upd_freq = (COST_UPDATE_TYPE)extra_cfg->mv_cost_upd_freq;
#if CONFIG_DIST_8X8
oxcf->using_dist_8x8 = extra_cfg->enable_dist_8x8;
if (extra_cfg->tuning == AOM_TUNE_CDEF_DIST ||
@ -815,7 +841,9 @@ static aom_codec_err_t set_encoder_config(
oxcf->enable_global_motion = extra_cfg->enable_global_motion;
oxcf->enable_warped_motion = extra_cfg->enable_warped_motion;
oxcf->allow_warped_motion =
extra_cfg->allow_warped_motion & extra_cfg->enable_warped_motion;
(cfg->g_usage == AOM_USAGE_REALTIME)
? 0
: (extra_cfg->allow_warped_motion & extra_cfg->enable_warped_motion);
oxcf->enable_filter_intra = extra_cfg->enable_filter_intra;
oxcf->enable_smooth_intra = extra_cfg->enable_smooth_intra;
oxcf->enable_paeth_intra = extra_cfg->enable_paeth_intra;
@ -853,19 +881,17 @@ static aom_codec_err_t set_encoder_config(
oxcf->timing_info_present = 0;
}
oxcf->enable_tpl_model =
extra_cfg->enable_tpl_model && (oxcf->superres_mode == SUPERRES_NONE);
oxcf->enable_tpl_model = extra_cfg->enable_tpl_model;
oxcf->enable_keyframe_filtering = extra_cfg->enable_keyframe_filtering;
oxcf->enable_chroma_deltaq = extra_cfg->enable_chroma_deltaq;
oxcf->aq_mode = extra_cfg->aq_mode;
oxcf->deltaq_mode = extra_cfg->deltaq_mode;
// Turn on tpl model for deltaq_mode == DELTA_Q_OBJECTIVE and no
// superres. If superres is being used on the other hand, turn
// delta_q off.
if (oxcf->deltaq_mode == DELTA_Q_OBJECTIVE) {
if (oxcf->superres_mode == SUPERRES_NONE)
oxcf->enable_tpl_model = 1;
else
oxcf->deltaq_mode = NO_DELTA_Q;
if (oxcf->deltaq_mode == DELTA_Q_OBJECTIVE && !oxcf->enable_tpl_model) {
oxcf->enable_tpl_model = 1;
}
oxcf->deltalf_mode =
@ -884,6 +910,7 @@ static aom_codec_err_t set_encoder_config(
memcpy(oxcf->target_seq_level_idx, extra_cfg->target_seq_level_idx,
sizeof(oxcf->target_seq_level_idx));
oxcf->tier_mask = extra_cfg->tier_mask;
oxcf->min_cr = extra_cfg->min_cr;
return AOM_CODEC_OK;
}
@ -1024,6 +1051,14 @@ static aom_codec_err_t ctrl_set_enable_tpl_model(aom_codec_alg_priv_t *ctx,
return update_extra_cfg(ctx, &extra_cfg);
}
static aom_codec_err_t ctrl_set_enable_keyframe_filtering(
aom_codec_alg_priv_t *ctx, va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
extra_cfg.enable_keyframe_filtering =
CAST(AV1E_SET_ENABLE_KEYFRAME_FILTERING, args);
return update_extra_cfg(ctx, &extra_cfg);
}
static aom_codec_err_t ctrl_set_arnr_max_frames(aom_codec_alg_priv_t *ctx,
va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
@ -1096,6 +1131,13 @@ static aom_codec_err_t ctrl_set_enable_restoration(aom_codec_alg_priv_t *ctx,
return update_extra_cfg(ctx, &extra_cfg);
}
static aom_codec_err_t ctrl_set_force_video_mode(aom_codec_alg_priv_t *ctx,
va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
extra_cfg.force_video_mode = CAST(AV1E_SET_FORCE_VIDEO_MODE, args);
return update_extra_cfg(ctx, &extra_cfg);
}
static aom_codec_err_t ctrl_set_enable_obmc(aom_codec_alg_priv_t *ctx,
va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
@ -1178,6 +1220,13 @@ static aom_codec_err_t ctrl_set_enable_dual_filter(aom_codec_alg_priv_t *ctx,
return update_extra_cfg(ctx, &extra_cfg);
}
static aom_codec_err_t ctrl_set_enable_chroma_deltaq(aom_codec_alg_priv_t *ctx,
va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
extra_cfg.enable_chroma_deltaq = CAST(AV1E_SET_ENABLE_CHROMA_DELTAQ, args);
return update_extra_cfg(ctx, &extra_cfg);
}
static aom_codec_err_t ctrl_set_enable_rect_partitions(
aom_codec_alg_priv_t *ctx, va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
@ -1396,6 +1445,13 @@ static aom_codec_err_t ctrl_set_enable_superres(aom_codec_alg_priv_t *ctx,
return update_extra_cfg(ctx, &extra_cfg);
}
static aom_codec_err_t ctrl_set_enable_overlay(aom_codec_alg_priv_t *ctx,
va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
extra_cfg.enable_overlay = CAST(AV1E_SET_ENABLE_OVERLAY, args);
return update_extra_cfg(ctx, &extra_cfg);
}
static aom_codec_err_t ctrl_set_enable_palette(aom_codec_alg_priv_t *ctx,
va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
@ -1503,6 +1559,13 @@ static aom_codec_err_t ctrl_set_mode_cost_upd_freq(aom_codec_alg_priv_t *ctx,
return update_extra_cfg(ctx, &extra_cfg);
}
static aom_codec_err_t ctrl_set_mv_cost_upd_freq(aom_codec_alg_priv_t *ctx,
va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
extra_cfg.mv_cost_upd_freq = CAST(AV1E_SET_MV_COST_UPD_FREQ, args);
return update_extra_cfg(ctx, &extra_cfg);
}
static aom_codec_err_t ctrl_set_film_grain_test_vector(
aom_codec_alg_priv_t *ctx, va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
@ -1518,22 +1581,32 @@ static aom_codec_err_t ctrl_set_film_grain_table(aom_codec_alg_priv_t *ctx,
return update_extra_cfg(ctx, &extra_cfg);
}
#if CONFIG_DENOISE
static aom_codec_err_t ctrl_set_denoise_noise_level(aom_codec_alg_priv_t *ctx,
va_list args) {
#if !CONFIG_DENOISE
(void)ctx;
(void)args;
return AOM_CODEC_INCAPABLE;
#else
struct av1_extracfg extra_cfg = ctx->extra_cfg;
extra_cfg.noise_level =
((float)CAST(AV1E_SET_DENOISE_NOISE_LEVEL, args)) / 10.0f;
return update_extra_cfg(ctx, &extra_cfg);
#endif
}
static aom_codec_err_t ctrl_set_denoise_block_size(aom_codec_alg_priv_t *ctx,
va_list args) {
#if !CONFIG_DENOISE
(void)ctx;
(void)args;
return AOM_CODEC_INCAPABLE;
#else
struct av1_extracfg extra_cfg = ctx->extra_cfg;
extra_cfg.noise_block_size = CAST(AV1E_SET_DENOISE_BLOCK_SIZE, args);
return update_extra_cfg(ctx, &extra_cfg);
}
#endif
}
static aom_codec_err_t ctrl_set_deltaq_mode(aom_codec_alg_priv_t *ctx,
va_list args) {
@ -1605,6 +1678,13 @@ static aom_codec_err_t ctrl_set_tier_mask(aom_codec_alg_priv_t *ctx,
return update_extra_cfg(ctx, &extra_cfg);
}
static aom_codec_err_t ctrl_set_min_cr(aom_codec_alg_priv_t *ctx,
va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
extra_cfg.min_cr = CAST(AV1E_SET_MIN_CR, args);
return update_extra_cfg(ctx, &extra_cfg);
}
static aom_codec_err_t encoder_init(aom_codec_ctx_t *ctx,
aom_codec_priv_enc_mr_cfg_t *data) {
aom_codec_err_t res = AOM_CODEC_OK;
@ -1747,7 +1827,8 @@ static aom_codec_err_t encoder_encode(aom_codec_alg_priv_t *ctx,
// Handle fixed keyframe intervals
if (ctx->cfg.kf_mode == AOM_KF_AUTO &&
ctx->cfg.kf_min_dist == ctx->cfg.kf_max_dist) {
if (++ctx->fixed_kf_cntr > ctx->cfg.kf_min_dist) {
if (cpi->common.spatial_layer_id == 0 &&
++ctx->fixed_kf_cntr > ctx->cfg.kf_min_dist) {
flags |= AOM_EFLAG_FORCE_KF;
ctx->fixed_kf_cntr = 1;
}
@ -1802,10 +1883,15 @@ static aom_codec_err_t encoder_encode(aom_codec_alg_priv_t *ctx,
int has_fwd_keyframe = 0;
// invisible frames get packed with the next visible frame
while (cx_data_sz - index_size >= ctx->cx_data_sz / 2 &&
!is_frame_visible &&
-1 != av1_get_compressed_data(cpi, &lib_flags, &frame_size, cx_data,
&dst_time_stamp, &dst_end_time_stamp,
!img, timestamp_ratio)) {
!is_frame_visible) {
const int status = av1_get_compressed_data(
cpi, &lib_flags, &frame_size, cx_data, &dst_time_stamp,
&dst_end_time_stamp, !img, timestamp_ratio);
if (status == -1) break;
if (status != AOM_CODEC_OK) {
aom_internal_error(&cpi->common.error, AOM_CODEC_ERROR, NULL);
}
cpi->seq_params_locked = 1;
if (frame_size) {
if (ctx->pending_cx_data == 0) ctx->pending_cx_data = cx_data;
@ -1830,8 +1916,8 @@ static aom_codec_err_t encoder_encode(aom_codec_alg_priv_t *ctx,
(uint8_t *)(ctx->pending_cx_data + obu_header_offset));
// OBUs are preceded/succeeded by an unsigned leb128 coded integer.
if (write_uleb_obu_size(obu_header_size, obu_payload_size,
ctx->pending_cx_data) != AOM_CODEC_OK) {
if (av1_write_uleb_obu_size(obu_header_size, obu_payload_size,
ctx->pending_cx_data) != AOM_CODEC_OK) {
aom_internal_error(&cpi->common.error, AOM_CODEC_ERROR, NULL);
}
@ -1852,7 +1938,7 @@ static aom_codec_err_t encoder_encode(aom_codec_alg_priv_t *ctx,
const size_t move_offset = length_field_size;
memmove(cx_data + move_offset, cx_data, frame_size);
}
if (write_uleb_obu_size(0, (uint32_t)frame_size, cx_data) !=
if (av1_write_uleb_obu_size(0, (uint32_t)frame_size, cx_data) !=
AOM_CODEC_OK) {
aom_internal_error(&cpi->common.error, AOM_CODEC_ERROR, NULL);
}
@ -1886,8 +1972,8 @@ static aom_codec_err_t encoder_encode(aom_codec_alg_priv_t *ctx,
memmove(ctx->pending_cx_data + move_offset, ctx->pending_cx_data,
tu_size);
}
if (write_uleb_obu_size(0, (uint32_t)tu_size, ctx->pending_cx_data) !=
AOM_CODEC_OK) {
if (av1_write_uleb_obu_size(0, (uint32_t)tu_size,
ctx->pending_cx_data) != AOM_CODEC_OK) {
aom_internal_error(&cpi->common.error, AOM_CODEC_ERROR, NULL);
}
ctx->pending_cx_data_sz += length_field_size;
@ -2108,6 +2194,62 @@ static aom_codec_err_t ctrl_set_number_spatial_layers(aom_codec_alg_priv_t *ctx,
return AOM_CODEC_OK;
}
static aom_codec_err_t ctrl_set_layer_id(aom_codec_alg_priv_t *ctx,
va_list args) {
aom_svc_layer_id_t *const data = va_arg(args, aom_svc_layer_id_t *);
ctx->cpi->common.spatial_layer_id = data->spatial_layer_id;
ctx->cpi->common.temporal_layer_id = data->temporal_layer_id;
ctx->cpi->svc.spatial_layer_id = data->spatial_layer_id;
ctx->cpi->svc.temporal_layer_id = data->temporal_layer_id;
return AOM_CODEC_OK;
}
static aom_codec_err_t ctrl_set_svc_params(aom_codec_alg_priv_t *ctx,
va_list args) {
AV1_COMP *const cpi = ctx->cpi;
aom_svc_params_t *const params = va_arg(args, aom_svc_params_t *);
cpi->common.number_spatial_layers = params->number_spatial_layers;
cpi->common.number_temporal_layers = params->number_temporal_layers;
cpi->svc.number_spatial_layers = params->number_spatial_layers;
cpi->svc.number_temporal_layers = params->number_temporal_layers;
if (cpi->common.number_spatial_layers > 1 ||
cpi->common.number_temporal_layers > 1) {
unsigned int sl, tl;
cpi->use_svc = 1;
for (sl = 0; sl < cpi->common.number_spatial_layers; ++sl) {
for (tl = 0; tl < cpi->common.number_temporal_layers; ++tl) {
const int layer =
LAYER_IDS_TO_IDX(sl, tl, cpi->common.number_temporal_layers);
LAYER_CONTEXT *lc = &cpi->svc.layer_context[layer];
lc->max_q = params->max_quantizers[layer];
lc->min_q = params->min_quantizers[layer];
lc->scaling_factor_num = params->scaling_factor_num[sl];
lc->scaling_factor_den = params->scaling_factor_den[sl];
lc->layer_target_bitrate = 1000 * params->layer_target_bitrate[layer];
lc->framerate_factor = params->framerate_factor[tl];
}
}
if (cpi->common.current_frame.frame_number == 0)
av1_init_layer_context(cpi);
else
av1_update_layer_context_change_config(cpi, cpi->oxcf.target_bandwidth);
}
return AOM_CODEC_OK;
}
static aom_codec_err_t ctrl_set_svc_ref_frame_config(aom_codec_alg_priv_t *ctx,
va_list args) {
AV1_COMP *const cpi = ctx->cpi;
aom_svc_ref_frame_config_t *const data =
va_arg(args, aom_svc_ref_frame_config_t *);
cpi->svc.external_ref_frame_config = 1;
for (unsigned int i = 0; i < INTER_REFS_PER_FRAME; ++i)
cpi->svc.ref_idx[i] = data->ref_idx[i];
for (unsigned int i = 0; i < REF_FRAMES; ++i)
cpi->svc.refresh[i] = data->refresh[i];
return AOM_CODEC_OK;
}
static aom_codec_err_t ctrl_set_tune_content(aom_codec_alg_priv_t *ctx,
va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
@ -2216,6 +2358,7 @@ static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
{ AV1E_SET_TILE_COLUMNS, ctrl_set_tile_columns },
{ AV1E_SET_TILE_ROWS, ctrl_set_tile_rows },
{ AV1E_SET_ENABLE_TPL_MODEL, ctrl_set_enable_tpl_model },
{ AV1E_SET_ENABLE_KEYFRAME_FILTERING, ctrl_set_enable_keyframe_filtering },
{ AOME_SET_ARNR_MAXFRAMES, ctrl_set_arnr_max_frames },
{ AOME_SET_ARNR_STRENGTH, ctrl_set_arnr_strength },
{ AOME_SET_TUNING, ctrl_set_tuning },
@ -2227,6 +2370,7 @@ static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
{ AV1E_SET_LOSSLESS, ctrl_set_lossless },
{ AV1E_SET_ENABLE_CDEF, ctrl_set_enable_cdef },
{ AV1E_SET_ENABLE_RESTORATION, ctrl_set_enable_restoration },
{ AV1E_SET_FORCE_VIDEO_MODE, ctrl_set_force_video_mode },
{ AV1E_SET_ENABLE_OBMC, ctrl_set_enable_obmc },
{ AV1E_SET_DISABLE_TRELLIS_QUANT, ctrl_set_disable_trellis_quant },
{ AV1E_SET_ENABLE_QM, ctrl_set_enable_qm },
@ -2250,6 +2394,7 @@ static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
{ AV1E_SET_MIN_PARTITION_SIZE, ctrl_set_min_partition_size },
{ AV1E_SET_MAX_PARTITION_SIZE, ctrl_set_max_partition_size },
{ AV1E_SET_ENABLE_DUAL_FILTER, ctrl_set_enable_dual_filter },
{ AV1E_SET_ENABLE_CHROMA_DELTAQ, ctrl_set_enable_chroma_deltaq },
{ AV1E_SET_ENABLE_INTRA_EDGE_FILTER, ctrl_set_enable_intra_edge_filter },
{ AV1E_SET_ENABLE_ORDER_HINT, ctrl_set_enable_order_hint },
{ AV1E_SET_ENABLE_TX64, ctrl_set_enable_tx64 },
@ -2275,6 +2420,7 @@ static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
{ AV1E_SET_ENABLE_PAETH_INTRA, ctrl_set_enable_paeth_intra },
{ AV1E_SET_ENABLE_CFL_INTRA, ctrl_set_enable_cfl_intra },
{ AV1E_SET_ENABLE_SUPERRES, ctrl_set_enable_superres },
{ AV1E_SET_ENABLE_OVERLAY, ctrl_set_enable_overlay },
{ AV1E_SET_ENABLE_PALETTE, ctrl_set_enable_palette },
{ AV1E_SET_ENABLE_INTRABC, ctrl_set_enable_intrabc },
{ AV1E_SET_ENABLE_ANGLE_DELTA, ctrl_set_enable_angle_delta },
@ -2286,6 +2432,7 @@ static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
{ AV1E_SET_QUANT_B_ADAPT, ctrl_set_quant_b_adapt },
{ AV1E_SET_COEFF_COST_UPD_FREQ, ctrl_set_coeff_cost_upd_freq },
{ AV1E_SET_MODE_COST_UPD_FREQ, ctrl_set_mode_cost_upd_freq },
{ AV1E_SET_MV_COST_UPD_FREQ, ctrl_set_mv_cost_upd_freq },
{ AV1E_SET_DELTAQ_MODE, ctrl_set_deltaq_mode },
{ AV1E_SET_DELTALF_MODE, ctrl_set_deltalf_mode },
{ AV1E_SET_FRAME_PERIODIC_BOOST, ctrl_set_frame_periodic_boost },
@ -2305,13 +2452,15 @@ static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
{ AV1E_SET_SINGLE_TILE_DECODING, ctrl_set_single_tile_decoding },
{ AV1E_SET_FILM_GRAIN_TEST_VECTOR, ctrl_set_film_grain_test_vector },
{ AV1E_SET_FILM_GRAIN_TABLE, ctrl_set_film_grain_table },
#if CONFIG_DENOISE
{ AV1E_SET_DENOISE_NOISE_LEVEL, ctrl_set_denoise_noise_level },
{ AV1E_SET_DENOISE_BLOCK_SIZE, ctrl_set_denoise_block_size },
#endif // CONFIG_FILM_GRAIN
{ AV1E_ENABLE_MOTION_VECTOR_UNIT_TEST, ctrl_enable_motion_vector_unit_test },
{ AV1E_SET_TARGET_SEQ_LEVEL_IDX, ctrl_set_target_seq_level_idx },
{ AV1E_SET_TIER_MASK, ctrl_set_tier_mask },
{ AV1E_SET_MIN_CR, ctrl_set_min_cr },
{ AV1E_SET_SVC_LAYER_ID, ctrl_set_layer_id },
{ AV1E_SET_SVC_PARAMS, ctrl_set_svc_params },
{ AV1E_SET_SVC_REF_FRAME_CONFIG, ctrl_set_svc_ref_frame_config },
// Getters
{ AOME_GET_LAST_QUANTIZER, ctrl_get_quantizer },
@ -2330,9 +2479,9 @@ static aom_codec_enc_cfg_map_t encoder_usage_cfg_map[] = {
{ 0,
{
// NOLINT
0, // g_usage - non-realtime usage
0, // g_threads
0, // g_profile
AOM_USAGE_GOOD_QUALITY, // g_usage - non-realtime usage
0, // g_threads
0, // g_profile
320, // g_width
240, // g_height
@ -2393,14 +2542,13 @@ static aom_codec_enc_cfg_map_t encoder_usage_cfg_map[] = {
0, // tile_height_count
{ 0 }, // tile_widths
{ 0 }, // tile_heights
{ 1 }, // config file
} },
{ 1,
{
// NOLINT
1, // g_usage - real-time usage
0, // g_threads
0, // g_profile
AOM_USAGE_REALTIME, // g_usage - real-time usage
0, // g_threads
0, // g_profile
320, // g_width
240, // g_height
@ -2461,7 +2609,6 @@ static aom_codec_enc_cfg_map_t encoder_usage_cfg_map[] = {
0, // tile_height_count
{ 0 }, // tile_widths
{ 0 }, // tile_heights
{ 1 }, // config file
} },
};

View file

@ -16,6 +16,7 @@
#include "config/aom_version.h"
#include "aom/internal/aom_codec_internal.h"
#include "aom/internal/aom_image_internal.h"
#include "aom/aomdx.h"
#include "aom/aom_decoder.h"
#include "aom_dsp/bitreader_buffer.h"
@ -65,7 +66,9 @@ struct aom_codec_alg_priv {
int num_frame_workers;
int next_output_worker_id;
aom_image_t *image_with_grain[MAX_NUM_SPATIAL_LAYERS];
aom_image_t image_with_grain;
aom_codec_frame_buffer_t grain_image_frame_buffers[MAX_NUM_SPATIAL_LAYERS];
size_t num_grain_image_frame_buffers;
int need_resync; // wait for key/intra-only frame
// BufferPool that holds all reference frames. Shared by all the FrameWorkers.
BufferPool *buffer_pool;
@ -98,14 +101,12 @@ static aom_codec_err_t decoder_init(aom_codec_ctx_t *ctx,
priv->flushed = 0;
// TODO(tdaede): this should not be exposed to the API
priv->cfg.allow_lowbitdepth = CONFIG_LOWBITDEPTH;
priv->cfg.allow_lowbitdepth = !FORCE_HIGHBITDEPTH_DECODING;
if (ctx->config.dec) {
priv->cfg = *ctx->config.dec;
ctx->config.dec = &priv->cfg;
// default values
priv->cfg.cfg.ext_partition = 1;
}
av1_zero(priv->image_with_grain);
priv->num_grain_image_frame_buffers = 0;
// Turn row_mt on by default.
priv->row_mt = 1;
@ -141,15 +142,16 @@ static aom_codec_err_t decoder_destroy(aom_codec_alg_priv_t *ctx) {
}
if (ctx->buffer_pool) {
for (size_t i = 0; i < ctx->num_grain_image_frame_buffers; i++) {
ctx->buffer_pool->release_fb_cb(ctx->buffer_pool->cb_priv,
&ctx->grain_image_frame_buffers[i]);
}
av1_free_ref_frame_buffers(ctx->buffer_pool);
av1_free_internal_frame_buffers(&ctx->buffer_pool->int_frame_buffers);
}
aom_free(ctx->frame_workers);
aom_free(ctx->buffer_pool);
for (int i = 0; i < MAX_NUM_SPATIAL_LAYERS; i++) {
if (ctx->image_with_grain[i]) aom_img_free(ctx->image_with_grain[i]);
}
aom_free(ctx);
return AOM_CODEC_OK;
}
@ -336,6 +338,8 @@ static aom_codec_err_t decoder_peek_si_internal(const uint8_t *data,
if (frame_type == KEY_FRAME) {
found_keyframe = 1;
break; // Stop here as no further OBUs will change the outcome.
} else if (frame_type == INTRA_ONLY_FRAME) {
intra_only_flag = 1;
}
}
}
@ -476,7 +480,6 @@ static aom_codec_err_t init_decoder(aom_codec_alg_priv_t *ctx) {
set_error_detail(ctx, "Failed to allocate frame_worker_data");
return AOM_CODEC_MEM_ERROR;
}
frame_worker_data->pbi->common.options = &ctx->cfg.cfg;
frame_worker_data->worker_id = i;
frame_worker_data->frame_context_ready = 0;
frame_worker_data->received_frame = 0;
@ -576,6 +579,7 @@ static aom_codec_err_t decoder_inspect(aom_codec_alg_priv_t *ctx,
void *user_priv) {
aom_codec_err_t res = AOM_CODEC_OK;
const uint8_t *const data_end = data + data_sz;
Av1DecodeReturn *data2 = (Av1DecodeReturn *)user_priv;
if (ctx->frame_workers == NULL) {
@ -594,6 +598,13 @@ static aom_codec_err_t decoder_inspect(aom_codec_alg_priv_t *ctx,
if (ctx->frame_workers->had_error)
return update_error_state(ctx, &frame_worker_data->pbi->common.error);
// Allow extra zero bytes after the frame end
while (data < data_end) {
const uint8_t marker = data[0];
if (marker) break;
++data;
}
data2->idx = -1;
for (int i = 0; i < REF_FRAMES; ++i)
if (cm->ref_frame_map[i] == cm->cur_frame) data2->idx = i;
@ -629,7 +640,14 @@ static aom_codec_err_t decoder_decode(aom_codec_alg_priv_t *ctx,
}
pbi->num_output_frames = 0;
}
unlock_buffer_pool(ctx->buffer_pool);
unlock_buffer_pool(pool);
for (size_t j = 0; j < ctx->num_grain_image_frame_buffers; j++) {
pool->release_fb_cb(pool->cb_priv, &ctx->grain_image_frame_buffers[j]);
ctx->grain_image_frame_buffers[j].data = NULL;
ctx->grain_image_frame_buffers[j].size = 0;
ctx->grain_image_frame_buffers[j].priv = NULL;
}
ctx->num_grain_image_frame_buffers = 0;
}
/* Sanity checks */
@ -697,45 +715,50 @@ static aom_codec_err_t decoder_decode(aom_codec_alg_priv_t *ctx,
return res;
}
typedef struct {
BufferPool *pool;
aom_codec_frame_buffer_t *fb;
} AllocCbParam;
static void *AllocWithGetFrameBufferCb(void *priv, size_t size) {
AllocCbParam *param = (AllocCbParam *)priv;
if (param->pool->get_fb_cb(param->pool->cb_priv, size, param->fb) < 0)
return NULL;
if (param->fb->data == NULL || param->fb->size < size) return NULL;
return param->fb->data;
}
// If grain_params->apply_grain is false, returns img. Otherwise, adds film
// grain to img, saves the result in *grain_img_ptr (allocating *grain_img_ptr
// if necessary), and returns *grain_img_ptr.
static aom_image_t *add_grain_if_needed(aom_image_t *img,
aom_image_t **grain_img_ptr,
// grain to img, saves the result in grain_img, and returns grain_img.
static aom_image_t *add_grain_if_needed(aom_codec_alg_priv_t *ctx,
aom_image_t *img,
aom_image_t *grain_img,
aom_film_grain_t *grain_params) {
if (!grain_params->apply_grain) return img;
aom_image_t *grain_img_buf = *grain_img_ptr;
const int w_even = ALIGN_POWER_OF_TWO(img->d_w, 1);
const int h_even = ALIGN_POWER_OF_TWO(img->d_h, 1);
if (grain_img_buf) {
const int alloc_w = ALIGN_POWER_OF_TWO(grain_img_buf->d_w, 1);
const int alloc_h = ALIGN_POWER_OF_TWO(grain_img_buf->d_h, 1);
if (w_even != alloc_w || h_even != alloc_h ||
img->fmt != grain_img_buf->fmt) {
aom_img_free(grain_img_buf);
grain_img_buf = NULL;
*grain_img_ptr = NULL;
}
}
if (!grain_img_buf) {
grain_img_buf = aom_img_alloc(NULL, img->fmt, w_even, h_even, 16);
*grain_img_ptr = grain_img_buf;
BufferPool *const pool = ctx->buffer_pool;
aom_codec_frame_buffer_t *fb =
&ctx->grain_image_frame_buffers[ctx->num_grain_image_frame_buffers];
AllocCbParam param;
param.pool = pool;
param.fb = fb;
if (!aom_img_alloc_with_cb(grain_img, img->fmt, w_even, h_even, 16,
AllocWithGetFrameBufferCb, &param)) {
return NULL;
}
if (grain_img_buf) {
grain_img_buf->user_priv = img->user_priv;
grain_img_buf->fb_priv = img->fb_priv;
if (av1_add_film_grain(grain_params, img, grain_img_buf)) {
aom_img_free(grain_img_buf);
grain_img_buf = NULL;
*grain_img_ptr = NULL;
}
grain_img->user_priv = img->user_priv;
grain_img->fb_priv = fb->priv;
if (av1_add_film_grain(grain_params, img, grain_img)) {
pool->release_fb_cb(pool->cb_priv, fb);
return NULL;
}
return grain_img_buf;
ctx->num_grain_image_frame_buffers++;
return grain_img;
}
static aom_image_t *decoder_get_frame(aom_codec_alg_priv_t *ctx,
@ -752,7 +775,6 @@ static aom_image_t *decoder_get_frame(aom_codec_alg_priv_t *ctx,
if (ctx->frame_workers != NULL) {
do {
YV12_BUFFER_CONFIG *sd;
// NOTE(david.barker): This code does not support multiple worker threads
// yet. We should probably move the iteration over threads into *iter
// instead of using ctx->next_output_worker_id.
@ -771,6 +793,7 @@ static aom_image_t *decoder_get_frame(aom_codec_alg_priv_t *ctx,
frame_worker_data->received_frame = 0;
check_resync(ctx, frame_worker_data->pbi);
}
YV12_BUFFER_CONFIG *sd;
aom_film_grain_t *grain_params;
if (av1_get_raw_frame(frame_worker_data->pbi, *index, &sd,
&grain_params) == 0) {
@ -832,7 +855,7 @@ static aom_image_t *decoder_get_frame(aom_codec_alg_priv_t *ctx,
img->spatial_id = cm->spatial_layer_id;
if (cm->skip_film_grain) grain_params->apply_grain = 0;
aom_image_t *res = add_grain_if_needed(
img, &ctx->image_with_grain[*index], grain_params);
ctx, img, &ctx->image_with_grain, grain_params);
if (!res) {
aom_internal_error(&pbi->common.error, AOM_CODEC_CORRUPT_FRAME,
"Grain systhesis failed\n");

View file

@ -56,6 +56,7 @@ static void yuvconfig2image(aom_image_t *img, const YV12_BUFFER_CONFIG *yv12,
img->stride[AOM_PLANE_U] = yv12->uv_stride;
img->stride[AOM_PLANE_V] = yv12->uv_stride;
if (yv12->flags & YV12_FLAG_HIGHBITDEPTH) {
bps *= 2;
// aom_image_t uses byte strides and a pointer to the first byte
// of the image.
img->fmt = (aom_img_fmt_t)(img->fmt | AOM_IMG_FMT_HIGHBITDEPTH);
@ -73,6 +74,7 @@ static void yuvconfig2image(aom_image_t *img, const YV12_BUFFER_CONFIG *yv12,
img->img_data_owner = 0;
img->self_allocd = 0;
img->sz = yv12->frame_size;
img->metadata = yv12->metadata;
}
static aom_codec_err_t image2yuvconfig(const aom_image_t *img,
@ -132,6 +134,7 @@ static aom_codec_err_t image2yuvconfig(const aom_image_t *img,
yv12->border = (border < 0) ? 0 : border;
yv12->subsampling_x = img->x_chroma_shift;
yv12->subsampling_y = img->y_chroma_shift;
yv12->metadata = img->metadata;
return AOM_CODEC_OK;
}

View file

@ -31,60 +31,6 @@ int av1_get_MBs(int width, int height) {
return mb_rows * mb_cols;
}
#if LOOP_FILTER_BITMASK
static int alloc_loop_filter_mask(AV1_COMMON *cm) {
aom_free(cm->lf.lfm);
cm->lf.lfm = NULL;
// Each lfm holds bit masks for all the 4x4 blocks in a max
// 64x64 (128x128 for ext_partitions) region. The stride
// and rows are rounded up / truncated to a multiple of 16
// (32 for ext_partition).
cm->lf.lfm_stride = (cm->mi_cols + (MI_SIZE_64X64 - 1)) >> MIN_MIB_SIZE_LOG2;
cm->lf.lfm_num = ((cm->mi_rows + (MI_SIZE_64X64 - 1)) >> MIN_MIB_SIZE_LOG2) *
cm->lf.lfm_stride;
cm->lf.lfm =
(LoopFilterMask *)aom_calloc(cm->lf.lfm_num, sizeof(*cm->lf.lfm));
if (!cm->lf.lfm) return 1;
unsigned int i;
for (i = 0; i < cm->lf.lfm_num; ++i) av1_zero(cm->lf.lfm[i]);
return 0;
}
static void free_loop_filter_mask(AV1_COMMON *cm) {
if (cm->lf.lfm == NULL) return;
aom_free(cm->lf.lfm);
cm->lf.lfm = NULL;
cm->lf.lfm_num = 0;
cm->lf.lfm_stride = 0;
}
#endif
void av1_set_mb_mi(AV1_COMMON *cm, int width, int height) {
// Ensure that the decoded width and height are both multiples of
// 8 luma pixels (note: this may only be a multiple of 4 chroma pixels if
// subsampling is used).
// This simplifies the implementation of various experiments,
// eg. cdef, which operates on units of 8x8 luma pixels.
const int aligned_width = ALIGN_POWER_OF_TWO(width, 3);
const int aligned_height = ALIGN_POWER_OF_TWO(height, 3);
cm->mi_cols = aligned_width >> MI_SIZE_LOG2;
cm->mi_rows = aligned_height >> MI_SIZE_LOG2;
cm->mi_stride = calc_mi_size(cm->mi_cols);
cm->mb_cols = (cm->mi_cols + 2) >> 2;
cm->mb_rows = (cm->mi_rows + 2) >> 2;
cm->MBs = cm->mb_rows * cm->mb_cols;
#if LOOP_FILTER_BITMASK
alloc_loop_filter_mask(cm);
#endif
}
void av1_free_ref_frame_buffers(BufferPool *pool) {
int i;
@ -222,8 +168,8 @@ void av1_free_context_buffers(AV1_COMMON *cm) {
av1_free_above_context_buffers(cm, cm->num_allocated_above_contexts);
#if LOOP_FILTER_BITMASK
free_loop_filter_mask(cm);
#if CONFIG_LPF_MASK
av1_free_loop_filter_mask(cm);
#endif
}
@ -272,20 +218,15 @@ int av1_alloc_above_context_buffers(AV1_COMMON *cm,
}
int av1_alloc_context_buffers(AV1_COMMON *cm, int width, int height) {
int new_mi_size;
cm->set_mb_mi(cm, width, height);
av1_set_mb_mi(cm, width, height);
new_mi_size = cm->mi_stride * calc_mi_size(cm->mi_rows);
if (cm->mi_alloc_size < new_mi_size) {
cm->free_mi(cm);
if (cm->alloc_mi(cm, new_mi_size)) goto fail;
}
if (cm->alloc_mi(cm)) goto fail;
return 0;
fail:
// clear the mi_* values to force a realloc on resync
av1_set_mb_mi(cm, 0, 0);
cm->set_mb_mi(cm, 0, 0);
av1_free_context_buffers(cm);
return 1;
}
@ -300,3 +241,35 @@ void av1_remove_common(AV1_COMMON *cm) {
}
void av1_init_context_buffers(AV1_COMMON *cm) { cm->setup_mi(cm); }
#if CONFIG_LPF_MASK
int av1_alloc_loop_filter_mask(AV1_COMMON *cm) {
aom_free(cm->lf.lfm);
cm->lf.lfm = NULL;
// Each lfm holds bit masks for all the 4x4 blocks in a max
// 64x64 (128x128 for ext_partitions) region. The stride
// and rows are rounded up / truncated to a multiple of 16
// (32 for ext_partition).
cm->lf.lfm_stride = (cm->mi_cols + (MI_SIZE_64X64 - 1)) >> MIN_MIB_SIZE_LOG2;
cm->lf.lfm_num = ((cm->mi_rows + (MI_SIZE_64X64 - 1)) >> MIN_MIB_SIZE_LOG2) *
cm->lf.lfm_stride;
cm->lf.lfm =
(LoopFilterMask *)aom_calloc(cm->lf.lfm_num, sizeof(*cm->lf.lfm));
if (!cm->lf.lfm) return 1;
unsigned int i;
for (i = 0; i < cm->lf.lfm_num; ++i) av1_zero(cm->lf.lfm[i]);
return 0;
}
void av1_free_loop_filter_mask(AV1_COMMON *cm) {
if (cm->lf.lfm == NULL) return;
aom_free(cm->lf.lfm);
cm->lf.lfm = NULL;
cm->lf.lfm_num = 0;
cm->lf.lfm_stride = 0;
}
#endif

View file

@ -14,6 +14,8 @@
#define INVALID_IDX -1 // Invalid buffer index.
#include "config/aom_config.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -38,9 +40,13 @@ void av1_free_restoration_buffers(struct AV1Common *cm);
int av1_alloc_state_buffers(struct AV1Common *cm, int width, int height);
void av1_free_state_buffers(struct AV1Common *cm);
void av1_set_mb_mi(struct AV1Common *cm, int width, int height);
int av1_get_MBs(int width, int height);
#if CONFIG_LPF_MASK
int av1_alloc_loop_filter_mask(struct AV1Common *cm);
void av1_free_loop_filter_mask(struct AV1Common *cm);
#endif
#ifdef __cplusplus
} // extern "C"
#endif

File diff suppressed because it is too large Load diff

View file

@ -131,6 +131,7 @@ static void cfl_luma_subsampling_444_lbd_neon(const uint8_t *input,
} while ((pred_buf_q3 += CFL_BUF_LINE) < end);
}
#if CONFIG_AV1_HIGHBITDEPTH
#ifndef __aarch64__
uint16x8_t vpaddq_u16(uint16x8_t a, uint16x8_t b) {
return vcombine_u16(vpadd_u16(vget_low_u16(a), vget_high_u16(a)),
@ -247,6 +248,7 @@ static void cfl_luma_subsampling_444_hbd_neon(const uint16_t *input,
input += input_stride;
} while ((pred_buf_q3 += CFL_BUF_LINE) < end);
}
#endif // CONFIG_AV1_HIGHBITDEPTH
CFL_GET_SUBSAMPLE_FUNCTION(neon)
@ -511,6 +513,7 @@ static INLINE void cfl_predict_lbd_neon(const int16_t *pred_buf_q3,
CFL_PREDICT_FN(neon, lbd)
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE uint16x4_t clamp_s16(int16x4_t a, int16x4_t max) {
return vreinterpret_u16_s16(vmax_s16(vmin_s16(a, max), vdup_n_s16(0)));
}
@ -582,3 +585,4 @@ static INLINE void cfl_predict_hbd_neon(const int16_t *pred_buf_q3,
}
CFL_PREDICT_FN(neon, hbd)
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -195,12 +195,12 @@ void av1_convolve_x_sr_neon(const uint8_t *src, int src_stride, uint8_t *dst,
int dst_stride, int w, int h,
const InterpFilterParams *filter_params_x,
const InterpFilterParams *filter_params_y,
const int subpel_x_q4, const int subpel_y_q4,
const int subpel_x_qn, const int subpel_y_qn,
ConvolveParams *conv_params) {
const uint8_t horiz_offset = filter_params_x->taps / 2 - 1;
const int8_t bits = FILTER_BITS - conv_params->round_0;
(void)subpel_y_q4;
(void)subpel_y_qn;
(void)conv_params;
(void)filter_params_y;
@ -214,7 +214,7 @@ void av1_convolve_x_sr_neon(const uint8_t *src, int src_stride, uint8_t *dst,
((conv_params->round_0 + conv_params->round_1) == 2 * FILTER_BITS));
const int16_t *x_filter = av1_get_interp_filter_subpel_kernel(
filter_params_x, subpel_x_q4 & SUBPEL_MASK);
filter_params_x, subpel_x_qn & SUBPEL_MASK);
const int16x8_t shift_round_0 = vdupq_n_s16(-conv_params->round_0);
const int16x8_t shift_by_bits = vdupq_n_s16(-bits);
@ -603,14 +603,14 @@ void av1_convolve_y_sr_neon(const uint8_t *src, int src_stride, uint8_t *dst,
int dst_stride, int w, int h,
const InterpFilterParams *filter_params_x,
const InterpFilterParams *filter_params_y,
const int subpel_x_q4, const int subpel_y_q4,
const int subpel_x_qn, const int subpel_y_qn,
ConvolveParams *conv_params) {
const int vert_offset = filter_params_y->taps / 2 - 1;
src -= vert_offset * src_stride;
(void)filter_params_x;
(void)subpel_x_q4;
(void)subpel_x_qn;
(void)conv_params;
assert(conv_params->round_0 <= FILTER_BITS);
@ -618,7 +618,7 @@ void av1_convolve_y_sr_neon(const uint8_t *src, int src_stride, uint8_t *dst,
((conv_params->round_0 + conv_params->round_1) == (2 * FILTER_BITS)));
const int16_t *y_filter = av1_get_interp_filter_subpel_kernel(
filter_params_y, subpel_y_q4 & SUBPEL_MASK);
filter_params_y, subpel_y_qn & SUBPEL_MASK);
if (w <= 4) {
uint8x8_t d01;
@ -848,7 +848,7 @@ void av1_convolve_2d_sr_neon(const uint8_t *src, int src_stride, uint8_t *dst,
int dst_stride, int w, int h,
const InterpFilterParams *filter_params_x,
const InterpFilterParams *filter_params_y,
const int subpel_x_q4, const int subpel_y_q4,
const int subpel_x_qn, const int subpel_y_qn,
ConvolveParams *conv_params) {
int im_dst_stride;
int width, height;
@ -880,7 +880,7 @@ void av1_convolve_2d_sr_neon(const uint8_t *src, int src_stride, uint8_t *dst,
const int16x8_t vec_round_bits = vdupq_n_s16(-round_bits);
const int offset_bits = bd + 2 * FILTER_BITS - conv_params->round_0;
const int16_t *x_filter = av1_get_interp_filter_subpel_kernel(
filter_params_x, subpel_x_q4 & SUBPEL_MASK);
filter_params_x, subpel_x_qn & SUBPEL_MASK);
int16_t x_filter_tmp[8];
int16x8_t filter_x_coef = vld1q_s16(x_filter);
@ -1149,7 +1149,7 @@ void av1_convolve_2d_sr_neon(const uint8_t *src, int src_stride, uint8_t *dst,
const int32_t sub_const = (1 << (offset_bits - conv_params->round_1)) +
(1 << (offset_bits - conv_params->round_1 - 1));
const int16_t *y_filter = av1_get_interp_filter_subpel_kernel(
filter_params_y, subpel_y_q4 & SUBPEL_MASK);
filter_params_y, subpel_y_qn & SUBPEL_MASK);
const int32x4_t round_shift_vec = vdupq_n_s32(-(conv_params->round_1));
const int32x4_t offset_const = vdupq_n_s32(1 << offset_bits);
@ -1409,12 +1409,12 @@ void av1_convolve_2d_copy_sr_neon(const uint8_t *src, int src_stride,
uint8_t *dst, int dst_stride, int w, int h,
const InterpFilterParams *filter_params_x,
const InterpFilterParams *filter_params_y,
const int subpel_x_q4, const int subpel_y_q4,
const int subpel_x_qn, const int subpel_y_qn,
ConvolveParams *conv_params) {
(void)filter_params_x;
(void)filter_params_y;
(void)subpel_x_q4;
(void)subpel_y_q4;
(void)subpel_x_qn;
(void)subpel_y_qn;
(void)conv_params;
const uint8_t *src1;

View file

@ -73,7 +73,7 @@ static INLINE uint16x8_t wiener_convolve8_horiz_8x8(
int32x4_t sum_0, sum_1;
int32x4_t s3_0, s3_1;
const int32_t round_const_0 = (1 << (bd + FILTER_BITS - 1));
const int32_t round_const_1 = (1 << ((bd) + 1 + FILTER_BITS - round0_bits));
const int32_t round_const_1 = (1 << (bd + 1 + FILTER_BITS - round0_bits)) - 1;
/* for the purpose of right shift by { conv_params->round_0 } */
const int32x4_t round_bits = vdupq_n_s32(-round0_bits);
@ -124,7 +124,7 @@ static INLINE uint16x4_t wiener_convolve8_horiz_4x8(
int16x4_t sum, temp0, temp1, temp2;
const int32_t round_const_0 = (1 << (bd + FILTER_BITS - 1));
const int32_t round_const_1 = (1 << ((bd) + 1 + FILTER_BITS - round0_bits));
const int32_t round_const_1 = (1 << (bd + 1 + FILTER_BITS - round0_bits)) - 1;
const int32x4_t round_bits = vdupq_n_s32(-round0_bits);
const int32x4_t zero = vdupq_n_s32(0);
const int32x4_t round_vec_0 = vdupq_n_s32(round_const_0);

View file

@ -717,7 +717,7 @@ void av1_dist_wtd_convolve_2d_neon(const uint8_t *src, int src_stride,
uint8_t *dst8, int dst8_stride, int w, int h,
const InterpFilterParams *filter_params_x,
const InterpFilterParams *filter_params_y,
const int subpel_x_q4, const int subpel_y_q4,
const int subpel_x_qn, const int subpel_y_qn,
ConvolveParams *conv_params) {
assert(!(w % 4));
assert(!(h % 4));
@ -732,9 +732,9 @@ void av1_dist_wtd_convolve_2d_neon(const uint8_t *src, int src_stride,
const int round_0 = conv_params->round_0 - 1;
const uint8_t *src_ptr = src - vert_offset * src_stride - horiz_offset;
const int16_t *x_filter = av1_get_interp_filter_subpel_kernel(
filter_params_x, subpel_x_q4 & SUBPEL_MASK);
filter_params_x, subpel_x_qn & SUBPEL_MASK);
const int16_t *y_filter = av1_get_interp_filter_subpel_kernel(
filter_params_y, subpel_y_q4 & SUBPEL_MASK);
filter_params_y, subpel_y_qn & SUBPEL_MASK);
int16_t x_filter_tmp[8];
int16x8_t filter_x_coef = vld1q_s16(x_filter);
@ -754,8 +754,8 @@ void av1_dist_wtd_convolve_2d_neon(const uint8_t *src, int src_stride,
void av1_dist_wtd_convolve_2d_copy_neon(
const uint8_t *src, int src_stride, uint8_t *dst8, int dst8_stride, int w,
int h, const InterpFilterParams *filter_params_x,
const InterpFilterParams *filter_params_y, const int subpel_x_q4,
const int subpel_y_q4, ConvolveParams *conv_params) {
const InterpFilterParams *filter_params_y, const int subpel_x_qn,
const int subpel_y_qn, ConvolveParams *conv_params) {
uint8x8_t res0_8, res1_8, res2_8, res3_8, tmp_shift0, tmp_shift1, tmp_shift2,
tmp_shift3;
uint16x8_t res_q0, res_q1, res_q2, res_q3, tmp_q0, tmp_q1, tmp_q2, tmp_q3;
@ -778,8 +778,8 @@ void av1_dist_wtd_convolve_2d_copy_neon(
(void)filter_params_x;
(void)filter_params_y;
(void)subpel_x_q4;
(void)subpel_y_q4;
(void)subpel_x_qn;
(void)subpel_y_qn;
if (!(w & 0x07)) {
for (y = 0; y < (h >> 2); ++y) {
@ -880,7 +880,7 @@ void av1_dist_wtd_convolve_x_neon(const uint8_t *src, int src_stride,
uint8_t *dst8, int dst8_stride, int w, int h,
const InterpFilterParams *filter_params_x,
const InterpFilterParams *filter_params_y,
const int subpel_x_q4, const int subpel_y_q4,
const int subpel_x_qn, const int subpel_y_qn,
ConvolveParams *conv_params) {
assert(!(w % 4));
assert(!(h % 4));
@ -900,11 +900,11 @@ void av1_dist_wtd_convolve_x_neon(const uint8_t *src, int src_stride,
const int use_dist_wtd_comp_avg = conv_params->use_dist_wtd_comp_avg;
(void)filter_params_y;
(void)subpel_y_q4;
(void)subpel_y_qn;
// horizontal filter
const int16_t *x_filter = av1_get_interp_filter_subpel_kernel(
filter_params_x, subpel_x_q4 & SUBPEL_MASK);
filter_params_x, subpel_x_qn & SUBPEL_MASK);
const uint8_t *src_ptr = src - horiz_offset;
@ -1343,7 +1343,7 @@ void av1_dist_wtd_convolve_y_neon(const uint8_t *src, int src_stride,
uint8_t *dst8, int dst8_stride, int w, int h,
const InterpFilterParams *filter_params_x,
const InterpFilterParams *filter_params_y,
const int subpel_x_q4, const int subpel_y_q4,
const int subpel_x_qn, const int subpel_y_qn,
ConvolveParams *conv_params) {
assert(!(w % 4));
assert(!(h % 4));
@ -1364,11 +1364,11 @@ void av1_dist_wtd_convolve_y_neon(const uint8_t *src, int src_stride,
const int shift_value = (conv_params->round_1 - 1 - bits);
(void)filter_params_x;
(void)subpel_x_q4;
(void)subpel_x_qn;
// vertical filter
const int16_t *y_filter = av1_get_interp_filter_subpel_kernel(
filter_params_y, subpel_y_q4 & SUBPEL_MASK);
filter_params_y, subpel_y_qn & SUBPEL_MASK);
const uint8_t *src_ptr = src - (vert_offset * src_stride);

Some files were not shown because too many files have changed in this diff Show more