Skip to content

Commit 5597963

Browse files
committed
added some additional information to the exr export and improved the segment saving
1 parent 80ec460 commit 5597963

File tree

7 files changed

+40
-101
lines changed

7 files changed

+40
-101
lines changed

assemble_video.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from PIL import Image
99

1010
frames_between_keyframes = 60
11-
maximum_keyframe_number = 728
11+
maximum_keyframe_number = 9
1212
zoom_scale = 2.0
1313

1414
# log1.1 of 2 is 7.27
@@ -29,8 +29,8 @@
2929

3030
framebuffer = []
3131

32-
writer = imageio.get_writer(f"segment_{segment:08}.mp4", **kargs)
33-
segment_names.append(f"segment_{segment:08}.mp4")
32+
writer = imageio.get_writer(f"segments/segment_{segment:08}.mp4", **kargs)
33+
segment_names.append(f"segments/segment_{segment:08}.mp4")
3434

3535
files = glob.glob("output/*.png")
3636
files.sort()
@@ -58,8 +58,8 @@
5858
framebuffer = []
5959

6060
# Writer for adding frames to the video
61-
writer = imageio.get_writer(f"segment_{segment:08}.mp4", **kargs)
62-
segment_names.append(f"segment_{segment:08}.mp4")
61+
writer = imageio.get_writer(f"segments/segment_{segment:08}.mp4", **kargs)
62+
segment_names.append(f"segments/segment_{segment:08}.mp4")
6363

6464
next_keyframe = Image.open(files[i + 1])
6565

default.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
image_width = 1000
2-
image_height = 1000
3-
frames = 1
4-
export = "both"
1+
image_width = 1920
2+
image_height = 1080
3+
frames = 10
4+
export = "raw"
55
glitch_tolerance = 0.000001
66
zoom_scale = 2.0
77
auto_adjust_iterations = true

locations/threads_colour.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
real = "-1.47414176240993896848662071528158693194984033295350953280086668957218887059547144798782958583693228230313082538417736408312283756916583038548770140907148842507795182301203312327678867411139743734088820831422587016737770172651132123623347543560592366451320269312832570538759109480956462838749508907791843703924365245276567942898938125705618894029328612293147151908041951365498962465718017136637923540348122292958335790053092495783869799482899842041593944847198560523459306518247398734178583094840989359335916427349271969694638813455484795519139180535389178899499218726674005407958574308338167164971091115429523451479626131276956228048957227740597867681604973361307242906518836130901630810235591139999999999999999999"
2+
imag = "1.837028624819189477865631515035097395323927302572629030865933104000355714583818892052507681177756076074900340375874325858424795164505875785998449146862924507042300051932135130891413370393327740037629084197582966724720858559206941967648864807892583328760554952794324657809197148266317196316651597885791947076110274629246850125745470256068262793065499915106947670845209696879646797896797942904780372999446765698282800418563469062689909330151614815763561772821921612271912492631000218876452296900861545848888915227426092699498959036990046882718777435775562966053647880616647866656164419540502287729221470963175939777275863084020159079375481684880087569411323863960416637609668567855099418820244664E-94"
3+
zoom = "8.6e508"
4+
iterations = 1544151

segments.txt

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1 @@
1-
file 'segment_00000072.mp4'
2-
file 'segment_00000071.mp4'
3-
file 'segment_00000070.mp4'
4-
file 'segment_00000069.mp4'
5-
file 'segment_00000068.mp4'
6-
file 'segment_00000067.mp4'
7-
file 'segment_00000066.mp4'
8-
file 'segment_00000065.mp4'
9-
file 'segment_00000064.mp4'
10-
file 'segment_00000063.mp4'
11-
file 'segment_00000062.mp4'
12-
file 'segment_00000061.mp4'
13-
file 'segment_00000060.mp4'
14-
file 'segment_00000059.mp4'
15-
file 'segment_00000058.mp4'
16-
file 'segment_00000057.mp4'
17-
file 'segment_00000056.mp4'
18-
file 'segment_00000055.mp4'
19-
file 'segment_00000054.mp4'
20-
file 'segment_00000053.mp4'
21-
file 'segment_00000052.mp4'
22-
file 'segment_00000051.mp4'
23-
file 'segment_00000050.mp4'
24-
file 'segment_00000049.mp4'
25-
file 'segment_00000048.mp4'
26-
file 'segment_00000047.mp4'
27-
file 'segment_00000046.mp4'
28-
file 'segment_00000045.mp4'
29-
file 'segment_00000044.mp4'
30-
file 'segment_00000043.mp4'
31-
file 'segment_00000042.mp4'
32-
file 'segment_00000041.mp4'
33-
file 'segment_00000040.mp4'
34-
file 'segment_00000039.mp4'
35-
file 'segment_00000038.mp4'
36-
file 'segment_00000037.mp4'
37-
file 'segment_00000036.mp4'
38-
file 'segment_00000035.mp4'
39-
file 'segment_00000034.mp4'
40-
file 'segment_00000033.mp4'
41-
file 'segment_00000032.mp4'
42-
file 'segment_00000031.mp4'
43-
file 'segment_00000030.mp4'
44-
file 'segment_00000029.mp4'
45-
file 'segment_00000028.mp4'
46-
file 'segment_00000027.mp4'
47-
file 'segment_00000026.mp4'
48-
file 'segment_00000025.mp4'
49-
file 'segment_00000024.mp4'
50-
file 'segment_00000023.mp4'
51-
file 'segment_00000022.mp4'
52-
file 'segment_00000021.mp4'
53-
file 'segment_00000020.mp4'
54-
file 'segment_00000019.mp4'
55-
file 'segment_00000018.mp4'
56-
file 'segment_00000017.mp4'
57-
file 'segment_00000016.mp4'
58-
file 'segment_00000015.mp4'
59-
file 'segment_00000014.mp4'
60-
file 'segment_00000013.mp4'
61-
file 'segment_00000012.mp4'
62-
file 'segment_00000011.mp4'
63-
file 'segment_00000010.mp4'
64-
file 'segment_00000009.mp4'
65-
file 'segment_00000008.mp4'
66-
file 'segment_00000007.mp4'
67-
file 'segment_00000006.mp4'
68-
file 'segment_00000005.mp4'
69-
file 'segment_00000004.mp4'
70-
file 'segment_00000003.mp4'
71-
file 'segment_00000002.mp4'
72-
file 'segment_00000001.mp4'
73-
file 'segment_00000000.mp4'
1+
file 'segments/segment_00000000.mp4'

