cutcutcodec 1.0.post3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cutcutcodec might be problematic. Click here for more details.
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/__init__.py +6 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/__main__.py +38 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/c_build.py +33 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/_helper_properties.py +52 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/audio/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/audio/properties/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/audio/properties/duration.py +83 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/ffprobe.py +637 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/graph/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/graph/find.py +82 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/graph/time_backprop.py +68 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/rate_audio.py +239 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/rate_video.py +97 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/shape.py +107 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/time_backprop.py +183 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/duration.py +162 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/nb_frames.py +159 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/rate.py +102 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/timestamps.py +194 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/container.py +40 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/encoder.py +152 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/filter.py +33 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/frame.py +127 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/frame_audio.py +205 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/frame_video.py +322 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/layout.py +206 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/meta_filter.py +41 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/muxer.py +184 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/node.py +164 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/stream.py +182 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/stream_audio.py +130 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/stream_video.py +193 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/__init__.py +7 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/ast_to_file.py +125 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/__init__.py +6 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/compatibility.py +734 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/default.py +99 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/encodec.py +40 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/muxer.py +8 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/rate.py +133 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/graph_to_ast.py +477 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/graph_to_json.py +104 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/graph_to_tree.py +190 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/json_to_graph.py +114 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/parse.py +123 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/__init__.py +15 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/dynamic.py +544 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/lambdify.py +612 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/preprocess.py +698 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/printer.py +926 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/tree_to_graph.py +168 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/decision/__init__.py +8 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/operation/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/operation/add.py +73 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/operation/remove.py +476 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/exceptions.py +60 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/add.py +170 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/cat.py +60 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/cut.py +112 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/delay.py +85 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/equation.py +261 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/fir.py +231 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/identity.py +48 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/resample.py +451 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/subclip.py +91 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/cut.py +74 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/mix/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/mix/audio_cast.py +208 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/mix/video_cast.py +197 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/subclip.py +53 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/add.py +331 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/cat.py +60 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/cut.py +113 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/delay.py +84 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/equation.py +265 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/identity.py +48 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/pad.py +99 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/subclip.py +91 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/empty.py +73 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/equation.py +56 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/noise.py +243 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/c_fractal.cpython-312-x86_64-linux-gnu.so +0 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/empty.py +69 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/equation.py +109 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/fractal.c +116 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/geometry.py +100 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/mandelbrot.py +176 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/noise.py +112 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/interfaces/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/interfaces/seedable.py +82 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/read_ffmpeg.py +904 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/read_svg.py +145 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/scheduler.py +356 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/write.py +340 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/basic.py +35 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/clean/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/clean/graph.py +80 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/hashes/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/hashes/graph.py +81 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/singleton.py +47 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cuda/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/factor/__init__.py +5 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/factor/proba.py +189 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/generalize/__init__.py +5 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/generalize/delay_to_fir.py +88 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/graph.py +17 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/parallel/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/parallel/buffer.py +90 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/utils.py +34 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/audio_5.1_narration.oga +0 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/intro.webm +0 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/logo.svg +13 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/project.json +226 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/video.mp4 +0 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/__init__.py +8 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/__main__.py +25 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/actions.py +63 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/app/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/app/app.py +248 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/base.py +50 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/container_input_ffmpeg.py +90 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_delay.py +9 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_equation.py +45 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_fir.py +58 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_subclip.py +9 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_cut.py +82 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_delay.py +20 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_subclip.py +21 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_video_delay.py +9 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_video_equation.py +53 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_video_subclip.py +9 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_audio_equation.py +14 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_audio_noise.py +19 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_video_equation.py +13 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_video_mandelbrot.py +60 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_video_noise.py +18 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/base.py +99 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/default.py +27 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/documentation.py +47 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/general.py +71 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/interface.py +305 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/loader.py +41 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/main.py +62 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edition_tabs.py +34 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/base.py +122 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/filters.py +42 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/generators.py +42 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry_tabs.py +46 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/_helper.py +54 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/container.py +226 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/doc.py +67 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/encodec.py +289 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/main.py +173 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/edge_properties.py +56 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/main.py +280 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/node.py +44 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/main.py +151 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/menu.py +21 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/audio_settings.py +183 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/main.py +41 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/video_settings.py +257 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/run.py +71 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/main.py +30 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/slider.py +286 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/track.py +97 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/view.py +90 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/toolbar.py +29 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/tools.py +23 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/audio_player.py +103 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/control.py +96 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/frame_extractor.py +254 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/main.py +115 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/__init__.py +8 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/__main__.py +27 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/coding_style.py +49 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/generation.py +52 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/install.py +72 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/run.py +58 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/abstract.py +215 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/audio_cast.py +35 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/audio_equation.py +71 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/c_memory.py +132 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/compatibility.py +27 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/compile.py +42 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/encoder.py +23 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/filter_cut.py +107 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/filter_delay.py +71 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/filter_empty.py +40 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/fir.py +143 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/hashes.py +23 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/initialisation.py +24 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/muxer.py +22 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/nan_snapshot.py +39 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/read.py +192 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/serialization_equality.py +50 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/snapshot_shape.py +21 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/sympy_to_torch.py +135 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/thread_safe.py +77 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/time_range.py +55 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/video_equation.py +77 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/write.py +95 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/utils.py +40 -0
- cutcutcodec-1.0.post3.dist-info/LICENSE +7 -0
- cutcutcodec-1.0.post3.dist-info/METADATA +271 -0
- cutcutcodec-1.0.post3.dist-info/RECORD +233 -0
- cutcutcodec-1.0.post3.dist-info/WHEEL +5 -0
- cutcutcodec-1.0.post3.dist-info/entry_points.txt +6 -0
- cutcutcodec-1.0.post3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Generate an audio noise signal."""
|
|
4
|
+
|
|
5
|
+
from fractions import Fraction
|
|
6
|
+
import math
|
|
7
|
+
import numbers
|
|
8
|
+
import typing
|
|
9
|
+
|
|
10
|
+
import numpy as np
|
|
11
|
+
|
|
12
|
+
from cutcutcodec.core.classes.container import ContainerInput
|
|
13
|
+
from cutcutcodec.core.classes.frame_audio import FrameAudio
|
|
14
|
+
from cutcutcodec.core.classes.layout import Layout
|
|
15
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
16
|
+
from cutcutcodec.core.classes.stream_audio import StreamAudio
|
|
17
|
+
from cutcutcodec.core.exceptions import OutOfTimeRange
|
|
18
|
+
from cutcutcodec.core.interfaces.seedable import Seedable
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class GeneratorAudioNoise(ContainerInput, Seedable):
|
|
22
|
+
"""Generate a pure noise audio signal.
|
|
23
|
+
|
|
24
|
+
Attributes
|
|
25
|
+
----------
|
|
26
|
+
layout : cutcutcodec.core.classes.layout.Layout
|
|
27
|
+
The signification of each channels (readonly).
|
|
28
|
+
|
|
29
|
+
Examples
|
|
30
|
+
--------
|
|
31
|
+
>>> from fractions import Fraction
|
|
32
|
+
>>> from cutcutcodec.core.generation.audio.noise import GeneratorAudioNoise
|
|
33
|
+
>>> (stream,) = GeneratorAudioNoise(0).out_streams
|
|
34
|
+
>>> stream.snapshot(Fraction(2, 48000), 48000, 5).numpy(force=True)
|
|
35
|
+
array([[-0.25397146, -0.1199106 , -0.12052107, -0.16986334, -0.50950706],
|
|
36
|
+
[ 0.17409873, 0.42185044, -0.7231959 , 0.39764726, -0.25968206]],
|
|
37
|
+
dtype=float32)
|
|
38
|
+
>>> stream.snapshot(0, 24000, 5).numpy(force=True)
|
|
39
|
+
array([[ 0.44649088, -0.25397146, -0.12052107, -0.50950706, 0.5112531 ],
|
|
40
|
+
[-0.8036704 , 0.17409873, -0.7231959 , -0.25968206, -0.7944578 ]],
|
|
41
|
+
dtype=float32)
|
|
42
|
+
>>> frame = stream.snapshot(0, 48000, 48000*60) # test uniform
|
|
43
|
+
>>> abs(round(frame.mean().item(), 3)) # theory 0
|
|
44
|
+
0.0
|
|
45
|
+
>>> round(frame.var().item(), 3) # theory 1/3
|
|
46
|
+
0.333
|
|
47
|
+
>>>
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
def __init__(
|
|
51
|
+
self,
|
|
52
|
+
seed: typing.Optional[numbers.Real] = None,
|
|
53
|
+
layout: typing.Optional[typing.Union[Layout, str, numbers.Integral]] = "stereo",
|
|
54
|
+
):
|
|
55
|
+
"""Initialise and create the class.
|
|
56
|
+
|
|
57
|
+
Parameters
|
|
58
|
+
----------
|
|
59
|
+
seed : numbers.Real, optional
|
|
60
|
+
Transmitted to ``cutcutcodec.core.interfaces.seedable.Seedable``.
|
|
61
|
+
layout: cutcutcodec.core.classes.layout.Layout or str or int, optional
|
|
62
|
+
The audio layout to associate to each equation,
|
|
63
|
+
let see ``cutcutcodec.core.classes.layout.Layout`` for more details.
|
|
64
|
+
By default, the layout is stereo, two channels.
|
|
65
|
+
"""
|
|
66
|
+
assert layout is None or isinstance(layout, (Layout, str, numbers.Integral)), \
|
|
67
|
+
layout.__class__.__name__
|
|
68
|
+
Seedable.__init__(self, seed)
|
|
69
|
+
super().__init__([_StreamAudioNoiseUniform(self)])
|
|
70
|
+
self._layout = Layout(layout)
|
|
71
|
+
|
|
72
|
+
def _getstate(self) -> dict:
|
|
73
|
+
return {**self._getstate_seed(), "layout": self._layout.name}
|
|
74
|
+
|
|
75
|
+
def _setstate(self, in_streams: typing.Iterable[Stream], state: dict) -> None:
|
|
76
|
+
assert state.keys() == {"seed", "layout"}, set(state)
|
|
77
|
+
self._setstate_seed(state)
|
|
78
|
+
self._layout = Layout(state["layout"])
|
|
79
|
+
ContainerInput.__init__(self, [_StreamAudioNoiseUniform(self)])
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def default(cls):
|
|
83
|
+
"""Provide a minimalist example of an instance of this node."""
|
|
84
|
+
return cls(0)
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def layout(self) -> Layout:
|
|
88
|
+
"""Return the signification of each channels."""
|
|
89
|
+
return self._layout
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class _StreamAudioNoiseUniform(StreamAudio):
|
|
93
|
+
"""Random audio stream where each sample follows a uniform law.
|
|
94
|
+
|
|
95
|
+
Based on the md5 hash algorithm on the timestamps.
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
is_time_continuous = True
|
|
99
|
+
|
|
100
|
+
def __init__(self, node: GeneratorAudioNoise):
|
|
101
|
+
assert isinstance(node, GeneratorAudioNoise), node.__class__.__name__
|
|
102
|
+
super().__init__(node)
|
|
103
|
+
self._seed = np.frombuffer(self.node.seed_bytes, dtype=np.uint32).reshape(8, 1)
|
|
104
|
+
|
|
105
|
+
def _snapshot(self, timestamp: Fraction, rate: int, samples: int) -> FrameAudio:
|
|
106
|
+
if timestamp < 0:
|
|
107
|
+
raise OutOfTimeRange(f"there is no audio frame at timestamp {timestamp} (need >= 0)")
|
|
108
|
+
|
|
109
|
+
# initialisation message, depend to the seed and the timestamps
|
|
110
|
+
string = np.empty((16, samples), dtype=np.uint32) # ti = t0 + i/rate
|
|
111
|
+
num = timestamp.numerator*rate + np.arange(samples, dtype=np.uint64)*timestamp.denominator
|
|
112
|
+
gcds = np.gcd(num, timestamp.denominator*rate)
|
|
113
|
+
num //= gcds
|
|
114
|
+
den = rate*timestamp.denominator // gcds
|
|
115
|
+
string[0, :] = num >> 32
|
|
116
|
+
string[1, :] = num # & 0x00000000ffffffff is implicite
|
|
117
|
+
string[2, :] = den >> 32
|
|
118
|
+
string[3, :] = den # & 0x00000000ffffffff is implicite
|
|
119
|
+
string[4:8, :] = 0 # because unitializated
|
|
120
|
+
string[8:16, :] = self._seed
|
|
121
|
+
|
|
122
|
+
# compute hash pseudo md5
|
|
123
|
+
hashes = []
|
|
124
|
+
while True:
|
|
125
|
+
hashes.extend(md5(string)) # +4 items
|
|
126
|
+
if len(hashes) >= len(self.node.layout.channels):
|
|
127
|
+
break
|
|
128
|
+
string[5, :] = hashes[-1]
|
|
129
|
+
|
|
130
|
+
# convertion uint32 to float32 uniform [0, 1]
|
|
131
|
+
n_channels = len(self.node.layout.channels)
|
|
132
|
+
for i in range(n_channels):
|
|
133
|
+
sign = hashes[i] & 0b1_00000000_00000000000000000000000
|
|
134
|
+
hashes[i] &= 0b0_00000000_11111111111111111111111 # exponant reset and sign > 0
|
|
135
|
+
hashes[i] ^= 0b0_01111111_00000000000000000000000 # exponant set for 2**0, range [1, 2]
|
|
136
|
+
hashes[i] = hashes[i].view(np.float32) # reinterpret cast for substraction operation
|
|
137
|
+
hashes[i] -= 1.0 # range [0, 1]
|
|
138
|
+
hashes[i] = hashes[i].view(np.uint32) # reinterpret cast for bit operation
|
|
139
|
+
hashes[i] |= sign # add random sign, range [-1, 1]
|
|
140
|
+
hashes[i] = hashes[i].view(np.float32) # reinterpret cast for final dtype
|
|
141
|
+
return FrameAudio(
|
|
142
|
+
timestamp,
|
|
143
|
+
rate,
|
|
144
|
+
self.node.layout,
|
|
145
|
+
np.vstack(hashes[:n_channels])
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
@property
|
|
149
|
+
def beginning(self) -> Fraction:
|
|
150
|
+
return Fraction(0)
|
|
151
|
+
|
|
152
|
+
@property
|
|
153
|
+
def duration(self) -> typing.Union[Fraction, float]:
|
|
154
|
+
return math.inf
|
|
155
|
+
|
|
156
|
+
@property
|
|
157
|
+
def layout(self) -> Layout:
|
|
158
|
+
"""Return the signification of each channels."""
|
|
159
|
+
return self.node.layout
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def md5(string: np.ndarray) -> np.ndarray:
|
|
163
|
+
"""Apply the md5 algorithm on each item.
|
|
164
|
+
|
|
165
|
+
Parameters
|
|
166
|
+
----------
|
|
167
|
+
string : np.ndarray
|
|
168
|
+
The values to hash, of shape (16, n) and dtype uint32.
|
|
169
|
+
|
|
170
|
+
Returns
|
|
171
|
+
-------
|
|
172
|
+
hash : tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]
|
|
173
|
+
The hashed value of the input string, of shape (n,).
|
|
174
|
+
Fours differents 32 bits values ares yields, total 128 bits.
|
|
175
|
+
|
|
176
|
+
Examples
|
|
177
|
+
--------
|
|
178
|
+
>>> import numpy as np
|
|
179
|
+
>>> from cutcutcodec.core.generation.audio.noise import md5
|
|
180
|
+
>>> string = np.zeros((16, 1), dtype=np.uint32)
|
|
181
|
+
>>> np.vstack(md5(string))
|
|
182
|
+
array([[1543640769],
|
|
183
|
+
[2049272632],
|
|
184
|
+
[1899532917],
|
|
185
|
+
[2915357108]], dtype=uint32)
|
|
186
|
+
>>>
|
|
187
|
+
"""
|
|
188
|
+
# verifs
|
|
189
|
+
assert isinstance(string, np.ndarray), string.__class__.__name__
|
|
190
|
+
assert string.dtype == np.uint32, string.dtype
|
|
191
|
+
assert string.ndim == 2, string.shape
|
|
192
|
+
assert string.shape[0] == 16, string.shape
|
|
193
|
+
|
|
194
|
+
# initialisation
|
|
195
|
+
_a = np.full((string.shape[1],), 0x67452301, dtype=np.uint32)
|
|
196
|
+
_b = np.full((string.shape[1],), 0xefcdab89, dtype=np.uint32)
|
|
197
|
+
_c = np.full((string.shape[1],), 0x98badcfe, dtype=np.uint32)
|
|
198
|
+
_d = np.full((string.shape[1],), 0x10325476, dtype=np.uint32)
|
|
199
|
+
_f = np.empty(string.shape[1], dtype=np.uint32)
|
|
200
|
+
|
|
201
|
+
# compute md5 on each elements
|
|
202
|
+
for i, (const, shift) in enumerate(zip(
|
|
203
|
+
[
|
|
204
|
+
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
|
|
205
|
+
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
|
|
206
|
+
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
|
|
207
|
+
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
|
|
208
|
+
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
|
|
209
|
+
0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
|
|
210
|
+
0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
|
|
211
|
+
0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
|
|
212
|
+
0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
|
|
213
|
+
0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
|
|
214
|
+
0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
|
|
215
|
+
0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
|
|
216
|
+
0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
|
|
217
|
+
0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
|
|
218
|
+
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
|
|
219
|
+
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391,
|
|
220
|
+
],
|
|
221
|
+
[
|
|
222
|
+
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
|
|
223
|
+
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
|
|
224
|
+
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
|
|
225
|
+
6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21,
|
|
226
|
+
],
|
|
227
|
+
)):
|
|
228
|
+
if i <= 15:
|
|
229
|
+
_f = (_b & _c) | ((~_b) & _d)
|
|
230
|
+
index = i
|
|
231
|
+
elif i <= 31:
|
|
232
|
+
_f = (_d & _b) | ((~_d) & _c)
|
|
233
|
+
index = (5*i + 1) % 16
|
|
234
|
+
elif i <= 47:
|
|
235
|
+
_f = _b ^ _c ^ _d
|
|
236
|
+
index = (3*i + 5) % 16
|
|
237
|
+
else:
|
|
238
|
+
_f = _c ^ (_b | (~_d))
|
|
239
|
+
index = (7*i) % 16
|
|
240
|
+
_f += const + _a + string[index]
|
|
241
|
+
_f = ((_f << shift) | (_f >> (32-shift)))
|
|
242
|
+
_a, _b, _c, _d = _d, _f, _b, _c
|
|
243
|
+
return _a, _b, _c, _d
|
|
Binary file
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Dedicated to tests, it is an empty video stream containing no frames."""
|
|
4
|
+
|
|
5
|
+
from fractions import Fraction
|
|
6
|
+
import typing
|
|
7
|
+
|
|
8
|
+
import torch
|
|
9
|
+
|
|
10
|
+
from cutcutcodec.core.classes.container import ContainerInput
|
|
11
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
12
|
+
from cutcutcodec.core.classes.stream_video import StreamVideo
|
|
13
|
+
from cutcutcodec.core.exceptions import OutOfTimeRange
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class GeneratorVideoEmpty(ContainerInput):
|
|
17
|
+
"""Contains an empty video stream.
|
|
18
|
+
|
|
19
|
+
Examples
|
|
20
|
+
--------
|
|
21
|
+
>>> from cutcutcodec.core.exceptions import OutOfTimeRange
|
|
22
|
+
>>> from cutcutcodec.core.generation.video.empty import GeneratorVideoEmpty
|
|
23
|
+
>>> (stream,) = GeneratorVideoEmpty().out_streams
|
|
24
|
+
>>> try:
|
|
25
|
+
... stream.snapshot(0, (1, 1))
|
|
26
|
+
... except OutOfTimeRange as err:
|
|
27
|
+
... print(err)
|
|
28
|
+
...
|
|
29
|
+
this stream does not contain any frames
|
|
30
|
+
>>>
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
def __init__(self):
|
|
34
|
+
out_streams = [_StreamVideoEmpty(self)]
|
|
35
|
+
super().__init__(out_streams)
|
|
36
|
+
|
|
37
|
+
def _getstate(self) -> dict:
|
|
38
|
+
return {}
|
|
39
|
+
|
|
40
|
+
def _setstate(self, in_streams: typing.Iterable[Stream], state: dict) -> None:
|
|
41
|
+
assert state == {}, state
|
|
42
|
+
GeneratorVideoEmpty.__init__(self)
|
|
43
|
+
|
|
44
|
+
@classmethod
|
|
45
|
+
def default(cls):
|
|
46
|
+
"""Provide a minimalist example of an instance of this node."""
|
|
47
|
+
return cls()
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class _StreamVideoEmpty(StreamVideo):
|
|
51
|
+
"""A video stream containing no frames."""
|
|
52
|
+
|
|
53
|
+
is_space_continuous = False
|
|
54
|
+
is_time_continuous = False
|
|
55
|
+
|
|
56
|
+
def __init__(self, node: GeneratorVideoEmpty):
|
|
57
|
+
assert isinstance(node, GeneratorVideoEmpty), node.__class__.__name__
|
|
58
|
+
super().__init__(node)
|
|
59
|
+
|
|
60
|
+
def _snapshot(self, timestamp: Fraction, mask: torch.Tensor) -> torch.Tensor:
|
|
61
|
+
raise OutOfTimeRange("this stream does not contain any frames")
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def beginning(self) -> Fraction:
|
|
65
|
+
return Fraction(0)
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def duration(self) -> typing.Union[Fraction, float]:
|
|
69
|
+
return Fraction(0)
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Allow to generate colors from mathematical functions."""
|
|
4
|
+
|
|
5
|
+
import numbers
|
|
6
|
+
import re
|
|
7
|
+
import typing
|
|
8
|
+
|
|
9
|
+
from sympy.core.basic import Basic
|
|
10
|
+
|
|
11
|
+
from cutcutcodec.core.classes.container import ContainerInput
|
|
12
|
+
from cutcutcodec.core.filters.video.equation import FilterVideoEquation
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class GeneratorVideoEquation(FilterVideoEquation, ContainerInput):
|
|
16
|
+
"""Generate a video stream whose channels are defened by any equations.
|
|
17
|
+
|
|
18
|
+
It is a particular case of ``cutcutcodec.core.filter.equation.FilterVideoEquation``.
|
|
19
|
+
|
|
20
|
+
Examples
|
|
21
|
+
--------
|
|
22
|
+
>>> from cutcutcodec.core.generation.video.equation import GeneratorVideoEquation
|
|
23
|
+
>>> (stream,) = GeneratorVideoEquation(
|
|
24
|
+
... "atan(pi*j)/pi + 1/2", # dark blue on the left and bright on the right
|
|
25
|
+
... "sin(2pi(i-t))**2", # horizontal descending green waves
|
|
26
|
+
... "exp(-(i**2+j**2)/(2*(1e-3+.1*t)))", # red spot in the center that grows
|
|
27
|
+
... ).out_streams
|
|
28
|
+
>>> stream.node.colors
|
|
29
|
+
[atan(pi*j)/pi + 1/2, sin(2*pi*(i - t))**2, exp((-i**2 - j**2)/((2*(0.1*t + 0.001))))]
|
|
30
|
+
>>> stream.snapshot(0, (13, 9))[..., 0] # blue at t=0
|
|
31
|
+
tensor([[ 25, 33, 46, 73, 128, 182, 209, 222, 230],
|
|
32
|
+
[ 25, 33, 46, 73, 128, 182, 209, 222, 230],
|
|
33
|
+
[ 25, 33, 46, 73, 128, 182, 209, 222, 230],
|
|
34
|
+
[ 25, 33, 46, 73, 128, 182, 209, 222, 230],
|
|
35
|
+
[ 25, 33, 46, 73, 128, 182, 209, 222, 230],
|
|
36
|
+
[ 25, 33, 46, 73, 128, 182, 209, 222, 230],
|
|
37
|
+
[ 25, 33, 46, 73, 128, 182, 209, 222, 230],
|
|
38
|
+
[ 25, 33, 46, 73, 128, 182, 209, 222, 230],
|
|
39
|
+
[ 25, 33, 46, 73, 128, 182, 209, 222, 230],
|
|
40
|
+
[ 25, 33, 46, 73, 128, 182, 209, 222, 230],
|
|
41
|
+
[ 25, 33, 46, 73, 128, 182, 209, 222, 230],
|
|
42
|
+
[ 25, 33, 46, 73, 128, 182, 209, 222, 230],
|
|
43
|
+
[ 25, 33, 46, 73, 128, 182, 209, 222, 230]], dtype=torch.uint8)
|
|
44
|
+
>>> stream.snapshot(0, (13, 9))[..., 1] # green at t=0
|
|
45
|
+
tensor([[ 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
46
|
+
[191, 191, 191, 191, 191, 191, 191, 191, 191],
|
|
47
|
+
[191, 191, 191, 191, 191, 191, 191, 191, 191],
|
|
48
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
49
|
+
[191, 191, 191, 191, 191, 191, 191, 191, 191],
|
|
50
|
+
[191, 191, 191, 191, 191, 191, 191, 191, 191],
|
|
51
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
52
|
+
[191, 191, 191, 191, 191, 191, 191, 191, 191],
|
|
53
|
+
[191, 191, 191, 191, 191, 191, 191, 191, 191],
|
|
54
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
55
|
+
[191, 191, 191, 191, 191, 191, 191, 191, 191],
|
|
56
|
+
[191, 191, 191, 191, 191, 191, 191, 191, 191],
|
|
57
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=torch.uint8)
|
|
58
|
+
>>> stream.snapshot(0, (13, 9))[..., 2] # red at t=0
|
|
59
|
+
tensor([[ 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
60
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
61
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
62
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
63
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
64
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
65
|
+
[ 0, 0, 0, 0, 255, 0, 0, 0, 0],
|
|
66
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
67
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
68
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
69
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
70
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
71
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=torch.uint8)
|
|
72
|
+
>>> stream.snapshot(1, (13, 9))[..., 2] # red at t=1
|
|
73
|
+
tensor([[ 0, 0, 1, 1, 2, 1, 1, 0, 0],
|
|
74
|
+
[ 0, 1, 2, 6, 8, 6, 2, 1, 0],
|
|
75
|
+
[ 0, 2, 8, 21, 28, 21, 8, 2, 0],
|
|
76
|
+
[ 1, 5, 21, 54, 74, 54, 21, 5, 1],
|
|
77
|
+
[ 1, 9, 43, 108, 147, 108, 43, 9, 1],
|
|
78
|
+
[ 2, 14, 64, 163, 222, 163, 64, 14, 2],
|
|
79
|
+
[ 2, 16, 74, 187, 255, 187, 74, 16, 2],
|
|
80
|
+
[ 2, 14, 64, 163, 222, 163, 64, 14, 2],
|
|
81
|
+
[ 1, 9, 43, 108, 147, 108, 43, 9, 1],
|
|
82
|
+
[ 1, 5, 21, 54, 74, 54, 21, 5, 1],
|
|
83
|
+
[ 0, 2, 8, 21, 28, 21, 8, 2, 0],
|
|
84
|
+
[ 0, 1, 2, 6, 8, 6, 2, 1, 0],
|
|
85
|
+
[ 0, 0, 1, 1, 2, 1, 1, 0, 0]], dtype=torch.uint8)
|
|
86
|
+
>>>
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
def __init__(self, *colors: typing.Union[Basic, numbers.Real, str]):
|
|
90
|
+
"""Initialise and create the class.
|
|
91
|
+
|
|
92
|
+
Parameters
|
|
93
|
+
----------
|
|
94
|
+
*colors : str or sympy.Basic
|
|
95
|
+
Transmitted to the
|
|
96
|
+
``cutcutcodec.core.filters.video.equation.FilterVideoEquation`` initialisator.
|
|
97
|
+
But the only available vars are `t`, `i` and `j`.
|
|
98
|
+
"""
|
|
99
|
+
FilterVideoEquation.__init__(self, [], *colors)
|
|
100
|
+
ContainerInput.__init__(self, self.out_streams)
|
|
101
|
+
if excess := (
|
|
102
|
+
{s for s in self._free_symbs if re.fullmatch(r"i|j|t", str(s)) is None}
|
|
103
|
+
):
|
|
104
|
+
raise ValueError(f"only i, j, and t symbols are allowed, not {excess}")
|
|
105
|
+
|
|
106
|
+
@classmethod
|
|
107
|
+
def default(cls):
|
|
108
|
+
"""Provide a minimalist example of an instance of this node."""
|
|
109
|
+
return cls(0)
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/* Fast generation of fractal. */
|
|
2
|
+
|
|
3
|
+
#define PY_SSIZE_T_CLEAN
|
|
4
|
+
#include <numpy/arrayobject.h>
|
|
5
|
+
#include <omp.h>
|
|
6
|
+
#include <Python.h>
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
void mandelbrot_longdouble(float *iters, long double *cst_reals, long double *cst_imags, const npy_intp dim, const long int iter_max) {
|
|
10
|
+
npy_intp i, j;
|
|
11
|
+
const float iter_max_float=(float)iter_max;
|
|
12
|
+
#pragma omp parallel for schedule(dynamic)
|
|
13
|
+
for ( i = 0; i < dim; ++i ) {
|
|
14
|
+
long double real, imag, cst_real, cst_imag, real_square, imag_square;
|
|
15
|
+
cst_real = cst_reals[i], cst_imag = cst_imags[i];
|
|
16
|
+
real = cst_real, imag = cst_imag;
|
|
17
|
+
real_square = real*real, imag_square = imag*imag;
|
|
18
|
+
for ( j = 0; j < iter_max && real_square + imag_square <= 4.0L; ++j ) {
|
|
19
|
+
imag = 2.0L*real*imag + cst_imag;
|
|
20
|
+
real = real_square - imag_square + cst_real;
|
|
21
|
+
real_square = real*real, imag_square = imag*imag;
|
|
22
|
+
}
|
|
23
|
+
iters[i] = (float)j / iter_max_float;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
void mandelbrot_double(float *iters, double *cst_reals, double *cst_imags, const npy_intp dim, const long int iter_max) {
|
|
29
|
+
npy_intp i, j;
|
|
30
|
+
const float iter_max_float=(float)iter_max;
|
|
31
|
+
#pragma omp parallel for schedule(dynamic)
|
|
32
|
+
for ( i = 0; i < dim; ++i ) {
|
|
33
|
+
double real, imag, cst_real, cst_imag, real_square, imag_square;
|
|
34
|
+
{ // simd
|
|
35
|
+
cst_real = cst_reals[i], cst_imag = cst_imags[i];
|
|
36
|
+
real = cst_real, imag = cst_imag;
|
|
37
|
+
real_square = real*real, imag_square = imag*imag;
|
|
38
|
+
};
|
|
39
|
+
for ( j = 0; j < iter_max && real_square + imag_square <= 4.0; ++j ) {
|
|
40
|
+
imag = 2.0*real*imag + cst_imag;
|
|
41
|
+
real = real_square - imag_square + cst_real;
|
|
42
|
+
real_square = real*real, imag_square = imag*imag; // simd
|
|
43
|
+
}
|
|
44
|
+
iters[i] = (float)j / iter_max_float;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
static PyObject *py_mandelbrot(PyObject *self, PyObject *args) {
|
|
50
|
+
PyArrayObject *iters, *reals, *imags;
|
|
51
|
+
long int iter_max;
|
|
52
|
+
npy_intp dim;
|
|
53
|
+
|
|
54
|
+
// parse arguments alloc new array
|
|
55
|
+
if ( !PyArg_ParseTuple(args, "O!O!l", &PyArray_Type, &reals, &PyArray_Type, &imags, &iter_max) ) {
|
|
56
|
+
return NULL;
|
|
57
|
+
}
|
|
58
|
+
dim = PyArray_DIM(reals, 0);
|
|
59
|
+
iters = (PyArrayObject *)PyArray_SimpleNew(1, &dim, NPY_FLOAT32);
|
|
60
|
+
if ( NULL == iters ) {
|
|
61
|
+
PyErr_SetString(PyExc_RuntimeError, "failed to create a new array");
|
|
62
|
+
return NULL;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// call c func
|
|
66
|
+
switch(PyArray_TYPE(reals)) {
|
|
67
|
+
case NPY_DOUBLE:
|
|
68
|
+
Py_BEGIN_ALLOW_THREADS
|
|
69
|
+
mandelbrot_double(
|
|
70
|
+
(float *)PyArray_DATA(iters),
|
|
71
|
+
(double *)PyArray_DATA(reals),
|
|
72
|
+
(double *)PyArray_DATA(imags),
|
|
73
|
+
dim,
|
|
74
|
+
iter_max
|
|
75
|
+
);
|
|
76
|
+
Py_END_ALLOW_THREADS
|
|
77
|
+
return (PyObject *)iters;
|
|
78
|
+
case NPY_LONGDOUBLE:
|
|
79
|
+
Py_BEGIN_ALLOW_THREADS
|
|
80
|
+
mandelbrot_longdouble(
|
|
81
|
+
(float *)PyArray_DATA(iters),
|
|
82
|
+
(long double *)PyArray_DATA(reals),
|
|
83
|
+
(long double *)PyArray_DATA(imags),
|
|
84
|
+
dim,
|
|
85
|
+
iter_max
|
|
86
|
+
);
|
|
87
|
+
Py_END_ALLOW_THREADS
|
|
88
|
+
return (PyObject *)iters;
|
|
89
|
+
default:
|
|
90
|
+
PyErr_SetString(PyExc_TypeError, "only the types double and long double are accepted");
|
|
91
|
+
Py_DECREF(iters);
|
|
92
|
+
return NULL;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
static PyMethodDef fractalMethods[] = {
|
|
98
|
+
{"mandelbrot", py_mandelbrot, METH_VARARGS, "Function for calculating mandelbrot in C."},
|
|
99
|
+
{NULL, NULL, 0, NULL}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
static struct PyModuleDef fractal = {
|
|
104
|
+
PyModuleDef_HEAD_INIT,
|
|
105
|
+
"fractal",
|
|
106
|
+
"Fast C fractal module.",
|
|
107
|
+
-1,
|
|
108
|
+
fractalMethods
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
PyMODINIT_FUNC PyInit_c_fractal(void)
|
|
113
|
+
{
|
|
114
|
+
import_array();
|
|
115
|
+
return PyModule_Create(&fractal);
|
|
116
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Deduce the missing vars with a given set."""
|
|
4
|
+
|
|
5
|
+
from sympy.core.basic import Basic
|
|
6
|
+
from sympy.core.relational import Equality
|
|
7
|
+
from sympy.core.symbol import Symbol
|
|
8
|
+
from sympy.sets.sets import EmptySet
|
|
9
|
+
from sympy.solvers.solveset import linsolve
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
SYMBOLS = {
|
|
13
|
+
# references
|
|
14
|
+
"i_min": Symbol("i_min", real=True),
|
|
15
|
+
"j_min": Symbol("j_min", real=True),
|
|
16
|
+
"i_max": Symbol("i_max", real=True),
|
|
17
|
+
"j_max": Symbol("j_max", real=True),
|
|
18
|
+
|
|
19
|
+
# others
|
|
20
|
+
"x_min": Symbol("x_min", real=True),
|
|
21
|
+
"y_min": Symbol("y_min", real=True),
|
|
22
|
+
"x_max": Symbol("x_max", real=True),
|
|
23
|
+
"y_max": Symbol("y_max", real=True),
|
|
24
|
+
|
|
25
|
+
"i_center": Symbol("i_center", real=True),
|
|
26
|
+
"j_center": Symbol("j_center", real=True),
|
|
27
|
+
"x_center": Symbol("x_center", real=True),
|
|
28
|
+
"y_center": Symbol("y_center", real=True),
|
|
29
|
+
|
|
30
|
+
"i_size": Symbol("i_size", real=True),
|
|
31
|
+
"j_size": Symbol("j_size", real=True),
|
|
32
|
+
"x_size": Symbol("x_size", real=True),
|
|
33
|
+
"y_size": Symbol("y_size", real=True),
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
EQUATIONS = [
|
|
37
|
+
Equality(SYMBOLS["x_min"], SYMBOLS["j_min"]),
|
|
38
|
+
Equality(SYMBOLS["y_min"], SYMBOLS["i_max"]),
|
|
39
|
+
Equality(SYMBOLS["x_max"], SYMBOLS["j_max"]),
|
|
40
|
+
Equality(SYMBOLS["y_max"], SYMBOLS["i_min"]),
|
|
41
|
+
Equality(SYMBOLS["i_center"], SYMBOLS["i_min"]/2 + SYMBOLS["i_max"]/2),
|
|
42
|
+
Equality(SYMBOLS["j_center"], SYMBOLS["j_min"]/2 + SYMBOLS["j_max"]/2),
|
|
43
|
+
Equality(SYMBOLS["x_center"], SYMBOLS["x_min"]/2 + SYMBOLS["x_max"]/2),
|
|
44
|
+
Equality(SYMBOLS["y_center"], SYMBOLS["y_min"]/2 + SYMBOLS["y_max"]/2),
|
|
45
|
+
Equality(SYMBOLS["i_size"], SYMBOLS["i_max"] - SYMBOLS["i_min"]),
|
|
46
|
+
Equality(SYMBOLS["j_size"], SYMBOLS["j_max"] - SYMBOLS["j_min"]),
|
|
47
|
+
Equality(SYMBOLS["x_size"], SYMBOLS["x_max"] - SYMBOLS["x_min"]),
|
|
48
|
+
Equality(SYMBOLS["y_size"], SYMBOLS["y_max"] - SYMBOLS["y_min"]),
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def deduce_all_bounds(**bounds: dict[str, Basic]) -> dict[str, Basic]:
|
|
53
|
+
"""Solve the system for extracting the values of the i, j bounds.
|
|
54
|
+
|
|
55
|
+
Parameters
|
|
56
|
+
----------
|
|
57
|
+
**bounds : dict[str, sympy.code.basic.Basic]
|
|
58
|
+
The values of the given vars.
|
|
59
|
+
The considerated keys are the keys presents in the ``SYMBOLS`` dict.
|
|
60
|
+
|
|
61
|
+
Returns
|
|
62
|
+
-------
|
|
63
|
+
all_bounds : dict[str, sympy.code.basic.Basic]
|
|
64
|
+
The expressions associated to all the values of ``SYMBOLS`` keys.
|
|
65
|
+
|
|
66
|
+
Raises
|
|
67
|
+
------
|
|
68
|
+
ValueError
|
|
69
|
+
If input is not valid or if the linear system is inconsistent.
|
|
70
|
+
|
|
71
|
+
Examples
|
|
72
|
+
--------
|
|
73
|
+
>>> from sympy.core.symbol import Symbol
|
|
74
|
+
>>> from sympy.core.sympify import sympify
|
|
75
|
+
>>> from cutcutcodec.core.generation.video.fractal.geometry import deduce_all_bounds
|
|
76
|
+
>>> solutions = deduce_all_bounds(
|
|
77
|
+
... x_center=Symbol("t", real=True, positive=True)/2,
|
|
78
|
+
... y_center=sympify(1),
|
|
79
|
+
... x_size=sympify(2),
|
|
80
|
+
... y_size=1 + Symbol("t", real=True, positive=True)**2,
|
|
81
|
+
... )
|
|
82
|
+
>>> solutions["i_min"]
|
|
83
|
+
t**2/2 + 3/2
|
|
84
|
+
>>> solutions["i_max"]
|
|
85
|
+
1/2 - t**2/2
|
|
86
|
+
>>> solutions["j_min"]
|
|
87
|
+
t/2 - 1
|
|
88
|
+
>>> solutions["j_max"]
|
|
89
|
+
t/2 + 1
|
|
90
|
+
>>>
|
|
91
|
+
"""
|
|
92
|
+
assert all(n in SYMBOLS for n in bounds), f"{set(bounds) - set(SYMBOLS)} are not allowed"
|
|
93
|
+
assert all(isinstance(e, Basic) for e in bounds.values()), bounds
|
|
94
|
+
assert len(bounds) == 4, f"only 4 expressions are required, not {len(bounds)}"
|
|
95
|
+
|
|
96
|
+
new_eqs = [Equality(SYMBOLS[name], expr) for name, expr in bounds.items()]
|
|
97
|
+
ordered_symbs = list(SYMBOLS) # not list(SYMBOLS.values()) for frozen order
|
|
98
|
+
if (sols := linsolve(EQUATIONS + new_eqs, [SYMBOLS[s] for s in ordered_symbs])) is EmptySet:
|
|
99
|
+
raise ValueError(f"not enouth provided informations for solving bounds {new_eqs}")
|
|
100
|
+
return dict(zip(ordered_symbs, sols.args[0]))
|