forked from jlesage/docker-handbrake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
A20-flac-encoder-crash.patch
59 lines (52 loc) · 1.78 KB
/
A20-flac-encoder-crash.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
--- a/libavcodec/flacenc.c.orig 2018-02-12 16:25:59.000000000 -0500
+++ b/libavcodec/flacenc.c 2018-04-25 21:14:15.000000000 -0400
@@ -606,7 +606,7 @@
static void calc_sums(int pmin, int pmax, uint32_t *data, int n, int pred_order,
- uint64_t sums[][MAX_PARTITIONS])
+ uint64_t **sums)
{
int i, j;
int parts;
@@ -638,14 +638,24 @@
int i;
uint64_t bits[MAX_PARTITION_ORDER+1];
int opt_porder;
- RiceContext tmp_rc;
- uint64_t sums[MAX_PARTITION_ORDER + 1][MAX_PARTITIONS] = { { 0 } };
+ RiceContext *tmp_rc;
+ uint64_t **sums;
assert(pmin >= 0 && pmin <= MAX_PARTITION_ORDER);
assert(pmax >= 0 && pmax <= MAX_PARTITION_ORDER);
assert(pmin <= pmax);
- tmp_rc.coding_mode = rc->coding_mode;
+ sums = calloc(1, (MAX_PARTITION_ORDER + 1) * sizeof(uint64_t*));
+ assert(sums);
+ for (i = 0; i < (MAX_PARTITION_ORDER + 1); i++) {
+ sums[i] = calloc(1, MAX_PARTITIONS * sizeof(uint64_t));
+ assert(sums[i] != NULL);
+ }
+
+ tmp_rc = malloc(sizeof(RiceContext));
+ assert(tmp_rc != NULL);
+
+ tmp_rc->coding_mode = rc->coding_mode;
for (i = 0; i < n; i++)
rc->udata[i] = (2 * data[i]) ^ (data[i] >> 31);
@@ -655,13 +665,17 @@
opt_porder = pmin;
bits[pmin] = UINT32_MAX;
for (i = pmin; i <= pmax; i++) {
- bits[i] = calc_optimal_rice_params(&tmp_rc, i, sums[i], n, pred_order);
+ bits[i] = calc_optimal_rice_params(tmp_rc, i, sums[i], n, pred_order);
if (bits[i] <= bits[opt_porder]) {
opt_porder = i;
- *rc = tmp_rc;
+ *rc = *tmp_rc;
}
}
+ for (i = 0; i < (MAX_PARTITION_ORDER + 1); i++)
+ free(sums[i]);
+ free(sums);
+ free(tmp_rc);
return bits[opt_porder];
}