/src/ffmpeg/libavcodec/diracdsp.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) 2009 David Conrad |
3 | | * |
4 | | * This file is part of FFmpeg. |
5 | | * |
6 | | * FFmpeg is free software; you can redistribute it and/or |
7 | | * modify it under the terms of the GNU Lesser General Public |
8 | | * License as published by the Free Software Foundation; either |
9 | | * version 2.1 of the License, or (at your option) any later version. |
10 | | * |
11 | | * FFmpeg is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | | * Lesser General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU Lesser General Public |
17 | | * License along with FFmpeg; if not, write to the Free Software |
18 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | | */ |
20 | | |
21 | | #include "config.h" |
22 | | #include "libavutil/attributes.h" |
23 | | #include "libavutil/common.h" |
24 | | #include "diracdsp.h" |
25 | | |
26 | | #define FILTER(src, stride) \ |
27 | 394M | ((21*((src)[ 0*stride] + (src)[1*stride]) \ |
28 | 394M | -7*((src)[-1*stride] + (src)[2*stride]) \ |
29 | 394M | +3*((src)[-2*stride] + (src)[3*stride]) \ |
30 | 394M | -1*((src)[-3*stride] + (src)[4*stride]) + 16) >> 5) |
31 | | |
32 | | static void dirac_hpel_filter(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, const uint8_t *src, |
33 | | int stride, int width, int height) |
34 | 27.9k | { |
35 | 27.9k | int x, y; |
36 | | |
37 | 1.54M | for (y = 0; y < height; y++) { |
38 | 141M | for (x = -3; x < width+5; x++) |
39 | 139M | dstv[x] = av_clip_uint8(FILTER(src+x, stride)); |
40 | | |
41 | 128M | for (x = 0; x < width; x++) |
42 | 127M | dstc[x] = av_clip_uint8(FILTER(dstv+x, 1)); |
43 | | |
44 | 128M | for (x = 0; x < width; x++) |
45 | 127M | dsth[x] = av_clip_uint8(FILTER(src+x, 1)); |
46 | | |
47 | 1.52M | src += stride; |
48 | 1.52M | dsth += stride; |
49 | 1.52M | dstv += stride; |
50 | 1.52M | dstc += stride; |
51 | 1.52M | } |
52 | 27.9k | } |
53 | | |
54 | | #define PIXOP_BILINEAR(PFX, OP, WIDTH) \ |
55 | | static void ff_ ## PFX ## _dirac_pixels ## WIDTH ## _bilinear_c(uint8_t *dst, const uint8_t *src[5], int stride, int h) \ |
56 | 224k | { \ |
57 | 224k | int x; \ |
58 | 224k | const uint8_t *s0 = src[0]; \ |
59 | 224k | const uint8_t *s1 = src[1]; \ |
60 | 224k | const uint8_t *s2 = src[2]; \ |
61 | 224k | const uint8_t *s3 = src[3]; \ |
62 | 224k | const uint8_t *w = src[4]; \ |
63 | 224k | \ |
64 | 3.15M | while (h--) { \ |
65 | 63.5M | for (x = 0; x < WIDTH; x++) { \ |
66 | 60.5M | OP(dst[x], (s0[x]*w[0] + s1[x]*w[1] + s2[x]*w[2] + s3[x]*w[3] + 8) >> 4); \ |
67 | 60.5M | } \ |
68 | 2.93M | \ |
69 | 2.93M | dst += stride; \ |
70 | 2.93M | s0 += stride; \ |
71 | 2.93M | s1 += stride; \ |
72 | 2.93M | s2 += stride; \ |
73 | 2.93M | s3 += stride; \ |
74 | 2.93M | } \ |
75 | 224k | } diracdsp.c:ff_put_dirac_pixels8_bilinear_c Line | Count | Source | 56 | 35.3k | { \ | 57 | 35.3k | int x; \ | 58 | 35.3k | const uint8_t *s0 = src[0]; \ | 59 | 35.3k | const uint8_t *s1 = src[1]; \ | 60 | 35.3k | const uint8_t *s2 = src[2]; \ | 61 | 35.3k | const uint8_t *s3 = src[3]; \ | 62 | 35.3k | const uint8_t *w = src[4]; \ | 63 | 35.3k | \ | 64 | 236k | while (h--) { \ | 65 | 1.81M | for (x = 0; x < WIDTH; x++) { \ | 66 | 1.61M | OP(dst[x], (s0[x]*w[0] + s1[x]*w[1] + s2[x]*w[2] + s3[x]*w[3] + 8) >> 4); \ | 67 | 1.61M | } \ | 68 | 201k | \ | 69 | 201k | dst += stride; \ | 70 | 201k | s0 += stride; \ | 71 | 201k | s1 += stride; \ | 72 | 201k | s2 += stride; \ | 73 | 201k | s3 += stride; \ | 74 | 201k | } \ | 75 | 35.3k | } |
diracdsp.c:ff_put_dirac_pixels16_bilinear_c Line | Count | Source | 56 | 129k | { \ | 57 | 129k | int x; \ | 58 | 129k | const uint8_t *s0 = src[0]; \ | 59 | 129k | const uint8_t *s1 = src[1]; \ | 60 | 129k | const uint8_t *s2 = src[2]; \ | 61 | 129k | const uint8_t *s3 = src[3]; \ | 62 | 129k | const uint8_t *w = src[4]; \ | 63 | 129k | \ | 64 | 1.87M | while (h--) { \ | 65 | 29.6M | for (x = 0; x < WIDTH; x++) { \ | 66 | 27.9M | OP(dst[x], (s0[x]*w[0] + s1[x]*w[1] + s2[x]*w[2] + s3[x]*w[3] + 8) >> 4); \ | 67 | 27.9M | } \ | 68 | 1.74M | \ | 69 | 1.74M | dst += stride; \ | 70 | 1.74M | s0 += stride; \ | 71 | 1.74M | s1 += stride; \ | 72 | 1.74M | s2 += stride; \ | 73 | 1.74M | s3 += stride; \ | 74 | 1.74M | } \ | 75 | 129k | } |
diracdsp.c:ff_put_dirac_pixels32_bilinear_c Line | Count | Source | 56 | 40.1k | { \ | 57 | 40.1k | int x; \ | 58 | 40.1k | const uint8_t *s0 = src[0]; \ | 59 | 40.1k | const uint8_t *s1 = src[1]; \ | 60 | 40.1k | const uint8_t *s2 = src[2]; \ | 61 | 40.1k | const uint8_t *s3 = src[3]; \ | 62 | 40.1k | const uint8_t *w = src[4]; \ | 63 | 40.1k | \ | 64 | 729k | while (h--) { \ | 65 | 22.7M | for (x = 0; x < WIDTH; x++) { \ | 66 | 22.0M | OP(dst[x], (s0[x]*w[0] + s1[x]*w[1] + s2[x]*w[2] + s3[x]*w[3] + 8) >> 4); \ | 67 | 22.0M | } \ | 68 | 689k | \ | 69 | 689k | dst += stride; \ | 70 | 689k | s0 += stride; \ | 71 | 689k | s1 += stride; \ | 72 | 689k | s2 += stride; \ | 73 | 689k | s3 += stride; \ | 74 | 689k | } \ | 75 | 40.1k | } |
diracdsp.c:ff_avg_dirac_pixels8_bilinear_c Line | Count | Source | 56 | 1.13k | { \ | 57 | 1.13k | int x; \ | 58 | 1.13k | const uint8_t *s0 = src[0]; \ | 59 | 1.13k | const uint8_t *s1 = src[1]; \ | 60 | 1.13k | const uint8_t *s2 = src[2]; \ | 61 | 1.13k | const uint8_t *s3 = src[3]; \ | 62 | 1.13k | const uint8_t *w = src[4]; \ | 63 | 1.13k | \ | 64 | 10.4k | while (h--) { \ | 65 | 83.6k | for (x = 0; x < WIDTH; x++) { \ | 66 | 74.3k | OP(dst[x], (s0[x]*w[0] + s1[x]*w[1] + s2[x]*w[2] + s3[x]*w[3] + 8) >> 4); \ | 67 | 74.3k | } \ | 68 | 9.29k | \ | 69 | 9.29k | dst += stride; \ | 70 | 9.29k | s0 += stride; \ | 71 | 9.29k | s1 += stride; \ | 72 | 9.29k | s2 += stride; \ | 73 | 9.29k | s3 += stride; \ | 74 | 9.29k | } \ | 75 | 1.13k | } |
diracdsp.c:ff_avg_dirac_pixels16_bilinear_c Line | Count | Source | 56 | 1.93k | { \ | 57 | 1.93k | int x; \ | 58 | 1.93k | const uint8_t *s0 = src[0]; \ | 59 | 1.93k | const uint8_t *s1 = src[1]; \ | 60 | 1.93k | const uint8_t *s2 = src[2]; \ | 61 | 1.93k | const uint8_t *s3 = src[3]; \ | 62 | 1.93k | const uint8_t *w = src[4]; \ | 63 | 1.93k | \ | 64 | 19.5k | while (h--) { \ | 65 | 298k | for (x = 0; x < WIDTH; x++) { \ | 66 | 281k | OP(dst[x], (s0[x]*w[0] + s1[x]*w[1] + s2[x]*w[2] + s3[x]*w[3] + 8) >> 4); \ | 67 | 281k | } \ | 68 | 17.5k | \ | 69 | 17.5k | dst += stride; \ | 70 | 17.5k | s0 += stride; \ | 71 | 17.5k | s1 += stride; \ | 72 | 17.5k | s2 += stride; \ | 73 | 17.5k | s3 += stride; \ | 74 | 17.5k | } \ | 75 | 1.93k | } |
diracdsp.c:ff_avg_dirac_pixels32_bilinear_c Line | Count | Source | 56 | 16.7k | { \ | 57 | 16.7k | int x; \ | 58 | 16.7k | const uint8_t *s0 = src[0]; \ | 59 | 16.7k | const uint8_t *s1 = src[1]; \ | 60 | 16.7k | const uint8_t *s2 = src[2]; \ | 61 | 16.7k | const uint8_t *s3 = src[3]; \ | 62 | 16.7k | const uint8_t *w = src[4]; \ | 63 | 16.7k | \ | 64 | 285k | while (h--) { \ | 65 | 8.87M | for (x = 0; x < WIDTH; x++) { \ | 66 | 8.60M | OP(dst[x], (s0[x]*w[0] + s1[x]*w[1] + s2[x]*w[2] + s3[x]*w[3] + 8) >> 4); \ | 67 | 8.60M | } \ | 68 | 268k | \ | 69 | 268k | dst += stride; \ | 70 | 268k | s0 += stride; \ | 71 | 268k | s1 += stride; \ | 72 | 268k | s2 += stride; \ | 73 | 268k | s3 += stride; \ | 74 | 268k | } \ | 75 | 16.7k | } |
|
76 | | |
77 | 51.6M | #define OP_PUT(dst, val) (dst) = (val) |
78 | 8.95M | #define OP_AVG(dst, val) (dst) = (((dst) + (val) + 1)>>1) |
79 | | |
80 | 1.61M | PIXOP_BILINEAR(put, OP_PUT, 8) |
81 | 27.9M | PIXOP_BILINEAR(put, OP_PUT, 16) |
82 | 22.0M | PIXOP_BILINEAR(put, OP_PUT, 32) |
83 | 74.3k | PIXOP_BILINEAR(avg, OP_AVG, 8) |
84 | 281k | PIXOP_BILINEAR(avg, OP_AVG, 16) |
85 | 8.60M | PIXOP_BILINEAR(avg, OP_AVG, 32) |
86 | | |
87 | 366M | #define op_scale1(x) block[x] = av_clip_uint8( (block[x]*weight + (1<<(log2_denom-1))) >> log2_denom) |
88 | 615M | #define op_scale2(x) dst[x] = av_clip_uint8( (src[x]*weights + dst[x]*weightd + (1<<(log2_denom-1))) >> log2_denom) |
89 | | |
90 | | #define DIRAC_WEIGHT(W) \ |
91 | | static void weight_dirac_pixels ## W ## _c(uint8_t *block, int stride, int log2_denom, \ |
92 | 878k | int weight, int h) { \ |
93 | 878k | int x; \ |
94 | 10.6M | while (h--) { \ |
95 | 192M | for (x = 0; x < W; x++) { \ |
96 | 183M | op_scale1(x); \ |
97 | 183M | op_scale1(x+1); \ |
98 | 183M | } \ |
99 | 9.72M | block += stride; \ |
100 | 9.72M | } \ |
101 | 878k | } \ diracdsp.c:weight_dirac_pixels8_c Line | Count | Source | 92 | 497k | int weight, int h) { \ | 93 | 497k | int x; \ | 94 | 3.40M | while (h--) { \ | 95 | 26.1M | for (x = 0; x < W; x++) { \ | 96 | 23.2M | op_scale1(x); \ | 97 | 23.2M | op_scale1(x+1); \ | 98 | 23.2M | } \ | 99 | 2.90M | block += stride; \ | 100 | 2.90M | } \ | 101 | 497k | } \ |
diracdsp.c:weight_dirac_pixels16_c Line | Count | Source | 92 | 245k | int weight, int h) { \ | 93 | 245k | int x; \ | 94 | 3.89M | while (h--) { \ | 95 | 62.0M | for (x = 0; x < W; x++) { \ | 96 | 58.3M | op_scale1(x); \ | 97 | 58.3M | op_scale1(x+1); \ | 98 | 58.3M | } \ | 99 | 3.64M | block += stride; \ | 100 | 3.64M | } \ | 101 | 245k | } \ |
diracdsp.c:weight_dirac_pixels32_c Line | Count | Source | 92 | 134k | int weight, int h) { \ | 93 | 134k | int x; \ | 94 | 3.30M | while (h--) { \ | 95 | 104M | for (x = 0; x < W; x++) { \ | 96 | 101M | op_scale1(x); \ | 97 | 101M | op_scale1(x+1); \ | 98 | 101M | } \ | 99 | 3.17M | block += stride; \ | 100 | 3.17M | } \ | 101 | 134k | } \ |
|
102 | | static void biweight_dirac_pixels ## W ## _c(uint8_t *dst, const uint8_t *src, int stride, int log2_denom, \ |
103 | 1.37M | int weightd, int weights, int h) { \ |
104 | 1.37M | int x; \ |
105 | 15.7M | while (h--) { \ |
106 | 321M | for (x = 0; x < W; x++) { \ |
107 | 307M | op_scale2(x); \ |
108 | 307M | op_scale2(x+1); \ |
109 | 307M | } \ |
110 | 14.3M | dst += stride; \ |
111 | 14.3M | src += stride; \ |
112 | 14.3M | } \ |
113 | 1.37M | } diracdsp.c:biweight_dirac_pixels8_c Line | Count | Source | 103 | 579k | int weightd, int weights, int h) { \ | 104 | 579k | int x; \ | 105 | 3.39M | while (h--) { \ | 106 | 25.3M | for (x = 0; x < W; x++) { \ | 107 | 22.5M | op_scale2(x); \ | 108 | 22.5M | op_scale2(x+1); \ | 109 | 22.5M | } \ | 110 | 2.81M | dst += stride; \ | 111 | 2.81M | src += stride; \ | 112 | 2.81M | } \ | 113 | 579k | } |
diracdsp.c:biweight_dirac_pixels16_c Line | Count | Source | 103 | 394k | int weightd, int weights, int h) { \ | 104 | 394k | int x; \ | 105 | 5.62M | while (h--) { \ | 106 | 88.9M | for (x = 0; x < W; x++) { \ | 107 | 83.7M | op_scale2(x); \ | 108 | 83.7M | op_scale2(x+1); \ | 109 | 83.7M | } \ | 110 | 5.23M | dst += stride; \ | 111 | 5.23M | src += stride; \ | 112 | 5.23M | } \ | 113 | 394k | } |
diracdsp.c:biweight_dirac_pixels32_c Line | Count | Source | 103 | 400k | int weightd, int weights, int h) { \ | 104 | 400k | int x; \ | 105 | 6.69M | while (h--) { \ | 106 | 207M | for (x = 0; x < W; x++) { \ | 107 | 201M | op_scale2(x); \ | 108 | 201M | op_scale2(x+1); \ | 109 | 201M | } \ | 110 | 6.28M | dst += stride; \ | 111 | 6.28M | src += stride; \ | 112 | 6.28M | } \ | 113 | 400k | } |
|
114 | | |
115 | | DIRAC_WEIGHT(8) |
116 | | DIRAC_WEIGHT(16) |
117 | | DIRAC_WEIGHT(32) |
118 | | |
119 | | #define ADD_OBMC(xblen) \ |
120 | | static void add_obmc ## xblen ## _c(uint16_t *dst, const uint8_t *src, int stride, \ |
121 | | const uint8_t *obmc_weight, int yblen) \ |
122 | 40.1M | { \ |
123 | 40.1M | int x; \ |
124 | 120M | while (yblen--) { \ |
125 | 598M | for (x = 0; x < xblen; x += 2) { \ |
126 | 518M | dst[x ] += src[x ] * obmc_weight[x ]; \ |
127 | 518M | dst[x+1] += src[x+1] * obmc_weight[x+1]; \ |
128 | 518M | } \ |
129 | 80.2M | dst += stride; \ |
130 | 80.2M | src += stride; \ |
131 | 80.2M | obmc_weight += 32; \ |
132 | 80.2M | } \ |
133 | 40.1M | } Line | Count | Source | 122 | 38.3M | { \ | 123 | 38.3M | int x; \ | 124 | 91.5M | while (yblen--) { \ | 125 | 265M | for (x = 0; x < xblen; x += 2) { \ | 126 | 212M | dst[x ] += src[x ] * obmc_weight[x ]; \ | 127 | 212M | dst[x+1] += src[x+1] * obmc_weight[x+1]; \ | 128 | 212M | } \ | 129 | 53.1M | dst += stride; \ | 130 | 53.1M | src += stride; \ | 131 | 53.1M | obmc_weight += 32; \ | 132 | 53.1M | } \ | 133 | 38.3M | } |
Line | Count | Source | 122 | 1.22M | { \ | 123 | 1.22M | int x; \ | 124 | 17.0M | while (yblen--) { \ | 125 | 142M | for (x = 0; x < xblen; x += 2) { \ | 126 | 126M | dst[x ] += src[x ] * obmc_weight[x ]; \ | 127 | 126M | dst[x+1] += src[x+1] * obmc_weight[x+1]; \ | 128 | 126M | } \ | 129 | 15.8M | dst += stride; \ | 130 | 15.8M | src += stride; \ | 131 | 15.8M | obmc_weight += 32; \ | 132 | 15.8M | } \ | 133 | 1.22M | } |
Line | Count | Source | 122 | 630k | { \ | 123 | 630k | int x; \ | 124 | 11.8M | while (yblen--) { \ | 125 | 190M | for (x = 0; x < xblen; x += 2) { \ | 126 | 178M | dst[x ] += src[x ] * obmc_weight[x ]; \ | 127 | 178M | dst[x+1] += src[x+1] * obmc_weight[x+1]; \ | 128 | 178M | } \ | 129 | 11.1M | dst += stride; \ | 130 | 11.1M | src += stride; \ | 131 | 11.1M | obmc_weight += 32; \ | 132 | 11.1M | } \ | 133 | 630k | } |
|
134 | | |
135 | | ADD_OBMC(8) |
136 | | ADD_OBMC(16) |
137 | | ADD_OBMC(32) |
138 | | |
139 | | static void put_signed_rect_clamped_8bit_c(uint8_t *dst, int dst_stride, const uint8_t *_src, int src_stride, int width, int height) |
140 | 616k | { |
141 | 616k | int x, y; |
142 | 616k | const int16_t *src = (const int16_t *)_src; |
143 | 10.4M | for (y = 0; y < height; y++) { |
144 | 328M | for (x = 0; x < width; x+=4) { |
145 | 318M | dst[x ] = av_clip_uint8(src[x ] + 128); |
146 | 318M | dst[x+1] = av_clip_uint8(src[x+1] + 128); |
147 | 318M | dst[x+2] = av_clip_uint8(src[x+2] + 128); |
148 | 318M | dst[x+3] = av_clip_uint8(src[x+3] + 128); |
149 | 318M | } |
150 | 9.86M | dst += dst_stride; |
151 | 9.86M | src += src_stride >> 1; |
152 | 9.86M | } |
153 | 616k | } |
154 | | |
155 | | #define PUT_SIGNED_RECT_CLAMPED(PX) \ |
156 | | static void put_signed_rect_clamped_ ## PX ## bit_c(uint8_t *_dst, int dst_stride, const uint8_t *_src, \ |
157 | 700k | int src_stride, int width, int height) \ |
158 | 700k | { \ |
159 | 700k | int x, y; \ |
160 | 700k | uint16_t *dst = (uint16_t *)_dst; \ |
161 | 700k | const int32_t *src = (const int32_t *)_src; \ |
162 | 11.9M | for (y = 0; y < height; y++) { \ |
163 | 583M | for (x = 0; x < width; x+=4) { \ |
164 | 571M | dst[x ] = av_clip_uintp2(src[x ] + (1U << (PX - 1)), PX); \ |
165 | 571M | dst[x+1] = av_clip_uintp2(src[x+1] + (1U << (PX - 1)), PX); \ |
166 | 571M | dst[x+2] = av_clip_uintp2(src[x+2] + (1U << (PX - 1)), PX); \ |
167 | 571M | dst[x+3] = av_clip_uintp2(src[x+3] + (1U << (PX - 1)), PX); \ |
168 | 571M | } \ |
169 | 11.2M | dst += dst_stride >> 1; \ |
170 | 11.2M | src += src_stride >> 2; \ |
171 | 11.2M | } \ |
172 | 700k | } diracdsp.c:put_signed_rect_clamped_10bit_c Line | Count | Source | 157 | 431k | int src_stride, int width, int height) \ | 158 | 431k | { \ | 159 | 431k | int x, y; \ | 160 | 431k | uint16_t *dst = (uint16_t *)_dst; \ | 161 | 431k | const int32_t *src = (const int32_t *)_src; \ | 162 | 7.33M | for (y = 0; y < height; y++) { \ | 163 | 479M | for (x = 0; x < width; x+=4) { \ | 164 | 472M | dst[x ] = av_clip_uintp2(src[x ] + (1U << (PX - 1)), PX); \ | 165 | 472M | dst[x+1] = av_clip_uintp2(src[x+1] + (1U << (PX - 1)), PX); \ | 166 | 472M | dst[x+2] = av_clip_uintp2(src[x+2] + (1U << (PX - 1)), PX); \ | 167 | 472M | dst[x+3] = av_clip_uintp2(src[x+3] + (1U << (PX - 1)), PX); \ | 168 | 472M | } \ | 169 | 6.90M | dst += dst_stride >> 1; \ | 170 | 6.90M | src += src_stride >> 2; \ | 171 | 6.90M | } \ | 172 | 431k | } |
diracdsp.c:put_signed_rect_clamped_12bit_c Line | Count | Source | 157 | 268k | int src_stride, int width, int height) \ | 158 | 268k | { \ | 159 | 268k | int x, y; \ | 160 | 268k | uint16_t *dst = (uint16_t *)_dst; \ | 161 | 268k | const int32_t *src = (const int32_t *)_src; \ | 162 | 4.57M | for (y = 0; y < height; y++) { \ | 163 | 103M | for (x = 0; x < width; x+=4) { \ | 164 | 99.1M | dst[x ] = av_clip_uintp2(src[x ] + (1U << (PX - 1)), PX); \ | 165 | 99.1M | dst[x+1] = av_clip_uintp2(src[x+1] + (1U << (PX - 1)), PX); \ | 166 | 99.1M | dst[x+2] = av_clip_uintp2(src[x+2] + (1U << (PX - 1)), PX); \ | 167 | 99.1M | dst[x+3] = av_clip_uintp2(src[x+3] + (1U << (PX - 1)), PX); \ | 168 | 99.1M | } \ | 169 | 4.30M | dst += dst_stride >> 1; \ | 170 | 4.30M | src += src_stride >> 2; \ | 171 | 4.30M | } \ | 172 | 268k | } |
|
173 | | |
174 | | PUT_SIGNED_RECT_CLAMPED(10) |
175 | | PUT_SIGNED_RECT_CLAMPED(12) |
176 | | |
177 | | static void add_rect_clamped_c(uint8_t *dst, const uint16_t *src, int stride, |
178 | | const int16_t *idwt, int idwt_stride, |
179 | | int width, int height) |
180 | 997k | { |
181 | 997k | int x, y; |
182 | | |
183 | 4.89M | for (y = 0; y < height; y++) { |
184 | 234M | for (x = 0; x < width; x+=2) { |
185 | 230M | dst[x ] = av_clip_uint8(((src[x ]+32)>>6) + idwt[x ]); |
186 | 230M | dst[x+1] = av_clip_uint8(((src[x+1]+32)>>6) + idwt[x+1]); |
187 | 230M | } |
188 | 3.89M | dst += stride; |
189 | 3.89M | src += stride; |
190 | 3.89M | idwt += idwt_stride; |
191 | 3.89M | } |
192 | 997k | } |
193 | | |
194 | | #define DEQUANT_SUBBAND(PX) \ |
195 | | static void dequant_subband_ ## PX ## _c(uint8_t *src, uint8_t *dst, ptrdiff_t stride, \ |
196 | 149k | const int qf, const int qs, int tot_v, int tot_h) \ |
197 | 149k | { \ |
198 | 149k | int i, y; \ |
199 | 4.94M | for (y = 0; y < tot_v; y++) { \ |
200 | 4.79M | PX c, *src_r = (PX *)src, *dst_r = (PX *)dst; \ |
201 | 169M | for (i = 0; i < tot_h; i++) { \ |
202 | 164M | c = *src_r++; \ |
203 | 164M | if (c < 0) c = -((-(unsigned)c*qf + qs) >> 2); \ |
204 | 164M | else if(c > 0) c = (( (unsigned)c*qf + qs) >> 2); \ |
205 | 164M | *dst_r++ = c; \ |
206 | 164M | } \ |
207 | 4.79M | src += tot_h << (sizeof(PX) >> 1); \ |
208 | 4.79M | dst += stride; \ |
209 | 4.79M | } \ |
210 | 149k | } diracdsp.c:dequant_subband_int16_t_c Line | Count | Source | 196 | 76.6k | const int qf, const int qs, int tot_v, int tot_h) \ | 197 | 76.6k | { \ | 198 | 76.6k | int i, y; \ | 199 | 2.34M | for (y = 0; y < tot_v; y++) { \ | 200 | 2.26M | PX c, *src_r = (PX *)src, *dst_r = (PX *)dst; \ | 201 | 40.6M | for (i = 0; i < tot_h; i++) { \ | 202 | 38.3M | c = *src_r++; \ | 203 | 38.3M | if (c < 0) c = -((-(unsigned)c*qf + qs) >> 2); \ | 204 | 38.3M | else if(c > 0) c = (( (unsigned)c*qf + qs) >> 2); \ | 205 | 38.3M | *dst_r++ = c; \ | 206 | 38.3M | } \ | 207 | 2.26M | src += tot_h << (sizeof(PX) >> 1); \ | 208 | 2.26M | dst += stride; \ | 209 | 2.26M | } \ | 210 | 76.6k | } |
diracdsp.c:dequant_subband_int32_t_c Line | Count | Source | 196 | 72.5k | const int qf, const int qs, int tot_v, int tot_h) \ | 197 | 72.5k | { \ | 198 | 72.5k | int i, y; \ | 199 | 2.59M | for (y = 0; y < tot_v; y++) { \ | 200 | 2.52M | PX c, *src_r = (PX *)src, *dst_r = (PX *)dst; \ | 201 | 128M | for (i = 0; i < tot_h; i++) { \ | 202 | 126M | c = *src_r++; \ | 203 | 126M | if (c < 0) c = -((-(unsigned)c*qf + qs) >> 2); \ | 204 | 126M | else if(c > 0) c = (( (unsigned)c*qf + qs) >> 2); \ | 205 | 126M | *dst_r++ = c; \ | 206 | 126M | } \ | 207 | 2.52M | src += tot_h << (sizeof(PX) >> 1); \ | 208 | 2.52M | dst += stride; \ | 209 | 2.52M | } \ | 210 | 72.5k | } |
|
211 | | |
212 | | DEQUANT_SUBBAND(int16_t) |
213 | | DEQUANT_SUBBAND(int32_t) |
214 | | |
215 | | #define PIXFUNC(PFX, WIDTH) \ |
216 | 52.5k | c->PFX ## _dirac_pixels_tab[WIDTH>>4][0] = ff_ ## PFX ## _dirac_pixels ## WIDTH ## _c; \ |
217 | 52.5k | c->PFX ## _dirac_pixels_tab[WIDTH>>4][1] = ff_ ## PFX ## _dirac_pixels ## WIDTH ## _l2_c; \ |
218 | 52.5k | c->PFX ## _dirac_pixels_tab[WIDTH>>4][2] = ff_ ## PFX ## _dirac_pixels ## WIDTH ## _l4_c; \ |
219 | 52.5k | c->PFX ## _dirac_pixels_tab[WIDTH>>4][3] = ff_ ## PFX ## _dirac_pixels ## WIDTH ## _bilinear_c |
220 | | |
221 | | av_cold void ff_diracdsp_init(DiracDSPContext *c) |
222 | 8.76k | { |
223 | 8.76k | c->dirac_hpel_filter = dirac_hpel_filter; |
224 | 8.76k | c->add_rect_clamped = add_rect_clamped_c; |
225 | 8.76k | c->put_signed_rect_clamped[0] = put_signed_rect_clamped_8bit_c; |
226 | 8.76k | c->put_signed_rect_clamped[1] = put_signed_rect_clamped_10bit_c; |
227 | 8.76k | c->put_signed_rect_clamped[2] = put_signed_rect_clamped_12bit_c; |
228 | | |
229 | 8.76k | c->add_dirac_obmc[0] = add_obmc8_c; |
230 | 8.76k | c->add_dirac_obmc[1] = add_obmc16_c; |
231 | 8.76k | c->add_dirac_obmc[2] = add_obmc32_c; |
232 | | |
233 | 8.76k | c->weight_dirac_pixels_tab[0] = weight_dirac_pixels8_c; |
234 | 8.76k | c->weight_dirac_pixels_tab[1] = weight_dirac_pixels16_c; |
235 | 8.76k | c->weight_dirac_pixels_tab[2] = weight_dirac_pixels32_c; |
236 | 8.76k | c->biweight_dirac_pixels_tab[0] = biweight_dirac_pixels8_c; |
237 | 8.76k | c->biweight_dirac_pixels_tab[1] = biweight_dirac_pixels16_c; |
238 | 8.76k | c->biweight_dirac_pixels_tab[2] = biweight_dirac_pixels32_c; |
239 | | |
240 | 8.76k | c->dequant_subband[0] = c->dequant_subband[2] = dequant_subband_int16_t_c; |
241 | 8.76k | c->dequant_subband[1] = c->dequant_subband[3] = dequant_subband_int32_t_c; |
242 | | |
243 | 8.76k | PIXFUNC(put, 8); |
244 | 8.76k | PIXFUNC(put, 16); |
245 | 8.76k | PIXFUNC(put, 32); |
246 | 8.76k | PIXFUNC(avg, 8); |
247 | 8.76k | PIXFUNC(avg, 16); |
248 | 8.76k | PIXFUNC(avg, 32); |
249 | | |
250 | | #if ARCH_X86 && HAVE_X86ASM |
251 | | ff_diracdsp_init_x86(c); |
252 | | #endif |
253 | 8.76k | } |