summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/hevc.c11
-rw-r--r--libavcodec/hevcdsp.c20
-rw-r--r--libavcodec/hevcdsp.h10
-rw-r--r--libavcodec/hevcdsp_template.c89
4 files changed, 47 insertions, 83 deletions
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 5e1b3a0125..d5d3f59859 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -1208,17 +1208,16 @@ static void hls_residual_coding(HEVCContext *s, int x0, int y0,
}
}
- if (lc->cu.cu_transquant_bypass_flag) {
- s->hevcdsp.transquant_bypass[log2_trafo_size - 2](dst, coeffs, stride);
- } else {
+ if (!lc->cu.cu_transquant_bypass_flag) {
if (transform_skip_flag)
- s->hevcdsp.transform_skip(dst, coeffs, stride);
+ s->hevcdsp.dequant(coeffs);
else if (lc->cu.pred_mode == MODE_INTRA && c_idx == 0 &&
log2_trafo_size == 2)
- s->hevcdsp.transform_4x4_luma_add(dst, coeffs, stride);
+ s->hevcdsp.transform_4x4_luma(coeffs);
else
- s->hevcdsp.transform_add[log2_trafo_size - 2](dst, coeffs, stride);
+ s->hevcdsp.idct[log2_trafo_size - 2](coeffs);
}
+ s->hevcdsp.add_residual[log2_trafo_size - 2](dst, coeffs, stride);
}
static int hls_transform_unit(HEVCContext *s, int x0, int y0,
diff --git a/libavcodec/hevcdsp.c b/libavcodec/hevcdsp.c
index 15a712def7..4bd3d97299 100644
--- a/libavcodec/hevcdsp.c
+++ b/libavcodec/hevcdsp.c
@@ -164,16 +164,16 @@ void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth)
#define HEVC_DSP(depth) \
hevcdsp->put_pcm = FUNC(put_pcm, depth); \
- hevcdsp->transquant_bypass[0] = FUNC(transquant_bypass4x4, depth); \
- hevcdsp->transquant_bypass[1] = FUNC(transquant_bypass8x8, depth); \
- hevcdsp->transquant_bypass[2] = FUNC(transquant_bypass16x16, depth); \
- hevcdsp->transquant_bypass[3] = FUNC(transquant_bypass32x32, depth); \
- hevcdsp->transform_skip = FUNC(transform_skip, depth); \
- hevcdsp->transform_4x4_luma_add = FUNC(transform_4x4_luma_add, depth); \
- hevcdsp->transform_add[0] = FUNC(transform_4x4_add, depth); \
- hevcdsp->transform_add[1] = FUNC(transform_8x8_add, depth); \
- hevcdsp->transform_add[2] = FUNC(transform_16x16_add, depth); \
- hevcdsp->transform_add[3] = FUNC(transform_32x32_add, depth); \
+ hevcdsp->add_residual[0] = FUNC(add_residual4x4, depth); \
+ hevcdsp->add_residual[1] = FUNC(add_residual8x8, depth); \
+ hevcdsp->add_residual[2] = FUNC(add_residual16x16, depth); \
+ hevcdsp->add_residual[3] = FUNC(add_residual32x32, depth); \
+ hevcdsp->dequant = FUNC(dequant, depth); \
+ hevcdsp->transform_4x4_luma = FUNC(transform_4x4_luma, depth); \
+ hevcdsp->idct[0] = FUNC(idct_4x4, depth); \
+ hevcdsp->idct[1] = FUNC(idct_8x8, depth); \
+ hevcdsp->idct[2] = FUNC(idct_16x16, depth); \
+ hevcdsp->idct[3] = FUNC(idct_32x32, depth); \
\
hevcdsp->sao_band_filter[0] = FUNC(sao_band_filter_0, depth); \
hevcdsp->sao_band_filter[1] = FUNC(sao_band_filter_1, depth); \
diff --git a/libavcodec/hevcdsp.h b/libavcodec/hevcdsp.h
index 4097233827..decd1c9376 100644
--- a/libavcodec/hevcdsp.h
+++ b/libavcodec/hevcdsp.h
@@ -42,13 +42,11 @@ typedef struct HEVCDSPContext {
void (*put_pcm)(uint8_t *dst, ptrdiff_t stride, int size,
GetBitContext *gb, int pcm_bit_depth);
- void (*transquant_bypass[4])(uint8_t *dst, int16_t *coeffs,
- ptrdiff_t stride);
+ void (*add_residual[4])(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
- void (*transform_skip)(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
- void (*transform_4x4_luma_add)(uint8_t *dst, int16_t *coeffs,
- ptrdiff_t stride);
- void (*transform_add[4])(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
+ void (*dequant)(int16_t *coeffs);
+ void (*transform_4x4_luma)(int16_t *coeffs);
+ void (*idct[4])(int16_t *coeffs);
void (*sao_band_filter[4])(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
struct SAOParams *sao, int *borders,
diff --git a/libavcodec/hevcdsp_template.c b/libavcodec/hevcdsp_template.c
index 31a2e7ab6f..b4816db624 100644
--- a/libavcodec/hevcdsp_template.c
+++ b/libavcodec/hevcdsp_template.c
@@ -40,8 +40,8 @@ static void FUNC(put_pcm)(uint8_t *_dst, ptrdiff_t stride, int size,
}
}
-static av_always_inline void FUNC(transquant_bypass)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride, int size)
+static av_always_inline void FUNC(add_residual)(uint8_t *_dst, int16_t *res,
+ ptrdiff_t stride, int size)
{
int x, y;
pixel *dst = (pixel *)_dst;
@@ -50,41 +50,39 @@ static av_always_inline void FUNC(transquant_bypass)(uint8_t *_dst, int16_t *coe
for (y = 0; y < size; y++) {
for (x = 0; x < size; x++) {
- dst[x] = av_clip_pixel(dst[x] + *coeffs);
- coeffs++;
+ dst[x] = av_clip_pixel(dst[x] + *res);
+ res++;
}
dst += stride;
}
}
-static void FUNC(transquant_bypass4x4)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(add_residual4x4)(uint8_t *_dst, int16_t *res,
+ ptrdiff_t stride)
{
- FUNC(transquant_bypass)(_dst, coeffs, stride, 4);
+ FUNC(add_residual)(_dst, res, stride, 4);
}
-static void FUNC(transquant_bypass8x8)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(add_residual8x8)(uint8_t *_dst, int16_t *res,
+ ptrdiff_t stride)
{
- FUNC(transquant_bypass)(_dst, coeffs, stride, 8);
+ FUNC(add_residual)(_dst, res, stride, 8);
}
-static void FUNC(transquant_bypass16x16)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(add_residual16x16)(uint8_t *_dst, int16_t *res,
+ ptrdiff_t stride)
{
- FUNC(transquant_bypass)(_dst, coeffs, stride, 16);
+ FUNC(add_residual)(_dst, res, stride, 16);
}
-static void FUNC(transquant_bypass32x32)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(add_residual32x32)(uint8_t *_dst, int16_t *res,
+ ptrdiff_t stride)
{
- FUNC(transquant_bypass)(_dst, coeffs, stride, 32);
+ FUNC(add_residual)(_dst, res, stride, 32);
}
-static void FUNC(transform_skip)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(dequant)(int16_t *coeffs)
{
- pixel *dst = (pixel *)_dst;
int shift = 13 - BIT_DEPTH;
#if BIT_DEPTH <= 13
int offset = 1 << (shift - 1);
@@ -93,19 +91,14 @@ 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++)
- dst[x] = av_clip_pixel(dst[x] + ((coeffs[y + x] + offset) >> shift));
- dst += stride;
+ coeffs[y + x] = (coeffs[y + x] + offset) >> shift;
}
}
#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 { \
@@ -122,17 +115,13 @@ static void FUNC(transform_skip)(uint8_t *_dst, int16_t *coeffs,
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)
+static void FUNC(transform_4x4_luma)(int16_t *coeffs)
{
int i;
- pixel *dst = (pixel *)_dst;
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++;
@@ -141,9 +130,8 @@ static void FUNC(transform_4x4_luma_add)(uint8_t *_dst, int16_t *coeffs,
shift = 20 - BIT_DEPTH;
add = 1 << (shift - 1);
for (i = 0; i < 4; i++) {
- TR_4x4_LUMA(dst, coeffs, 1, ADD_AND_SCALE);
+ TR_4x4_LUMA(coeffs, coeffs, 1, SCALE);
coeffs += 4;
- dst += stride;
}
}
@@ -166,17 +154,13 @@ static void FUNC(transform_4x4_luma_add)(uint8_t *_dst, int16_t *coeffs,
assign(dst[3 * dstep], e0 - o0); \
} while (0)
-static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(idct_4x4)(int16_t *coeffs)
{
int i;
- pixel *dst = (pixel *)_dst;
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);
src++;
@@ -185,9 +169,8 @@ static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs,
shift = 20 - BIT_DEPTH;
add = 1 << (shift - 1);
for (i = 0; i < 4; i++) {
- TR_4(dst, coeffs, 1, 1, ADD_AND_SCALE);
+ TR_4(coeffs, coeffs, 1, 1, SCALE);
coeffs += 4;
- dst += stride;
}
}
@@ -241,17 +224,13 @@ static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs,
-static void FUNC(transform_8x8_add)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(idct_8x8)(int16_t *coeffs)
{
int i;
- pixel *dst = (pixel *)_dst;
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);
src++;
@@ -260,23 +239,18 @@ static void FUNC(transform_8x8_add)(uint8_t *_dst, int16_t *coeffs,
shift = 20 - BIT_DEPTH;
add = 1 << (shift - 1);
for (i = 0; i < 8; i++) {
- TR_8(dst, coeffs, 1, 1, ADD_AND_SCALE);
+ TR_8(coeffs, coeffs, 1, 1, SCALE);
coeffs += 8;
- dst += stride;
}
}
-static void FUNC(transform_16x16_add)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(idct_16x16)(int16_t *coeffs)
{
int i;
- pixel *dst = (pixel *)_dst;
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);
src++;
@@ -285,23 +259,18 @@ static void FUNC(transform_16x16_add)(uint8_t *_dst, int16_t *coeffs,
shift = 20 - BIT_DEPTH;
add = 1 << (shift - 1);
for (i = 0; i < 16; i++) {
- TR_16(dst, coeffs, 1, 1, ADD_AND_SCALE);
+ TR_16(coeffs, coeffs, 1, 1, SCALE);
coeffs += 16;
- dst += stride;
}
}
-static void FUNC(transform_32x32_add)(uint8_t *_dst, int16_t *coeffs,
- ptrdiff_t stride)
+static void FUNC(idct_32x32)(int16_t *coeffs)
{
int i;
- pixel *dst = (pixel *)_dst;
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);
src++;
@@ -310,9 +279,8 @@ static void FUNC(transform_32x32_add)(uint8_t *_dst, int16_t *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(coeffs, coeffs, 1, 1, SCALE);
coeffs += 32;
- dst += stride;
}
}
@@ -769,7 +737,6 @@ static void FUNC(sao_edge_filter_3)(uint8_t *_dst, uint8_t *_src,
#undef SET
#undef SCALE
-#undef ADD_AND_SCALE
#undef TR_4
#undef TR_8
#undef TR_16