Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/hevcdsp_template.c')
-rw-r--r--libavcodec/hevcdsp_template.c448
1 files changed, 229 insertions, 219 deletions
diff --git a/libavcodec/hevcdsp_template.c b/libavcodec/hevcdsp_template.c
index 027b77c7c7..b91ed3dfa9 100644
--- a/libavcodec/hevcdsp_template.c
+++ b/libavcodec/hevcdsp_template.c
@@ -1,37 +1,41 @@
/*
- * HEVC video decoder
+ * HEVC video Decoder
*
* Copyright (C) 2012 - 2013 Guillaume Martres
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg 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.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg 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 Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "get_bits.h"
+#include "bit_depth_template.c"
+#include "hevcdsp.h"
+
#include "hevc.h"
-#include "bit_depth_template.c"
+#define SET(dst, x) (dst) = (x)
+#define SCALE(dst, x) (dst) = av_clip_int16(((x) + add) >> shift)
+#define ADD_AND_SCALE(dst, x) (dst) = av_clip_pixel((dst) + av_clip_int16(((x) + add) >> shift))
-static void FUNC(put_pcm)(uint8_t *_dst, ptrdiff_t stride, int size,
+static void FUNC(put_pcm)(uint8_t *_dst, ptrdiff_t _stride, int size,
GetBitContext *gb, int pcm_bit_depth)
{
int x, y;
- pixel *dst = (pixel *)_dst;
-
- stride /= sizeof(pixel);
+ pixel *dst = (pixel*)_dst;
+ ptrdiff_t stride = _stride / sizeof(pixel);
for (y = 0; y < size; y++) {
for (x = 0; x < size; x++)
@@ -40,13 +44,11 @@ static void FUNC(put_pcm)(uint8_t *_dst, ptrdiff_t stride, int size,
}
}
-static void FUNC(transquant_bypass4x4)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(transquant_bypass4x4)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _stride)
{
int x, y;
- pixel *dst = (pixel *)_dst;
-
- stride /= sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t stride = _stride / sizeof(pixel);
for (y = 0; y < 4; y++) {
for (x = 0; x < 4; x++) {
@@ -55,15 +57,14 @@ static void FUNC(transquant_bypass4x4)(uint8_t *_dst, int16_t *coeffs,
}
dst += stride;
}
+
}
-static void FUNC(transquant_bypass8x8)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(transquant_bypass8x8)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _stride)
{
int x, y;
- pixel *dst = (pixel *)_dst;
-
- stride /= sizeof(pixel);
+ pixel *dst = (pixel*)_dst;
+ ptrdiff_t stride = _stride / sizeof(pixel);
for (y = 0; y < 8; y++) {
for (x = 0; x < 8; x++) {
@@ -74,13 +75,11 @@ static void FUNC(transquant_bypass8x8)(uint8_t *_dst, int16_t *coeffs,
}
}
-static void FUNC(transquant_bypass16x16)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(transquant_bypass16x16)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _stride)
{
int x, y;
- pixel *dst = (pixel *)_dst;
-
- stride /= sizeof(pixel);
+ pixel *dst = (pixel*)_dst;
+ ptrdiff_t stride = _stride / sizeof(pixel);
for (y = 0; y < 16; y++) {
for (x = 0; x < 16; x++) {
@@ -89,15 +88,14 @@ static void FUNC(transquant_bypass16x16)(uint8_t *_dst, int16_t *coeffs,
}
dst += stride;
}
+
}
-static void FUNC(transquant_bypass32x32)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(transquant_bypass32x32)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _stride)
{
int x, y;
- pixel *dst = (pixel *)_dst;
-
- stride /= sizeof(pixel);
+ pixel *dst = (pixel*)_dst;
+ ptrdiff_t stride = _stride / sizeof(pixel);
for (y = 0; y < 32; y++) {
for (x = 0; x < 32; x++) {
@@ -108,11 +106,11 @@ static void FUNC(transquant_bypass32x32)(uint8_t *_dst, int16_t *coeffs,
}
}
-static void FUNC(transform_skip)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(transform_skip)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _stride)
{
- pixel *dst = (pixel *)_dst;
- int shift = 13 - BIT_DEPTH;
+ pixel *dst = (pixel*)_dst;
+ ptrdiff_t stride = _stride / sizeof(pixel);
+ int shift = 13 - BIT_DEPTH;
#if BIT_DEPTH <= 13
int offset = 1 << (shift - 1);
#else
@@ -120,106 +118,96 @@ static void FUNC(transform_skip)(uint8_t *_dst, int16_t *coeffs,
#endif
int x, y;
- stride /= sizeof(pixel);
-
- for (y = 0; y < 4 * 4; y += 4) {
- for (x = 0; x < 4; x++)
+ for (y = 0; y < 4*4; y+=4) {
+ for (x = 0; x < 4; x++) {
dst[x] = av_clip_pixel(dst[x] + ((coeffs[y + x] + offset) >> shift));
+ }
dst += stride;
}
}
-#define SET(dst, x) (dst) = (x)
-#define SCALE(dst, x) (dst) = av_clip_int16(((x) + add) >> shift)
-#define ADD_AND_SCALE(dst, x) \
- (dst) = av_clip_pixel((dst) + av_clip_int16(((x) + add) >> shift))
-
-#define TR_4x4_LUMA(dst, src, step, assign) \
- do { \
- int c0 = src[0 * step] + src[2 * step]; \
- int c1 = src[2 * step] + src[3 * step]; \
- int c2 = src[0 * step] - src[3 * step]; \
- int c3 = 74 * src[1 * step]; \
- \
- assign(dst[2 * step], 74 * (src[0 * step] - \
- src[2 * step] + \
- src[3 * step])); \
- assign(dst[0 * step], 29 * c0 + 55 * c1 + c3); \
- assign(dst[1 * step], 55 * c2 - 29 * c1 + c3); \
- assign(dst[3 * step], 55 * c0 + 29 * c2 - c3); \
+static void FUNC(transform_4x4_luma_add)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _stride)
+{
+#define TR_4x4_LUMA(dst, src, step, assign) \
+ do { \
+ int c0 = src[0*step] + src[2*step]; \
+ int c1 = src[2*step] + src[3*step]; \
+ int c2 = src[0*step] - src[3*step]; \
+ int c3 = 74 * src[1*step]; \
+ \
+ assign(dst[2*step], 74 * (src[0*step] - src[2*step] + src[3*step])); \
+ assign(dst[0*step], 29 * c0 + 55 * c1 + c3); \
+ assign(dst[1*step], 55 * c2 - 29 * c1 + c3); \
+ assign(dst[3*step], 55 * c0 + 29 * c2 - c3); \
} while (0)
-static void FUNC(transform_4x4_luma_add)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
-{
int i;
- pixel *dst = (pixel *)_dst;
- int shift = 7;
- int add = 1 << (shift - 1);
+ pixel *dst = (pixel*)_dst;
+ ptrdiff_t stride = _stride / sizeof(pixel);
+ int shift = 7;
+ int add = 1 << (shift - 1);
int16_t *src = coeffs;
- stride /= sizeof(pixel);
-
for (i = 0; i < 4; i++) {
TR_4x4_LUMA(src, src, 4, SCALE);
src++;
}
shift = 20 - BIT_DEPTH;
- add = 1 << (shift - 1);
+ add = 1 << (shift - 1);
for (i = 0; i < 4; i++) {
TR_4x4_LUMA(dst, coeffs, 1, ADD_AND_SCALE);
coeffs += 4;
- dst += stride;
+ dst += stride;
}
-}
#undef TR_4x4_LUMA
+}
-#define TR_4(dst, src, dstep, sstep, assign) \
- do { \
- const int e0 = transform[8 * 0][0] * src[0 * sstep] + \
- transform[8 * 2][0] * src[2 * sstep]; \
- const int e1 = transform[8 * 0][1] * src[0 * sstep] + \
- transform[8 * 2][1] * src[2 * sstep]; \
- const int o0 = transform[8 * 1][0] * src[1 * sstep] + \
- transform[8 * 3][0] * src[3 * sstep]; \
- const int o1 = transform[8 * 1][1] * src[1 * sstep] + \
- transform[8 * 3][1] * src[3 * sstep]; \
- \
- assign(dst[0 * dstep], e0 + o0); \
- assign(dst[1 * dstep], e1 + o1); \
- assign(dst[2 * dstep], e1 - o1); \
- assign(dst[3 * dstep], e0 - o0); \
+#define TR_4(dst, src, dstep, sstep, assign) \
+ do { \
+ const int e0 = transform[8*0][0] * src[0*sstep] + \
+ transform[8*2][0] * src[2*sstep]; \
+ const int e1 = transform[8*0][1] * src[0*sstep] + \
+ transform[8*2][1] * src[2*sstep]; \
+ const int o0 = transform[8*1][0] * src[1*sstep] + \
+ transform[8*3][0] * src[3*sstep]; \
+ const int o1 = transform[8*1][1] * src[1*sstep] + \
+ transform[8*3][1] * src[3*sstep]; \
+ \
+ assign(dst[0*dstep], e0 + o0); \
+ assign(dst[1*dstep], e1 + o1); \
+ assign(dst[2*dstep], e1 - o1); \
+ assign(dst[3*dstep], e0 - o0); \
} while (0)
+#define TR_4_1(dst, src) TR_4(dst, src, 4, 4, SCALE)
+#define TR_4_2(dst, src) TR_4(dst, src, 1, 1, ADD_AND_SCALE)
-static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _stride)
{
int i;
- pixel *dst = (pixel *)_dst;
- int shift = 7;
- int add = 1 << (shift - 1);
+ pixel *dst = (pixel*)_dst;
+ ptrdiff_t stride = _stride / sizeof(pixel);
+ int shift = 7;
+ int add = 1 << (shift - 1);
int16_t *src = coeffs;
- stride /= sizeof(pixel);
-
for (i = 0; i < 4; i++) {
- TR_4(src, src, 4, 4, SCALE);
+ TR_4_1(src, src);
src++;
}
shift = 20 - BIT_DEPTH;
- add = 1 << (shift - 1);
+ add = 1 << (shift - 1);
for (i = 0; i < 4; i++) {
- TR_4(dst, coeffs, 1, 1, ADD_AND_SCALE);
+ TR_4_2(dst, coeffs);
coeffs += 4;
- dst += stride;
+ dst += stride;
}
}
-#define TR_8(dst, src, dstep, sstep, assign) \
- do { \
+#define TR_8(dst, src, dstep, sstep, assign) \
+ do { \
int i, j; \
int e_8[4]; \
int o_8[4] = { 0 }; \
@@ -266,118 +254,131 @@ static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs,
} \
} while (0)
+#define TR_8_1(dst, src) TR_8(dst, src, 8, 8, SCALE)
+#define TR_16_1(dst, src) TR_16(dst, src, 16, 16, SCALE)
+#define TR_32_1(dst, src) TR_32(dst, src, 32, 32, SCALE)
+#define TR_8_2(dst, src) TR_8(dst, src, 1, 1, ADD_AND_SCALE)
+#define TR_16_2(dst, src) TR_16(dst, src, 1, 1, ADD_AND_SCALE)
+#define TR_32_2(dst, src) TR_32(dst, src, 1, 1, ADD_AND_SCALE)
-static void FUNC(transform_8x8_add)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(transform_8x8_add)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _stride)
{
int i;
- pixel *dst = (pixel *)_dst;
- int shift = 7;
- int add = 1 << (shift - 1);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t stride = _stride / sizeof(pixel);
+ int shift = 7;
+ int add = 1 << (shift - 1);
int16_t *src = coeffs;
- stride /= sizeof(pixel);
-
for (i = 0; i < 8; i++) {
- TR_8(src, src, 8, 8, SCALE);
+ TR_8_1(src, src);
src++;
}
shift = 20 - BIT_DEPTH;
- add = 1 << (shift - 1);
+ add = 1 << (shift - 1);
for (i = 0; i < 8; i++) {
- TR_8(dst, coeffs, 1, 1, ADD_AND_SCALE);
+ TR_8_2(dst, coeffs);
coeffs += 8;
- dst += stride;
+ dst += stride;
}
}
-static void FUNC(transform_16x16_add)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(transform_16x16_add)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _stride)
{
int i;
- pixel *dst = (pixel *)_dst;
- int shift = 7;
- int add = 1 << (shift - 1);
+ pixel *dst = (pixel*)_dst;
+ ptrdiff_t stride = _stride / sizeof(pixel);
+ int shift = 7;
+ int add = 1 << (shift - 1);
int16_t *src = coeffs;
- stride /= sizeof(pixel);
-
for (i = 0; i < 16; i++) {
- TR_16(src, src, 16, 16, SCALE);
+ TR_16_1(src, src);
src++;
}
shift = 20 - BIT_DEPTH;
- add = 1 << (shift - 1);
+ add = 1 << (shift - 1);
for (i = 0; i < 16; i++) {
- TR_16(dst, coeffs, 1, 1, ADD_AND_SCALE);
+ TR_16_2(dst, coeffs);
coeffs += 16;
- dst += stride;
+ dst += stride;
}
}
-static void FUNC(transform_32x32_add)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(transform_32x32_add)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _stride)
{
+#define IT32x32_even(i,w) ( src[ 0*w] * transform[ 0][i] ) + ( src[16*w] * transform[16][i] )
+#define IT32x32_odd(i,w) ( src[ 8*w] * transform[ 8][i] ) + ( src[24*w] * transform[24][i] )
+#define IT16x16(i,w) ( src[ 4*w] * transform[ 4][i] ) + ( src[12*w] * transform[12][i] ) + ( src[20*w] * transform[20][i] ) + ( src[28*w] * transform[28][i] )
+#define IT8x8(i,w) ( src[ 2*w] * transform[ 2][i] ) + ( src[ 6*w] * transform[ 6][i] ) + ( src[10*w] * transform[10][i] ) + ( src[14*w] * transform[14][i] ) + \
+ ( src[18*w] * transform[18][i] ) + ( src[22*w] * transform[22][i] ) + ( src[26*w] * transform[26][i] ) + ( src[30*w] * transform[30][i] )
+#define IT4x4(i,w) ( src[ 1*w] * transform[ 1][i] ) + ( src[ 3*w] * transform[ 3][i] ) + ( src[ 5*w] * transform[ 5][i] ) + ( src[ 7*w] * transform[ 7][i] ) + \
+ ( src[ 9*w] * transform[ 9][i] ) + ( src[11*w] * transform[11][i] ) + ( src[13*w] * transform[13][i] ) + ( src[15*w] * transform[15][i] ) + \
+ ( src[17*w] * transform[17][i] ) + ( src[19*w] * transform[19][i] ) + ( src[21*w] * transform[21][i] ) + ( src[23*w] * transform[23][i] ) + \
+ ( src[25*w] * transform[25][i] ) + ( src[27*w] * transform[27][i] ) + ( src[29*w] * transform[29][i] ) + ( src[31*w] * transform[31][i] )
int i;
- pixel *dst = (pixel *)_dst;
- int shift = 7;
- int add = 1 << (shift - 1);
+ pixel *dst = (pixel*)_dst;
+ ptrdiff_t stride = _stride / sizeof(pixel);
+ int shift = 7;
+ int add = 1 << (shift - 1);
int16_t *src = coeffs;
- stride /= sizeof(pixel);
-
for (i = 0; i < 32; i++) {
- TR_32(src, src, 32, 32, SCALE);
+ TR_32_1(src, src);
src++;
}
src = coeffs;
shift = 20 - BIT_DEPTH;
add = 1 << (shift - 1);
for (i = 0; i < 32; i++) {
- TR_32(dst, coeffs, 1, 1, ADD_AND_SCALE);
+ TR_32_2(dst, coeffs);
coeffs += 32;
- dst += stride;
+ dst += stride;
}
+#undef IT32x32_even
+#undef IT32x32_odd
+#undef IT16x16
+#undef IT8x8
+#undef IT4x4
}
static void FUNC(sao_band_filter)(uint8_t *_dst, uint8_t *_src,
- ptrdiff_t stride, SAOParams *sao,
- int *borders, int width, int height,
+ ptrdiff_t _stride, SAOParams *sao,
+ int *borders, int width, int height,
int c_idx, int class)
{
- pixel *dst = (pixel *)_dst;
- pixel *src = (pixel *)_src;
+ pixel *dst = (pixel*)_dst;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t stride = _stride / sizeof(pixel);
int offset_table[32] = { 0 };
int k, y, x;
int chroma = !!c_idx;
- int shift = BIT_DEPTH - 5;
+ int shift = BIT_DEPTH - 5;
int *sao_offset_val = sao->offset_val[c_idx];
int sao_left_class = sao->band_position[c_idx];
int init_y = 0, init_x = 0;
- stride /= sizeof(pixel);
-
switch (class) {
case 0:
if (!borders[2])
- width -= (8 >> chroma) + 2;
+ width -= ((8 >> chroma) + 2);
if (!borders[3])
- height -= (4 >> chroma) + 2;
+ height -= ((4 >> chroma) + 2);
break;
case 1:
init_y = -(4 >> chroma) - 2;
if (!borders[2])
- width -= (8 >> chroma) + 2;
+ width -= ((8 >> chroma) + 2);
height = (4 >> chroma) + 2;
break;
case 2:
init_x = -(8 >> chroma) - 2;
width = (8 >> chroma) + 2;
if (!borders[3])
- height -= (4 >> chroma) + 2;
+ height -= ((4 >> chroma) + 2);
break;
case 3:
init_y = -(4 >> chroma) - 2;
@@ -422,32 +423,30 @@ static void FUNC(sao_band_filter_2)(uint8_t *dst, uint8_t *src,
int *borders, int width, int height,
int c_idx)
{
- FUNC(sao_band_filter)(dst, src, stride, sao, borders,
- width, height, c_idx, 2);
+ FUNC(sao_band_filter)(dst, src, stride, sao, borders, width, height, c_idx, 2);
}
static void FUNC(sao_band_filter_3)(uint8_t *_dst, uint8_t *_src,
- ptrdiff_t stride, SAOParams *sao,
+ ptrdiff_t _stride, SAOParams *sao,
int *borders, int width, int height,
int c_idx)
{
- FUNC(sao_band_filter)(_dst, _src, stride, sao, borders,
- width, height, c_idx, 3);
+ FUNC(sao_band_filter)(_dst, _src, _stride, sao, borders, width, height, c_idx, 3);
}
static void FUNC(sao_edge_filter_0)(uint8_t *_dst, uint8_t *_src,
- ptrdiff_t stride, SAOParams *sao,
+ ptrdiff_t _stride, SAOParams *sao,
int *borders, int _width, int _height,
- int c_idx, uint8_t vert_edge,
- uint8_t horiz_edge, uint8_t diag_edge)
+ int c_idx,
+ uint8_t vert_edge, uint8_t horiz_edge, uint8_t diag_edge)
{
int x, y;
- pixel *dst = (pixel *)_dst;
- pixel *src = (pixel *)_src;
+ pixel *dst = (pixel*)_dst;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t stride = _stride / sizeof(pixel);
int chroma = !!c_idx;
int *sao_offset_val = sao->offset_val[c_idx];
- int sao_eo_class = sao->eo_class[c_idx];
- int init_x = 0, init_y = 0, width = _width, height = _height;
+ int sao_eo_class = sao->eo_class[c_idx];
static const int8_t pos[4][2][2] = {
{ { -1, 0 }, { 1, 0 } }, // horizontal
@@ -457,9 +456,9 @@ static void FUNC(sao_edge_filter_0)(uint8_t *_dst, uint8_t *_src,
};
static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
-#define CMP(a, b) ((a) > (b) ? 1 : ((a) == (b) ? 0 : -1))
+ int init_x = 0, init_y = 0, width = _width, height = _height;
- stride /= sizeof(pixel);
+#define CMP(a, b) ((a) > (b) ? 1 : ((a) == (b) ? 0 : -1))
if (!borders[2])
width -= (8 >> chroma) + 2;
@@ -492,15 +491,17 @@ static void FUNC(sao_edge_filter_0)(uint8_t *_dst, uint8_t *_src,
if (sao_eo_class != SAO_EO_HORIZ) {
if (borders[1]) {
int offset_val = sao_offset_val[0];
- for (x = init_x; x < width; x++)
+ for (x = init_x; x < width; x++) {
dst[x] = av_clip_pixel(src[x] + offset_val);
+ }
init_y = 1;
}
if (borders[3]) {
int offset_val = sao_offset_val[0];
int y_stride = stride * (height - 1);
- for (x = init_x; x < width; x++)
+ for (x = init_x; x < width; x++) {
dst[x + y_stride] = av_clip_pixel(src[x + y_stride] + offset_val);
+ }
height--;
}
}
@@ -543,7 +544,7 @@ static void FUNC(sao_edge_filter_0)(uint8_t *_dst, uint8_t *_src,
}
static void FUNC(sao_edge_filter_1)(uint8_t *_dst, uint8_t *_src,
- ptrdiff_t stride, SAOParams *sao,
+ ptrdiff_t _stride, SAOParams *sao,
int *borders, int _width, int _height,
int c_idx, uint8_t vert_edge,
uint8_t horiz_edge, uint8_t diag_edge)
@@ -551,10 +552,10 @@ static void FUNC(sao_edge_filter_1)(uint8_t *_dst, uint8_t *_src,
int x, y;
pixel *dst = (pixel *)_dst;
pixel *src = (pixel *)_src;
+ ptrdiff_t stride = _stride / sizeof(pixel);
int chroma = !!c_idx;
int *sao_offset_val = sao->offset_val[c_idx];
int sao_eo_class = sao->eo_class[c_idx];
- int init_x = 0, init_y = 0, width = _width, height = _height;
static const int8_t pos[4][2][2] = {
{ { -1, 0 }, { 1, 0 } }, // horizontal
@@ -564,9 +565,9 @@ static void FUNC(sao_edge_filter_1)(uint8_t *_dst, uint8_t *_src,
};
static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
-#define CMP(a, b) ((a) > (b) ? 1 : ((a) == (b) ? 0 : -1))
+ int init_x = 0, init_y = 0, width = _width, height = _height;
- stride /= sizeof(pixel);
+#define CMP(a, b) ((a) > (b) ? 1 : ((a) == (b) ? 0 : -1))
init_y = -(4 >> chroma) - 2;
if (!borders[2])
@@ -635,7 +636,7 @@ static void FUNC(sao_edge_filter_1)(uint8_t *_dst, uint8_t *_src,
}
static void FUNC(sao_edge_filter_2)(uint8_t *_dst, uint8_t *_src,
- ptrdiff_t stride, SAOParams *sao,
+ ptrdiff_t _stride, SAOParams *sao,
int *borders, int _width, int _height,
int c_idx, uint8_t vert_edge,
uint8_t horiz_edge, uint8_t diag_edge)
@@ -643,10 +644,10 @@ static void FUNC(sao_edge_filter_2)(uint8_t *_dst, uint8_t *_src,
int x, y;
pixel *dst = (pixel *)_dst;
pixel *src = (pixel *)_src;
+ ptrdiff_t stride = _stride / sizeof(pixel);
int chroma = !!c_idx;
int *sao_offset_val = sao->offset_val[c_idx];
int sao_eo_class = sao->eo_class[c_idx];
- int init_x = 0, init_y = 0, width = _width, height = _height;
static const int8_t pos[4][2][2] = {
{ { -1, 0 }, { 1, 0 } }, // horizontal
@@ -656,9 +657,9 @@ static void FUNC(sao_edge_filter_2)(uint8_t *_dst, uint8_t *_src,
};
static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
-#define CMP(a, b) ((a) > (b) ? 1 : ((a) == (b) ? 0 : -1))
+ int init_x = 0, init_y = 0, width = _width, height = _height;
- stride /= sizeof(pixel);
+#define CMP(a, b) ((a) > (b) ? 1 : ((a) == (b) ? 0 : -1))
init_x = -(8 >> chroma) - 2;
width = (8 >> chroma) + 2;
@@ -671,15 +672,17 @@ static void FUNC(sao_edge_filter_2)(uint8_t *_dst, uint8_t *_src,
if (sao_eo_class != SAO_EO_HORIZ) {
if (borders[1]) {
int offset_val = sao_offset_val[0];
- for (x = init_x; x < width; x++)
+ for (x = init_x; x < width; x++) {
dst[x] = av_clip_pixel(src[x] + offset_val);
+ }
init_y = 1;
}
if (borders[3]) {
int offset_val = sao_offset_val[0];
int y_stride = stride * (height - 1);
- for (x = init_x; x < width; x++)
+ for (x = init_x; x < width; x++) {
dst[x + y_stride] = av_clip_pixel(src[x + y_stride] + offset_val);
+ }
height--;
}
}
@@ -721,7 +724,7 @@ static void FUNC(sao_edge_filter_2)(uint8_t *_dst, uint8_t *_src,
}
static void FUNC(sao_edge_filter_3)(uint8_t *_dst, uint8_t *_src,
- ptrdiff_t stride, SAOParams *sao,
+ ptrdiff_t _stride, SAOParams *sao,
int *borders, int _width, int _height,
int c_idx, uint8_t vert_edge,
uint8_t horiz_edge, uint8_t diag_edge)
@@ -729,10 +732,10 @@ static void FUNC(sao_edge_filter_3)(uint8_t *_dst, uint8_t *_src,
int x, y;
pixel *dst = (pixel *)_dst;
pixel *src = (pixel *)_src;
+ ptrdiff_t stride = _stride / sizeof(pixel);
int chroma = !!c_idx;
int *sao_offset_val = sao->offset_val[c_idx];
int sao_eo_class = sao->eo_class[c_idx];
- int init_x = 0, init_y = 0, width = _width, height = _height;
static const int8_t pos[4][2][2] = {
{ { -1, 0 }, { 1, 0 } }, // horizontal
@@ -742,9 +745,9 @@ static void FUNC(sao_edge_filter_3)(uint8_t *_dst, uint8_t *_src,
};
static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
-#define CMP(a, b) ((a) > (b) ? 1 : ((a) == (b) ? 0 : -1))
+ int init_x = 0, init_y = 0, width = _width, height = _height;
- stride /= sizeof(pixel);
+#define CMP(a, b) ((a) > (b) ? 1 : ((a) == (b) ? 0 : -1))
init_y = -(4 >> chroma) - 2;
init_x = -(8 >> chroma) - 2;
@@ -798,9 +801,17 @@ static void FUNC(sao_edge_filter_3)(uint8_t *_dst, uint8_t *_src,
#undef SCALE
#undef ADD_AND_SCALE
#undef TR_4
+#undef TR_4_1
+#undef TR_4_2
#undef TR_8
+#undef TR_8_1
+#undef TR_8_2
#undef TR_16
+#undef TR_16_1
+#undef TR_16_2
#undef TR_32
+#undef TR_32_1
+#undef TR_32_2
static void FUNC(put_hevc_qpel_pixels)(int16_t *dst, ptrdiff_t dststride,
uint8_t *_src, ptrdiff_t _srcstride,
@@ -819,32 +830,16 @@ static void FUNC(put_hevc_qpel_pixels)(int16_t *dst, ptrdiff_t dststride,
}
#define QPEL_FILTER_1(src, stride) \
- (1 * -src[x - 3 * stride] + \
- 4 * src[x - 2 * stride] - \
- 10 * src[x - stride] + \
- 58 * src[x] + \
- 17 * src[x + stride] - \
- 5 * src[x + 2 * stride] + \
- 1 * src[x + 3 * stride])
+ (-src[x - 3 * stride] + 4 * src[x - 2 * stride] - 10 * src[x - stride] + 58 * src[x] + \
+ 17 * src[x + stride] - 5 * src[x + 2 * stride] + 1 * src[x + 3 * stride])
#define QPEL_FILTER_2(src, stride) \
- (1 * -src[x - 3 * stride] + \
- 4 * src[x - 2 * stride] - \
- 11 * src[x - stride] + \
- 40 * src[x] + \
- 40 * src[x + stride] - \
- 11 * src[x + 2 * stride] + \
- 4 * src[x + 3 * stride] - \
- 1 * src[x + 4 * stride])
+ (-src[x - 3 * stride] + 4 * src[x - 2 * stride] - 11 * src[x - stride] + 40 * src[x] + \
+ 40 * src[x + stride] - 11 * src[x + 2 * stride] + 4 * src[x + 3 * stride] - src[x + 4 * stride])
#define QPEL_FILTER_3(src, stride) \
- (1 * src[x - 2 * stride] - \
- 5 * src[x - stride] + \
- 17 * src[x] + \
- 58 * src[x + stride] - \
- 10 * src[x + 2 * stride] + \
- 4 * src[x + 3 * stride] - \
- 1 * src[x + 4 * stride])
+ (src[x - 2 * stride] - 5 * src[x - stride] + 17 * src[x] + 58 * src[x + stride] \
+ - 10 * src[x + 2 * stride] + 4 * src[x + 3 * stride] - src[x + 4 * stride])
#define PUT_HEVC_QPEL_H(H) \
@@ -884,10 +879,8 @@ static void FUNC(put_hevc_qpel_v ## V)(int16_t *dst, ptrdiff_t dststride, \
}
#define PUT_HEVC_QPEL_HV(H, V) \
-static void FUNC(put_hevc_qpel_h ## H ## v ## V)(int16_t *dst, \
- ptrdiff_t dststride, \
- uint8_t *_src, \
- ptrdiff_t _srcstride, \
+static void FUNC(put_hevc_qpel_h ## H ## v ## V)(int16_t *dst, ptrdiff_t dststride, \
+ uint8_t *_src, ptrdiff_t _srcstride,\
int width, int height, \
int16_t* mcbuffer) \
{ \
@@ -943,18 +936,16 @@ static void FUNC(put_hevc_epel_pixels)(int16_t *dst, ptrdiff_t dststride,
ptrdiff_t srcstride = _srcstride / sizeof(pixel);
for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++)
+ for (x = 0; x < width; x++) {
dst[x] = src[x] << (14 - BIT_DEPTH);
+ }
src += srcstride;
dst += dststride;
}
}
#define EPEL_FILTER(src, stride) \
- (filter_0 * src[x - stride] + \
- filter_1 * src[x] + \
- filter_2 * src[x + stride] + \
- filter_3 * src[x + 2 * stride])
+ (filter_0 * src[x - stride] + filter_1 * src[x] + filter_2 * src[x + stride] + filter_3 * src[x + 2 * stride])
static void FUNC(put_hevc_epel_h)(int16_t *dst, ptrdiff_t dststride,
uint8_t *_src, ptrdiff_t _srcstride,
@@ -970,8 +961,9 @@ static void FUNC(put_hevc_epel_h)(int16_t *dst, ptrdiff_t dststride,
int8_t filter_2 = filter[2];
int8_t filter_3 = filter[3];
for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++)
+ for (x = 0; x < width; x++) {
dst[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
+ }
src += srcstride;
dst += dststride;
}
@@ -992,8 +984,9 @@ static void FUNC(put_hevc_epel_v)(int16_t *dst, ptrdiff_t dststride,
int8_t filter_3 = filter[3];
for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++)
+ for (x = 0; x < width; x++) {
dst[x] = EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8);
+ }
src += srcstride;
dst += dststride;
}
@@ -1019,8 +1012,9 @@ static void FUNC(put_hevc_epel_hv)(int16_t *dst, ptrdiff_t dststride,
src -= EPEL_EXTRA_BEFORE * srcstride;
for (y = 0; y < height + EPEL_EXTRA; y++) {
- for (x = 0; x < width; x++)
+ for (x = 0; x < width; x++) {
tmp[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
+ }
src += srcstride;
tmp += MAX_PB_SIZE;
}
@@ -1031,8 +1025,9 @@ static void FUNC(put_hevc_epel_hv)(int16_t *dst, ptrdiff_t dststride,
filter_2 = filter_v[2];
filter_3 = filter_v[3];
for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++)
+ for (x = 0; x < width; x++) {
dst[x] = EPEL_FILTER(tmp, MAX_PB_SIZE) >> 6;
+ }
tmp += MAX_PB_SIZE;
dst += dststride;
}
@@ -1053,8 +1048,9 @@ static void FUNC(put_unweighted_pred)(uint8_t *_dst, ptrdiff_t _dststride,
int offset = 0;
#endif
for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++)
+ for (x = 0; x < width; x++) {
dst[x] = av_clip_pixel((src[x] + offset) >> shift);
+ }
dst += dststride;
src += srcstride;
}
@@ -1077,8 +1073,9 @@ static void FUNC(put_weighted_pred_avg)(uint8_t *_dst, ptrdiff_t _dststride,
#endif
for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++)
+ for (x = 0; x < width; x++) {
dst[x] = av_clip_pixel((src1[x] + src2[x] + offset) >> shift);
+ }
dst += dststride;
src1 += srcstride;
src2 += srcstride;
@@ -1090,7 +1087,12 @@ static void FUNC(weighted_pred)(uint8_t denom, int16_t wlxFlag, int16_t olxFlag,
int16_t *src, ptrdiff_t srcstride,
int width, int height)
{
- int shift, log2Wd, wx, ox, x, y, offset;
+ int shift;
+ int log2Wd;
+ int wx;
+ int ox;
+ int x , y;
+ int offset;
pixel *dst = (pixel *)_dst;
ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -1121,7 +1123,13 @@ static void FUNC(weighted_pred_avg)(uint8_t denom,
ptrdiff_t srcstride,
int width, int height)
{
- int shift, log2Wd, w0, w1, o0, o1, x, y;
+ int shift;
+ int log2Wd;
+ int w0;
+ int w1;
+ int o0;
+ int o1;
+ int x , y;
pixel *dst = (pixel *)_dst;
ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -1129,13 +1137,14 @@ static void FUNC(weighted_pred_avg)(uint8_t denom,
log2Wd = denom + shift;
w0 = wl0Flag;
w1 = wl1Flag;
- o0 = ol0Flag * (1 << (BIT_DEPTH - 8));
- o1 = ol1Flag * (1 << (BIT_DEPTH - 8));
+ o0 = (ol0Flag) * (1 << (BIT_DEPTH - 8));
+ o1 = (ol1Flag) * (1 << (BIT_DEPTH - 8));
for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++)
+ for (x = 0; x < width; x++) {
dst[x] = av_clip_pixel((src1[x] * w0 + src2[x] * w1 +
((o0 + o1 + 1) << log2Wd)) >> (log2Wd + 1));
+ }
dst += dststride;
src1 += srcstride;
src2 += srcstride;
@@ -1146,9 +1155,9 @@ static void FUNC(weighted_pred_avg)(uint8_t denom,
#define P3 pix[-4 * xstride]
#define P2 pix[-3 * xstride]
#define P1 pix[-2 * xstride]
-#define P0 pix[-1 * xstride]
-#define Q0 pix[0 * xstride]
-#define Q1 pix[1 * xstride]
+#define P0 pix[-xstride]
+#define Q0 pix[0]
+#define Q1 pix[xstride]
#define Q2 pix[2 * xstride]
#define Q3 pix[3 * xstride]
@@ -1156,9 +1165,9 @@ static void FUNC(weighted_pred_avg)(uint8_t denom,
#define TP3 pix[-4 * xstride + 3 * ystride]
#define TP2 pix[-3 * xstride + 3 * ystride]
#define TP1 pix[-2 * xstride + 3 * ystride]
-#define TP0 pix[-1 * xstride + 3 * ystride]
-#define TQ0 pix[0 * xstride + 3 * ystride]
-#define TQ1 pix[1 * xstride + 3 * ystride]
+#define TP0 pix[-xstride+3 * ystride]
+#define TQ0 pix[3 * ystride]
+#define TQ1 pix[xstride+3 * ystride]
#define TQ2 pix[2 * xstride + 3 * ystride]
#define TQ3 pix[3 * xstride + 3 * ystride]
@@ -1179,12 +1188,12 @@ static void FUNC(hevc_loop_filter_luma)(uint8_t *_pix,
const int dq3 = abs(TQ2 - 2 * TQ1 + TQ0);
const int d0 = dp0 + dq0;
const int d3 = dp3 + dq3;
- const int beta = _beta[j] << (BIT_DEPTH - 8);
+ int beta = _beta[j] << (BIT_DEPTH - 8);
const int tc = _tc[j] << (BIT_DEPTH - 8);
const int no_p = _no_p[j];
const int no_q = _no_q[j];
- if (d0 + d3 >= beta) {
+ if (d0 + d3 >= beta /*|| tc <= 0*/) {
pix += 4 * ystride;
continue;
} else {
@@ -1261,7 +1270,8 @@ static void FUNC(hevc_loop_filter_chroma)(uint8_t *_pix, ptrdiff_t _xstride,
ptrdiff_t _ystride, int *_tc,
uint8_t *_no_p, uint8_t *_no_q)
{
- int d, j, no_p, no_q;
+ int d, j;
+ int no_p, no_q;
pixel *pix = (pixel *)_pix;
ptrdiff_t xstride = _xstride / sizeof(pixel);
ptrdiff_t ystride = _ystride / sizeof(pixel);