src/renderer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::util::{data_export::*, ComplexFixed, ComplexArbitrary, PixelData, complex_extended::ComplexExtended, float_extended::FloatExtended, string_to_extended, extended_to_string, get_approximation_terms, get_delta_top_left};
1+
use crate::util::{data_export::*, ComplexFixed, ComplexArbitrary, PixelData, complex_extended::ComplexExtended, float_extended::FloatExtended, string_to_extended, extended_to_string_short, extended_to_string_long, get_approximation_terms, get_delta_top_left};
22
use crate::math::{SeriesApproximation, Perturbation, Reference};
33

44
use std::time::Instant;
@@ -86,7 +86,7 @@ impl FractalRenderer {
8686

8787
pub fn render_frame(&mut self, frame_index: usize, filename: String) {
8888
print!("{:<6}", frame_index);
89-
print!("| {:<15}", extended_to_string(self.zoom));
89+
print!("| {:<15}", extended_to_string_short(self.zoom));
9090
std::io::stdout().flush().unwrap();
9191
let frame_time = Instant::now();
9292
let approximation_time = Instant::now();
@@ -215,7 +215,7 @@ impl FractalRenderer {
215215
std::io::stdout().flush().unwrap();
216216

217217
let saving_time = Instant::now();
218-
self.data_export.save(&filename, self.maximum_iteration);
218+
self.data_export.save(&filename, self.maximum_iteration, self.series_approximation.order, &extended_to_string_long(self.zoom));
219219
print!("| {:<15}", saving_time.elapsed().as_millis());
220220
println!("| {:<15}| {:<15}", frame_time.elapsed().as_millis(), self.start_render_time.elapsed().as_millis());
221221
std::io::stdout().flush().unwrap();
@@ -227,7 +227,7 @@ impl FractalRenderer {
227227

228228
let mut count = 0;
229229
while self.remaining_frames > 0 && self.zoom.to_float() > 0.5 {
230-
self.render_frame(count, format!("output/{:08}_{}", count, extended_to_string(self.zoom)));
230+
self.render_frame(count, format!("output/{:08}_{}", count, extended_to_string_short(self.zoom)));
231231
self.zoom.mantissa /= self.zoom_scale_factor;
232232
self.zoom.reduce();
233233

src/util/data_export.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl DataExport {
3636
image_width,
3737
image_height,
3838
rgb: vec![0u8; image_width * image_height * 3],
39-
palette: DataExport::generate_colour_palette(),
39+
palette: DataExport::generate_default_palette(),
4040
iterations: vec![0u32; image_width * image_height],
4141
smooth_f16: Vec::new(),
4242
smooth_f32: Vec::new(),
@@ -75,7 +75,7 @@ impl DataExport {
7575
image_width,
7676
image_height,
7777
rgb: vec![0u8; image_width * image_height * 3],
78-
palette: DataExport::generate_colour_palette(),
78+
palette: DataExport::generate_default_palette(),
7979
iterations: vec![0u32; image_width * image_height],
8080
smooth_f16: vec![f16::ZERO; image_width * image_height],
8181
smooth_f32: Vec::new(),
@@ -196,20 +196,20 @@ impl DataExport {
196196
}
197197
}
198198

199-
pub fn save(&mut self, filename: &str, maximum_iteration: usize) {
199+
pub fn save(&mut self, filename: &str, maximum_iteration: usize, approximation_order: usize, zoom: &str) {
200200
match self.data_type {
201201
DataType::COLOUR => {
202202
self.save_colour(filename);
203203
},
204204
DataType::RAW => {
205-
self.save_raw(filename);
205+
self.save_raw(filename, maximum_iteration, approximation_order, zoom);
206206
},
207207
DataType::KFB => {
208208
self.save_kfb(filename, maximum_iteration);
209209
}
210210
DataType::BOTH => {
211211
self.save_colour(filename);
212-
self.save_raw(filename);
212+
self.save_raw(filename, maximum_iteration, approximation_order, zoom);
213213
}
214214
}
215215
}
@@ -223,20 +223,22 @@ impl DataExport {
223223
image::ColorType::Rgb8).unwrap();
224224
}
225225

226-
fn save_raw(&mut self, filename: &str) {
226+
fn save_raw(&mut self, filename: &str, maximum_iteration: usize, approximation_order: usize, zoom: &str) {
227227
let iterations = simple_image::Channel::non_color_data(simple_image::Text::from("N").unwrap(), simple_image::Samples::U32(self.iterations.clone()));
228228
let smooth = simple_image::Channel::non_color_data(simple_image::Text::from("NF").unwrap(), simple_image::Samples::F16(self.smooth_f16.clone()));
229229

230230
let mut layer = simple_image::Layer::new(simple_image::Text::from("fractal_data").unwrap(), (self.image_width, self.image_height), smallvec::smallvec![iterations, smooth])
231231
.with_compression(simple_image::Compression::PXR24)
232232
.with_block_format(None, simple_image::attribute::LineOrder::Increasing);
233233

234-
235-
let mut test = HashMap::new();
236-
test.insert(simple_image::Text::from("IterationsBias").unwrap(), exr::meta::attribute::AttributeValue::I32(0));
234+
let mut attributes = HashMap::new();
235+
attributes.insert(simple_image::Text::from("IterationsBias").unwrap(), exr::meta::attribute::AttributeValue::I32(0));
236+
attributes.insert(simple_image::Text::from("Iterations").unwrap(), exr::meta::attribute::AttributeValue::I32(maximum_iteration as i32));
237+
attributes.insert(simple_image::Text::from("Zoom").unwrap(), exr::meta::attribute::AttributeValue::Text(simple_image::Text::from(zoom).unwrap()));
238+
attributes.insert(simple_image::Text::from("approximation_order").unwrap(), exr::meta::attribute::AttributeValue::I32(approximation_order as i32));
237239

238240
layer.attributes = exr::meta::header::LayerAttributes::new(simple_image::Text::from("fractal_data").unwrap());
239-
layer.attributes.custom = test;
241+
layer.attributes.custom = attributes;
240242

241243
let image = simple_image::Image::new_from_single_layer(layer);
242244

@@ -251,7 +253,7 @@ impl DataExport {
251253
let test1 = [self.image_width as u32, self.image_height as u32];
252254

253255
// Colours in colourmap
254-
let test5 = DataExport::generate_colour_palette();
256+
let test5 = DataExport::generate_default_palette();
255257

256258
// iteration division??
257259
let test3 = [1u32, test5.len() as u32];
@@ -285,7 +287,7 @@ impl DataExport {
285287

286288
}
287289

288-
fn generate_colour_palette() -> Vec<(u8, u8, u8)> {
290+
fn generate_default_palette() -> Vec<(u8, u8, u8)> {
289291
let mut colours = Vec::with_capacity(1024);
290292

291293
for i in 0..1024 {

src/util/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,20 @@ pub fn string_to_extended(string: &str) -> FloatExtended {
6868
FloatExtended::new(first * 2.0f64.powf(second.fract()), second.floor() as i32)
6969
}
7070

71-
pub fn extended_to_string(value: FloatExtended) -> String {
71+
pub fn extended_to_string_short(value: FloatExtended) -> String {
7272
let first = value.mantissa;
7373
let second = value.exponent as f64 * LOG10_2;
7474

7575
format!("{:.2}E{}", first * 10.0f64.powf(second.fract()), second.floor() as i32)
7676
}
7777

78+
pub fn extended_to_string_long(value: FloatExtended) -> String {
79+
let first = value.mantissa;
80+
let second = value.exponent as f64 * LOG10_2;
81+
82+
format!("{}E{}", first * 10.0f64.powf(second.fract()), second.floor() as i32)
83+
}
84+
7885
pub fn get_delta_top_left(delta_pixel: f64, image_width: usize, image_height: usize, cos_rotate: f64, sin_rotate: f64) -> ComplexFixed<f64> {
7986
let aspect = image_width as f64 / image_height as f64;
8087

@@ -95,8 +102,6 @@ pub fn get_approximation_terms(approximation_order: usize, image_width: usize, i
95102
}
96103
}
97104

98-
99-
100105
#[derive(Clone)]
101106
pub struct PixelData {
102107
pub image_x: usize,

0 commit comments

Comments
 (0)