Browse code

fade: fix slice sizes

This more evenly distributes the load between threads

This also fixes the chroma filtering where the filter was applied twice

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2013/05/25 00:34:36
Showing 2 changed files
... ...
@@ -163,9 +163,8 @@ static int filter_slice_luma(AVFilterContext *ctx, void *arg, int jobnr,
163 163
 {
164 164
     FadeContext *s = ctx->priv;
165 165
     AVFrame *frame = arg;
166
-    int slice_h     = frame->height / nb_jobs;
167
-    int slice_start = jobnr * slice_h;
168
-    int slice_end   = (jobnr == nb_jobs - 1) ? frame->height : (jobnr + 1) * slice_h;
166
+    int slice_start = (frame->height *  jobnr   ) / nb_jobs;
167
+    int slice_end   = (frame->height * (jobnr+1)) / nb_jobs;
169 168
     int i, j;
170 169
 
171 170
     for (i = slice_start; i < slice_end; i++) {
... ...
@@ -187,15 +186,15 @@ static int filter_slice_chroma(AVFilterContext *ctx, void *arg, int jobnr,
187 187
 {
188 188
     FadeContext *s = ctx->priv;
189 189
     AVFrame *frame = arg;
190
-    int slice_h     = FFALIGN(frame->height / nb_jobs, 1 << s->vsub);
191
-    int slice_start = jobnr * slice_h;
192
-    int slice_end   = (jobnr == nb_jobs - 1) ? frame->height : (jobnr + 1) * slice_h;
193 190
     int i, j, plane;
194 191
     const int width = FF_CEIL_RSHIFT(frame->width, s->hsub);
192
+    const int height= FF_CEIL_RSHIFT(frame->height, s->vsub);
193
+    int slice_start = (height *  jobnr   ) / nb_jobs;
194
+    int slice_end   = (height * (jobnr+1)) / nb_jobs;
195 195
 
196 196
     for (plane = 1; plane < 3; plane++) {
197 197
         for (i = slice_start; i < slice_end; i++) {
198
-            uint8_t *p = frame->data[plane] + (i >> s->vsub) * frame->linesize[plane];
198
+            uint8_t *p = frame->data[plane] + i * frame->linesize[plane];
199 199
             for (j = 0; j < width; j++) {
200 200
                 /* 8421367 = ((128 << 1) + 1) << 15. It is an integer
201 201
                  * representation of 128.5. The .5 is for rounding
... ...
@@ -5,20 +5,20 @@
5 5
 0,          3,          3,        1,   152064, 0xb4e6c735
6 6
 0,          4,          4,        1,   152064, 0xb4e6c735
7 7
 0,          5,          5,        1,   152064, 0xb4e6c735
8
-0,          6,          6,        1,   152064, 0x54bae320
9
-0,          7,          7,        1,   152064, 0x53b60b7e
10
-0,          8,          8,        1,   152064, 0x8bed0304
11
-0,          9,          9,        1,   152064, 0x509c4b78
12
-0,         10,         10,        1,   152064, 0x4cf869a4
13
-0,         11,         11,        1,   152064, 0x958b7c66
14
-0,         12,         12,        1,   152064, 0x45841fbf
15
-0,         13,         13,        1,   152064, 0xcfee57ea
16
-0,         14,         14,        1,   152064, 0x979ff709
17
-0,         15,         15,        1,   152064, 0xf7ffd5e2
18
-0,         16,         16,        1,   152064, 0xc42f4370
19
-0,         17,         17,        1,   152064, 0x71ae098f
20
-0,         18,         18,        1,   152064, 0x64146a42
21
-0,         19,         19,        1,   152064, 0xdb3068fd
8
+0,          6,          6,        1,   152064, 0x1f3b0657
9
+0,          7,          7,        1,   152064, 0x6e7547e6
10
+0,          8,          8,        1,   152064, 0x1197524c
11
+0,          9,          9,        1,   152064, 0xb4cdb293
12
+0,         10,         10,        1,   152064, 0xdd7cf1b8
13
+0,         11,         11,        1,   152064, 0x360b1005
14
+0,         12,         12,        1,   152064, 0x11a49918
15
+0,         13,         13,        1,   152064, 0xa10dd4f9
16
+0,         14,         14,        1,   152064, 0x78da71d7
17
+0,         15,         15,        1,   152064, 0x105e4cc0
18
+0,         16,         16,        1,   152064, 0x54bfa1c5
19
+0,         17,         17,        1,   152064, 0xd666559e
20
+0,         18,         18,        1,   152064, 0xd93faa1c
21
+0,         19,         19,        1,   152064, 0xb1af85ed
22 22
 0,         20,         20,        1,   152064, 0xfc7bf570
23 23
 0,         21,         21,        1,   152064, 0x9dc72412
24 24
 0,         22,         22,        1,   152064, 0x445d1d59
... ...
@@ -30,20 +30,20 @@
30 30
 0,         28,         28,        1,   152064, 0x76d2a455
31 31
 0,         29,         29,        1,   152064, 0x6dc3650e
32 32
 0,         30,         30,        1,   152064, 0x0f9d6aca
33
-0,         31,         31,        1,   152064, 0x11446a9b
34
-0,         32,         32,        1,   152064, 0x00be684c
35
-0,         33,         33,        1,   152064, 0xe5f9ee52
36
-0,         34,         34,        1,   152064, 0x21ecafb8
37
-0,         35,         35,        1,   152064, 0xd42c962c
38
-0,         36,         36,        1,   152064, 0xe00a270d
39
-0,         37,         37,        1,   152064, 0xc1b53878
40
-0,         38,         38,        1,   152064, 0xfc4e28dd
41
-0,         39,         39,        1,   152064, 0x9c574e39
42
-0,         40,         40,        1,   152064, 0xdd25cf9d
43
-0,         41,         41,        1,   152064, 0x32959e70
44
-0,         42,         42,        1,   152064, 0xac6498d5
45
-0,         43,         43,        1,   152064, 0xcd595d21
46
-0,         44,         44,        1,   152064, 0x2953ff74
33
+0,         31,         31,        1,   152064, 0xddae8141
34
+0,         32,         32,        1,   152064, 0x67cb8f24
35
+0,         33,         33,        1,   152064, 0xc7a72348
36
+0,         34,         34,        1,   152064, 0x0d7a1144
37
+0,         35,         35,        1,   152064, 0x39adfb3d
38
+0,         36,         36,        1,   152064, 0x0ecc70d5
39
+0,         37,         37,        1,   152064, 0xf3a6805e
40
+0,         38,         38,        1,   152064, 0xc3bd71ad
41
+0,         39,         39,        1,   152064, 0xa9be9730
42
+0,         40,         40,        1,   152064, 0xab9af790
43
+0,         41,         41,        1,   152064, 0x4c3ccd25
44
+0,         42,         42,        1,   152064, 0xbc83c58a
45
+0,         43,         43,        1,   152064, 0x94877df4
46
+0,         44,         44,        1,   152064, 0xa2360ea6
47 47
 0,         45,         45,        1,   152064, 0xb4e6c735
48 48
 0,         46,         46,        1,   152064, 0xb4e6c735
49 49
 0,         47,         47,        1,   152064, 0xb4e6c735