Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 626692 | Differences between
and this patch

Collapse All | Expand All

(-)a/media-video/movit/files/movit-revert-c++11-dependency.patch (+144 lines)
Line 0 Link Here
1
From: Steinar H. Gunderson <sgunderson@bigfoot.com>
2
Date: Tue, 1 Aug 2017 07:25:10 +0000 (+0200)
3
Subject: Remove C++11 dependency from ResampleEffect.
4
X-Git-Url: https://git.sesse.net/?p=movit;a=commitdiff_plain;h=8e9f58fec54a4c879035b214fd7411f6ff7b3a32
5
6
Remove C++11 dependency from ResampleEffect.
7
8
We really ought to allow C++11 in Movit soon, but 1.5.2 is not the right release.
9
10
Reported by Etienne d'Hautefeuille.
11
---
12
13
diff --git a/resample_effect.cpp b/resample_effect.cpp
14
index 30c40c4..86d574b 100644
15
--- a/resample_effect.cpp
16
+++ b/resample_effect.cpp
17
@@ -206,7 +206,7 @@ void normalize_sum(Tap<T>* vals, unsigned num)
18
 //
19
 // The greedy strategy for combining samples is optimal.
20
 template<class DestFloat>
21
-unsigned combine_many_samples(const Tap<float> *weights, unsigned src_size, unsigned src_samples, unsigned dst_samples, unique_ptr<Tap<DestFloat>[]> *bilinear_weights)
22
+unsigned combine_many_samples(const Tap<float> *weights, unsigned src_size, unsigned src_samples, unsigned dst_samples, Tap<DestFloat> **bilinear_weights)
23
 {
24
 	float num_subtexels = src_size / movit_texel_subpixel_precision;
25
 	float inv_num_subtexels = movit_texel_subpixel_precision / src_size;
26
@@ -221,9 +221,10 @@ unsigned combine_many_samples(const Tap<float> *weights, unsigned src_size, unsi
27
 
28
 	// Now that we know the right width, actually combine the samples.
29
 	unsigned src_bilinear_samples = src_samples - max_samples_saved;
30
-	bilinear_weights->reset(new Tap<DestFloat>[dst_samples * src_bilinear_samples]);
31
+	if (*bilinear_weights != NULL) delete[] *bilinear_weights;
32
+	*bilinear_weights = new Tap<DestFloat>[dst_samples * src_bilinear_samples];
33
 	for (unsigned y = 0; y < dst_samples; ++y) {
34
-		Tap<DestFloat> *bilinear_weights_ptr = bilinear_weights->get() + y * src_bilinear_samples;
35
+		Tap<DestFloat> *bilinear_weights_ptr = *bilinear_weights + y * src_bilinear_samples;
36
 		unsigned num_samples_saved = combine_samples(
37
 			weights + y * src_samples,
38
 			bilinear_weights_ptr,
39
@@ -526,15 +527,15 @@ void SingleResamplePassEffect::update_texture(GLuint glsl_program_num, const str
40
 
41
 	GLenum type, internal_format;
42
 	void *pixels;
43
-	assert((weights.bilinear_weights_fp16 == nullptr) != (weights.bilinear_weights_fp32 == nullptr));
44
-	if (weights.bilinear_weights_fp32 != nullptr) {
45
+	assert((weights.bilinear_weights_fp16 == NULL) != (weights.bilinear_weights_fp32 == NULL));
46
+	if (weights.bilinear_weights_fp32 != NULL) {
47
 		type = GL_FLOAT;
48
 		internal_format = GL_RG32F;
49
-		pixels = weights.bilinear_weights_fp32.get();
50
+		pixels = weights.bilinear_weights_fp32;
51
 	} else {
52
 		type = GL_HALF_FLOAT;
53
 		internal_format = GL_RG16F;
54
-		pixels = weights.bilinear_weights_fp16.get();
55
+		pixels = weights.bilinear_weights_fp16;
56
 	}
57
 
58
 	if (int(weights.src_bilinear_samples) == last_texture_width &&
59
@@ -550,6 +551,9 @@ void SingleResamplePassEffect::update_texture(GLuint glsl_program_num, const str
60
 		last_texture_internal_format = internal_format;
61
 	}
62
 	check_error();
63
+
64
+	delete[] weights.bilinear_weights_fp16;
65
+	delete[] weights.bilinear_weights_fp32;
66
 }
67
 
68
 ScalingWeights calculate_scaling_weights(unsigned src_size, unsigned dst_size, float zoom, float offset)
69
@@ -632,7 +636,7 @@ ScalingWeights calculate_scaling_weights(unsigned src_size, unsigned dst_size, f
70
 	float radius_scaling_factor = min(scaling_factor, 1.0f);
71
 	int int_radius = lrintf(LANCZOS_RADIUS / radius_scaling_factor);
72
 	int src_samples = int_radius * 2 + 1;
73
-	unique_ptr<Tap<float>[]> weights(new Tap<float>[dst_samples * src_samples]);
74
+	Tap<float> *weights = new Tap<float>[dst_samples * src_samples];
75
 	float subpixel_offset = offset - lrintf(offset);  // The part not covered by whole_pixel_offset.
76
 	assert(subpixel_offset >= -0.5f && subpixel_offset <= 0.5f);
77
 	for (unsigned y = 0; y < dst_samples; ++y) {
78
@@ -656,14 +660,14 @@ ScalingWeights calculate_scaling_weights(unsigned src_size, unsigned dst_size, f
79
 	// Our tolerance level for total error is a bit higher than the one for invididual
80
 	// samples, since one would assume overall errors in the shape don't matter as much.
81
 	const float max_error = 2.0f / (255.0f * 255.0f);
82
-	unique_ptr<Tap<fp16_int_t>[]> bilinear_weights_fp16;
83
-	int src_bilinear_samples = combine_many_samples(weights.get(), src_size, src_samples, dst_samples, &bilinear_weights_fp16);
84
-	unique_ptr<Tap<float>[]> bilinear_weights_fp32 = NULL;
85
+	Tap<fp16_int_t> *bilinear_weights_fp16 = NULL;
86
+	int src_bilinear_samples = combine_many_samples(weights, src_size, src_samples, dst_samples, &bilinear_weights_fp16);
87
+	Tap<float> *bilinear_weights_fp32 = NULL;
88
 	double max_sum_sq_error_fp16 = 0.0;
89
 	for (unsigned y = 0; y < dst_samples; ++y) {
90
 		double sum_sq_error_fp16 = compute_sum_sq_error(
91
-			weights.get() + y * src_samples, src_samples,
92
-			bilinear_weights_fp16.get() + y * src_bilinear_samples, src_bilinear_samples,
93
+			weights + y * src_samples, src_samples,
94
+			bilinear_weights_fp16 + y * src_bilinear_samples, src_bilinear_samples,
95
 			src_size);
96
 		max_sum_sq_error_fp16 = std::max(max_sum_sq_error_fp16, sum_sq_error_fp16);
97
 		if (max_sum_sq_error_fp16 > max_error) {
98
@@ -672,16 +676,19 @@ ScalingWeights calculate_scaling_weights(unsigned src_size, unsigned dst_size, f
99
 	}
100
 
101
 	if (max_sum_sq_error_fp16 > max_error) {
102
-		bilinear_weights_fp16.reset();
103
-		src_bilinear_samples = combine_many_samples(weights.get(), src_size, src_samples, dst_samples, &bilinear_weights_fp32);
104
+		delete[] bilinear_weights_fp16;
105
+		bilinear_weights_fp16 = NULL;
106
+		src_bilinear_samples = combine_many_samples(weights, src_size, src_samples, dst_samples, &bilinear_weights_fp32);
107
 	}
108
 
109
+	delete[] weights;
110
+
111
 	ScalingWeights ret;
112
 	ret.src_bilinear_samples = src_bilinear_samples;
113
 	ret.dst_samples = dst_samples;
114
 	ret.num_loops = num_loops;
115
-	ret.bilinear_weights_fp16 = move(bilinear_weights_fp16);
116
-	ret.bilinear_weights_fp32 = move(bilinear_weights_fp32);
117
+	ret.bilinear_weights_fp16 = bilinear_weights_fp16;
118
+	ret.bilinear_weights_fp32 = bilinear_weights_fp32;
119
 	return ret;
120
 }
121
 
122
diff --git a/resample_effect.h b/resample_effect.h
123
index 7538a68..7cd613f 100644
124
--- a/resample_effect.h
125
+++ b/resample_effect.h
126
@@ -18,7 +18,6 @@
127
 #include <epoxy/gl.h>
128
 #include <assert.h>
129
 #include <stddef.h>
130
-#include <memory>
131
 #include <string>
132
 
133
 #include "effect.h"
134
@@ -41,8 +40,8 @@ struct ScalingWeights {
135
 	unsigned dst_samples, num_loops;
136
 
137
 	// Exactly one of these is set.
138
-	std::unique_ptr<Tap<fp16_int_t>[]> bilinear_weights_fp16;
139
-	std::unique_ptr<Tap<float>[]> bilinear_weights_fp32;
140
+	Tap<fp16_int_t> *bilinear_weights_fp16;
141
+	Tap<float> *bilinear_weights_fp32;
142
 };
143
 ScalingWeights calculate_scaling_weights(unsigned src_size, unsigned dst_size, float zoom, float offset);
144
 
(-)a/media-video/movit/movit-1.5.2.ebuild (-1 / +4 lines)
Lines 27-32 RDEPEND="media-libs/mesa Link Here
27
	"
27
	"
28
DEPEND="${RDEPEND}"
28
DEPEND="${RDEPEND}"
29
29
30
src_prepare() {
31
	epatch "${FILESDIR}/${PN}-revert-c++11-dependency.patch"
32
}
33
30
src_compile() {
34
src_compile() {
31
	GTEST_DIR="${WORKDIR}/gtest-1.7.0" emake
35
	GTEST_DIR="${WORKDIR}/gtest-1.7.0" emake
32
}
36
}
33
- 

Return to bug 626692