Merge branch 'sao-avx2'

This commit is contained in:
Ari Lemmetti 2016-03-16 20:19:56 +02:00
commit c950e7c8ad
13 changed files with 773 additions and 158 deletions

View file

@ -163,8 +163,15 @@
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
</ClCompile>
<ClCompile Include="..\..\src\strategies\avx2\sao-avx2.c">
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
</ClCompile>
<ClCompile Include="..\..\src\strategies\generic\intra-generic.c" />
<ClCompile Include="..\..\src\strategies\generic\quant-generic.c" />
<ClCompile Include="..\..\src\strategies\generic\sao-generic.c" />
<ClCompile Include="..\..\src\strategies\strategies-intra.c" />
<ClCompile Include="..\..\src\strategies\strategies-quant.c" />
<ClInclude Include="..\..\src\checkpoint.h" />
@ -200,6 +207,7 @@
<ClCompile Include="..\..\src\strategies\strategies-ipol.c" />
<ClCompile Include="..\..\src\strategies\strategies-nal.c" />
<ClCompile Include="..\..\src\strategies\strategies-picture.c" />
<ClCompile Include="..\..\src\strategies\strategies-sao.c" />
<ClCompile Include="..\..\src\strategies\x86_asm\picture-x86-asm.c" />
<ClCompile Include="..\..\src\videoframe.c" />
<ClInclude Include="..\..\src\encoder_state-bitstream.h" />
@ -215,7 +223,9 @@
<ClInclude Include="..\..\src\search_inter.h" />
<ClInclude Include="..\..\src\search_intra.h" />
<ClInclude Include="..\..\src\strategies\avx2\intra-avx2.h" />
<ClInclude Include="..\..\src\strategies\avx2\sao-avx2.h" />
<ClInclude Include="..\..\src\strategies\generic\intra-generic.h" />
<ClInclude Include="..\..\src\strategies\generic\sao-generic.h" />
<ClInclude Include="..\..\src\strategies\strategies-common.h" />
<ClInclude Include="..\..\src\strategies\avx2\quant-avx2.h" />
<ClInclude Include="..\..\src\strategies\generic\quant-generic.h" />
@ -255,6 +265,7 @@
<ClInclude Include="..\..\src\strategies\strategies-ipol.h" />
<ClInclude Include="..\..\src\strategies\strategies-nal.h" />
<ClInclude Include="..\..\src\strategies\strategies-picture.h" />
<ClInclude Include="..\..\src\strategies\strategies-sao.h" />
<ClInclude Include="..\..\src\strategies\x86_asm\picture-x86-asm-sad.h" />
<ClInclude Include="..\..\src\strategies\x86_asm\picture-x86-asm-satd.h" />
<ClInclude Include="..\..\src\strategies\x86_asm\picture-x86-asm.h" />

View file

@ -207,6 +207,15 @@
<ClCompile Include="..\..\src\encoder_state-bitstream.c">
<Filter>Bitstream</Filter>
</ClCompile>
<ClCompile Include="..\..\src\strategies\strategies-sao.c">
<Filter>Optimization\strategies</Filter>
</ClCompile>
<ClCompile Include="..\..\src\strategies\generic\sao-generic.c">
<Filter>Optimization\strategies\generic</Filter>
</ClCompile>
<ClCompile Include="..\..\src\strategies\avx2\sao-avx2.c">
<Filter>Optimization\strategies\avx2</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\bitstream.h">
@ -383,6 +392,15 @@
<Filter>Bitstream</Filter>
</ClInclude>
<ClInclude Include="..\..\src\kvz_math.h" />
<ClInclude Include="..\..\src\strategies\strategies-sao.h">
<Filter>Optimization\strategies</Filter>
</ClInclude>
<ClInclude Include="..\..\src\strategies\generic\sao-generic.h">
<Filter>Optimization\strategies\generic</Filter>
</ClInclude>
<ClInclude Include="..\..\src\strategies\avx2\sao-avx2.h">
<Filter>Optimization\strategies\avx2</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<YASM Include="..\..\src\extras\x86inc.asm">

View file

@ -109,6 +109,8 @@ libkvazaar_la_SOURCES = \
strategies/generic/picture-generic.h \
strategies/generic/quant-generic.c \
strategies/generic/quant-generic.h \
strategies/generic/sao-generic.c \
strategies/generic/sao-generic.h \
strategies/strategies-common.h \
strategies/strategies-dct.c \
strategies/strategies-dct.h \
@ -122,6 +124,8 @@ libkvazaar_la_SOURCES = \
strategies/strategies-picture.h \
strategies/strategies-quant.c \
strategies/strategies-quant.h \
strategies/strategies-sao.c \
strategies/strategies-sao.h \
strategies/x86_asm/picture-x86-asm.c \
strategies/x86_asm/picture-x86-asm.h \
strategyselector.c \
@ -150,7 +154,10 @@ libavx2_la_SOURCES = \
strategies/avx2/picture-avx2.c \
strategies/avx2/picture-avx2.h \
strategies/avx2/quant-avx2.c \
strategies/avx2/quant-avx2.h
strategies/avx2/quant-avx2.h \
strategies/avx2/sao-avx2.c \
strategies/avx2/sao-avx2.h
libsse2_la_SOURCES = \
strategies/sse2/picture-sse2.c \

161
src/sao.c
View file

