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,265 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Allow to filter independentely each audio and video samples by any equation."""
|
|
4
|
+
|
|
5
|
+
from fractions import Fraction
|
|
6
|
+
import math
|
|
7
|
+
import numbers
|
|
8
|
+
import re
|
|
9
|
+
import typing
|
|
10
|
+
|
|
11
|
+
from sympy.core.basic import Basic
|
|
12
|
+
from sympy.core.containers import Tuple
|
|
13
|
+
from sympy.core.numbers import Zero
|
|
14
|
+
from sympy.core.symbol import Symbol
|
|
15
|
+
import torch
|
|
16
|
+
|
|
17
|
+
from cutcutcodec.core.classes.filter import Filter
|
|
18
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
19
|
+
from cutcutcodec.core.classes.stream_video import StreamVideo
|
|
20
|
+
from cutcutcodec.core.compilation.parse import parse_to_sympy
|
|
21
|
+
from cutcutcodec.core.compilation.sympy_to_torch import Lambdify
|
|
22
|
+
from cutcutcodec.core.exceptions import OutOfTimeRange
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class FilterVideoEquation(Filter):
|
|
26
|
+
"""Apply any equation on each pixels.
|
|
27
|
+
|
|
28
|
+
The relation is only between the pixel at the same timestamp at the same position.
|
|
29
|
+
|
|
30
|
+
Attributes
|
|
31
|
+
----------
|
|
32
|
+
colors : list[sympy.core.expr.Expr]
|
|
33
|
+
The luminosity expression of the differents channels (readonly).
|
|
34
|
+
|
|
35
|
+
Examples
|
|
36
|
+
--------
|
|
37
|
+
>>> from cutcutcodec.core.filters.video.equation import FilterVideoEquation
|
|
38
|
+
>>> from cutcutcodec.core.generation.video.noise import GeneratorVideoNoise
|
|
39
|
+
>>> (stream_in,) = GeneratorVideoNoise(0).out_streams
|
|
40
|
+
>>> (stream_out,) = FilterVideoEquation([stream_in], "b0", "(b0+g0+r0)/3", "0").out_streams
|
|
41
|
+
>>> stream_in.snapshot(0, (2, 2))
|
|
42
|
+
FrameVideo(0, [[[127, 101, 236],
|
|
43
|
+
[ 38, 57, 254]],
|
|
44
|
+
<BLANKLINE>
|
|
45
|
+
[[184, 95, 125],
|
|
46
|
+
[235, 3, 208]]])
|
|
47
|
+
>>> stream_out.snapshot(0, (2, 2))
|
|
48
|
+
FrameVideo(0, [[[127, 155, 0],
|
|
49
|
+
[ 38, 116, 0]],
|
|
50
|
+
<BLANKLINE>
|
|
51
|
+
[[184, 135, 0],
|
|
52
|
+
[235, 148, 0]]])
|
|
53
|
+
>>>
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
def __init__(
|
|
57
|
+
self,
|
|
58
|
+
in_streams: typing.Iterable[StreamVideo],
|
|
59
|
+
*colors: typing.Union[Basic, numbers.Real, str],
|
|
60
|
+
):
|
|
61
|
+
"""Initialise and create the class.
|
|
62
|
+
|
|
63
|
+
Parameters
|
|
64
|
+
----------
|
|
65
|
+
in_streams : typing.Iterable[Stream]
|
|
66
|
+
Transmitted to ``cutcutcodec.core.classes.filter.Filter``.
|
|
67
|
+
*colors : str or sympy.Basic
|
|
68
|
+
The brightness of the color channels.
|
|
69
|
+
The channels are interpreted like is describe in
|
|
70
|
+
``cutcutcodec.core.classes.frame_video.FrameVideo``.
|
|
71
|
+
The return values will be cliped to stay in the range [0, 1].
|
|
72
|
+
The value is 0 for min brightness and 1 for the max.
|
|
73
|
+
If the expression gives a complex, the module is taken.
|
|
74
|
+
The variables that can be used in these functions are the following:
|
|
75
|
+
|
|
76
|
+
* i : The relative position along the vertical axis (numpy convention).
|
|
77
|
+
This value evolves between -1 and 1.
|
|
78
|
+
* j : The relative position along the horizontal axis (numpy convention).
|
|
79
|
+
This value evolves between -1 and 1.
|
|
80
|
+
* t : The time in seconds since the beginning of the video.
|
|
81
|
+
* bi: The blue channel of the stream index i, i starts from 0 included.
|
|
82
|
+
This value evolves between 0 (dark) and 1 (light).
|
|
83
|
+
* gi: The green channel of the stream index i, i starts from 0 included.
|
|
84
|
+
This value evolves between 0 (dark) and 1 (light).
|
|
85
|
+
* ri: The red channel of the stream index i, i starts from 0 included.
|
|
86
|
+
This value evolves between 0 (dark) and 1 (light).
|
|
87
|
+
* ai: The alpha channel of the stream index i, i starts from 0 included.
|
|
88
|
+
This value evolves between 0 (transparent) and 1 (blind).
|
|
89
|
+
"""
|
|
90
|
+
# check
|
|
91
|
+
assert isinstance(in_streams, typing.Iterable), in_streams.__class__.__name__
|
|
92
|
+
in_streams = tuple(in_streams)
|
|
93
|
+
assert all(isinstance(s, StreamVideo) for s in in_streams), in_streams
|
|
94
|
+
assert all(isinstance(c, (Basic, numbers.Real, str)) for c in colors), colors
|
|
95
|
+
assert len(colors) <= 4, len(colors)
|
|
96
|
+
|
|
97
|
+
# initialisation
|
|
98
|
+
self._colors = [
|
|
99
|
+
parse_to_sympy(
|
|
100
|
+
c,
|
|
101
|
+
symbols={
|
|
102
|
+
"t": Symbol("t", real=True, positive=True),
|
|
103
|
+
"i": Symbol("i", real=True),
|
|
104
|
+
"j": Symbol("j", real=True),
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
for c in colors
|
|
108
|
+
]
|
|
109
|
+
Filter.__init__(self, in_streams, in_streams)
|
|
110
|
+
if not self.in_streams and not self._colors:
|
|
111
|
+
self._free_symbs = set()
|
|
112
|
+
return
|
|
113
|
+
self._colors = self._colors or [Zero()]
|
|
114
|
+
self._free_symbs = set.union(*(c.free_symbols for c in self._colors))
|
|
115
|
+
|
|
116
|
+
# check
|
|
117
|
+
if excess := (
|
|
118
|
+
{s for s in self._free_symbs if re.fullmatch(r"i|j|t|[bgra]\d+", str(s)) is None}
|
|
119
|
+
):
|
|
120
|
+
raise ValueError(f"only i, j, t, bi, gi, ri and ai symbols are allowed, not {excess}")
|
|
121
|
+
if excess := (
|
|
122
|
+
{
|
|
123
|
+
s for s in self._free_symbs
|
|
124
|
+
if re.fullmatch(r"[bgra]\d+", str(s)) is not None
|
|
125
|
+
and int(str(s)[1:]) >= len(self.in_streams)
|
|
126
|
+
}
|
|
127
|
+
):
|
|
128
|
+
raise ValueError(f"only {len(self.in_streams)} input stream, {excess} is not reachable")
|
|
129
|
+
|
|
130
|
+
Filter.__init__(self, self.in_streams, [_StreamVideoEquation(self)])
|
|
131
|
+
|
|
132
|
+
def _getstate(self) -> dict:
|
|
133
|
+
return {"colors": [str(c) for c in self.colors]}
|
|
134
|
+
|
|
135
|
+
def _setstate(self, in_streams: typing.Iterable[Stream], state: dict) -> None:
|
|
136
|
+
assert state.keys() == {"colors"}, set(state)
|
|
137
|
+
FilterVideoEquation.__init__(self, in_streams, *state["colors"])
|
|
138
|
+
|
|
139
|
+
@property
|
|
140
|
+
def colors(self) -> list[Basic]:
|
|
141
|
+
"""Return the luminosity expression of the differents channels."""
|
|
142
|
+
return self._colors.copy()
|
|
143
|
+
|
|
144
|
+
@classmethod
|
|
145
|
+
def default(cls):
|
|
146
|
+
"""Provide a minimalist example of an instance of this node."""
|
|
147
|
+
return cls([])
|
|
148
|
+
|
|
149
|
+
@property
|
|
150
|
+
def free_symbols(self) -> set[Symbol]:
|
|
151
|
+
"""Return the set of the diferents used symbols."""
|
|
152
|
+
return self._free_symbs.copy()
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class _StreamVideoEquation(StreamVideo):
|
|
156
|
+
"""Color field parameterized by time, position and incoming pixels."""
|
|
157
|
+
|
|
158
|
+
is_space_continuous = True
|
|
159
|
+
is_time_continuous = True
|
|
160
|
+
|
|
161
|
+
def __init__(self, node: FilterVideoEquation):
|
|
162
|
+
assert isinstance(node, FilterVideoEquation), node.__class__.__name__
|
|
163
|
+
super().__init__(node)
|
|
164
|
+
self._colors_func = None # cache
|
|
165
|
+
self._fields = None # cache
|
|
166
|
+
self._fileds_mask = None
|
|
167
|
+
|
|
168
|
+
def _get_colors_func(self) -> callable:
|
|
169
|
+
"""Allow to "compile" equations at the last moment."""
|
|
170
|
+
if self._colors_func is None:
|
|
171
|
+
free_symbs = Tuple(*self.node.colors).free_symbols
|
|
172
|
+
cst_args = {s for s in free_symbs if str(s) in {"i, j"}}
|
|
173
|
+
shapes = {frozenset(s for s in free_symbs if str(s) != "t")}
|
|
174
|
+
self._colors_func = Lambdify(
|
|
175
|
+
self.node.colors, cst_args=cst_args, shapes=shapes, safe=True
|
|
176
|
+
)
|
|
177
|
+
return self._colors_func
|
|
178
|
+
|
|
179
|
+
def _get_fields(self, mask: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
|
|
180
|
+
"""Return the i and j field, minimising realloc by cache.
|
|
181
|
+
|
|
182
|
+
Returns a new copy each time.
|
|
183
|
+
"""
|
|
184
|
+
height, width = mask.shape
|
|
185
|
+
if self._fields is None or self._fields[0].shape != (height, width):
|
|
186
|
+
self._fields = torch.meshgrid(
|
|
187
|
+
torch.linspace(-1, 1, height, dtype=torch.float32),
|
|
188
|
+
torch.linspace(-1, 1, width, dtype=torch.float32),
|
|
189
|
+
indexing="ij",
|
|
190
|
+
)
|
|
191
|
+
if self._fileds_mask is None or mask.numpy(force=True).tobytes() != self._fileds_mask[2]:
|
|
192
|
+
self._fileds_mask = (
|
|
193
|
+
self._fields[0][mask], self._fields[1][mask], mask.numpy(force=True).tobytes()
|
|
194
|
+
)
|
|
195
|
+
return (self._fileds_mask[0], self._fileds_mask[1])
|
|
196
|
+
|
|
197
|
+
def _get_inputs(
|
|
198
|
+
self, timestamp: Fraction, mask: torch.Tensor
|
|
199
|
+
) -> dict[str, typing.Union[float, torch.Tensor]]:
|
|
200
|
+
"""Help for getting input vars."""
|
|
201
|
+
symbs = {}
|
|
202
|
+
in_frames = {} # cache
|
|
203
|
+
for symb in self.node.free_symbols:
|
|
204
|
+
symb = str(symb)
|
|
205
|
+
if (func := {
|
|
206
|
+
"i": lambda: self._get_fields(mask)[0],
|
|
207
|
+
"j": lambda: self._get_fields(mask)[1],
|
|
208
|
+
"t": lambda: torch.tensor(timestamp, dtype=torch.float32),
|
|
209
|
+
}.get(symb, None)) is not None:
|
|
210
|
+
symbs[symb] = func()
|
|
211
|
+
continue
|
|
212
|
+
stream_index = int(symb[1:])
|
|
213
|
+
if stream_index not in in_frames:
|
|
214
|
+
in_frames[stream_index] = self._frame_to_float(
|
|
215
|
+
self.node.in_streams[stream_index]._snapshot(timestamp, mask)
|
|
216
|
+
)
|
|
217
|
+
frame = in_frames[stream_index]
|
|
218
|
+
if symb[0] in {"b", "g", "r"}:
|
|
219
|
+
if frame.shape[2] in {1, 2}:
|
|
220
|
+
symbs[symb] = frame[..., 0][mask]
|
|
221
|
+
else:
|
|
222
|
+
symbs[symb] = frame[..., {"b": 0, "g": 1, "r": 2}[symb[0]]][mask]
|
|
223
|
+
elif symb[0] == "a":
|
|
224
|
+
if frame.shape[2] in {2, 4}:
|
|
225
|
+
symbs[symb] = frame[..., -1][mask]
|
|
226
|
+
else:
|
|
227
|
+
symbs[symb] = torch.tensor(1.0, dtype=torch.float32)
|
|
228
|
+
else:
|
|
229
|
+
raise NotImplementedError(f"only i, j, t, b, g, r and are allowed, not {symb}")
|
|
230
|
+
return symbs
|
|
231
|
+
|
|
232
|
+
def _snapshot(self, timestamp: Fraction, mask: torch.Tensor) -> torch.Tensor:
|
|
233
|
+
# verif
|
|
234
|
+
if timestamp < 0:
|
|
235
|
+
raise OutOfTimeRange(f"there is no video frame at timestamp {timestamp} (need >= 0)")
|
|
236
|
+
|
|
237
|
+
# calculation
|
|
238
|
+
colors = self._get_colors_func()(**self._get_inputs(timestamp, mask))
|
|
239
|
+
|
|
240
|
+
# correction
|
|
241
|
+
frame = torch.empty((*mask.shape, len(self.node.colors)), dtype=torch.float32)
|
|
242
|
+
for i, col in enumerate(colors):
|
|
243
|
+
if col.dtype.is_complex:
|
|
244
|
+
col = torch.abs(col)
|
|
245
|
+
torch.nan_to_num(col, nan=127.0/255.0, posinf=1.0, neginf=0.0, out=col)
|
|
246
|
+
torch.clip(col, 0.0, 1.0, out=col)
|
|
247
|
+
frame[:, :, i][mask] = col
|
|
248
|
+
|
|
249
|
+
return frame
|
|
250
|
+
|
|
251
|
+
@property
|
|
252
|
+
def beginning(self) -> Fraction:
|
|
253
|
+
index = (
|
|
254
|
+
{int(str(s)[1:]) for s in self.node.free_symbols if re.fullmatch(r"[bgra]\d+", str(s))}
|
|
255
|
+
)
|
|
256
|
+
return min((self.node.in_streams[i].beginning for i in index), default=Fraction(0))
|
|
257
|
+
|
|
258
|
+
@property
|
|
259
|
+
def duration(self) -> typing.Union[Fraction, float]:
|
|
260
|
+
index = (
|
|
261
|
+
{int(str(s)[1:]) for s in self.node.free_symbols if re.fullmatch(r"[bgra]\d+", str(s))}
|
|
262
|
+
)
|
|
263
|
+
streams = (self.node.in_streams[i] for i in index)
|
|
264
|
+
end = max((s.beginning + s.duration for s in streams), default=math.inf)
|
|
265
|
+
return end - self.beginning
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""A video filter that doing nothing."""
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
|
|
7
|
+
from cutcutcodec.core.classes.filter import Filter
|
|
8
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class FilterVideoIdentity(Filter):
|
|
12
|
+
"""Allow to convert a set of streams into a filter.
|
|
13
|
+
|
|
14
|
+
Examples
|
|
15
|
+
--------
|
|
16
|
+
>>> from cutcutcodec.core.filters.video.identity import FilterVideoIdentity
|
|
17
|
+
>>> from cutcutcodec.core.generation.video.noise import GeneratorVideoNoise
|
|
18
|
+
>>>
|
|
19
|
+
>>> (s_base_video,) = GeneratorVideoNoise(0).out_streams
|
|
20
|
+
>>> identity = FilterVideoIdentity([s_base_video])
|
|
21
|
+
>>>
|
|
22
|
+
>>> s_base_video is identity.out_streams[0]
|
|
23
|
+
True
|
|
24
|
+
>>>
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self, in_streams: typing.Iterable[Stream]):
|
|
28
|
+
"""Initialise and create the class.
|
|
29
|
+
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
in_streams : typing.Iterable[Stream]
|
|
33
|
+
All the streams to keep intact.
|
|
34
|
+
Transmitted to ``cutcutcodec.core.classes.filter.Filter``.
|
|
35
|
+
"""
|
|
36
|
+
super().__init__(in_streams, in_streams)
|
|
37
|
+
|
|
38
|
+
def _getstate(self) -> dict:
|
|
39
|
+
return {}
|
|
40
|
+
|
|
41
|
+
def _setstate(self, in_streams: typing.Iterable[Stream], state: dict) -> None:
|
|
42
|
+
assert state == {}
|
|
43
|
+
FilterVideoIdentity.__init__(self, in_streams)
|
|
44
|
+
|
|
45
|
+
@classmethod
|
|
46
|
+
def default(cls):
|
|
47
|
+
"""Provide a minimalist example of an instance of this node."""
|
|
48
|
+
return cls([])
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Resizes an image while keeping the proportions."""
|
|
4
|
+
|
|
5
|
+
import numbers
|
|
6
|
+
import typing
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
|
|
10
|
+
from cutcutcodec.core.classes.frame_video import FrameVideo
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def pad_keep_ratio(
|
|
14
|
+
frame: typing.Union[np.ndarray, FrameVideo],
|
|
15
|
+
shape: typing.Union[tuple[numbers.Integral, numbers.Integral], list[numbers.Integral]],
|
|
16
|
+
) -> typing.Union[np.ndarray, FrameVideo]:
|
|
17
|
+
"""Pad the frame with transparent borders.
|
|
18
|
+
|
|
19
|
+
Parameters
|
|
20
|
+
----------
|
|
21
|
+
frame : np.ndarray or cutcutcodec.core.classes.frame_video.FrameVideo
|
|
22
|
+
The image to be padded. If a numpy array is provide, the format
|
|
23
|
+
has to match with the video frame specifications.
|
|
24
|
+
shape : int and int
|
|
25
|
+
The pixel dimensions of the returned frame.
|
|
26
|
+
Each dimension has to be larger or equal to the provided frame.
|
|
27
|
+
The convention adopted is the numpy convention (height, width).
|
|
28
|
+
|
|
29
|
+
Returns
|
|
30
|
+
-------
|
|
31
|
+
np.ndarray or cutcutcodec.core.classes.frame_video.FrameVideo
|
|
32
|
+
The padded frame homogeneous with the input.
|
|
33
|
+
The underground datas are not sharded with the input. A safe copy is done.
|
|
34
|
+
|
|
35
|
+
Examples
|
|
36
|
+
--------
|
|
37
|
+
>>> import torch
|
|
38
|
+
>>> from cutcutcodec.core.classes.frame_video import FrameVideo
|
|
39
|
+
>>> from cutcutcodec.core.filters.video.pad import pad_keep_ratio
|
|
40
|
+
>>> ref = FrameVideo(0, torch.full((4, 8, 3), 128, dtype=torch.uint8))
|
|
41
|
+
>>> pad_keep_ratio(ref, (8, 8))[..., 3] # alpha layer
|
|
42
|
+
tensor([[ 0, 0, 0, 0, 0, 0, 0, 0],
|
|
43
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0],
|
|
44
|
+
[255, 255, 255, 255, 255, 255, 255, 255],
|
|
45
|
+
[255, 255, 255, 255, 255, 255, 255, 255],
|
|
46
|
+
[255, 255, 255, 255, 255, 255, 255, 255],
|
|
47
|
+
[255, 255, 255, 255, 255, 255, 255, 255],
|
|
48
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0],
|
|
49
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0]], dtype=torch.uint8)
|
|
50
|
+
>>> pad_keep_ratio(ref, (4, 9)).convert(1)[..., 0] # as gray
|
|
51
|
+
tensor([[128, 128, 128, 128, 128, 128, 128, 128, 0],
|
|
52
|
+
[128, 128, 128, 128, 128, 128, 128, 128, 0],
|
|
53
|
+
[128, 128, 128, 128, 128, 128, 128, 128, 0],
|
|
54
|
+
[128, 128, 128, 128, 128, 128, 128, 128, 0]], dtype=torch.uint8)
|
|
55
|
+
>>> pad_keep_ratio(ref, (6, 10)).convert(1)[..., 0] # as gray
|
|
56
|
+
tensor([[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
57
|
+
[ 0, 128, 128, 128, 128, 128, 128, 128, 128, 0],
|
|
58
|
+
[ 0, 128, 128, 128, 128, 128, 128, 128, 128, 0],
|
|
59
|
+
[ 0, 128, 128, 128, 128, 128, 128, 128, 128, 0],
|
|
60
|
+
[ 0, 128, 128, 128, 128, 128, 128, 128, 128, 0],
|
|
61
|
+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=torch.uint8)
|
|
62
|
+
>>>
|
|
63
|
+
"""
|
|
64
|
+
# case FrameVideo
|
|
65
|
+
if isinstance(frame, FrameVideo):
|
|
66
|
+
return FrameVideo(frame.time, pad_keep_ratio(frame.numpy(force=True), shape))
|
|
67
|
+
|
|
68
|
+
# verif case np.ndarray
|
|
69
|
+
assert isinstance(frame, np.ndarray), frame.__class__.__name__
|
|
70
|
+
assert frame.ndim == 3, frame.shape
|
|
71
|
+
assert frame.shape[0] >= 1, frame.shape
|
|
72
|
+
assert frame.shape[1] >= 1, frame.shape
|
|
73
|
+
assert frame.shape[2] in {1, 2, 3, 4}, frame.shape
|
|
74
|
+
assert frame.dtype == np.uint8, frame.dtype
|
|
75
|
+
assert len(shape) == 2, len(shape)
|
|
76
|
+
assert all(isinstance(s, numbers.Integral) and s >= 1 for s in shape), shape
|
|
77
|
+
assert shape >= frame.shape[:1], f"no crop from {frame.shape} to {shape}, only padding"
|
|
78
|
+
|
|
79
|
+
# optimization, avoid management of alpha channel
|
|
80
|
+
if frame.shape[:2] == shape:
|
|
81
|
+
return frame.copy()
|
|
82
|
+
|
|
83
|
+
# manage alpha channel
|
|
84
|
+
channels = {1: 2, 2: 2, 3: 4, 4: 4}[frame.shape[2]]
|
|
85
|
+
frame_paded = np.empty((*shape, channels), dtype=np.uint8) # 1500 faster than np.zeros
|
|
86
|
+
if (dec_h := shape[0]-frame.shape[0]): # if height needs padding
|
|
87
|
+
dec_h //= 2
|
|
88
|
+
frame_paded[:dec_h, :, -1] = 0 # set band transparent
|
|
89
|
+
frame_paded[frame.shape[0]+dec_h:, :, -1] = 0
|
|
90
|
+
if (dec_w := shape[1]-frame.shape[1]): # if width needs padding
|
|
91
|
+
dec_w //= 2
|
|
92
|
+
frame_paded[dec_h:frame.shape[0]+dec_h, :dec_w, -1] = 0 # set band transparent
|
|
93
|
+
frame_paded[dec_h:frame.shape[0]+dec_h, frame.shape[1]+dec_w, -1] = 0
|
|
94
|
+
if frame.shape[2] != channels: # if no alpha specify
|
|
95
|
+
frame_paded[dec_h:frame.shape[0]+dec_h, dec_w:frame.shape[1]+dec_w] = 255 # blind
|
|
96
|
+
|
|
97
|
+
# copy data
|
|
98
|
+
frame_paded[dec_h:frame.shape[0]+dec_h, dec_w:frame.shape[1]+dec_w, :frame.shape[2]] = frame
|
|
99
|
+
return frame_paded
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Selects a time slice of a video stream."""
|
|
4
|
+
|
|
5
|
+
from fractions import Fraction
|
|
6
|
+
import math
|
|
7
|
+
import numbers
|
|
8
|
+
import typing
|
|
9
|
+
|
|
10
|
+
from cutcutcodec.core.classes.meta_filter import MetaFilter
|
|
11
|
+
from cutcutcodec.core.classes.node import Node
|
|
12
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
13
|
+
from cutcutcodec.core.compilation.parse import parse_to_number
|
|
14
|
+
from cutcutcodec.core.filters.subclip import FilterSubclip
|
|
15
|
+
from cutcutcodec.core.filters.video.cut import FilterVideoCut
|
|
16
|
+
from cutcutcodec.core.filters.video.identity import FilterVideoIdentity
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class FilterVideoSubclip(FilterSubclip, MetaFilter):
|
|
20
|
+
"""Extract a segment from a video stream.
|
|
21
|
+
|
|
22
|
+
It is a particular case of ``cutcutcodec.core.filters.video.cut.FilterVideoCut``.
|
|
23
|
+
Allows to start a flow after the beginning and or finish it before the end.
|
|
24
|
+
|
|
25
|
+
Examples
|
|
26
|
+
--------
|
|
27
|
+
>>> from cutcutcodec.core.filters.video.subclip import FilterVideoSubclip
|
|
28
|
+
>>> from cutcutcodec.core.generation.video.noise import GeneratorVideoNoise
|
|
29
|
+
>>>
|
|
30
|
+
>>> (s_a,) = GeneratorVideoNoise(0).out_streams
|
|
31
|
+
>>> (s_b,) = GeneratorVideoNoise(0).out_streams
|
|
32
|
+
>>> s_subclip_a, s_subclip_b = FilterVideoSubclip([s_a, s_b], 10, 20).out_streams
|
|
33
|
+
>>>
|
|
34
|
+
>>> s_subclip_a.beginning
|
|
35
|
+
Fraction(10, 1)
|
|
36
|
+
>>> s_subclip_a.duration
|
|
37
|
+
Fraction(20, 1)
|
|
38
|
+
>>> s_subclip_b.beginning
|
|
39
|
+
Fraction(10, 1)
|
|
40
|
+
>>> s_subclip_b.duration
|
|
41
|
+
Fraction(20, 1)
|
|
42
|
+
>>>
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def __init__(
|
|
46
|
+
self,
|
|
47
|
+
in_streams: typing.Iterable[Stream],
|
|
48
|
+
delay: numbers.Real = Fraction(0),
|
|
49
|
+
duration_max: numbers.Real = math.inf,
|
|
50
|
+
):
|
|
51
|
+
"""Initialise and create the class.
|
|
52
|
+
|
|
53
|
+
Parameters
|
|
54
|
+
----------
|
|
55
|
+
in_streams : typing.Iterable[Stream]
|
|
56
|
+
Transmitted to ``cutcutcodec.core.classes.filter.Filter``.
|
|
57
|
+
delay: numbers.Real, default=0
|
|
58
|
+
Transmitted to ``cutcutcodec.core.filters.subclip.FilterSubClip``.
|
|
59
|
+
duration_max : numbers.Real, default=inf
|
|
60
|
+
Transmitted to ``cutcutcodec.core.filters.subclip.FilterSubClip``.
|
|
61
|
+
"""
|
|
62
|
+
FilterSubclip.__init__(self, delay, duration_max)
|
|
63
|
+
MetaFilter.__init__(self, in_streams)
|
|
64
|
+
|
|
65
|
+
def _compile(self, in_streams: tuple[Stream]) -> Node:
|
|
66
|
+
if self.delay:
|
|
67
|
+
if math.isfinite(self.duration_max):
|
|
68
|
+
sub_streams = FilterVideoCut(
|
|
69
|
+
in_streams, self.delay, self.delay+self.duration_max
|
|
70
|
+
).out_streams[len(in_streams):2*len(in_streams)]
|
|
71
|
+
else:
|
|
72
|
+
sub_streams = FilterVideoCut(in_streams, self.delay).out_streams[len(in_streams):]
|
|
73
|
+
else:
|
|
74
|
+
if math.isfinite(self.duration_max):
|
|
75
|
+
sub_streams = FilterVideoCut(
|
|
76
|
+
in_streams, self.delay+self.duration_max
|
|
77
|
+
).out_streams[:len(in_streams)]
|
|
78
|
+
else:
|
|
79
|
+
sub_streams = in_streams
|
|
80
|
+
return FilterVideoIdentity(sub_streams)
|
|
81
|
+
|
|
82
|
+
def _setstate(self, in_streams: typing.Iterable[Stream], state: dict) -> None:
|
|
83
|
+
assert set(state) == {"delay", "duration_max"}, set(state)
|
|
84
|
+
FilterVideoSubclip.__init__(
|
|
85
|
+
self, in_streams, Fraction(state["delay"]), parse_to_number(state["duration_max"])
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
@classmethod
|
|
89
|
+
def default(cls):
|
|
90
|
+
"""Provide a minimalist example of an instance of this node."""
|
|
91
|
+
return cls([], 0, math.inf)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Dedicated to tests, it is an empty audio stream containing no samples."""
|
|
4
|
+
|
|
5
|
+
from fractions import Fraction
|
|
6
|
+
import typing
|
|
7
|
+
|
|
8
|
+
from cutcutcodec.core.classes.container import ContainerInput
|
|
9
|
+
from cutcutcodec.core.classes.frame_audio import FrameAudio
|
|
10
|
+
from cutcutcodec.core.classes.layout import Layout
|
|
11
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
12
|
+
from cutcutcodec.core.classes.stream_audio import StreamAudio
|
|
13
|
+
from cutcutcodec.core.exceptions import OutOfTimeRange
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class GeneratorAudioEmpty(ContainerInput):
|
|
17
|
+
"""Contains an empty audio stream.
|
|
18
|
+
|
|
19
|
+
Examples
|
|
20
|
+
--------
|
|
21
|
+
>>> from cutcutcodec.core.exceptions import OutOfTimeRange
|
|
22
|
+
>>> from cutcutcodec.core.generation.audio.empty import GeneratorAudioEmpty
|
|
23
|
+
>>> (stream,) = GeneratorAudioEmpty().out_streams
|
|
24
|
+
>>> try:
|
|
25
|
+
... stream.snapshot(0)
|
|
26
|
+
... except OutOfTimeRange as err:
|
|
27
|
+
... print(err)
|
|
28
|
+
...
|
|
29
|
+
this stream does not contain any samples
|
|
30
|
+
>>>
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
def __init__(self):
|
|
34
|
+
out_streams = [_StreamAudioEmpty(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
|
+
GeneratorAudioEmpty.__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 _StreamAudioEmpty(StreamAudio):
|
|
51
|
+
"""An audio stream containing no sample."""
|
|
52
|
+
|
|
53
|
+
is_time_continuous = True
|
|
54
|
+
|
|
55
|
+
def __init__(self, node: GeneratorAudioEmpty):
|
|
56
|
+
assert isinstance(node, GeneratorAudioEmpty), node.__class__.__name__
|
|
57
|
+
super().__init__(node)
|
|
58
|
+
|
|
59
|
+
def _snapshot(self, timestamp: Fraction, rate: int, samples: int) -> FrameAudio:
|
|
60
|
+
raise OutOfTimeRange("this stream does not contain any samples")
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def beginning(self) -> Fraction:
|
|
64
|
+
return Fraction(0)
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def duration(self) -> typing.Union[Fraction, float]:
|
|
68
|
+
return Fraction(0)
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def layout(self) -> Layout:
|
|
72
|
+
"""Return the signification of each channels."""
|
|
73
|
+
raise KeyError("it makes no sense to give an audio layout to an absence of sample")
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Allow to generate sound from mathematical functions."""
|
|
4
|
+
|
|
5
|
+
import numbers
|
|
6
|
+
import typing
|
|
7
|
+
|
|
8
|
+
from sympy.core.basic import Basic
|
|
9
|
+
|
|
10
|
+
from cutcutcodec.core.classes.container import ContainerInput
|
|
11
|
+
from cutcutcodec.core.classes.layout import Layout
|
|
12
|
+
from cutcutcodec.core.filters.audio.equation import FilterAudioEquation
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class GeneratorAudioEquation(FilterAudioEquation, ContainerInput):
|
|
16
|
+
"""Generate an audio stream whose channels are defened by any equations.
|
|
17
|
+
|
|
18
|
+
It is a particular case of ``cutcutcodec.core.filter.equation.FilterAudioEquation``.
|
|
19
|
+
|
|
20
|
+
Examples
|
|
21
|
+
--------
|
|
22
|
+
>>> import torch
|
|
23
|
+
>>> from cutcutcodec.core.generation.audio.equation import GeneratorAudioEquation
|
|
24
|
+
>>> (stream,) = GeneratorAudioEquation("sin(2*pi*440*t)").out_streams
|
|
25
|
+
>>> torch.round(stream.snapshot(0, 3520, 8), decimals=3)
|
|
26
|
+
FrameAudio(0, 3520, 'mono', [[ 0. , 0.707, 1. , 0.707, 0. ,
|
|
27
|
+
-0.707, -1. , -0.707]])
|
|
28
|
+
>>>
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(
|
|
32
|
+
self,
|
|
33
|
+
*signals: typing.Union[Basic, numbers.Real, str],
|
|
34
|
+
layout: typing.Union[Layout, str, numbers.Integral] = None,
|
|
35
|
+
):
|
|
36
|
+
"""Initialise and create the class.
|
|
37
|
+
|
|
38
|
+
Parameters
|
|
39
|
+
----------
|
|
40
|
+
*signals : str or sympy.Basic
|
|
41
|
+
Transmitted to the
|
|
42
|
+
``cutcutcodec.core.filters.audio.equation.FilterAudioEquation`` initialisator.
|
|
43
|
+
But the only available vars is `t`.
|
|
44
|
+
layout : cutcutcodec.core.classes.layout.Layout or str or int, optional
|
|
45
|
+
Transmitted to the
|
|
46
|
+
``cutcutcodec.core.filters.audio.equation.FilterAudioEquation`` initialisator.
|
|
47
|
+
"""
|
|
48
|
+
FilterAudioEquation.__init__(self, [], *signals, layout=layout)
|
|
49
|
+
ContainerInput.__init__(self, self.out_streams)
|
|
50
|
+
if excess := set(map(str, self._free_symbs)) - {"t"}:
|
|
51
|
+
raise ValueError(f"only t symbol is allowed, not {excess}")
|
|
52
|
+
|
|
53
|
+
@classmethod
|
|
54
|
+
def default(cls):
|
|
55
|
+
"""Provide a minimalist example of an instance of this node."""
|
|
56
|
+
return cls(0)
|