@ -21,93 +21,12 @@
#include "sao.h"
#include "rdo.h"
#include "strategies/strategies-picture.h"
#include "strategies/strategies-sao.h"
#include <string.h>
#include <stdlib.h>
#include <assert.h>
// Offsets of a and b in relation to c.
// dir_offset[dir][a or b]
// | | a | a | a |
// | a c b | c | c | c |
// | | b | b | b |
static const vector2d_t g_sao_edge_offsets[SAO_NUM_EO][2] = {
{ { -1, 0 }, { 1, 0 } },
{ { 0, -1 }, { 0, 1 } },
{ { -1, -1 }, { 1, 1 } },
{ { 1, -1 }, { -1, 1 } }
};
// Mapping of edge_idx values to eo-classes.
static int sao_calc_eo_cat(kvz_pixel a, kvz_pixel b, kvz_pixel c)
{
// Mapping relationships between a, b and c to eo_idx.
static const int sao_eo_idx_to_eo_category[] = { 1, 2, 0, 3, 4 };
int eo_idx = 2 + SIGN3((int)c - (int)a) + SIGN3((int)c - (int)b);
return sao_eo_idx_to_eo_category[eo_idx];
}
int kvz_sao_band_ddistortion(const encoder_state_t * const state, const kvz_pixel *orig_data, const kvz_pixel *rec_data,
int block_width, int block_height,
int band_pos, int sao_bands[4])
{
int y, x;
int shift = state->encoder_control->bitdepth-5;
int sum = 0;
for (y = 0; y < block_height; ++y) {
for (x = 0; x < block_width; ++x) {
int band = (rec_data[y * block_width + x] >> shift) - band_pos;
int offset = 0;
if (band >= 0 && band < 4) {
offset = sao_bands[band];
}
if (offset != 0) {
int diff = orig_data[y * block_width + x] - rec_data[y * block_width + x];
// Offset is applied to reconstruction, so it is subtracted from diff.
sum += (diff - offset) * (diff - offset) - diff * diff;
}
}
}
return sum;
}
int kvz_sao_edge_ddistortion(const kvz_pixel *orig_data, const kvz_pixel *rec_data,
int block_width, int block_height,
int eo_class, int offsets[NUM_SAO_EDGE_CATEGORIES])
{
int y, x;
int sum = 0;
vector2d_t a_ofs = g_sao_edge_offsets[eo_class][0];
vector2d_t b_ofs = g_sao_edge_offsets[eo_class][1];
for (y = 1; y < block_height - 1; ++y) {
for (x = 1; x < block_width - 1; ++x) {
const kvz_pixel *c_data = &rec_data[y * block_width + x];
kvz_pixel a = c_data[a_ofs.y * block_width + a_ofs.x];
kvz_pixel c = c_data[0];
kvz_pixel b = c_data[b_ofs.y * block_width + b_ofs.x];
int offset = offsets[sao_calc_eo_cat(a, b, c)];
if (offset != 0) {
int diff = orig_data[y * block_width + x] - c;
// Offset is applied to reconstruction, so it is subtracted from diff.
sum += (diff - offset) * (diff - offset) - diff * diff;
}
}
}
return sum;
}
static void init_sao_info(sao_info_t *sao) {
sao->type = SAO_TYPE_NONE;
@ -240,7 +159,7 @@ static float sao_mode_bits_band(const encoder_state_t * const state,
/**
* \brief calculate an array of intensity correlations for each intensity value
*/
static void calc_sao_offset_array(const encoder_control_t * const encoder, const sao_info_t *sao, int *offset, color_t color_i)
void kvz_calc_sao_offset_array(const encoder_control_t * const encoder, const sao_info_t *sao, int *offset, color_t color_i)
{
int val;
int values = (1<<encoder->bitdepth);
@ -340,78 +259,6 @@ static void calc_sao_bands(const encoder_state_t * const state, const kvz_pixel
}
/**
* \param orig_data Original pixel data. 64x64 for luma, 32x32 for chroma.
* \param rec_data Reconstructed pixel data. 64x64 for luma, 32x32 for chroma.
* \param dir_offsets
* \param is_chroma 0 for luma, 1 for chroma. Indicates
*/
static void calc_sao_edge_dir(const kvz_pixel *orig_data, const kvz_pixel *rec_data,
int eo_class, int block_width, int block_height,
int cat_sum_cnt[2][NUM_SAO_EDGE_CATEGORIES])
{
int y, x;
vector2d_t a_ofs = g_sao_edge_offsets[eo_class][0];
vector2d_t b_ofs = g_sao_edge_offsets[eo_class][1];
// Arrays orig_data and rec_data are quarter size for chroma.
// Don't sample the edge pixels because this function doesn't have access to
// their neighbours.
for (y = 1; y < block_height - 1; ++y) {
for (x = 1; x < block_width - 1; ++x) {
const kvz_pixel *c_data = &rec_data[y * block_width + x];
kvz_pixel a = c_data[a_ofs.y * block_width + a_ofs.x];
kvz_pixel c = c_data[0];
kvz_pixel b = c_data[b_ofs.y * block_width + b_ofs.x];
int eo_cat = sao_calc_eo_cat(a, b, c);
cat_sum_cnt[0][eo_cat] += orig_data[y * block_width + x] - c;
cat_sum_cnt[1][eo_cat] += 1;
}
}
}
static void sao_reconstruct_color(const encoder_control_t * const encoder,
const kvz_pixel *rec_data, kvz_pixel *new_rec_data,
const sao_info_t *sao,
int stride, int new_stride,
int block_width, int block_height,
color_t color_i)
{
int y, x;
// Arrays orig_data and rec_data are quarter size for chroma.
int offset_v = color_i == COLOR_V ? 5 : 0;
if(sao->type == SAO_TYPE_BAND) {
int offsets[1<<KVZ_BIT_DEPTH];
calc_sao_offset_array(encoder, sao, offsets, color_i);
for (y = 0; y < block_height; ++y) {
for (x = 0; x < block_width; ++x) {
new_rec_data[y * new_stride + x] = offsets[rec_data[y * stride + x]];
}
}
} else {
// Don't sample the edge pixels because this function doesn't have access to
// their neighbours.
for (y = 0; y < block_height; ++y) {
for (x = 0; x < block_width; ++x) {
vector2d_t a_ofs = g_sao_edge_offsets[sao->eo_class][0];
vector2d_t b_ofs = g_sao_edge_offsets[sao->eo_class][1];
const kvz_pixel *c_data = &rec_data[y * stride + x];
kvz_pixel *new_data = &new_rec_data[y * new_stride + x];
kvz_pixel a = c_data[a_ofs.y * stride + a_ofs.x];
kvz_pixel c = c_data[0];
kvz_pixel b = c_data[b_ofs.y * stride + b_ofs.x];
int eo_cat = sao_calc_eo_cat(a, b, c);
new_data[0] = (kvz_pixel)CLIP(0, (1 << KVZ_BIT_DEPTH) - 1, c_data[0] + sao->offsets[eo_cat + offset_v]);
}
}
}
}
/**
* \brief Calculate dimensions of the buffer used by sao reconstruction.
@ -575,7 +422,7 @@ void kvz_sao_reconstruct(const encoder_control_t * const encoder, videoframe_t *
tl.y + block.y + br.y,
pic_stride, buf_stride);
sao_reconstruct_color(encoder, &buf_rec[tl.y * buf_stride + tl.x],
kvz_sao_reconstruct_color(encoder, &buf_rec[tl.y * buf_stride + tl.x],
&new_rec[(ofs.y + tl.y) * lcu_stride + ofs.x + tl.x],
sao,
buf_stride, lcu_stride,
@ -613,7 +460,7 @@ static void sao_search_edge_sao(const encoder_state_t * const state,
// Call calc_sao_edge_dir once for luma and twice for chroma.
for (i = 0; i < buf_cnt; ++i) {
FILL(cat_sum_cnt, 0);
calc_sao_edge_dir(data[i], recdata[i], edge_class,
kvz_calc_sao_edge_dir(data[i], recdata[i], edge_class,
block_width, block_height, cat_sum_cnt);

View file

@ -50,6 +50,20 @@ typedef struct sao_info_t {
int offsets[NUM_SAO_EDGE_CATEGORIES * 2];
} sao_info_t;
// Offsets of a and b in relation to c.
// dir_offset[dir][a or b]
// | | a | a | a |
// | a c b | c | c | c |
// | | b | b | b |
static const vector2d_t g_sao_edge_offsets[SAO_NUM_EO][2] = {
{ { -1, 0 }, { 1, 0 } },
{ { 0, -1 }, { 0, 1 } },
{ { -1, -1 }, { 1, 1 } },
{ { 1, -1 }, { -1, 1 } }
};
#define CHECKPOINT_SAO_INFO(prefix_str, sao) CHECKPOINT(prefix_str " type=%d eo_class=%d ddistortion=%d " \
"merge_left_flag=%d merge_up_flag=%d band_position=%d " \
"offsets[0]=%d offsets[1]=%d offsets[2]=%d offsets[3]=%d offsets[4]=%d", \
@ -63,5 +77,6 @@ void kvz_sao_reconstruct(const encoder_control_t * encoder, videoframe_t *frame,
const sao_info_t *sao, color_t color_i);
void kvz_sao_reconstruct_frame(encoder_state_t *state);
void kvz_sao_search_lcu(const encoder_state_t* const state, int lcu_x, int lcu_y);
void kvz_calc_sao_offset_array(const encoder_control_t * const encoder, const sao_info_t *sao, int *offset, color_t color_i);
#endif

View file

@ -0,0 +1,346 @@
/*****************************************************************************
* This file is part of Kvazaar HEVC encoder.
*
* Copyright (C) 2013-2015 Tampere University of Technology and others (see
* COPYING file).
*
* Kvazaar is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* Kvazaar is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with Kvazaar. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <stdlib.h>
#include "sao-avx2.h"
#include "sao.h"
#include "strategyselector.h"
#include "rdo.h"
#include "strategies/strategies-common.h"
#if COMPILE_INTEL_AVX2
#include <immintrin.h>
// These optimizations are based heavily on sao-generic.c.
// Might be useful to check that if (when) this file
// is difficult to understand.
static INLINE __m256i load_6_offsets(const int* offsets){
return _mm256_inserti128_si256(_mm256_castsi128_si256(_mm_loadu_si128((__m128i*) offsets)), _mm_loadl_epi64((__m128i*)&(offsets[4])), 1);
}
static INLINE __m128i load_6_pixels(const kvz_pixel* data){
return _mm_insert_epi16(_mm_cvtsi32_si128(*(int32_t*)&(data[0])), *(int16_t*)&(data[4]), 2);
}
static INLINE __m256i load_5_offsets(const int* offsets){
return _mm256_inserti128_si256(_mm256_castsi128_si256(_mm_loadu_si128((__m128i*) offsets)), _mm_insert_epi32(_mm_setzero_si128(), offsets[4], 0), 1);
}
static __m128i sao_calc_eo_cat_avx2(__m128i* a, __m128i* b, __m128i* c)
{
__m128i v_eo_idx = _mm_set1_epi16(2);
__m128i v_a = _mm_cvtepu8_epi16(*a);
__m128i v_c = _mm_cvtepu8_epi16(*c);
__m128i v_b = _mm_cvtepu8_epi16(*b);
__m128i temp_a = _mm_sign_epi16(_mm_set1_epi16(1), _mm_sub_epi16(v_c, v_a));
__m128i temp_b = _mm_sign_epi16(_mm_set1_epi16(1), _mm_sub_epi16(v_c, v_b));
v_eo_idx = _mm_add_epi16(v_eo_idx, temp_a);
v_eo_idx = _mm_add_epi16(v_eo_idx, temp_b);
v_eo_idx = _mm_packus_epi16(v_eo_idx, v_eo_idx);
__m128i v_cat_lookup = _mm_setr_epi8(1,2,0,3,4,0,0,0,0,0,0,0,0,0,0,0);
__m128i v_cat = _mm_shuffle_epi8(v_cat_lookup, v_eo_idx);
return v_cat;
}
int kvz_sao_edge_ddistortion_avx2(const kvz_pixel *orig_data, const kvz_pixel *rec_data,
int block_width, int block_height,
int eo_class, int offsets[NUM_SAO_EDGE_CATEGORIES])
{
int y, x;
int sum = 0;
vector2d_t a_ofs = g_sao_edge_offsets[eo_class][0];
vector2d_t b_ofs = g_sao_edge_offsets[eo_class][1];
__m256i v_accum = { 0 };
for (y = 1; y < block_height - 1; ++y) {
for (x = 1; x < block_width - 8; x+=8) {
const kvz_pixel *c_data = &rec_data[y * block_width + x];
__m128i v_c_data = _mm_loadl_epi64((__m128i*)c_data);
__m128i v_a = _mm_loadl_epi64((__m128i*)(&c_data[a_ofs.y * block_width + a_ofs.x]));
__m128i v_c = v_c_data;
__m128i v_b = _mm_loadl_epi64((__m128i*)(&c_data[b_ofs.y * block_width + b_ofs.x]));
__m256i v_cat = _mm256_cvtepu8_epi32(sao_calc_eo_cat_avx2(&v_a, &v_b, &v_c));
__m256i v_offset = _mm256_loadu_si256((__m256i*) offsets);
v_offset = _mm256_permutevar8x32_epi32(v_offset, v_cat);
__m256i v_diff = _mm256_cvtepu8_epi32(_mm_loadl_epi64((__m128i*)&(orig_data[y * block_width + x])));
v_diff = _mm256_sub_epi32(v_diff, _mm256_cvtepu8_epi32(v_c));
__m256i v_diff_minus_offset = _mm256_sub_epi32(v_diff, v_offset);
__m256i v_temp_sum = _mm256_sub_epi32(_mm256_mullo_epi32(v_diff_minus_offset, v_diff_minus_offset), _mm256_mullo_epi32(v_diff, v_diff));
v_accum = _mm256_add_epi32(v_accum, v_temp_sum);
}
//Handle last 6 pixels separately to prevent reading over boundary
const kvz_pixel *c_data = &rec_data[y * block_width + x];
__m128i v_c_data = load_6_pixels(c_data);
const kvz_pixel* a_ptr = &c_data[a_ofs.y * block_width + a_ofs.x];
const kvz_pixel* b_ptr = &c_data[b_ofs.y * block_width + b_ofs.x];
__m128i v_a = load_6_pixels(a_ptr);
__m128i v_c = v_c_data;
__m128i v_b = load_6_pixels(b_ptr);
__m256i v_cat = _mm256_cvtepu8_epi32(sao_calc_eo_cat_avx2(&v_a, &v_b, &v_c));
__m256i v_offset = load_6_offsets(offsets);
v_offset = _mm256_permutevar8x32_epi32(v_offset, v_cat);
const kvz_pixel* orig_ptr = &(orig_data[y * block_width + x]);
__m256i v_diff = _mm256_cvtepu8_epi32(load_6_pixels(orig_ptr));
v_diff = _mm256_sub_epi32(v_diff, _mm256_cvtepu8_epi32(v_c));
__m256i v_diff_minus_offset = _mm256_sub_epi32(v_diff, v_offset);
__m256i v_temp_sum = _mm256_sub_epi32(_mm256_mullo_epi32(v_diff_minus_offset, v_diff_minus_offset), _mm256_mullo_epi32(v_diff, v_diff));
v_accum = _mm256_add_epi32(v_accum, v_temp_sum);
}
//Full horizontal sum
v_accum = _mm256_add_epi32(v_accum, _mm256_castsi128_si256(_mm256_extracti128_si256(v_accum, 1)));
v_accum = _mm256_add_epi32(v_accum, _mm256_shuffle_epi32(v_accum, KVZ_PERMUTE(2, 3, 0, 1)));
v_accum = _mm256_add_epi32(v_accum, _mm256_shuffle_epi32(v_accum, KVZ_PERMUTE(1, 0, 1, 0)));
sum += _mm_cvtsi128_si32(_mm256_castsi256_si128(v_accum));
return sum;
}
static INLINE void accum_count_eo_cat_avx2(__m256i* __restrict v_diff_accum, __m256i* __restrict v_count, __m256i* __restrict v_cat, __m256i* __restrict v_diff, int eo_cat){
__m256i v_mask = _mm256_cmpeq_epi32(*v_cat, _mm256_set1_epi32(eo_cat));
*v_diff_accum = _mm256_add_epi32(*v_diff_accum, _mm256_and_si256(*v_diff, v_mask));
*v_count = _mm256_sub_epi32(*v_count, v_mask);
}
#define ACCUM_COUNT_EO_CAT_AVX2(EO_CAT, V_CAT) \
\
accum_count_eo_cat_avx2(&(v_diff_accum[ EO_CAT ]), &(v_count[ EO_CAT ]), &V_CAT , &v_diff, EO_CAT);
void kvz_calc_sao_edge_dir_avx2(const kvz_pixel *orig_data, const kvz_pixel *rec_data,
int eo_class, int block_width, int block_height,
int cat_sum_cnt[2][NUM_SAO_EDGE_CATEGORIES])
{
int y, x;
vector2d_t a_ofs = g_sao_edge_offsets[eo_class][0];
vector2d_t b_ofs = g_sao_edge_offsets[eo_class][1];
// Don't sample the edge pixels because this function doesn't have access to
// their neighbours.
__m256i v_diff_accum[NUM_SAO_EDGE_CATEGORIES] = { { 0 } };
__m256i v_count[NUM_SAO_EDGE_CATEGORIES] = { { 0 } };
for (y = 1; y < block_height - 1; ++y) {
//Calculation for 8 pixels per round
for (x = 1; x < block_width - 8; x += 8) {
const kvz_pixel *c_data = &rec_data[y * block_width + x];
__m128i v_c_data = _mm_loadl_epi64((__m128i* __restrict)c_data);
__m128i v_a = _mm_loadl_epi64((__m128i* __restrict)(&c_data[a_ofs.y * block_width + a_ofs.x]));
__m128i v_c = v_c_data;
__m128i v_b = _mm_loadl_epi64((__m128i* __restrict)(&c_data[b_ofs.y * block_width + b_ofs.x]));
__m256i v_cat = _mm256_cvtepu8_epi32(sao_calc_eo_cat_avx2(&v_a, &v_b, &v_c));
__m256i v_diff = _mm256_cvtepu8_epi32(_mm_loadl_epi64((__m128i* __restrict)&(orig_data[y * block_width + x])));
v_diff = _mm256_sub_epi32(v_diff, _mm256_cvtepu8_epi32(v_c));
//Accumulate differences and occurrences for each category
ACCUM_COUNT_EO_CAT_AVX2(SAO_EO_CAT0, v_cat);
ACCUM_COUNT_EO_CAT_AVX2(SAO_EO_CAT1, v_cat);
ACCUM_COUNT_EO_CAT_AVX2(SAO_EO_CAT2, v_cat);
ACCUM_COUNT_EO_CAT_AVX2(SAO_EO_CAT3, v_cat);
ACCUM_COUNT_EO_CAT_AVX2(SAO_EO_CAT4, v_cat);
}
//Handle last 6 pixels separately to prevent reading over boundary
const kvz_pixel *c_data = &rec_data[y * block_width + x];
__m128i v_c_data = load_6_pixels(c_data);
const kvz_pixel* a_ptr = &c_data[a_ofs.y * block_width + a_ofs.x];
const kvz_pixel* b_ptr = &c_data[b_ofs.y * block_width + b_ofs.x];
__m128i v_a = load_6_pixels(a_ptr);
__m128i v_c = v_c_data;
__m128i v_b = load_6_pixels(b_ptr);
__m256i v_cat = _mm256_cvtepu8_epi32(sao_calc_eo_cat_avx2(&v_a, &v_b, &v_c));
//Set the last two elements to a non-existing category to cause
//the accumulate-count macro to discard those values.
__m256i v_mask = _mm256_setr_epi32(0, 0, 0, 0, 0, 0, -1, -1);
v_cat = _mm256_or_si256(v_cat, v_mask);
const kvz_pixel* orig_ptr = &(orig_data[y * block_width + x]);
__m256i v_diff = _mm256_cvtepu8_epi32(load_6_pixels(orig_ptr));
v_diff = _mm256_sub_epi32(v_diff, _mm256_cvtepu8_epi32(v_c));
//Accumulate differences and occurrences for each category
ACCUM_COUNT_EO_CAT_AVX2(SAO_EO_CAT0, v_cat);
ACCUM_COUNT_EO_CAT_AVX2(SAO_EO_CAT1, v_cat);
ACCUM_COUNT_EO_CAT_AVX2(SAO_EO_CAT2, v_cat);
ACCUM_COUNT_EO_CAT_AVX2(SAO_EO_CAT3, v_cat);
ACCUM_COUNT_EO_CAT_AVX2(SAO_EO_CAT4, v_cat);
}
for (int eo_cat = 0; eo_cat < NUM_SAO_EDGE_CATEGORIES; ++eo_cat) {
int accum = 0;
int count = 0;
//Full horizontal sum of accumulated values
v_diff_accum[eo_cat] = _mm256_add_epi32(v_diff_accum[eo_cat], _mm256_castsi128_si256(_mm256_extracti128_si256(v_diff_accum[eo_cat], 1)));
v_diff_accum[eo_cat] = _mm256_add_epi32(v_diff_accum[eo_cat], _mm256_shuffle_epi32(v_diff_accum[eo_cat], KVZ_PERMUTE(2, 3, 0, 1)));
v_diff_accum[eo_cat] = _mm256_add_epi32(v_diff_accum[eo_cat], _mm256_shuffle_epi32(v_diff_accum[eo_cat], KVZ_PERMUTE(1, 0, 1, 0)));
accum += _mm_cvtsi128_si32(_mm256_castsi256_si128(v_diff_accum[eo_cat]));
//Full horizontal sum of accumulated values
v_count[eo_cat] = _mm256_add_epi32(v_count[eo_cat], _mm256_castsi128_si256(_mm256_extracti128_si256(v_count[eo_cat], 1)));
v_count[eo_cat] = _mm256_add_epi32(v_count[eo_cat], _mm256_shuffle_epi32(v_count[eo_cat], KVZ_PERMUTE(2, 3, 0, 1)));
v_count[eo_cat] = _mm256_add_epi32(v_count[eo_cat], _mm256_shuffle_epi32(v_count[eo_cat], KVZ_PERMUTE(1, 0, 1, 0)));
count += _mm_cvtsi128_si32(_mm256_castsi256_si128(v_count[eo_cat]));
cat_sum_cnt[0][eo_cat] += accum;
cat_sum_cnt[1][eo_cat] += count;
}
}
void kvz_sao_reconstruct_color_avx2(const encoder_control_t * const encoder,
const kvz_pixel *rec_data, kvz_pixel *new_rec_data,
const sao_info_t *sao,
int stride, int new_stride,
int block_width, int block_height,
color_t color_i)
{
int y, x;
// Arrays orig_data and rec_data are quarter size for chroma.
int offset_v = color_i == COLOR_V ? 5 : 0;
if(sao->type == SAO_TYPE_BAND) {
int offsets[1<<KVZ_BIT_DEPTH];
kvz_calc_sao_offset_array(encoder, sao, offsets, color_i);
for (y = 0; y < block_height; ++y) {
for (x = 0; x < block_width; ++x) {
new_rec_data[y * new_stride + x] = offsets[rec_data[y * stride + x]];
}
}
} else {
// Don't sample the edge pixels because this function doesn't have access to
// their neighbours.
for (y = 0; y < block_height; ++y) {
for (x = 0; x < block_width; x+=8) {
vector2d_t a_ofs = g_sao_edge_offsets[sao->eo_class][0];
vector2d_t b_ofs = g_sao_edge_offsets[sao->eo_class][1];
const kvz_pixel *c_data = &rec_data[y * stride + x];
kvz_pixel *new_data = &new_rec_data[y * new_stride + x];
const kvz_pixel* a_ptr = &c_data[a_ofs.y * stride + a_ofs.x];
const kvz_pixel* c_ptr = &c_data[0];
const kvz_pixel* b_ptr = &c_data[b_ofs.y * stride + b_ofs.x];
__m128i v_a = _mm_loadl_epi64((__m128i*)a_ptr);
__m128i v_b = _mm_loadl_epi64((__m128i*)b_ptr);
__m128i v_c = _mm_loadl_epi64((__m128i*)c_ptr);
__m256i v_cat = _mm256_cvtepu8_epi32(sao_calc_eo_cat_avx2(&v_a, &v_b, &v_c) );
__m256i v_offset_v = load_5_offsets(sao->offsets + offset_v);
__m256i v_new_data = _mm256_permutevar8x32_epi32(v_offset_v, v_cat);
v_new_data = _mm256_add_epi32(v_new_data, _mm256_cvtepu8_epi32(v_c));
__m128i v_new_data_128 = _mm_packus_epi32(_mm256_castsi256_si128(v_new_data), _mm256_extracti128_si256(v_new_data, 1));
v_new_data_128 = _mm_packus_epi16(v_new_data_128, v_new_data_128);
_mm_storel_epi64((__m128i*)new_data, v_new_data_128);
}
}
}
}
int kvz_sao_band_ddistortion_avx2(const encoder_state_t * const state, const kvz_pixel *orig_data, const kvz_pixel *rec_data,
int block_width, int block_height,
int band_pos, int sao_bands[4])
{
int y, x;
int shift = state->encoder_control->bitdepth-5;
int sum = 0;
__m256i v_accum = { 0 };
for (y = 0; y < block_height; ++y) {
for (x = 0; x < block_width; x+=8) {
__m256i v_band = _mm256_cvtepu8_epi32(_mm_loadl_epi64((__m128i*)&(rec_data[y * block_width + x])));
v_band = _mm256_srli_epi32(v_band, shift);
v_band = _mm256_sub_epi32(v_band, _mm256_set1_epi32(band_pos));
__m256i v_offset = { 0 };
__m256i v_mask = _mm256_cmpeq_epi32(_mm256_and_si256(_mm256_set1_epi32(~3), v_band), _mm256_setzero_si256());
v_offset = _mm256_permutevar8x32_epi32(_mm256_castsi128_si256(_mm_loadu_si128((__m128i*)sao_bands)), v_band);
v_offset = _mm256_and_si256(v_offset, v_mask);
__m256i v_diff = _mm256_cvtepu8_epi32(_mm_loadl_epi64((__m128i*)&(orig_data[y * block_width + x])));
__m256i v_rec = _mm256_cvtepu8_epi32(_mm_loadl_epi64((__m128i*)&(rec_data[y * block_width + x])));
v_diff = _mm256_sub_epi32(v_diff, v_rec);
__m256i v_diff_minus_offset = _mm256_sub_epi32(v_diff, v_offset);
__m256i v_temp_sum = _mm256_sub_epi32(_mm256_mullo_epi32(v_diff_minus_offset, v_diff_minus_offset), _mm256_mullo_epi32(v_diff, v_diff));
v_accum = _mm256_add_epi32(v_accum, v_temp_sum);
}
}
//Full horizontal sum
v_accum = _mm256_add_epi32(v_accum, _mm256_castsi128_si256(_mm256_extracti128_si256(v_accum, 1)));
v_accum = _mm256_add_epi32(v_accum, _mm256_shuffle_epi32(v_accum, KVZ_PERMUTE(2, 3, 0, 1)));
v_accum = _mm256_add_epi32(v_accum, _mm256_shuffle_epi32(v_accum, KVZ_PERMUTE(1, 0, 1, 0)));
sum += _mm_cvtsi128_si32(_mm256_castsi256_si128(v_accum));
return sum;
}
#endif //COMPILE_INTEL_AVX2
int kvz_strategy_register_sao_avx2(void* opaque, uint8_t bitdepth)
{
bool success = true;
#if COMPILE_INTEL_AVX2
if (bitdepth == 8) {
success &= kvz_strategyselector_register(opaque, "sao_edge_ddistortion", "avx2", 40, &kvz_sao_edge_ddistortion_avx2);
success &= kvz_strategyselector_register(opaque, "calc_sao_edge_dir", "avx2", 40, &kvz_calc_sao_edge_dir_avx2);
success &= kvz_strategyselector_register(opaque, "sao_reconstruct_color", "avx2", 40, &kvz_sao_reconstruct_color_avx2);
success &= kvz_strategyselector_register(opaque, "sao_band_ddistortion", "avx2", 40, &kvz_sao_band_ddistortion_avx2);
}
#endif //COMPILE_INTEL_AVX2
return success;
}

View file

@ -0,0 +1,33 @@
#ifndef STRATEGIES_SAO_AVX2_H_
#define STRATEGIES_SAO_AVX2_H_
/*****************************************************************************
* This file is part of Kvazaar HEVC encoder.
*
* Copyright (C) 2013-2015 Tampere University of Technology and others (see
* COPYING file).
*
* Kvazaar is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* Kvazaar is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with Kvazaar. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
/**
* \ingroup Optimization
* \file
* AVX2 implementations of optimized functions.
*/
#include "global.h"
int kvz_strategy_register_sao_avx2(void* opaque, uint8_t bitdepth);
#endif //STRATEGIES_SAO_AVX2_H_

View file

@ -0,0 +1,182 @@
/*****************************************************************************
* This file is part of Kvazaar HEVC encoder.
*
* Copyright (C) 2013-2015 Tampere University of Technology and others (see
* COPYING file).
*
* Kvazaar is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* Kvazaar is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with Kvazaar. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <stdlib.h>
#include "sao-generic.h"
#include "sao.h"
#include "strategyselector.h"
#include "rdo.h"
// Mapping of edge_idx values to eo-classes.
static int sao_calc_eo_cat(kvz_pixel a, kvz_pixel b, kvz_pixel c)
{
// Mapping relationships between a, b and c to eo_idx.
static const int sao_eo_idx_to_eo_category[] = { 1, 2, 0, 3, 4 };
int eo_idx = 2 + SIGN3((int)c - (int)a) + SIGN3((int)c - (int)b);
return sao_eo_idx_to_eo_category[eo_idx];
}
int kvz_sao_edge_ddistortion_generic(const kvz_pixel *orig_data, const kvz_pixel *rec_data,
int block_width, int block_height,
int eo_class, int offsets[NUM_SAO_EDGE_CATEGORIES])
{
int y, x;
int sum = 0;
vector2d_t a_ofs = g_sao_edge_offsets[eo_class][0];
vector2d_t b_ofs = g_sao_edge_offsets[eo_class][1];
for (y = 1; y < block_height - 1; ++y) {
for (x = 1; x < block_width - 1; ++x) {
const kvz_pixel *c_data = &rec_data[y * block_width + x];
kvz_pixel a = c_data[a_ofs.y * block_width + a_ofs.x];
kvz_pixel c = c_data[0];
kvz_pixel b = c_data[b_ofs.y * block_width + b_ofs.x];
int offset = offsets[sao_calc_eo_cat(a, b, c)];
if (offset != 0) {
int diff = orig_data[y * block_width + x] - c;
// Offset is applied to reconstruction, so it is subtracted from diff.
sum += (diff - offset) * (diff - offset) - diff * diff;
}
}
}
return sum;
}
/**
* \param orig_data Original pixel data. 64x64 for luma, 32x32 for chroma.
* \param rec_data Reconstructed pixel data. 64x64 for luma, 32x32 for chroma.
* \param dir_offsets
* \param is_chroma 0 for luma, 1 for chroma. Indicates
*/
void kvz_calc_sao_edge_dir_generic(const kvz_pixel *orig_data, const kvz_pixel *rec_data,
int eo_class, int block_width, int block_height,
int cat_sum_cnt[2][NUM_SAO_EDGE_CATEGORIES])
{
int y, x;
vector2d_t a_ofs = g_sao_edge_offsets[eo_class][0];
vector2d_t b_ofs = g_sao_edge_offsets[eo_class][1];
// Arrays orig_data and rec_data are quarter size for chroma.
// Don't sample the edge pixels because this function doesn't have access to
// their neighbours.
for (y = 1; y < block_height - 1; ++y) {
for (x = 1; x < block_width - 1; ++x) {
const kvz_pixel *c_data = &rec_data[y * block_width + x];
kvz_pixel a = c_data[a_ofs.y * block_width + a_ofs.x];
kvz_pixel c = c_data[0];
kvz_pixel b = c_data[b_ofs.y * block_width + b_ofs.x];
int eo_cat = sao_calc_eo_cat(a, b, c);
cat_sum_cnt[0][eo_cat] += orig_data[y * block_width + x] - c;
cat_sum_cnt[1][eo_cat] += 1;
}
}
}
void kvz_sao_reconstruct_color_generic(const encoder_control_t * const encoder,
const kvz_pixel *rec_data, kvz_pixel *new_rec_data,
const sao_info_t *sao,
int stride, int new_stride,
int block_width, int block_height,
color_t color_i)
{
int y, x;
// Arrays orig_data and rec_data are quarter size for chroma.
int offset_v = color_i == COLOR_V ? 5 : 0;
if(sao->type == SAO_TYPE_BAND) {
int offsets[1<<KVZ_BIT_DEPTH];
kvz_calc_sao_offset_array(encoder, sao, offsets, color_i);
for (y = 0; y < block_height; ++y) {
for (x = 0; x < block_width; ++x) {
new_rec_data[y * new_stride + x] = offsets[rec_data[y * stride + x]];
}
}
} else {
// Don't sample the edge pixels because this function doesn't have access to
// their neighbours.
for (y = 0; y < block_height; ++y) {
for (x = 0; x < block_width; ++x) {
vector2d_t a_ofs = g_sao_edge_offsets[sao->eo_class][0];
vector2d_t b_ofs = g_sao_edge_offsets[sao->eo_class][1];
const kvz_pixel *c_data = &rec_data[y * stride + x];
kvz_pixel *new_data = &new_rec_data[y * new_stride + x];
kvz_pixel a = c_data[a_ofs.y * stride + a_ofs.x];
kvz_pixel c = c_data[0];
kvz_pixel b = c_data[b_ofs.y * stride + b_ofs.x];
int eo_cat = sao_calc_eo_cat(a, b, c);
new_data[0] = (kvz_pixel)CLIP(0, (1 << KVZ_BIT_DEPTH) - 1, c_data[0] + sao->offsets[eo_cat + offset_v]);
}
}
}
}
int kvz_sao_band_ddistortion_generic(const encoder_state_t * const state, const kvz_pixel *orig_data, const kvz_pixel *rec_data,
int block_width, int block_height,
int band_pos, int sao_bands[4])
{
int y, x;
int shift = state->encoder_control->bitdepth-5;
int sum = 0;
for (y = 0; y < block_height; ++y) {
for (x = 0; x < block_width; ++x) {
int band = (rec_data[y * block_width + x] >> shift) - band_pos;
int offset = 0;
if (band >= 0 && band < 4) {
offset = sao_bands[band];
}
if (offset != 0) {
int diff = orig_data[y * block_width + x] - rec_data[y * block_width + x];
// Offset is applied to reconstruction, so it is subtracted from diff.
sum += (diff - offset) * (diff - offset) - diff * diff;
}
}
}
return sum;
}
int kvz_strategy_register_sao_generic(void* opaque, uint8_t bitdepth)
{
bool success = true;
success &= kvz_strategyselector_register(opaque, "sao_edge_ddistortion", "generic", 0, &kvz_sao_edge_ddistortion_generic);
success &= kvz_strategyselector_register(opaque, "calc_sao_edge_dir", "generic", 0, &kvz_calc_sao_edge_dir_generic);
success &= kvz_strategyselector_register(opaque, "sao_reconstruct_color", "generic", 0, &kvz_sao_reconstruct_color_generic);
success &= kvz_strategyselector_register(opaque, "sao_band_ddistortion", "generic", 0, &kvz_sao_band_ddistortion_generic);
return success;
}

View file

@ -0,0 +1,33 @@
#ifndef STRATEGIES_SAO_GENERIC_H_
#define STRATEGIES_SAO_GENERIC_H_
/*****************************************************************************
* This file is part of Kvazaar HEVC encoder.
*
* Copyright (C) 2013-2015 Tampere University of Technology and others (see
* COPYING file).
*
* Kvazaar is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* Kvazaar is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with Kvazaar. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
/**
* \ingroup Optimization
* \file
* Generic C implementations of optimized functions.
*/
#include "global.h"
int kvz_strategy_register_sao_generic(void* opaque, uint8_t bitdepth);
#endif //STRATEGIES_SAO_GENERIC_H_

View file

@ -0,0 +1,45 @@
/*****************************************************************************
* This file is part of Kvazaar HEVC encoder.
*
* Copyright (C) 2013-2015 Tampere University of Technology and others (see
* COPYING file).
*
* Kvazaar is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* Kvazaar is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with Kvazaar. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "strategies-sao.h"
#include "strategyselector.h"
// Define function pointers.
sao_edge_ddistortion_func * kvz_sao_edge_ddistortion;
calc_sao_edge_dir_func * kvz_calc_sao_edge_dir;
sao_reconstruct_color_func * kvz_sao_reconstruct_color;
sao_band_ddistortion_func * kvz_sao_band_ddistortion;
// Headers for platform optimizations.
#include "generic/sao-generic.h"
#include "avx2/sao-avx2.h"
int kvz_strategy_register_sao(void* opaque, uint8_t bitdepth) {
bool success = true;
success &= kvz_strategy_register_sao_generic(opaque, bitdepth);
if (kvz_g_hardware_flags.intel_flags.avx2) {
success &= kvz_strategy_register_sao_avx2(opaque, bitdepth);
}
return success;
}

View file

@ -0,0 +1,71 @@
#ifndef STRATEGIES_SAO_H_
#define STRATEGIES_SAO_H_
/*****************************************************************************
* This file is part of Kvazaar HEVC encoder.
*
* Copyright (C) 2013-2015 Tampere University of Technology and others (see
* COPYING file).
*
* Kvazaar is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* Kvazaar is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with Kvazaar. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
/**
* \ingroup Optimization
* \file
* Interface for sao functions.
*/
#include "global.h"
#include "encoderstate.h"
#include "sao.h"
// Declare function pointers.
typedef int (sao_edge_ddistortion_func)(const kvz_pixel *orig_data, const kvz_pixel *rec_data,
int block_width, int block_height,
int eo_class, int offsets[NUM_SAO_EDGE_CATEGORIES]);
typedef void (calc_sao_edge_dir_func)(const kvz_pixel *orig_data, const kvz_pixel *rec_data,
int eo_class, int block_width, int block_height,
int cat_sum_cnt[2][NUM_SAO_EDGE_CATEGORIES]);
typedef void (sao_reconstruct_color_func)(const encoder_control_t * const encoder,
const kvz_pixel *rec_data, kvz_pixel *new_rec_data,
const sao_info_t *sao,
int stride, int new_stride,
int block_width, int block_height,
color_t color_i);
typedef int (sao_band_ddistortion_func)(const encoder_state_t * const state, const kvz_pixel *orig_data, const kvz_pixel *rec_data,
int block_width, int block_height,
int band_pos, int sao_bands[4]);
// Declare function pointers.
extern sao_edge_ddistortion_func * kvz_sao_edge_ddistortion;
extern calc_sao_edge_dir_func * kvz_calc_sao_edge_dir;
extern sao_reconstruct_color_func * kvz_sao_reconstruct_color;
extern sao_band_ddistortion_func * kvz_sao_band_ddistortion;
int kvz_strategy_register_sao(void* opaque, uint8_t bitdepth);
#define STRATEGIES_SAO_EXPORTS \
{"sao_edge_ddistortion", (void**) &kvz_sao_edge_ddistortion}, \
{"calc_sao_edge_dir", (void**) &kvz_calc_sao_edge_dir}, \
{"sao_reconstruct_color", (void**) &kvz_sao_reconstruct_color}, \
{"sao_band_ddistortion", (void**) &kvz_sao_band_ddistortion}, \
#endif //STRATEGIES_SAO_H_

View file

@ -75,6 +75,11 @@ int kvz_strategyselector_init(int32_t cpuid, uint8_t bitdepth) {
fprintf(stderr, "kvz_strategy_register_intra failed!\n");
return 0;
}
if (!kvz_strategy_register_sao(&strategies, bitdepth)) {
fprintf(stderr, "kvz_strategy_register_sao failed!\n");
return 0;
}
while(cur_strategy_to_select->fptr) {
*(cur_strategy_to_select->fptr) = strategyselector_choose_for(&strategies, cur_strategy_to_select->strategy_type);

View file

@ -153,6 +153,7 @@ int kvz_strategyselector_register(void *opaque, const char *type, const char *st
#include "strategies/strategies-ipol.h"
#include "strategies/strategies-quant.h"
#include "strategies/strategies-intra.h"
#include "strategies/strategies-sao.h"
static const strategy_to_select_t strategies_to_select[] = {
STRATEGIES_NAL_EXPORTS
@ -161,6 +162,7 @@ static const strategy_to_select_t strategies_to_select[] = {
STRATEGIES_IPOL_EXPORTS
STRATEGIES_QUANT_EXPORTS
STRATEGIES_INTRA_EXPORTS
STRATEGIES_SAO_EXPORTS
{ NULL, NULL },
};